projects
/
osm
/
N2VC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Revert "Bug 1000: Fix authentication when deleting service"
[osm/N2VC.git]
/
n2vc
/
juju_observer.py
diff --git
a/n2vc/juju_observer.py
b/n2vc/juju_observer.py
index
ac40f34
..
10efa98
100644
(file)
--- a/
n2vc/juju_observer.py
+++ b/
n2vc/juju_observer.py
@@
-52,7
+52,12
@@
class JujuModelObserver(ModelObserver):
self.actions = dict()
def register_machine(self, machine: Machine, db_dict: dict):
self.actions = dict()
def register_machine(self, machine: Machine, db_dict: dict):
- entity_id = machine.entity_id
+ try:
+ entity_id = machine.entity_id
+ except Exception as e:
+ # no entity_id aatribute, try machine attribute
+ entity_id = machine.machine
+ # 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
entity = _Entity(entity_id=entity_id, entity_type='machine', obj=machine, db_dict=db_dict)
self.machines[entity_id] = entity
@@
-65,6
+70,7
@@
class JujuModelObserver(ModelObserver):
def register_application(self, application: Application, db_dict: dict):
entity_id = application.entity_id
def register_application(self, application: Application, db_dict: dict):
entity_id = application.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
entity = _Entity(entity_id=entity_id, entity_type='application', obj=application, db_dict=db_dict)
self.applications[entity_id] = entity
@@
-77,6
+83,7
@@
class JujuModelObserver(ModelObserver):
def register_action(self, action: Action, db_dict: dict):
entity_id = action.entity_id
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))
entity = _Entity(entity_id=entity_id, entity_type='action', obj=action, db_dict=db_dict)
self.actions[entity_id] = entity
entity = _Entity(entity_id=entity_id, entity_type='action', obj=action, db_dict=db_dict)
self.actions[entity_id] = entity
@@
-96,6
+103,8
@@
class JujuModelObserver(ModelObserver):
if not self.is_machine_registered(machine_id):
return
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(
# wait for a final state
entity = self.machines[machine_id]
return await self._wait_for_entity(
@@
-114,6
+123,8
@@
class JujuModelObserver(ModelObserver):
if not self.is_application_registered(application_id):
return
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]
# application statuses: unknown, active, waiting
# wait for a final state
entity = self.applications[application_id]
@@
-133,6
+144,8
@@
class JujuModelObserver(ModelObserver):
if not self.is_action_registered(action_id):
return
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]
# action statuses: pending, running, completed, failed, cancelled
# wait for a final state
entity = self.actions[action_id]
@@
-186,8
+199,8
@@
class JujuModelObserver(ModelObserver):
.format(progress_timeout, entity.entity_type, entity.entity_id)
self.n2vc.debug(message)
raise N2VCTimeoutException(message=message, timeout='progress')
.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 retries
async def on_change(self, delta, old, new, model):
@@
-196,8
+209,8
@@
class JujuModelObserver(ModelObserver):
return
# log
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':
if delta.entity == 'machine':