101
102
("Service placement to machine"
102
103
"not supported %s to %s") % (
103
self.service.name, unit_placement[idx]))
104
self.service.name, unit_placement[idx]))
104
105
elif p in services:
105
106
if services[p].unit_placement:
112
113
self.service.name, unit_placement[idx]))
115
def get(self, unit_number):
116
def get(self, unit_number, env=None):
116
117
status = self.status
117
118
svc = self.service
135
136
if self.arbitrary_machines or placement == '0':
136
137
return self._format_placement(placement, container)
137
138
if placement == 'maas':
139
# find the machine id that matches the target machine
140
# unlike juju status output, the dns-name is one of the
141
# many values returned from our env.status()
142
mid = [x for x in status['machines'].keys()
144
[v.get('Value') for v in
145
status['machines'][x]['addresses']]]
146
self.deployment.log.info('mid=%s' % mid)
149
self.deployment.log.debug(
150
'Found juju machine (%s) matching placement: %s', m, u_idx)
153
self.deployment.log.info(
154
'No match in juju machines for: %s', u_idx)
155
uuid = env.get_env_config()['Config']['uuid']
156
mid = env.add_machine(scope=uuid, directive=u_idx)
157
self.deployment.log.debug(
158
'Waiting for machine to show up in status.')
159
m = mid.get('Machine')
161
if m in status['machines'].keys():
162
s = [x for x in status['machines'].keys()
164
[v.get('Value') for v in
165
status['machines'][x]['addresses']]]
166
self.deployment.log.debug('addresses: %s' % s)
170
self.deployment.log.debug(
171
'Machine %s not in status yet' % m)
173
status = env.status()
174
self.deployment.log.debug('Machine %s up!' % m)
175
return mid.get('Machine')
139
176
elif placement == "zone":
140
177
return "zone=%s" % u_idx