Merge changes I9a6c5927,I055eabb8,I81efc98d,Icc5b7830
* changes:
RIFT-14308 Meaningful logs while initalizing Openstack driver
RIFT-14481 uptime for vlr, vnfr, nsr
RIFT-14481 No create-time on VLR
RIFT-14555 Fixing few console error messages
diff --git a/common/python/rift/mano/cloud/accounts.py b/common/python/rift/mano/cloud/accounts.py
index 57ca55f..d3aa860 100644
--- a/common/python/rift/mano/cloud/accounts.py
+++ b/common/python/rift/mano/cloud/accounts.py
@@ -21,6 +21,7 @@
require_version('RwcalYang', '1.0')
require_version('RwTypes', '1.0')
require_version('RwCloudYang', '1.0')
+require_version('RwCal', '1.0')
from gi.repository import (
RwTypes,
diff --git a/models/plugins/yang/nsr.yang b/models/plugins/yang/nsr.yang
index c2b7d06..f7c16fe 100644
--- a/models/plugins/yang/nsr.yang
+++ b/models/plugins/yang/nsr.yang
@@ -613,6 +613,14 @@
type uint32;
}
+ leaf uptime {
+ description
+ "Active period of this Network Service.
+ Uptime is expressed in seconds";
+
+ type uint32;
+ }
+
list connection-point {
description
"List for external connection points.
diff --git a/models/plugins/yang/vlr.yang b/models/plugins/yang/vlr.yang
index ef3d603..20ba6f7 100644
--- a/models/plugins/yang/vlr.yang
+++ b/models/plugins/yang/vlr.yang
@@ -132,6 +132,14 @@
type uint32;
}
+ leaf uptime {
+ description
+ "Active period of this Virtual Link.
+ Uptime is expressed in seconds";
+
+ type uint32;
+ }
+
leaf network-id {
description
"Identifier for the allocated network resource.";
diff --git a/models/plugins/yang/vnfr.yang b/models/plugins/yang/vnfr.yang
index 4a427d4..a4419ce 100644
--- a/models/plugins/yang/vnfr.yang
+++ b/models/plugins/yang/vnfr.yang
@@ -199,6 +199,14 @@
type uint32;
}
+ leaf uptime {
+ description
+ "Active period of this Virtual Network Function.
+ Uptime is expressed in seconds";
+
+ type uint32;
+ }
+
leaf vnfd-ref {
description "Reference to VNFD";
type leafref {
diff --git a/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py b/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py
index 2505da3..a720b8a 100644
--- a/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py
+++ b/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py
@@ -123,6 +123,8 @@
try:
ksconn = self._get_keystone_connection()
service_endpoint = ksconn.service_catalog.url_for(**endpoint_kwargs)
+ except (KeystoneExceptions.Unauthorized, KeystoneExceptions.AuthorizationFailure) as e:
+ raise
except Exception as e:
logger.error("OpenstackDriver: Service Catalog discovery operation failed for service_type: %s, endpoint_type: %s. Exception: %s" %(service_type, endpoint_type, str(e)))
raise
@@ -1652,6 +1654,8 @@
try:
ntconn = self.neutron_drv._get_neutron_connection()
networks = ntconn.list_networks()
+ except (KeystoneExceptions.Unauthorized, KeystoneExceptions.AuthorizationFailure) as e:
+ raise
except Exception as e:
logger.error("OpenstackDriver: List Network operation failed. Exception: %s" %(str(e)))
raise
diff --git a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py
index 19eea3b..8a2d275 100644
--- a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py
+++ b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py
@@ -26,6 +26,7 @@
import rift.cal.rwcal_status as rwcal_status
import rwlogger
import neutronclient.common.exceptions as NeutronException
+import keystoneclient.exceptions as KeystoneExceptions
from gi.repository import (
GObject,
@@ -88,6 +89,9 @@
tenant_name = account.openstack.tenant,
mgmt_network = account.openstack.mgmt_network,
cert_validate = account.openstack.cert_validate )
+ except (KeystoneExceptions.Unauthorized, KeystoneExceptions.AuthorizationFailure,
+ NeutronException.NotFound) as e:
+ raise
except Exception as e:
self.log.error("RwcalOpenstackPlugin: OpenstackDriver init failed. Exception: %s" %(str(e)))
raise
@@ -118,11 +122,27 @@
Validation Code and Details String
"""
status = RwcalYang.CloudConnectionStatus()
-
try:
with self._use_driver(account) as drv:
drv.validate_account_creds()
+ except KeystoneExceptions.Unauthorized as e:
+ self.log.error("Invalid credentials given for VIM account %s" %account.name)
+ status.status = "failure"
+ status.details = "Invalid Credentials: %s" % str(e)
+
+ except KeystoneExceptions.AuthorizationFailure as e:
+ self.log.error("Bad authentication URL given for VIM account %s. Given auth url: %s" % (
+ account.name, account.openstack.auth_url))
+ status.status = "failure"
+ status.details = "Invalid auth url: %s" % str(e)
+
+ except NeutronException.NotFound as e:
+ self.log.error("Given management network %s could not be found for VIM account %s" % (
+ account.openstack.mgmt_network, account.name))
+ status.status = "failure"
+ status.details = "mgmt network does not exist: %s" % str(e)
+
except openstack_drv.ValidationError as e:
self.log.error("RwcalOpenstackPlugin: OpenstackDriver credential validation failed. Exception: %s", str(e))
status.status = "failure"
diff --git a/rwlaunchpad/plugins/rwmonparam/rift/tasklets/rwmonparam/nsr_core.py b/rwlaunchpad/plugins/rwmonparam/rift/tasklets/rwmonparam/nsr_core.py
index b1b9cd0..31b7647 100644
--- a/rwlaunchpad/plugins/rwmonparam/rift/tasklets/rwmonparam/nsr_core.py
+++ b/rwlaunchpad/plugins/rwmonparam/rift/tasklets/rwmonparam/nsr_core.py
@@ -113,6 +113,10 @@
# value => (value_type, value)
self.vnfr_monparams = {}
+ # create_nsr_mon_params() is already validating for 'is_legacy' by checking if
+ # nsd is having 'monitoring_param'. So removing 'self.aggregation_type is None' check for is_legacy.
+ self.is_legacy = is_legacy
+
if not is_legacy:
self._msg = self._convert_nsd_msg(monp_config)
else:
@@ -144,9 +148,9 @@
"""Aggregation type"""
return self.nsr_mon_param_msg.aggregation_type
- @property
- def is_legacy(self):
- return (self.aggregation_type is None)
+ # @property
+ # def is_legacy(self):
+ # return (self.aggregation_type is None)
@classmethod
def extract_value(cls, monp):
diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsm_conman.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsm_conman.py
index e29f491..23ab7b6 100644
--- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsm_conman.py
+++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsm_conman.py
@@ -103,9 +103,13 @@
# Update the NSR's config status
new_status = ROConfigManager.map_config_status(cm_nsr['state'])
- self._log.debug("Updating config status of NSR {} to {}({})".
- format(nsrid, new_status, cm_nsr['state']))
- yield from self.nsm.nsrs[nsrid].set_config_status(new_status, cm_nsr.get('state_details'))
+ self._log.info("Updating config status of NSR {} to {}({})".
+ format(nsrid, new_status, cm_nsr['state']))
+
+ # If terminate nsr request comes when NS instantiation is in 'Configuring state'; self.nsm.nsrs dict
+ # is already empty when self.nsm.nsrs[nsrid].set_config_status gets executed. So adding a check here.
+ if nsrid in self.nsm.nsrs:
+ yield from self.nsm.nsrs[nsrid].set_config_status(new_status, cm_nsr.get('state_details'))
except Exception as e:
self._log.error("Failed to process cm-state for nsr {}: {}".
diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py
index cf03857..62d06f9 100755
--- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py
+++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py
@@ -460,6 +460,7 @@
class VirtualLinkRecord(object):
""" Virtual Link Records class"""
+ XPATH = "D,/vlr:vlr-catalog/vlr:vlr"
@staticmethod
@asyncio.coroutine
def create_record(dts, log, loop, nsr_name, vld_msg, cloud_account_name, om_datacenter, ip_profile, nsr_id, restart_mode=False):
@@ -515,6 +516,7 @@
self._vlr_id = str(uuid.uuid4())
self._state = VlRecordState.INIT
self._prev_state = None
+ self._create_time = int(time.time())
@property
def xpath(self):
@@ -608,6 +610,7 @@
"nsr_id_ref": self._nsr_id,
"vld_ref": self.vld_msg.id,
"name": self.name,
+ "create_time": self._create_time,
"cloud_account": self.cloud_account_name,
"om_datacenter": self.om_datacenter_name,
}
@@ -645,7 +648,6 @@
@asyncio.coroutine
def instantiate(self):
""" Instantiate this VL """
-
self._log.debug("Instaniating VLR key %s, vld %s",
self.xpath, self._vld_msg)
vlr = None
@@ -1231,7 +1233,8 @@
""" Network service record """
XPATH = "D,/nsr:ns-instance-opdata/nsr:nsr"
- def __init__(self, dts, log, loop, nsm, nsm_plugin, nsr_cfg_msg, sdn_account_name, key_pairs, restart_mode=False):
+ def __init__(self, dts, log, loop, nsm, nsm_plugin, nsr_cfg_msg, sdn_account_name, key_pairs, restart_mode=False,
+ vlr_handler=None):
self._dts = dts
self._log = log
self._loop = loop
@@ -1239,6 +1242,7 @@
self._nsr_cfg_msg = nsr_cfg_msg
self._nsm_plugin = nsm_plugin
self._sdn_account_name = sdn_account_name
+ self._vlr_handler = vlr_handler
self._nsd = None
self._nsr_msg = None
@@ -1452,6 +1456,18 @@
for vlr in self._vlrs:
yield from self.nsm_plugin.instantiate_vl(self, vlr)
vlr.state = VlRecordState.ACTIVE
+ self._loop.create_task(self.vlr_uptime_update(vlr))
+
+
+ def vlr_uptime_update(self, vlr):
+ vlr_ = RwVlrYang.YangData_Vlr_VlrCatalog_Vlr.from_dict({'id': vlr.id})
+ while True:
+ if vlr.state not in [VlRecordState.INIT, VlRecordState.INSTANTIATION_PENDING, VlRecordState.ACTIVE]:
+ return
+ vlr_.uptime = int(time.time()) - vlr._create_time
+ yield from self._vlr_handler.update(None, VirtualLinkRecord.vlr_xpath(vlr), vlr_)
+ yield from asyncio.sleep(2, loop=self._loop)
+
@asyncio.coroutine
def create(self, config_xact):
@@ -2472,6 +2488,7 @@
nsr.config_status = self.map_config_status()
nsr.config_status_details = self._config_status_details
nsr.create_time = self._create_time
+ nsr.uptime = int(time.time()) - self._create_time
for cfg_prim in self.nsd_msg.service_primitive:
cfg_prim = NsrYang.YangData_Nsr_NsInstanceOpdata_Nsr_ServicePrimitive.from_dict(
@@ -3835,7 +3852,8 @@
nsr_msg,
sdn_account_name,
key_pairs,
- restart_mode=restart_mode
+ restart_mode=restart_mode,
+ vlr_handler=self._ro_plugin_selector._records_publisher._vlr_pub_hdlr
)
self._nsrs[nsr_msg.id] = nsr
nsm_plugin.create_nsr(nsr_msg, nsr_msg.nsd, key_pairs)
diff --git a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py
index 2c6c102..1a89681 100755
--- a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py
+++ b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py
@@ -1227,6 +1227,7 @@
vnfr_dict.update(vnfd_copy_dict)
vnfr_msg = RwVnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr.from_dict(vnfr_dict)
+ vnfr_msg.uptime = int(time.time()) - self._create_time
vnfr_msg.mgmt_interface = mgmt_intf
# Add all the VLRs to VNFR
@@ -1760,6 +1761,10 @@
self._log.debug("VNFR-ID %s: Instantiation Done", self._vnfr_id)
+ # create task updating uptime for this vnfr
+ self._log.debug("VNFR-ID %s: Starting task to update uptime", self._vnfr_id)
+ self._loop.create_task(self.vnfr_uptime_update(xact))
+
@asyncio.coroutine
def terminate(self, xact):
""" Terminate this virtual network function """
@@ -1797,6 +1802,19 @@
self._log.debug("Terminated VNF id %s", self.vnfr_id)
self.set_state(VirtualNetworkFunctionRecordState.TERMINATED)
+ @asyncio.coroutine
+ def vnfr_uptime_update(self, xact):
+ while True:
+ # Return when vnfr state is FAILED or TERMINATED etc
+ if self._state not in [VirtualNetworkFunctionRecordState.INIT,
+ VirtualNetworkFunctionRecordState.VL_INIT_PHASE,
+ VirtualNetworkFunctionRecordState.VM_INIT_PHASE,
+ VirtualNetworkFunctionRecordState.READY]:
+ return
+ yield from self.publish(xact)
+ yield from asyncio.sleep(2, loop=self._loop)
+
+
class VnfdDtsHandler(object):
""" DTS handler for VNFD config changes """