artifact_path: str,
db_dict: dict,
progress_timeout: float = None,
- total_timeout: float = None
+ total_timeout: float = None,
+ config: dict = None,
):
self.log.info('Installing configuration sw on ee_id: {}, artifact path: {}, db_dict: {}'
machine_id=machine_id,
db_dict=db_dict,
progress_timeout=progress_timeout,
- total_timeout=total_timeout
+ total_timeout=total_timeout,
+ config=config
)
except Exception as e:
raise N2VCException(message='Error desploying charm into ee={} : {}'.format(ee_id, e))
machine_id: str,
db_dict: dict,
progress_timeout: float = None,
- total_timeout: float = None
+ total_timeout: float = None,
+ config: dict = None
) -> (Application, int):
# get juju model and observer
channel='stable',
num_units=1,
series=series,
- to=machine_id
+ to=machine_id,
+ config=config
)
# register application with observer
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
- # wait for machine removal
- machines = await model.get_machines()
- while machine_id in machines and time.time() < end:
- self.log.debug('Waiting for machine {} is destroyed'.format(machine_id))
- await asyncio.sleep(0.5)
+ # TODO: change this by machine.is_manual when this is upstreamed: https://github.com/juju/python-libjuju/pull/396
+ if "instance-id" in machine.safe_data and machine.safe_data[
+ "instance-id"
+ ].startswith("manual:"):
+ self.log.debug("machine.destroy(force=True) started.")
+ await machine.destroy(force=True)
+ self.log.debug("machine.destroy(force=True) passed.")
+ # max timeout
+ end = time.time() + total_timeout
+ # wait for machine removal
machines = await model.get_machines()
- self.log.debug('Machine destroyed: {}'.format(machine_id))
+ while machine_id in machines and time.time() < end:
+ self.log.debug("Waiting for machine {} is destroyed".format(machine_id))
+ await asyncio.sleep(0.5)
+ machines = await model.get_machines()
+ self.log.debug("Machine destroyed: {}".format(machine_id))
else:
self.log.debug('Machine not found: {}'.format(machine_id))
total_timeout = 3600
model = await self._juju_get_model(model_name=model_name)
+
+ if not model:
+ raise N2VCException(
+ message="Model {} does not exist".format(model_name)
+ )
+
uuid = model.info.uuid
+ # destroy applications
+ for application_name in model.applications:
+ try:
+ await self._juju_destroy_application(model_name=model_name, application_name=application_name)
+ except Exception as e:
+ self.log.error(
+ "Error destroying application {} in model {}: {}".format(
+ application_name,
+ model_name,
+ e
+ )
+ )
+
# destroy machines
machines = await model.get_machines()
for machine_id in machines:
pass
await self._juju_disconnect_model(model_name=model_name)
- self.juju_models[model_name] = None
- self.juju_observers[model_name] = None
self.log.debug('destroying model {}...'.format(model_name))
await self.controller.destroy_model(uuid)