except Exception as e:
# no entity_id aatribute, try machine attribute
entity_id = machine.machine
- self.n2vc.debug(msg='Registering machine for changes notifications: {}'.format(entity_id))
+ # self.n2vc.debug(msg='Registering machine for change notifications: {}'.format(entity_id))
entity = _Entity(entity_id=entity_id, entity_type='machine', obj=machine, db_dict=db_dict)
self.machines[entity_id] = entity
def register_application(self, application: Application, db_dict: dict):
entity_id = application.entity_id
- self.n2vc.debug(msg='Registering application for changes notifications: {}'.format(entity_id))
+ # self.n2vc.debug(msg='Registering application for change notifications: {}'.format(entity_id))
entity = _Entity(entity_id=entity_id, entity_type='application', obj=application, db_dict=db_dict)
self.applications[entity_id] = entity
def register_action(self, action: Action, db_dict: dict):
entity_id = action.entity_id
- self.n2vc.debug(msg='Registering action for changes notifications: {}'.format(entity_id))
+ # self.n2vc.debug(msg='Registering action for changes notifications: {}'.format(entity_id))
entity = _Entity(entity_id=entity_id, entity_type='action', obj=action, db_dict=db_dict)
self.actions[entity_id] = entity
if not self.is_machine_registered(machine_id):
return
+ self.n2vc.debug('Waiting for machine completed: {}'.format(machine_id))
+
# wait for a final state
entity = self.machines[machine_id]
return await self._wait_for_entity(
if not self.is_application_registered(application_id):
return
+ self.n2vc.debug('Waiting for application completed: {}'.format(application_id))
+
# application statuses: unknown, active, waiting
# wait for a final state
entity = self.applications[application_id]
if not self.is_action_registered(action_id):
return
+ self.n2vc.debug('Waiting for action completed: {}'.format(action_id))
+
# action statuses: pending, running, completed, failed, cancelled
# wait for a final state
entity = self.actions[action_id]
.format(progress_timeout, entity.entity_type, entity.entity_id)
self.n2vc.debug(message)
raise N2VCTimeoutException(message=message, timeout='progress')
- self.n2vc.debug('End of wait. Final state: {}, retries: {}'
- .format(entity.obj.__getattribute__(field_to_check), retries))
+ # self.n2vc.debug('End of wait. Final state: {}, retries: {}'
+ # .format(entity.obj.__getattribute__(field_to_check), retries))
return retries
async def on_change(self, delta, old, new, model):
return
# log
- self.n2vc.debug('on_change(): type: {}, entity: {}, id: {}'
- .format(delta.type, delta.entity, new.entity_id))
+ # self.n2vc.debug('on_change(): type: {}, entity: {}, id: {}'
+ # .format(delta.type, delta.entity, new.entity_id))
if delta.entity == 'machine':
return
# write change in database
- await self.n2vc.write_app_status_to_db(
- db_dict=self.applications[application_id].db_dict,
- status=juju_status_2_osm_status(delta.entity, new.workload_status),
- detailed_status=new.workload_status_message,
- vca_status=new.workload_status,
- entity_type='unit'
- )
+ if not new.dead:
+ await self.n2vc.write_app_status_to_db(
+ db_dict=self.applications[application_id].db_dict,
+ status=juju_status_2_osm_status(delta.entity, new.workload_status),
+ detailed_status=new.workload_status_message,
+ vca_status=new.workload_status,
+ entity_type='unit'
+ )
# set event for this application
self.applications[application_id].event.set()