else:
self.apt_mirror = None
+ self.cloud = vca_config.get('cloud')
self.log.debug('Arguments have been checked')
# juju data
.format(ee_id, application_name, e))
# destroy the machine
- try:
- await self._juju_destroy_machine(
- model_name=model_name,
- machine_id=machine_id,
- total_timeout=total_timeout
- )
- except Exception as e:
- raise N2VCException(message='Error deleting execution environment {} (machine {}) : {}'
- .format(ee_id, machine_id, e))
+ # try:
+ # await self._juju_destroy_machine(
+ # model_name=model_name,
+ # machine_id=machine_id,
+ # total_timeout=total_timeout
+ # )
+ # except Exception as e:
+ # raise N2VCException(message='Error deleting execution environment {} (machine {}) : {}'
+ # .format(ee_id, machine_id, e))
self.log.info('Execution environment {} deleted'.format(ee_id))
application = await self._juju_get_application(model_name=model_name, application_name=application_name)
- unit = application.units[0]
+ unit = None
+ for u in application.units:
+ if await u.is_leader_from_status():
+ unit = u
if unit is not None:
actions = await application.get_actions()
if action_name in actions:
model = await self.controller.add_model(
model_name=model_name,
- config=config_dict
+ config=config_dict,
+ cloud_name=self.cloud,
)
self.log.info('New model created, name={}'.format(model_name))
else:
# get juju model and observer
model = await self._juju_get_model(model_name=model_name)
+ observer = self.juju_observers[model_name]
application = model.applications.get(application_name)
if application:
+ observer.unregister_application(application_name)
await application.destroy()
else:
self.log.debug('Application not found: {}'.format(application_name))
# get juju model and observer
model = await self._juju_get_model(model_name=model_name)
+ observer = self.juju_observers[model_name]
machines = await model.get_machines()
if machine_id in machines:
machine = model.machines[machine_id]
+ observer.unregister_machine(machine_id)
await machine.destroy(force=True)
# max timeout
end = time.time() + total_timeout