~fginther/juju-deployer/updated-juju

« back to all changes in this revision

Viewing changes to deployer/env/base.py

  • Committer: Tim Van Steenburgh
  • Date: 2015-09-25 21:40:45 UTC
  • mfrom: (157.1.1 juju-deployer)
  • Revision ID: tim.van.steenburgh@canonical.com-20150925214045-mhtr52qlgfhlh0g5
Add force-termination option using -TT

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
        self._check_call(
112
112
            params, self.log, "Error exposing service %r", name)
113
113
 
114
 
    def terminate_machine(self, mid, wait=False):
 
114
    def terminate_machine(self, mid, wait=False, force=False):
115
115
        """Terminate a machine.
116
116
 
117
 
        The machine can't have any running units, after removing the units or
118
 
        destroying the service, use wait_for_units to know when its safe to
119
 
        delete the machine (ie units have finished executing stop hooks and are
120
 
        removed)
 
117
        Unless ``force=True``, the machine can't have any running units.
 
118
        After removing the units or destroying the service, use wait_for_units
 
119
        to know when its safe to delete the machine (i.e., units have finished
 
120
        executing stop hooks and are removed).
 
121
 
121
122
        """
122
123
        if ((isinstance(mid, int) and mid == 0) or
123
124
           (mid.isdigit() and int(mid) == 0)):
125
126
            raise RuntimeError("Can't terminate machine 0")
126
127
        params = self._named_env(["juju", "terminate-machine"])
127
128
        params.append(mid)
 
129
        if force:
 
130
            params.append('--force')
128
131
        try:
129
132
            self._check_call(
130
133
                params, self.log, "Error terminating machine %r" % mid)