예제 #1
0
 def test_encode_process_input(self):
     bytes_idata = helpers.compact_byte("%s\n" % self.test_file[:-1])
     bytes_odata = helpers.compact_byte("%s\n" % self.test_file)
     self.mock_popen.return_value = [bytes_odata, b'']
     result = utils.execute(['cat'], process_input=bytes_idata)
     self.mock_popen.assert_called_once_with(bytes_idata)
     self.assertEqual(bytes_odata, result)
예제 #2
0
 def test_encode_process_input(self):
     bytes_idata = helpers.compact_byte("%s\n" % self.test_file[:-1])
     bytes_odata = helpers.compact_byte("%s\n" % self.test_file)
     self.mock_popen.return_value = [bytes_odata, b'']
     result = utils.execute(['cat'], process_input=bytes_idata)
     self.mock_popen.assert_called_once_with(bytes_idata)
     self.assertEqual(bytes_odata, result)
예제 #3
0
    def _get_expected_tosca_vnf(self,
                                tosca_tpl_name,
                                hot_tpl_name,
                                param_values='',
                                is_monitor=True,
                                multi_vdus=False):
        tosca_tpl = _get_template(tosca_tpl_name)
        exp_tmpl = self._get_expected_vnfd(tosca_tpl)
        tosca_hw_dict = yaml.safe_load(_get_template(hot_tpl_name))
        dvc = {
            'vnfd': exp_tmpl,
            'description': u'OpenWRT with services',
            'attributes': {
                'heat_template': tosca_hw_dict,
                'param_values': param_values
            },
            'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123',
            'instance_id': None,
            'mgmt_ip_address': None,
            'name': u'test_openwrt',
            'service_context': [],
            'status': 'PENDING_CREATE',
            'vnfd_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e',
            'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437'
        }
        # Add monitoring attributes for those yaml, which are having it
        if is_monitor:
            if multi_vdus:
                dvc['attributes'].update({
                    'monitoring_policy':
                    helpers.compact_byte('{"vdus": {"VDU1": {"ping": '
                                         '{"name": "ping", "actions": '
                                         '{"failure": "respawn"}, '
                                         '"parameters": {"count": 3, '
                                         '"interval": 10}, '
                                         '"monitoring_params": '
                                         '{"count": 3, "interval": 10}}}, '
                                         '"VDU2": {"ping": {"name": "ping", '
                                         '"actions": {"failure": "respawn"}, '
                                         '"parameters": {"count": 3, '
                                         '"interval": 10}, '
                                         '"monitoring_params": {"count": 3, '
                                         '"interval": 10}}}}}')
                })
            else:
                dvc['attributes'].update({
                    'monitoring_policy':
                    helpers.compact_byte('{"vdus": {"VDU1": {"ping": '
                                         '{"name": "ping", "actions": '
                                         '{"failure": "respawn"}, '
                                         '"parameters": {"count": 3, '
                                         '"interval": 10}, '
                                         '"monitoring_params": '
                                         '{"count": 3, '
                                         '"interval": 10}}}}}')
                })

        return dvc
예제 #4
0
    def _get_expected_tosca_vnf(self,
                                tosca_tpl_name,
                                hot_tpl_name,
                                param_values='',
                                is_monitor=True,
                                multi_vdus=False):
        tosca_tpl = _get_template(tosca_tpl_name)
        exp_tmpl = self._get_expected_vnfd(tosca_tpl)
        tosca_hw_dict = yaml.safe_load(_get_template(hot_tpl_name))
        dvc = {
            'vnfd': exp_tmpl,
            'description': u'OpenWRT with services',
            'attributes': {
                'heat_template': tosca_hw_dict,
                'param_values': param_values
            },
            'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123',
            'instance_id': None,
            'mgmt_ip_address': None,
            'name': u'test_openwrt',
            'service_context': [],
            'status': 'PENDING_CREATE',
            'vnfd_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e',
            'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437'
        }
        # Add monitoring attributes for those yaml, which are having it
        if is_monitor:
            if multi_vdus:
                dvc['attributes'].update(
                    {'monitoring_policy': helpers.compact_byte(
                     '{"vdus": {"VDU1": {"ping": '
                     '{"name": "ping", "actions": '
                     '{"failure": "respawn"}, '
                     '"parameters": {"count": 3, '
                     '"interval": 10}, '
                     '"monitoring_params": '
                     '{"count": 3, "interval": 10}}}, '
                     '"VDU2": {"ping": {"name": "ping", '
                     '"actions": {"failure": "respawn"}, '
                     '"parameters": {"count": 3, '
                     '"interval": 10}, '
                     '"monitoring_params": {"count": 3, '
                     '"interval": 10}}}}}')})
            else:
                dvc['attributes'].update(
                    {'monitoring_policy': helpers.compact_byte(
                     '{"vdus": {"VDU1": {"ping": '
                     '{"name": "ping", "actions": '
                     '{"failure": "respawn"}, '
                     '"parameters": {"count": 3, '
                     '"interval": 10}, '
                     '"monitoring_params": '
                     '{"count": 3, '
                     '"interval": 10}}}}}')})

        return dvc
