Merge lp:~hazmat/pyjuju/env-safety-belt into lp:pyjuju
Proposed by
Kapil Thangavelu
Status: | Merged |
---|---|
Approved by: | Clint Byrum |
Approved revision: | 580 |
Merged at revision: | 624 |
Proposed branch: | lp:~hazmat/pyjuju/env-safety-belt |
Merge into: | lp:pyjuju |
Diff against target: |
59 lines (+30/-0) 3 files modified
juju/control/destroy_environment.py (+6/-0) juju/control/tests/test_destroy_environment.py (+20/-0) juju/environment/environment.py (+4/-0) |
To merge this branch: | bzr merge lp:~hazmat/pyjuju/env-safety-belt |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Clint Byrum (community) | Approve | ||
Review via email: mp+126819@code.launchpad.net |
Description of the change
configuration safety belt for environments.
Per request, an environment with a client side config value of prevent-destroy:
true will not allow itself to be destroyed via juju destroy-
appropriate message to that effect will instead result on an attempt.
To post a comment you must log in.
Reviewers: mp+126819_ code.launchpad. net,
Message:
Please take a look.
Description:
configuration safety belt for environments.
Per request, an environment with a client side config value of environment,
prevent-destroy:
true will not allow itself to be destroyed via juju destroy-
and
appropriate message to that effect will instead result on an attempt.
https:/ /code.launchpad .net/~hazmat/ juju/env- safety- belt/+merge/ 126819
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/6574059/
Affected files: destroy_ environment. py tests/test_ destroy_ environment. py t/environment. py
A [revision details]
M juju/control/
M juju/control/
M juju/environmen
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: juju/control/ destroy_ environment. py destroy_ environment. py' destroy_ environment. py 2012-07-13 15:12:02 +0000 destroy_ environment. py 2012-09-27 21:53:57 +0000 (options) get_machine_ provider( )
=== modified file 'juju/control/
--- juju/control/
+++ juju/control/
@@ -21,6 +21,12 @@
environment = get_environment
provider = environment.
+ if environment. prevent_ destroy: log.warning(
+ options.
+ "Environment %r configuration prevents destruction" % (
+ environment.name))
+ return
+
value = raw_input(
"WARNING: this command will destroy the %r environment
(type: %s).\n"
"This includes all machines, services, data, and other resources. "
Index: juju/environmen t/environment. py nt/environment. py' t/environment. py 2012-04-06 18:53:52 +0000 t/environment. py 2012-09-27 21:53:57 +0000
"""Returns the origin of the code.""" nt_config. get("juju- origin" , "distro") destroy( self): nt_config. get("prevent- destroy" , False)
=== modified file 'juju/environme
--- juju/environmen
+++ juju/environmen
@@ -56,3 +56,7 @@
def origin(self):
return self._environme
+
+ @property
+ def prevent_
+ return self._environme
Index: juju/control/ tests/test_ destroy_ environment. py tests/test_ destroy_ environment. py' tests/test_ destroy_ environment. py 2012-09-10 03:20:20 +0000 tests/test_ destroy_ environment. py 2012-09-27 21:53:57 +0000 nvironmentTest( ControlToolTest ):
=== modified file 'juju/control/
--- juju/control/
+++ juju/control/
@@ -11,6 +11,26 @@
class ControlDestroyE
@ inlineCallbacks destroy_ setting( self): config( dump(config) ) cli_reactor( ) replay( ) logging( ) destroy- environment' ])
+ def test_prevent_
+ """Environment config can explicitly prevent destruction.
+ """
+ config = {
+ 'environments': {'firstenv': {
+ 'type': 'dummy', 'prevent-destroy': True}}
+ }
+ self.write_
+ finished = self.setup_
+ self.setup_exit(0)
+ self.mocker.
+
+ stderr = self.capture_
+ main(['
+ yield finished
+ self.assertIn(
+ "Environment 'firstenv' co...