def _response_in_wait_until_stack_ready(self, status_list, stack_outputs=True): # response for heat_client's get() for status in status_list: url = self.url + '/stacks/' + self.instance_uuid json = {'stack': fd_utils.get_dummy_stack(stack_outputs, status=status)} self.requests_mock.register_uri('GET', url, json=json, headers=self.json_headers)
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'])
def test_create_wait_without_mgmt_ips(self): self._response_in_wait_until_stack_ready( ["CREATE_IN_PROGRESS", "CREATE_COMPLETE"], stack_outputs=False) vnf_dict = utils.get_dummy_vnf(instance_id=self.instance_uuid) self.openstack.create_wait(None, None, vnf_dict, self.instance_uuid, None) self.mock_log.debug.assert_called_with( 'outputs %s', fd_utils.get_dummy_stack(outputs=False)['outputs']) self.assertIsNone(vnf_dict['mgmt_ip_address'])
def test_create_wait(self): self._response_in_wait_until_stack_ready(["CREATE_IN_PROGRESS", "CREATE_COMPLETE"]) vnf_dict = utils.get_dummy_vnf(instance_id=self.instance_uuid) self.openstack.create_wait(None, None, vnf_dict, self.instance_uuid, None) self.mock_log.debug.assert_called_with('outputs %s', fd_utils.get_dummy_stack()['outputs']) self.assertEqual('{"VDU1": "192.168.120.216"}', vnf_dict['mgmt_ip_address'])
def _responses_in_resource_event_list(self, dummy_event): # response for heat_client's resource_event_list() url = self.url + '/stacks/' + self.instance_uuid json = {'stack': [fd_utils.get_dummy_stack()]} self.requests_mock.register_uri('GET', url, json=json, headers=self.json_headers) url = self.url + '/stacks/' + self.instance_uuid + ('/myStack/60f83b5e' '/resources/SP1_scale_out/events?limit=1&sort_dir=desc&sort_keys=' 'event_time') json = {'events': [dummy_event]} self.requests_mock.register_uri('GET', url, json=json, headers=self.json_headers)