def test_get_param_data_with_flavour_description(self): vnfd_dict = fakes.get_vnfd_dict() vnfd_dict.update({'imports': []}) instantiate_vnf_req = fakes.get_instantiate_vnf_request_obj() param_value = vnflcm_utils._get_param_data(vnfd_dict, instantiate_vnf_req) expected_flavour_description = 'A simple flavor' self.assertEqual(expected_flavour_description, param_value['flavour_description'])
def test_instantiate_vnf_instance_with_vnf_package_in_use( self, mock_vnf_package_in_use, mock_get_lock): vnf_package_vnfd = self._create_and_upload_vnf_package() vnf_instance_data = fake_obj.get_vnf_instance_data( vnf_package_vnfd.vnfd_id) mock_vnf_package_in_use.return_value = True vnf_instance = objects.VnfInstance(context=self.context, **vnf_instance_data) vnf_instance.create() instantiate_vnf_req = vnflcm_fakes.get_instantiate_vnf_request_obj() self.conductor.instantiate(self.context, vnf_instance, instantiate_vnf_req) self.vnflcm_driver.instantiate_vnf.assert_called_once_with( self.context, mock.ANY, instantiate_vnf_req) mock_vnf_package_in_use.assert_called_once()
def test_instantiate_vnf_instance_failed_with_exception( self, mock_log, mock_is_package_in_use, mock_get_lock): vnf_package_vnfd = self._create_and_upload_vnf_package() vnf_instance_data = fake_obj.get_vnf_instance_data( vnf_package_vnfd.vnfd_id) vnf_instance = objects.VnfInstance(context=self.context, **vnf_instance_data) vnf_instance.create() instantiate_vnf_req = vnflcm_fakes.get_instantiate_vnf_request_obj() mock_is_package_in_use.side_effect = Exception self.conductor.instantiate(self.context, vnf_instance, instantiate_vnf_req) self.vnflcm_driver.instantiate_vnf.assert_called_once_with( self.context, mock.ANY, instantiate_vnf_req) mock_is_package_in_use.assert_called_once() expected_log = 'Failed to update usage_state of vnf package %s' mock_log.error.assert_called_once_with(expected_log, vnf_package_vnfd.package_uuid)
def test_instantiate_vnf_instance_already_instantiated(self, mock_log, mock_package_in_use, mock_get_lock): vnf_package_vnfd = self._create_and_upload_vnf_package() vnf_instance_data = fake_obj.get_vnf_instance_data( vnf_package_vnfd.vnfd_id) vnf_instance_data['instantiation_state'] =\ fields.VnfInstanceState.INSTANTIATED vnf_instance = objects.VnfInstance(context=self.context, **vnf_instance_data) vnf_instance.create() instantiate_vnf_req = vnflcm_fakes.get_instantiate_vnf_request_obj() self.conductor.instantiate(self.context, vnf_instance, instantiate_vnf_req) self.vnflcm_driver.instantiate_vnf.assert_not_called() mock_package_in_use.assert_not_called() expected_log = 'Vnf instance %(id)s is already in %(state)s state.' mock_log.error.assert_called_once_with(expected_log, {'id': vnf_instance.id, 'state': fields.VnfInstanceState.INSTANTIATED})