diff options
author | Bin Sun <bins@vmware.com> | 2018-06-07 11:03:25 +0800 |
---|---|---|
committer | Bin Sun <bins@vmware.com> | 2018-06-07 11:05:05 +0800 |
commit | 3b93ad7d722930f70c3f70b89c035b5c17d3f63a (patch) | |
tree | 4bd16e930279a8977ac82d51716b022f9a2722a4 | |
parent | 439dd5d538f23c0c10193f96260925bd153c7516 (diff) |
Fix bug for Dynamic Recovery
Change-Id: Ic16d530d20de98b99e77c7d1ddf27afb3a951530
Issue-ID: VFC-791
Signed-off-by: Bin Sun <bins@vmware.com>
-rwxr-xr-x | docker/instance_config.sh | 11 | ||||
-rw-r--r-- | lcm/ns/vnfs/heal_vnfs.py | 45 | ||||
-rw-r--r-- | lcm/pub/config/config.py | 4 |
3 files changed, 43 insertions, 17 deletions
diff --git a/docker/instance_config.sh b/docker/instance_config.sh index 3f566453..3a9f3a03 100755 --- a/docker/instance_config.sh +++ b/docker/instance_config.sh @@ -3,6 +3,9 @@ MSB_IP=`echo $MSB_ADDR | cut -d: -f 1` MSB_PORT=`echo $MSB_ADDR | cut -d: -f 2` +MR_IP=`echo $MR_ADDR | cut -d: -f 1` +MR_PORT=`echo $MR_ADDR | cut -d: -f 2` + if [ $MSB_IP ]; then sed -i "s|MSB_SERVICE_IP.*|MSB_SERVICE_IP = '$MSB_IP'|" vfc/nfvo/lcm/lcm/pub/config/config.py fi @@ -11,6 +14,14 @@ if [ $MSB_PORT ]; then sed -i "s|MSB_SERVICE_PORT.*|MSB_SERVICE_PORT = '$MSB_PORT'|" vfc/nfvo/lcm/lcm/pub/config/config.py fi +if [ $MR_IP ]; then + sed -i "s|MR_IP.*|MR_IP = '$MR_IP'|" vfc/nfvo/lcm/lcm/pub/config/config.py +fi + +if [ $MR_PORT ]; then + sed -i "s|MR_PORT.*|MR_PORT = '$MR_PORT'|" vfc/nfvo/lcm/lcm/pub/config/config.py +fi + if [ $SERVICE_IP ]; then sed -i "s|\"ip\": \".*\"|\"ip\": \"$SERVICE_IP\"|" vfc/nfvo/lcm/lcm/pub/config/config.py fi diff --git a/lcm/ns/vnfs/heal_vnfs.py b/lcm/ns/vnfs/heal_vnfs.py index 5117d597..b9520adc 100644 --- a/lcm/ns/vnfs/heal_vnfs.py +++ b/lcm/ns/vnfs/heal_vnfs.py @@ -24,6 +24,9 @@ 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 from lcm.pub.utils.values import ignore_case_get +from lcm.pub.config.config import MR_IP +from lcm.pub.config.config import MR_PORT +from lcm.pub.utils import restcall JOB_ERROR = 255 @@ -75,25 +78,33 @@ class NFHealService(threading.Thread): logger.error('additionalParams parameter does not exist or value incorrect') raise NSLCMException('additionalParams parameter does not exist or value incorrect') - action = ignore_case_get(self.nf_additional_params, 'action') - if action == "restartvm": - action = "vmReset" - # action = "vmStart" - actionvminfo = ignore_case_get(self.nf_additional_params, 'actionvminfo') vmid = ignore_case_get(actionvminfo, 'vmid') - vmname = ignore_case_get(actionvminfo, 'vmname') - - vduid = self.get_vudId(vmid) - - self.nf_heal_params = { - "action": action, - "affectedvm": { - "vmid": vmid, - "vduid": vduid, - "vmname": vmname, - } - } + retry_count = 10 + while (retry_count > 0): + resp = restcall.call_req('http://%s:%s/events' % (MR_IP, MR_PORT), + '', + '', + restcall.rest_no_auth, + '/test/bins/1?timeout=15000', + 'GET') + if resp[2] == '200' and resp[1] != '[]': + for message in eval(resp[1]): + if 'powering-off' in message: + action = "vmReset" + vm_info = json.loads(message) + if vmid == vm_info['instance_id']: + vduid = self.get_vudId(vm_info['instance_id']) + self.nf_heal_params = { + "action": action, + "affectedvm": { + "vmid": vm_info['instance_id'], + "vduid": vduid, + "vmname": vm_info['display_name'] + } + } + retry_count = -1 + retry_count = retry_count - 1 def send_nf_healing_request(self): req_param = json.JSONEncoder().encode(self.nf_heal_params) diff --git a/lcm/pub/config/config.py b/lcm/pub/config/config.py index 3dbe7e5e..131ccdb0 100644 --- a/lcm/pub/config/config.py +++ b/lcm/pub/config/config.py @@ -72,6 +72,10 @@ SDC_BASE_URL = "http://10.0.14.1:80/api" SDC_USER = "SDC" SDC_PASSWD = "SDC" +# [DMaaP] +MR_IP = '127.0.0.1' +MR_PORT = '3904' + # [workflow] DEPLOY_WORKFLOW_WHEN_START = False # Support option: activiti/wso2/buildin |