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
14 from opera import openo_connect
17 import functest.opnfv_tests.vnf.ims.clearwater_ims_base as clearwater_ims_base
18 from functest.utils.constants import CONST
19 import functest.utils.functest_logger as ft_logger
22 class OperaIms(clearwater_ims_base.ClearwaterOnBoardingBase):
24 def __init__(self, project='functest', case='opera_ims',
25 repo=CONST.dir_repo_opera, cmd=''):
26 super(OperaIms, self).__init__(project, case, repo, cmd)
27 self.logger = ft_logger.Logger(__name__).getLogger()
28 self.ellis_file = os.path.join(self.result_dir, 'ellis.info')
29 self.live_test_file = os.path.join(self.result_dir,
30 'live_test_report.json')
32 self.openo_msb_endpoint = os.environ['OPENO_MSB_ENDPOINT']
34 raise Exception('OPENO_MSB_ENDPOINT is not specified,'
35 ' put it as <OPEN-O ip>:<port>')
37 self.logger.info('OPEN-O endpoint is: %s', self.openo_msb_endpoint)
47 openo_connect.create_service(self.openo_msb_endpoint,
49 'VNF for functest testing')
50 except Exception as e:
52 return {'status': 'FAIL', 'result': e}
54 self.logger.info('vIMS deployment is kicked off')
55 return {'status': 'PASS', 'result': ''}
57 def dump_info(self, info_file, result):
58 with open(info_file, 'w') as f:
59 self.logger.debug('Save information to file: %s', info_file)
63 vnfm_ip = openo_connect.get_vnfm_ip(self.openo_msb_endpoint)
64 self.logger.info('VNFM IP: %s', vnfm_ip)
65 vnf_status_url = 'http://{0}:5000/api/v1/model/status'.format(vnfm_ip)
69 self.logger.info('Check the VNF status')
71 rq = requests.get(vnf_status_url)
73 vnf_alive = response['vnf_alive']
78 self.logger.info('check again in one minute...')
83 raise Exception('VNF failed to start: {0}'.format(msg))
85 ellis_config_url = ('http://{0}:5000/api/v1/model/ellis/configure'
87 rq = requests.get(ellis_config_url, timeout=60)
88 if rq.json() and not rq.json()['ellis_ok']:
89 self.logger.error(rq.json()['data'])
90 raise Exception('Failed to configure Ellis')
92 self.logger.info('Get Clearwater deployment detail')
93 vnf_info_url = ('http://{0}:5000/api/v1/model/output'
95 rq = requests.get(vnf_info_url, timeout=60)
96 data = rq.json()['data']
97 self.logger.info(data)
98 bono_ip = data['bono_ip']
99 ellis_ip = data['ellis_ip']
100 dns_ip = data['dns_ip']
101 result = self.config_ellis(ellis_ip, 'signup', True)
102 self.logger.debug('Ellis Result: %s', result)
103 self.dump_info(self.ellis_file, result)
106 vims_test_result = self.run_clearwater_live_test(
112 if vims_test_result != '':
113 self.dump_info(self.live_test_file, vims_test_result)
114 return {'status': 'PASS', 'result': vims_test_result}
116 return {'status': 'FAIL', 'result': ''}
118 def main(self, **kwargs):
119 self.logger.info("Start to run Opera vIMS VNF onboarding test")
121 self.logger.info("Opera vIMS VNF onboarding test finished")
122 if self.criteria is "PASS":
125 return self.EX_RUN_ERROR
129 return self.main(**kwargs)