self._log.info("Notification called by creating dts query: %s", ac_status)
+ @asyncio.coroutine
def _register_show_status(self):
def get_xpath(cloud_name=None):
return "D,/rw-cloud:cloud/account{}/connection-status".format(
def on_prepare(xact_info, action, ks_path, msg):
path_entry = RwCloudYang.CloudAcc.schema().keyspec_to_entry(ks_path)
cloud_account_name = path_entry.key00.name
- self._log.debug("Got show cloud connection status request: %s", ks_path.create_string())
+ self._log.debug("Got show cloud connection status request (action: %s): %s",
+ xact_info.query_action, ks_path.create_string())
try:
saved_accounts = self.get_saved_cloud_accounts(cloud_account_name)
flags=rwdts.Flag.PUBLISHER,
)
+ @asyncio.coroutine
def _register_validate_rpc(self):
def get_xpath():
return "/rw-cloud:update-cloud-status"
@asyncio.coroutine
def register(self):
+ self._log.debug("Register cloud account for project %s", self._project.name)
yield from self._register_show_status()
yield from self._register_validate_rpc()
def deregister(self):
- yield from self._rpc.deregister()
- yield from self._regh.deregister()
+ self._log.debug("De-register cloud account for project %s", self._project.name)
+ self._rpc.deregister()
+ self._regh.deregister()
def register(self):
""" Register for VNFD configuration"""
- if self.reg:
- self._log.warning("RPC already registered for project {}".
- format(self._project.name))
- return
-
def on_apply(dts, acg, xact, action, scratch):
"""Apply the configuration"""
is_recovery = xact.xact is None and action == rwdts.AppconfAction.INSTALL
@asyncio.coroutine
def on_prepare(dts, acg, xact, xact_info, ks_path, msg, scratch):
""" on prepare callback """
+ self._log.debug("Subscriber DTS prepare for project %s: %s",
+ self.project, xact_info.query_action)
xact_info.respond_xpath(rwdts.XactRspCode.ACK)
acg_hdl = rift.tasklets.AppConfGroup.Handler(on_apply=on_apply)
is_recovery = xact.xact is None and action == rwdts.AppconfAction.INSTALL
self._log.debug("Got nsd apply cfg (xact:%s) (action:%s)",
xact, action)
- # Create/Update an NSD record
- for cfg in self._regh.get_xact_elements(xact):
- # Only interested in those NSD cfgs whose ID was received in prepare callback
- if cfg.id in scratch.get('nsds', []) or is_recovery:
- self._nsm.update_nsd(cfg)
+
+ if self._regh:
+ # Create/Update an NSD record
+ for cfg in self._regh.get_xact_elements(xact):
+ # Only interested in those NSD cfgs whose ID was received in prepare callback
+ if cfg.id in scratch.get('nsds', []) or is_recovery:
+ self._nsm.update_nsd(cfg)
+
+ else:
+ self._log.error("No reg handle for {} for project {}".
+ format(self.__class__, self._project.name))
scratch.pop('nsds', None)
self._log.debug("Got NSM VNFD apply (xact: %s) (action: %s)(scr: %s)",
xact, action, scratch)
- # Create/Update a VNFD record
- for cfg in self._regh.get_xact_elements(xact):
- # Only interested in those VNFD cfgs whose ID was received in prepare callback
- if cfg.id in scratch.get('vnfds', []):
- self._nsm.update_vnfd(cfg)
+ if self._regh:
+ # Create/Update a VNFD record
+ for cfg in self._regh.get_xact_elements(xact):
+ # Only interested in those VNFD cfgs whose ID was received in prepare callback
+ if cfg.id in scratch.get('vnfds', []):
+ self._nsm.update_vnfd(cfg)
- for cfg in self._regh.elements:
- if cfg.id in scratch.get('deleted_vnfds', []):
- yield from self._nsm.delete_vnfd(cfg.id)
+ for cfg in self._regh.elements:
+ if cfg.id in scratch.get('deleted_vnfds', []):
+ yield from self._nsm.delete_vnfd(cfg.id)
+
+ else:
+ self._log.error("Reg handle none for {} in project {}".
+ format(self.__class__, self._project))
scratch.pop('vnfds', None)
scratch.pop('deleted_vnfds', None)
if action == rwdts.AppconfAction.INSTALL and xact.id is None:
key_pairs = []
- for element in self._key_pair_regh.elements:
- key_pairs.append(element)
- for element in self._nsr_regh.elements:
- nsr = handle_create_nsr(element, key_pairs, restart_mode=True)
- self._loop.create_task(begin_instantiation(nsr))
+ if self._key_pair_regh:
+ for element in self._key_pair_regh.elements:
+ key_pairs.append(element)
+ else:
+ self._log.error("Reg handle none for key pair in project {}".
+ format(self._project))
+
+ if self._nsr_regh:
+ for element in self._nsr_regh.elements:
+ nsr = handle_create_nsr(element, key_pairs, restart_mode=True)
+ self._loop.create_task(begin_instantiation(nsr))
+ else:
+ self._log.error("Reg handle none for NSR in project {}".
+ format(self._project))
(added_msgs, deleted_msgs, updated_msgs) = get_add_delete_update_cfgs(self._nsr_regh,
def deregister(self):
self._log.debug("De-register VNFR for project {}".
- format(self._project.name))
+ format(self._nsm._project.name))
if self._regh:
self._regh.deregister()
self._regh = None
def deregister(self):
self._log.debug("De-register NSD Ref count for project {}".
- format(self._project.name))
+ format(self._nsm._project.name))
if self._regh:
self._regh.deregister()
self._regh = None
def deregister(self):
""" Register all static DTS handlers """
for dts_handle in self._dts_handlers:
- yield from dts_handle.deregister()
+ dts_handle.deregister()
def get_ns_by_nsr_id(self, nsr_id):
self._vnffgmgr.deregister()
self._cloud_account_handler.deregister()
self._ro_plugin_selector.deregister()
+ self._nsm = None
+
+ @asyncio.coroutine
+ def delete_prepare(self):
+ # Check if any NS instance is present
+ if self._nsm and self._nsm._nsrs:
+ return False
+ return True
class NsmTasklet(rift.tasklets.Tasklet):