3 # Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
15 from opera import openo_connect
18 import functest.opnfv_tests.vnf.ims.clearwater_ims_base as clearwater_ims_base
19 from functest.utils.constants import CONST
22 class OperaIms(clearwater_ims_base.ClearwaterOnBoardingBase):
24 def __init__(self, **kwargs):
25 if "case_name" not in kwargs:
26 kwargs["case_name"] = "opera_ims"
27 super(OperaIms, self).__init__(**kwargs)
28 self.logger = logging.getLogger(__name__)
29 self.ellis_file = os.path.join(
30 CONST.__getattribute__('dir_results'), 'ellis.info')
31 self.live_test_file = os.path.join(
32 CONST.__getattribute__('dir_results'), 'live_test_report.json')
34 self.openo_msb_endpoint = os.environ['OPENO_MSB_ENDPOINT']
36 raise Exception('OPENO_MSB_ENDPOINT is not specified,'
37 ' put it as <OPEN-O ip>:<port>')
39 self.logger.info('OPEN-O endpoint is: %s', self.openo_msb_endpoint)
49 openo_connect.create_service(self.openo_msb_endpoint,
51 'VNF for functest testing')
52 except Exception as e:
54 return {'status': 'FAIL', 'result': e}
56 self.logger.info('vIMS deployment is kicked off')
57 return {'status': 'PASS', 'result': ''}
59 def dump_info(self, info_file, result):
60 with open(info_file, 'w') as f:
61 self.logger.debug('Save information to file: %s', info_file)
65 vnfm_ip = openo_connect.get_vnfm_ip(self.openo_msb_endpoint)
66 self.logger.info('VNFM IP: %s', vnfm_ip)
67 vnf_status_url = 'http://{0}:5000/api/v1/model/status'.format(vnfm_ip)
71 self.logger.info('Check the VNF status')
73 rq = requests.get(vnf_status_url, timeout=90)
75 vnf_alive = response['vnf_alive']
80 self.logger.info('check again in one and half a minute...')
85 raise Exception('VNF failed to start: {0}'.format(msg))
87 ellis_config_url = ('http://{0}:5000/api/v1/model/ellis/configure'
89 rq = requests.get(ellis_config_url, timeout=90)
90 if rq.json() and not rq.json()['ellis_ok']:
91 self.logger.error(rq.json()['data'])
92 raise Exception('Failed to configure Ellis')
94 self.logger.info('Get Clearwater deployment detail')
95 vnf_info_url = ('http://{0}:5000/api/v1/model/output'
97 rq = requests.get(vnf_info_url, timeout=90)
98 data = rq.json()['data']
99 self.logger.info(data)
100 bono_ip = data['bono_ip']
101 ellis_ip = data['ellis_ip']
102 dns_ip = data['dns_ip']
103 result = self.config_ellis(ellis_ip, 'signup', True)
104 self.logger.debug('Ellis Result: %s', result)
105 self.dump_info(self.ellis_file, result)
108 vims_test_result = self.run_clearwater_live_test(
114 if vims_test_result != '':
115 self.dump_info(self.live_test_file, vims_test_result)
116 return {'status': 'PASS', 'result': vims_test_result}
118 return {'status': 'FAIL', 'result': ''}
120 def main(self, **kwargs):
121 self.logger.info("Start to run Opera vIMS VNF onboarding test")
123 self.logger.info("Opera vIMS VNF onboarding test finished")
124 if self.result is "PASS":
127 return self.EX_RUN_ERROR
131 return self.main(**kwargs)