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

Adding nixops delete-resources command #1201

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

PsyanticY
Copy link
Contributor

This command will allow users to painlessly remove resources from nixops database while preserving the actual resource. This can be helpful in various disater recovery scenarios when we need to attach an EBS volume to prod form shadow or vice versa. then can safely reeuse that deployment since the shadow won't clain the volume transfered to prod as it's own and tires to destory it

@PsyanticY PsyanticY changed the title Adding Nixops clear-state Command: Adding Nixops clear-state Command Oct 3, 2019
@@ -189,6 +189,16 @@ def destroy(self, wipe=False):
)
return False

def clear_state(self):
"""clear this resource state, if possible."""
if not self.depl.logger.confirm("are you sure you want to clear resources state {}: this will only remove the resource from the local NixOPS state and the resource may still exist outside of the NixOPS database.".format(self.name)):
Copy link
Member

Choose a reason for hiding this comment

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

Can you split into multiple lines, something like:

def clear_state(self):
    """clear this resource state, if possible."""
    if not self.depl.logger.confirm(
            "are you sure you want to clear resources state {}:"
            "this will only remove the resource from the local "
            "NixOPS state and the resource may still exist outside"
            " of the NixOPS database.".format(self.name)):
        return False

scripts/nixops Outdated
@@ -81,6 +81,11 @@ subparser.add_argument('--exclude', nargs='+', metavar='MACHINE-NAME', help='des
subparser.add_argument('--wipe', action='store_true', help='securely wipe data on the machines')
subparser.add_argument('--all', action='store_true', help='destroy all deployments')

subparser = add_subparser(subparsers, 'clear-state', help='clear resources from state file')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
subparser = add_subparser(subparsers, 'clear-state', help='clear resources from state file')
subparser = add_subparser(subparsers, 'clear-state', help='deletes the resource from the local NixOPS state file.')

scripts/nixops Outdated
@@ -81,6 +81,11 @@ subparser.add_argument('--exclude', nargs='+', metavar='MACHINE-NAME', help='des
subparser.add_argument('--wipe', action='store_true', help='securely wipe data on the machines')
subparser.add_argument('--all', action='store_true', help='destroy all deployments')

subparser = add_subparser(subparsers, 'clear-state', help='clear resources from state file')
subparser.set_defaults(op=op_clear_state)
subparser.add_argument('--include', nargs='+', metavar='MACHINE-NAME', help='clear only the specified machines')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
subparser.add_argument('--include', nargs='+', metavar='MACHINE-NAME', help='clear only the specified machines')
subparser.add_argument('--include', nargs='+', metavar='RESOURCE-NAME', help='delete only the specified resources')

scripts/nixops Outdated
subparser = add_subparser(subparsers, 'clear-state', help='clear resources from state file')
subparser.set_defaults(op=op_clear_state)
subparser.add_argument('--include', nargs='+', metavar='MACHINE-NAME', help='clear only the specified machines')
subparser.add_argument('--exclude', nargs='+', metavar='MACHINE-NAME', help='clear all resources except the specified machines')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
subparser.add_argument('--exclude', nargs='+', metavar='MACHINE-NAME', help='clear all resources except the specified machines')
subparser.add_argument('--exclude', nargs='+', metavar='RESOURCE-NAME', help='delete all except the specified resources')

@PsyanticY PsyanticY force-pushed the clearstate branch 3 times, most recently from 6c9b5ec to 49190f2 Compare October 23, 2019 14:44
@PsyanticY PsyanticY force-pushed the clearstate branch 4 times, most recently from 868a169 to 63e886f Compare October 23, 2019 15:22
This command will allow users to painlessly remove resources from nixops database while preserving the actual resource. This can be helpful in various disater recovery scenarios when we need to attach an EBS volume to prod form shadow or vice versa. then can safely reeuse that deployment since the shadow won't clain the volume transfered to prod as it's own and tires to destory it
@AmineChikhaoui AmineChikhaoui changed the title Adding Nixops clear-state Command Adding Nixops delete-resources command Oct 23, 2019
@AmineChikhaoui AmineChikhaoui changed the title Adding Nixops delete-resources command Adding nixops delete-resources command Oct 23, 2019
@AmineChikhaoui AmineChikhaoui merged commit e59765e into NixOS:master Oct 23, 2019
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.

None yet

2 participants