1
from twisted.internet.defer import inlineCallbacks, returnValue
1
from twisted.internet.defer import fail, inlineCallbacks, returnValue
3
from juju.errors import ProviderError
3
5
from .cloudinit import CloudInit
4
6
from .utils import get_user_authorized_keys
24
26
.. automethod:: _create_cloud_init
27
def __init__(self, provider, master=False, constraints=None):
29
def __init__(self, provider, constraints, master=False):
28
30
self._provider = provider
31
self._constraints = constraints
29
32
self._master = master
30
self._constraints = constraints or {}
35
def launch(cls, provider, machine_data, master):
36
"""Create and run a machine launch operation.
38
Exists for the convenience of the `MachineProvider` implementations
39
which actually use the "constraints" key in machine_data, which would
40
otherwise duplicate code.
42
if "machine-id" not in machine_data:
43
return fail(ProviderError(
44
"Cannot launch a machine without specifying a machine-id"))
45
if "constraints" not in machine_data:
46
return fail(ProviderError(
47
"Cannot launch a machine without specifying constraints"))
48
launcher = cls(provider, machine_data["constraints"], master)
49
return launcher.run(machine_data["machine-id"])
33
52
def run(self, machine_id):
91
110
cloud_init.enable_bootstrap()
92
111
cloud_init.set_zookeeper_secret(config["admin-secret"])
112
cloud_init.set_constraints(self._constraints)
95
115
def _on_new_zookeepers(self, machines):