Browse Source

[WIP] Set different number of instances for same delta and aspectId.

As per SOL001(*1) "A.6.1 ScalingAspect and InstantiationLevels
policies with uniform delta",number_of_instance of deltas
in `VduScalingAspectDeltas`is able to have different value
for same aspect_id and delta_id.This patch fixes the code
which was earlier overwriting the value for same aspect and
delta id.
Closes-Bug: 1906779

Change-Id: Ic28b5748c8d63d943218d0ac524dcbcfdc06366a
changes/33/825833/4
Pooja Singla 4 months ago
parent
commit
4da741dadc
  1. 27
      tacker/tosca/utils.py
  2. 2
      tacker/vnflcm/utils.py
  3. 16
      tacker/vnfm/infra_drivers/kubernetes/kubernetes_driver.py

27
tacker/tosca/utils.py

@ -863,8 +863,22 @@ def _extract_policy_info(tosca_policies, inst_level_dict,
delta_id_dict = {}
for delta_id, delta_val in deltas.items():
delta_num = delta_val['number_of_instances']
delta_id_dict[delta_id] = delta_num
aspect_delta_dict[aspect_id] = delta_id_dict
vdu_delta_dict = {vdu_list[0]: delta_num}
delta_id_dict[delta_id] = vdu_delta_dict
if aspect_id in aspect_delta_dict:
existing_delta_id_dict = aspect_delta_dict[aspect_id]
if delta_id in existing_delta_id_dict:
existing_delta_id_dict[delta_id].update(
delta_id_dict[delta_id])
else:
aspect_delta_dict[aspect_id].update(delta_id_dict)
else:
aspect_delta_dict[aspect_id] = delta_id_dict
if aspect_id in aspect_vdu_dict:
existing_vdu_list = aspect_vdu_dict[aspect_id]
vdu_list.extend(existing_vdu_list)
aspect_vdu_dict[aspect_id] = vdu_list
elif p.type == ETSI_INST_LEVEL:
@ -910,16 +924,15 @@ def _convert_desired_capacity(inst_level_id, inst_level_dict,
for aspect_id, level_num in al_dict.items():
delta_id = aspect_id_dict.get(aspect_id)
# Get delta_num.
if delta_id is not None:
delta_num = \
aspect_delta_dict.get(aspect_id).get(delta_id)
# Get initial_delta.
vdus = aspect_vdu_dict.get(aspect_id)
initial_delta = None
for vdu in vdus:
initial_delta = vdu_delta_dict.get(vdu)
# Get delta_num.
if delta_id is not None:
delta_num = \
aspect_delta_dict.get(aspect_id).get(delta_id).get(vdu)
if initial_delta is not None:
# Calculate desired_capacity.

2
tacker/vnflcm/utils.py

@ -1148,7 +1148,7 @@ def _convert_desired_capacity(inst_level_id, vnfd_dict, vdu):
if delta_id is not None:
delta_num = \
aspect_delta_dict.get(aspect_id).get(delta_id)
aspect_delta_dict.get(aspect_id).get(delta_id).get(vdu)
vdus = aspect_vdu_dict.get(aspect_id)
initial_delta = None

16
tacker/vnfm/infra_drivers/kubernetes/kubernetes_driver.py

@ -1212,6 +1212,7 @@ class Kubernetes(abstract_driver.VnfAbstractDriver,
auth=auth_cred)
aspect_id = policy['name']
vdu_defs = policy['vdu_defs']
vdu_name = None
is_found = False
error_reason = None
target_kinds = ["Deployment", "ReplicaSet", "StatefulSet"]
@ -1227,6 +1228,7 @@ class Kubernetes(abstract_driver.VnfAbstractDriver,
for vdu_id, vdu_def in vdu_defs.items():
vdu_properties = vdu_def.get('properties')
if name == vdu_properties.get('name'):
vdu_name = vdu_properties.get('name')
namespace = vnf_resource.resource_name.\
split(COMMA_CHARACTER)[0]
if not namespace:
@ -1253,10 +1255,20 @@ class Kubernetes(abstract_driver.VnfAbstractDriver,
current_replicas = scale_info.status.replicas
vdu_profile = vdu_properties.get('vdu_profile')
delta_num = 1
if isinstance(policy['delta_num'], dict):
delta_num = policy['delta_num'].get(vdu_name)
else:
delta_num = policy['delta_num']
if delta_num is None or not isinstance(delta_num,int):
delta_num = 1
if policy['action'] == 'out':
scale_replicas = current_replicas + policy['delta_num']
scale_replicas = current_replicas + delta_num
elif policy['action'] == 'in':
scale_replicas = current_replicas - policy['delta_num']
scale_replicas = current_replicas - delta_num
max_replicas = vdu_profile.get('max_number_of_instances')
min_replicas = vdu_profile.get('min_number_of_instances')

Loading…
Cancel
Save