from n2vc.exceptions import (
JujuMachineNotFound,
JujuApplicationNotFound,
+ JujuLeaderUnitNotFound,
+ JujuActionNotFound,
JujuModelAlreadyExists,
JujuControllerFailedConnecting,
JujuApplicationExists,
machine_id, model_name
)
)
- machine = model.machines[machine_id]
+ machine = machines[machine_id]
else:
raise JujuMachineNotFound("Machine {} not found".format(machine_id))
:param: application_name: Application name
:param: model_name: Model name
- :param: cloud_name: Cloud name
:param: action_name: Name of the action
:param: db_dict: Dictionary with data of the DB to write the updates
:param: progress_timeout: Maximum time between two updates in the model
if await u.is_leader_from_status():
unit = u
if unit is None:
- raise Exception("Cannot execute action: leader unit not found")
+ raise JujuLeaderUnitNotFound("Cannot execute action: leader unit not found")
actions = await application.get_actions()
if action_name not in actions:
- raise Exception(
+ raise JujuActionNotFound(
"Action {} not in available actions".format(action_name)
)
action_name, action.status, application_name, model_name
)
)
- except Exception as e:
- raise e
finally:
await self.disconnect_model(model)
await self.disconnect_controller(controller)
"""
machines = await model.get_machines()
if machine_id in machines:
- machine = model.machines[machine_id]
+ machine = machines[machine_id]
await machine.destroy(force=True)
# max timeout
end = time.time() + total_timeout