Browse Source

Fix for Anti Affinity verification Exception

This will fix the exception that occurs when editing Grant transmission
data during Anti Affinity verification.

Co-authored-By: Hiroo Kitamura <hiroo.kitamura@ntt-at.co.jp>
Closes-Bug: #1923136
Change-Id: If0d02d1cab40b0bf9be9bc6825d96cdfaa5ea495
changes/92/785592/11
Aldinson Esto 1 year ago committed by Hiroo Kitamura
parent
commit
1ce0d93410
  1. 3
      tacker/conductor/conductor_server.py
  2. 92
      tacker/tests/unit/conductor/test_conductor_server.py
  3. 10
      tacker/tests/unit/db/utils.py
  4. 103
      tacker/tests/unit/vnfm/infra_drivers/openstack/data/etsi_nfv/tosca_vnfd_group_member.yaml

3
tacker/conductor/conductor_server.py

@ -1102,7 +1102,8 @@ class Conductor(manager.Manager):
placement_constraint.fallback_best_effort = True
for target in policy_dict.get('targets', []):
if target in topo_temp.get('groups', []):
for member in topo_temp['groups']['members']:
for member in (topo_temp['groups'][target]
['members']):
for vnfc_rsc in vnf_inf.vnfc_resource_info:
if member == vnfc_rsc.vdu_id:
resource = \

92
tacker/tests/unit/conductor/test_conductor_server.py

