X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Fvnf.py;h=9cdbb330977a27fb41108409bd07bb0344f38cab;hp=6e4aaf37e8bd013663eb4d03c6dbe766408cdb3f;hb=7bf2f4d5ba51d8a6909a8709aeda200ddb153b03;hpb=6d84dbd8746388114361e09300697da471de20ca;ds=sidebyside diff --git a/n2vc/vnf.py b/n2vc/vnf.py index 6e4aaf3..9cdbb33 100644 --- a/n2vc/vnf.py +++ b/n2vc/vnf.py @@ -805,6 +805,10 @@ class N2VC: except JujuError as e: if "already exists" not in e.message: raise e + + # Create an observer for this model + await self.create_model_monitor(ns_uuid) + return True async def DestroyNetworkService(self, ns_uuid): @@ -1061,10 +1065,20 @@ class N2VC: self.refcount['model'] += 1 # Create an observer for this model + await self.create_model_monitor(model_name) + + return self.models[model_name] + + async def create_model_monitor(self, model_name): + """Create a monitor for the model, if none exists.""" + if not self.authenticated: + await self.login() + + if model_name not in self.monitors: self.monitors[model_name] = VCAMonitor(model_name) self.models[model_name].add_observer(self.monitors[model_name]) - return self.models[model_name] + return True async def login(self): """Login to the Juju controller."""