aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfengyuanxing <feng.yuanxing@zte.com.cn>2017-09-21 16:32:44 +0800
committerfengyuanxing <feng.yuanxing@zte.com.cn>2017-09-21 16:32:44 +0800
commitbaeb79abd6ffb53050cdf54a25740d7889eff04a (patch)
tree5d2f536cdb4075f9244f77eda12b3a7383001db5
parent5661218e007c45113d4218ba9e5cc7743677eda4 (diff)
Add code to get vdu id
Change-Id: I07128968718db4dc784a29be8a5456b3576a55eb Issue-Id: VFC-412 Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
-rw-r--r--lcm/ns/vnfs/heal_vnfs.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/lcm/ns/vnfs/heal_vnfs.py b/lcm/ns/vnfs/heal_vnfs.py
index f17be258..ce847955 100644
--- a/lcm/ns/vnfs/heal_vnfs.py
+++ b/lcm/ns/vnfs/heal_vnfs.py
@@ -19,7 +19,7 @@ import traceback
from lcm.ns.vnfs.const import VNF_STATUS
from lcm.ns.vnfs.wait_job import wait_job_finish
-from lcm.pub.database.models import NfInstModel
+from lcm.pub.database.models import NfInstModel, VNFCInstModel
from lcm.pub.exceptions import NSLCMException
from lcm.pub.msapi.vnfmdriver import send_nf_heal_request
from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS
@@ -82,8 +82,8 @@ class NFHealService(threading.Thread):
actionvminfo = ignore_case_get(self.nf_additional_params, 'actionvminfo')
vmid = ignore_case_get(actionvminfo, 'vmid')
vmname = ignore_case_get(actionvminfo, 'vmname')
- # TODO(sshank): Find how to get 'vduid'
- vduid = ""
+ # Gets vduid
+ vduid = self.get_vudId(vmid)
self.nf_heal_params = {
"action": action,
@@ -104,6 +104,13 @@ class NFHealService(threading.Thread):
logger.error('[NF heal] nf heal failed')
raise NSLCMException("nf heal failed")
+ # Gets vdu id according to the given vm id.
+ def get_vudId(self, vmId):
+ vnfcInstance = VNFCInstModel.objects.filter(vmid = vmId).first()
+ if not vnfcInstance:
+ raise NSLCMException('VDU [vmid=%s] does not exist' % self.vmId)
+ return vnfcInstance.vduid
+
def update_job(self, progress, desc=''):
JobUtil.add_job_status(self.job_id, progress, desc)