Fix vnf heal logic 15/73315/1
authorfujinhua <fu.jinhua@zte.com.cn>
Thu, 22 Nov 2018 00:57:06 +0000 (08:57 +0800)
committerfujinhua <fu.jinhua@zte.com.cn>
Thu, 22 Nov 2018 00:57:06 +0000 (08:57 +0800)
Change-Id: I1304b832b5e11e003c26405355f2e09d4dbc850a
Issue-ID: VFC-1163
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
lcm/ns_vnfs/biz/heal_vnfs.py

index 31dbc96..60d0621 100644 (file)
@@ -19,7 +19,7 @@ import traceback
 
 from lcm.pub.config.config import MR_IP
 from lcm.pub.config.config import MR_PORT
-from lcm.pub.database.models import NfInstModel, VNFCInstModel
+from lcm.pub.database.models import NfInstModel, VNFCInstModel, VmInstModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi.vnfmdriver import send_nf_heal_request
 from lcm.pub.utils import restcall
@@ -80,6 +80,14 @@ class NFHealService(threading.Thread):
 
         actionvminfo = ignore_case_get(self.nf_additional_params, 'actionvminfo')
         vmid = ignore_case_get(actionvminfo, 'vmid')
+        self.nf_heal_params = {
+            "action": "vmReset",
+            "affectedvm": {
+                "vmid": vmid,
+                "vduid": self.get_vudId(vmid),
+                "vmname": self.get_vmname(vmid)
+            }
+        }
         retry_count = 10
         while (retry_count > 0):
             resp = restcall.call_req('http://%s:%s/events' % (MR_IP, MR_PORT),
@@ -122,8 +130,13 @@ class NFHealService(threading.Thread):
         if not vnfcInstances:
             raise NSLCMException('VDU [vmid=%s, vnfInstanceId=%s] does not exist' % (vmid, self.vnf_instance_id))
 
-        vnfcInstance = VNFCInstModel.objects.filter(vmid=vmid, nfinstid=self.vnf_instance_id).first()
-        return vnfcInstance.vduid
+        return vnfcInstances.first().vduid
+
+    def get_vmname(self, vmid):
+        vms = VmInstModel.objects.filter(resouceid=vmid)
+        if not vms:
+            return vmid
+        return vms.first().vmname
 
     def update_job(self, progress, desc=''):
         JobUtil.add_job_status(self.job_id, progress, desc)