-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
Conversation
nixops/resources/__init__.py
Outdated
@@ -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)): |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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') |
6c9b5ec
to
49190f2
Compare
868a169
to
63e886f
Compare
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
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