@ -358,6 +358,98 @@ class TestConductor(SqlTestCase, unit_base.FixturedTestCase):
mock.ANY, 'PENDING_CREATE')
mock_update_vnf_attributes.assert_called_once()
@mock.patch('tacker.conductor.conductor_server.Conductor'
'.send_notification')
@mock.patch('tacker.conductor.conductor_server.Conductor'
'._update_vnf_attributes')
@mock.patch('tacker.conductor.conductor_server.Conductor'
'._change_vnf_status')
@mock.patch('tacker.conductor.conductor_server.Conductor'
'._build_instantiated_vnf_info')
@mock.patch('tacker.conductor.conductor_server.Conductor'
'._check_res_add_remove_rsc')
@mock.patch.object(objects.VnfLcmOpOcc, "save")
@mock.patch.object(conductor_server.Conductor, "_get_grant_execute")
@mock.patch.object(test_nfvo_client.GrantRequest, "grants")
@mock.patch.object(coordination.Coordinator, 'get_lock')
@mock.patch('tacker.vnflcm.utils._get_vnfd_dict')
@mock.patch('tacker.vnflcm.utils._convert_desired_capacity')
@mock.patch.object(objects.VnfLcmOpOcc, "get_by_id")
def test_instantiate_grant(self,
mock_vnf_by_id,
mock_des,
mock_vnfd_dict,
mock_get_lock,
mock_grants,
mock_exec,
mock_save,
mock_check,
mock_build_info,
mock_change_vnf_status,
mock_update_vnf_attributes,
mock_send_notification):
lcm_op_occs_data = fakes.get_lcm_op_occs_data()
mock_vnf_by_id.return_value = (
objects.VnfLcmOpOcc(context=self.context,
**lcm_op_occs_data))
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()
vnf_lcm_op_occs_id = uuidsentinel.vnf_lcm_op_occs_id
vnf_dict = db_utils.get_dummy_vnf_etsi(instance_id=self.instance_uuid,
flavour=instantiate_vnf_req.flavour_id,
vnfd_name="etsi_vnfd_group")
vnf_dict['before_error_point'] = fields.ErrorPoint.INITIAL
vnfd_key = 'vnfd_' + instantiate_vnf_req.flavour_id
vnfd_yaml = vnf_dict['vnfd']['attributes'].get(vnfd_key, '')
mock_vnfd_dict.return_value = yaml.safe_load(vnfd_yaml)
vimAssets = {'computeResourceFlavours': [
{'vimConnectionId': uuidsentinel.vim_id,
'vnfdVirtualComputeDescId': 'CDU1',
'vimFlavourId': 'm1.tiny'}],
'softwareImages': [
{'vimConnectionId': uuidsentinel.vim_id,
'vnfdSoftwareImageId': 'VDU1',
'vimSoftwareImageId': 'cirros'}]}
resAddResource = []
resource = {
'resourceDefinitionId': '2c6e5cc7-240d-4458-a683-1fe648351280',
'vimConnectionId': uuidsentinel.vim_id,
'zoneId': '5e4da3c3-4a55-412a-b624-843921f8b51d'}
resAddResource.append(resource)
resource = {
'resourceDefinitionId': 'faf14707-da7c-4eec-be99-8099fa1e9fa9',
'vimConnectionId': uuidsentinel.vim_id,
'zoneId': '5e4da3c3-4a55-412a-b624-843921f8b51d'}
resAddResource.append(resource)
resource = {
'resourceDefinitionId': 'faf14707-da7c-4eec-be99-8099fa1e9fa0',
'vimConnectionId': uuidsentinel.vim_id,
'zoneId': '5e4da3c3-4a55-412a-b624-843921f8b51d'}
resAddResource.append(resource)
resource = {
'resourceDefinitionId': 'faf14707-da7c-4eec-be99-8099fa1e9fa1',
'vimConnectionId': uuidsentinel.vim_id,
'zoneId': '5e4da3c3-4a55-412a-b624-843921f8b51d'}
resAddResource.append(resource)
grant_dict = {}
grant_dict['id'] = 'c213e465-8220-487e-9464-f79104e81e96'
grant_dict['vnfInstanceId'] = vnf_instance.id
grant_dict['vnfLcmOpOccId'] = vnf_lcm_op_occs_id
grant_dict['addResources'] = []
grant_dict['addResources'].extend(resAddResource)
grant_dict['vimAssets'] = vimAssets
mock_grants.return_value = MockResponse(json_data=grant_dict)
self.conductor.instantiate(self.context, vnf_instance, vnf_dict,
instantiate_vnf_req, vnf_lcm_op_occs_id)
self.assertEqual(mock_send_notification.call_count, 1)
self.assertEqual(mock_change_vnf_status.call_count, 1)
@mock.patch('tacker.conductor.conductor_server.Conductor'
'._change_vnf_status')
@mock.patch('tacker.conductor.conductor_server.Conductor'

10
tacker/tests/unit/db/utils.py

@ -35,6 +35,7 @@ tosca_vnfd_openwrt = _get_template('test_tosca_openwrt.yaml')
tosca_vnfd_openwrt_param = _get_template('test_tosca_openwrt_param.yaml')
tosca_invalid_vnfd = _get_template('test_tosca_parser_failure.yaml')
etsi_vnfd = _get_template('etsi_nfv/tosca_vnfd.yaml')
etsi_vnfd_group = _get_template('etsi_nfv/tosca_vnfd_group_member.yaml')
config_data = _get_template('config_data.yaml')
update_config_data = _get_template('update_config_data.yaml')
hot_data = _get_template('hot_data.yaml')
@ -222,7 +223,7 @@ def get_dummy_vnf_test(status='PENDING_CREATE', scaling_group=False,
def get_dummy_vnf_etsi(status='PENDING_CREATE', scaling_group=False,
instance_id=None, flavour='Simple'):
instance_id=None, flavour='Simple', vnfd_name=None):
vnfd_key = 'vnfd_' + flavour
dummy_vnf = {'status': status, 'instance_id': instance_id, 'name':
'test_openwrt', 'tenant_id': 'ad7ebc56538745a08ef7c5e97f8bd437',
@ -233,13 +234,18 @@ def get_dummy_vnf_etsi(status='PENDING_CREATE', scaling_group=False,
'description': 'OpenWRT with services',
'tenant_id': 'ad7ebc56538745a08ef7c5e97f8bd437',
'mgmt_driver': 'openwrt',
'attributes': {vnfd_key: etsi_vnfd},
'id': 'fb048660-dc1b-4f0f-bd89-b023666650ec',
'name': 'openwrt_services'},
'mgmt_ip_address': None, 'service_context': [],
'attributes': {'param_values': ''},
'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123',
'description': 'OpenWRT with services'}
if not vnfd_name:
# Set vnfd including without "tosca.groups.nfv.PlacementGroup"
dummy_vnf['vnfd']['attributes'] = {vnfd_key: etsi_vnfd}
else:
# Set vnfd including with "tosca.groups.nfv.PlacementGroup"
dummy_vnf['vnfd']['attributes'] = {vnfd_key: etsi_vnfd_group}
if scaling_group:
dummy_vnf['attributes'].update({'scaling_group_names':
'{"SP1": "SP1_group"}',

103
tacker/tests/unit/vnfm/infra_drivers/openstack/data/etsi_nfv/tosca_vnfd_group_member.yaml

@ -0,0 +1,103 @@
tosca_definitions_version: tosca_simple_yaml_1_2
description: >
Template for test _generate_hot_from_tosca().
imports:
- etsi_nfv_sol001_common_types.yaml
- etsi_nfv_sol001_vnfd_types.yaml
node_types:
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.Vdu.Compute
properties:
name: VDU1
description: VDU1 compute node
vdu_profile:
min_number_of_instances: 1
max_number_of_instances: 1
sw_image_data:
name: Software of VDU1
version: '0.5.2'
checksum:
algorithm: sha-256
hash: 932fcae93574e242dc3d772d5235061747dfe537668443a1f0567d893614b464
container_format: bare
disk_format: qcow2
min_disk: 1 GiB
size: 1 GiB
artifacts:
sw_image:
type: tosca.artifacts.nfv.SwImage
file: Files/images/cirros-0.5.2-x86_64-disk.img
capabilities:
virtual_compute:
properties:
virtual_memory:
virtual_mem_size: 512 MiB
virtual_cpu:
num_virtual_cpu: 1
virtual_local_storage:
- size_of_storage: 1 GiB
requirements:
- virtual_storage: VB1
VB1:
type: tosca.nodes.nfv.Vdu.VirtualBlockStorage
properties:
virtual_block_storage_data:
size_of_storage: 100 GB
rdma_enabled: true
sw_image_data:
name: cirros
version: '0.0.0'
checksum:
algorithm: sha512
hash: f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed2d6f919ca35d9046d437c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232
container_format: bare
disk_format: qcow2
min_disk: 0 B
min_ram: 0 B
size: 13267968 B
CP1:
type: tosca.nodes.nfv.VduCp
properties:
layer_protocols: [ ipv4 ]
order: 0
requirements:
- virtual_binding: VDU1
- virtual_link: VL3
VL3:
type: tosca.nodes.nfv.VnfVirtualLink
properties:
connectivity_type:
layer_protocols: [ ipv4 ]
description: Internal Virtual link in the VNF
vl_profile:
max_bitrate_requirements:
root: 1048576
leaf: 1048576
min_bitrate_requirements:
root: 1048576
leaf: 1048576
virtual_link_protocol_data:
- associated_layer_protocol: ipv4
l3_protocol_data:
ip_version: ipv4
cidr: 33.33.0.0/24
groups:
VDU1:
type: tosca.groups.nfv.PlacementGroup
members: [ VDU1 ]
policies:
- policy_affinity_local_VDU1:
type: tosca.policies.nfv.AntiAffinityRule
targets: [ VDU1 ]
properties:
scope: zone
Loading…
Cancel
Save