X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwlaunchpad%2Fplugins%2Frwmonitor%2Frift%2Ftasklets%2Frwmonitor%2Fcore.py;h=f43da6fcfca5b94f938dded33721088d1bed782c;hb=a3bb91f092d378448cb870eccd45d43865de143c;hp=b97b2f53c8d0da93ac07387be126def98b778699;hpb=6f07e6f33f751ab4ffe624f6037f887b243bece2;p=osm%2FSO.git diff --git a/rwlaunchpad/plugins/rwmonitor/rift/tasklets/rwmonitor/core.py b/rwlaunchpad/plugins/rwmonitor/rift/tasklets/rwmonitor/core.py index b97b2f53..f43da6fc 100644 --- a/rwlaunchpad/plugins/rwmonitor/rift/tasklets/rwmonitor/core.py +++ b/rwlaunchpad/plugins/rwmonitor/rift/tasklets/rwmonitor/core.py @@ -231,7 +231,7 @@ class NfviMetrics(object): self._account = account self._plugin = plugin self._timestamp = 0 - self._metrics = RwVnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr_Vdur_NfviMetrics() + self._metrics = RwVnfrYang.YangData_RwProject_Project_VnfrCatalog_Vnfr_Vdur_NfviMetrics() self._vdur = vdur self._vim_id = vdur.vim_id self._updating = None @@ -305,7 +305,7 @@ class NfviMetrics(object): try: # Create uninitialized metric structure - vdu_metrics = RwVnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr_Vdur_NfviMetrics() + vdu_metrics = RwVnfrYang.YangData_RwProject_Project_VnfrCatalog_Vnfr_Vdur_NfviMetrics() # VCPU vdu_metrics.vcpu.total = self.vdur.vm_flavor.vcpu_count @@ -317,9 +317,22 @@ class NfviMetrics(object): vdu_metrics.memory.utilization = 100 * vdu_metrics.memory.used / vdu_metrics.memory.total # Storage - vdu_metrics.storage.used = metrics.storage.used - vdu_metrics.storage.total = 1e9 * self.vdur.vm_flavor.storage_gb - vdu_metrics.storage.utilization = 100 * vdu_metrics.storage.used / vdu_metrics.storage.total + try: + vdu_metrics.storage.used = metrics.storage.used + if self.vdur.has_field('volumes'): + for volume in self.vdur.volumes: + if vdu_metrics.storage.total is None: + vdu_metrics.storage.total = 1e9 * volume.size + else: + vdu_metrics.storage.total += (1e9 * volume.size) + else: + vdu_metrics.storage.total = 1e9 * self.vdur.vm_flavor.storage_gb + utilization = 100 * vdu_metrics.storage.used / vdu_metrics.storage.total + if utilization > 100: + utilization = 100 + vdu_metrics.storage.utilization = utilization + except ZeroDivisionError: + vdu_metrics.storage.utilization = 0 # Network (incoming) vdu_metrics.network.incoming.packets = metrics.network.incoming.packets @@ -536,17 +549,19 @@ class Monitor(object): different sub-systems that are used to monitor the NFVI. """ - def __init__(self, loop, log, config): + def __init__(self, loop, log, config, project): """Create a Monitor object Arguments: - loop - an event loop - log - the logger used by this object - config - an instance of InstanceConfiguration + loop - an event loop + log - the logger used by this object + config - an instance of InstanceConfiguration + project - an instance of the project """ self._loop = loop self._log = log + self._project = project self._cloud_accounts = dict() self._nfvi_plugins = NfviMetricsPluginManager(log) @@ -567,6 +582,10 @@ class Monitor(object): """The event log used by this object""" return self._log + @property + def project(self): + return self._project + @property def cache(self): """The NFVI metrics cache"""