1
4
from twisted.internet.defer import inlineCallbacks, returnValue
3
6
from juju.providers.common.launch import LaunchMachine
5
8
from .machine import machine_from_dict
10
log = logging.getLogger("juju.orchestra")
8
13
class OrchestraLaunchMachine(LaunchMachine):
9
14
"""Orchestra operation for launching an instance"""
27
32
cobbler = self._provider.cobbler
28
33
instance_id = yield cobbler.acquire_system()
30
cloud_init = self._create_cloud_init(machine_id, zookeepers)
31
cloud_init.set_provider_type("orchestra")
32
cloud_init.set_instance_id_accessor(instance_id)
34
info = yield cobbler.start_system(
35
instance_id, machine_id, cloud_init.render())
36
returnValue([machine_from_dict(info)])
34
# If anything goes wrong after the acquire and before the launch
35
# actually happens, we attempt to roll back by calling shutdown_system.
36
# This is not guaranteed to work, ofc, but it's the best effort we can
37
# make towards avoiding lp:894362, in which a machine gets stuck in an
38
# 'acquired' state and cannot be reused without manual intervention.
40
cloud_init = self._create_cloud_init(machine_id, zookeepers)
41
cloud_init.set_provider_type("orchestra")
42
cloud_init.set_instance_id_accessor(instance_id)
44
info = yield cobbler.start_system(
45
instance_id, machine_id, cloud_init.render())
46
returnValue([machine_from_dict(info)])
49
"Failed to launch machine %s; attempting to revert.",
51
exc_info = sys.exc_info()
52
yield cobbler.shutdown_system(instance_id)