예제 #5
0
 def test_update_wait(self):
     self._response_in_wait_until_stack_ready(["CREATE_COMPLETE"])
     vnf_dict = utils.get_dummy_vnf(status='PENDING_UPDATE',
                                    instance_id=self.instance_uuid)
     self.openstack.update_wait(None, None, vnf_dict, None)
     self.mock_log.debug.assert_called_with('outputs %s',
                                 fd_utils.get_dummy_stack()['outputs'])
     self.assertEqual(helpers.compact_byte('{"VDU1": "192.168.120.216"}'),
                      vnf_dict['mgmt_ip_address'])
예제 #6
0
 def test_scale_wait_with_same_last_event_id(self, resource_status):
     self._test_scale(resource_status)
     mgmt_ip = self.openstack.scale_wait(plugin=self,
                             context=self.context,
                             auth_attr=None,
                             policy=fd_utils.get_dummy_policy_dict(),
                             region_name=None,
                             last_event_id=fd_utils.get_dummy_event()['id'])
     self.assertEqual(helpers.compact_byte('{"vdu1": ["test1"]}'),
                      mgmt_ip)
예제 #7
0
 def test_scale_wait_with_different_last_event_id(self):
     self._test_scale("SIGNAL_COMPLETE")
     mgmt_ip = self.openstack.scale_wait(plugin=self, context=self.context,
                                  auth_attr=None,
                                  policy=fd_utils.get_dummy_policy_dict(),
                                  region_name=None,
                                  last_event_id=uuidsentinel.
                                         non_last_event_id)
     self.assertEqual(helpers.compact_byte('{"vdu1": ["test1"]}'),
                      mgmt_ip)
예제 #8
0
    def test_process_request(self, mock_create_token):
        mock_create_token.return_value = 'fake_token'
        req = Request.blank(self.ordered_url)
        req.method = 'POST'
        self.alarmrc.process_request(req)

        self.assertEqual(helpers.compact_byte(''), req.body)
        self.assertEqual('fake_token', req.headers['X_AUTH_TOKEN'])
        self.assertIn(self.alarm_url['01_url_base'], req.environ['PATH_INFO'])
        self.assertIn('triggers', req.environ['PATH_INFO'])
        self.assertEqual('', req.environ['QUERY_STRING'])
        mock_create_token.assert_called_once_with()
예제 #9
0
 def test_create_wait_with_scaling_group_names(self):
     self._response_in_wait_until_stack_ready(["CREATE_IN_PROGRESS",
                                              "CREATE_COMPLETE"])
     self._response_in_resource_get(self.instance_uuid,
                                    res_name='SP1_group')
     url = self.url + '/stacks/' + self.stack_id + '/resources'
     json = {'resources': [fd_utils.get_dummy_resource()]}
     self.requests_mock.register_uri('GET', url, json=json,
                                     headers=self.json_headers)
     self._response_in_resource_get(self.stack_id)
     vnf_dict = utils.get_dummy_vnf(scaling_group=True)
     self.openstack.create_wait(None, None, vnf_dict, self.instance_uuid,
                                None)
     self.assertEqual(helpers.compact_byte('{"vdu1": ["test1"]}'),
                      vnf_dict['mgmt_ip_address'])
예제 #10
0
 def test_decode_return_data(self):
     str_data = helpers.compact_byte("%s\n" % self.test_file)
     result = utils.execute(['ls', self.test_file], return_stderr=True)
     self.assertEqual((str_data, helpers.compact_byte('')), result)
예제 #11
0
 def test_decode_return_data(self):
     str_data = helpers.compact_byte("%s\n" % self.test_file)
     result = utils.execute(['ls', self.test_file], return_stderr=True)
     self.assertEqual((str_data, helpers.compact_byte('')), result)