Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ Decommissioning Job #85

Merged
merged 43 commits into from
Jan 4, 2024
Merged

Conversation

chadell
Copy link
Contributor

@chadell chadell commented Dec 12, 2023

TODO

  • Documentation for developers
  • Job test
  • Example Job to demonstrate overlap: l3vpn
  • Refactor decommission into a DesignInstance model method
  • Unittest for revert of Journal and DesignInstance

Comment on lines 27 to 32
# TODO: how to make this more decoupled?
self.log_info(
f"Checking if the design instance {design_instance} can be decommissioned by external dependencies."
)
self.log_success(f"No dependency issues found for {design_instance}.")
return True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is not the final implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the decoupling has to happen in this PR. any suggestion?

nautobot_design_builder/jobs.py Outdated Show resolved Hide resolved
nautobot_design_builder/jobs.py Outdated Show resolved Hide resolved
nautobot_design_builder/jobs.py Outdated Show resolved Hide resolved
Comment on lines 123 to 126
content_type = ContentType.objects.get_for_model(DesignInstance)
design_instance.status = Status.objects.get(
content_types=content_type, name=DesignInstanceStatusChoices.DECOMMISSIONED
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
content_type = ContentType.objects.get_for_model(DesignInstance)
design_instance.status = Status.objects.get(
content_types=content_type, name=DesignInstanceStatusChoices.DECOMMISSIONED
)
design_instance.status = Status.objects.get(
name=DesignInstanceStatusChoices.DECOMMISSIONED
)

This should be the same, shouldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likely. I guess a Status can't have the same name and belong to a different content_type. will check

Comment on lines 41 to 49
try:
func = import_string(pre_decommission_hook)
except ImportError as error:
msg = (
"There was an issue attempting to import the pre decommission hook "
f"{pre_decommission_hook}, this is expected with a local configuration issue and not related to"
" the Design Builder App, please contact your system admin for further details.\n"
)
raise ValueError(msg + str(error)) from error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this approach - does it make sense/is it possible to instead just pass the callable directly? I.e. have the settings import it and then just use it here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it would make it easier. I will try it.

chadell and others added 8 commits December 14, 2023 14:47
The `TransactionTestCase` actually has less test isolation than `TestCase` which caused the test designs to not actually get reverted between tests.
Moved the revertting code from the decommissioning job and into the JournalEntry model. Also added some tests to validate the code.
@chadell chadell requested review from Kircheneer and abates January 3, 2024 07:31
@chadell chadell dismissed Kircheneer’s stale review January 3, 2024 08:15

looking forward for a new review

@abates abates self-requested a review January 3, 2024 16:08
Comment on lines 330 to 333
ValidationError: _description_

class JournalEntry(PrimaryModel):
Returns:
_type_: _description_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these would need to be fixed - I don't want to hold the MR up over this but before this gets into develop we will need to work with it anyway

@chadell chadell merged commit df33046 into feature_delices Jan 4, 2024
14 checks passed
@chadell chadell deleted the feature_delices_decom_job branch January 4, 2024 09:43
This was referenced Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants