summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2019-05-20 08:23:08 +0000
committerGerrit Code Review <gerrit@onap.org>2019-05-20 08:23:08 +0000
commit629f34264bb5301fb9cc1541fb0e3132faa706af (patch)
treee3b622720e15f5747e466de2da61266213dfc8e5
parent383ebeaa7238bdda0450d199a4083e26ffd20dd6 (diff)
parentc8942adc34c28f9f0b76d310fdb704c0934759bb (diff)
Merge "Fix FCAPS integraton test bugs"1.3.3
-rw-r--r--fcaps/fcaps/vesagent/event_domain/pm_vm.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/fcaps/fcaps/vesagent/event_domain/pm_vm.py b/fcaps/fcaps/vesagent/event_domain/pm_vm.py
index 032655ba..eed6fe07 100644
--- a/fcaps/fcaps/vesagent/event_domain/pm_vm.py
+++ b/fcaps/fcaps/vesagent/event_domain/pm_vm.py
@@ -22,7 +22,7 @@ from django.conf import settings
from fcaps.vesagent.vespublish import publishAnyEventToVES
from common.utils import restcall
from common.msapi.helper import Helper as helper
-
+from common.msapi import extsys
import datetime
import time
@@ -139,6 +139,7 @@ def processBacklog_pm_vm(vesAgentConfig, vesAgentState, oneBacklog):
# get token
# resolve tenant_name to tenant_id
+ vimid = vesAgentConfig["vimid"]
cloud_owner, regionid = extsys.decode_vim_id(vimid)
# should go via multicloud proxy so that the selflink is updated by multicloud
retcode, v2_token_resp_json, os_status = helper.MultiCloudIdentityHelper(
@@ -152,7 +153,7 @@ def processBacklog_pm_vm(vesAgentConfig, vesAgentState, oneBacklog):
service_type = "metering"
resource_uri = oneBacklog["api_link"]
template_data = ''
- self._logger.info("retrieve metering resources, URI:%s" % resource_uri)
+ logger.info("retrieve metering resources, URI:%s" % resource_uri)
retcode, content, os_status = helper.MultiCloudServiceHelper(cloud_owner,
regionid,
v2_token_resp_json,
@@ -161,7 +162,7 @@ def processBacklog_pm_vm(vesAgentConfig, vesAgentState, oneBacklog):
template_data,
"GET")
meters = content if retcode == 0 and content else []
-
+ all_events = []
for meter in meters:
encodeData = data2event_pm_vm(meter)
encodeData['event']['commonEventHeader']['eventType'] = 'guestOS'
@@ -201,7 +202,10 @@ def data2event_pm_vm(vm_data):
sequence = 1
startEpochMicrosec = int(time.mktime(time.strptime(vm_data['recorded_at'], '%Y-%m-%dT%H:%M:%S')))
lastEpochMicrosec = startEpochMicrosec
- # now populate the event structure
+ additionalMeasurements = []
+ arrayOfFields = []
+ arrayOfFields.append({'name': vm_data['meter'], 'value': str(vm_data['volume'])})
+ additionalMeasurements.append({'name': sourceId, 'arrayOfFields': arrayOfFields})
this_event = {
'event': {
'commonEventHeader': {
@@ -222,7 +226,7 @@ def data2event_pm_vm(vm_data):
'measurementsForVfScalingFields': {
'measurementsForVfScalingVersion': VES_EVENT_pm_VERSION,
'measurementInterval': 0,
- 'additionalMeasurements': vm_data['additionalMeasurements']
+ 'additionalMeasurements': additionalMeasurements
}
}
}