diff options
author | Lukasz Rajewski <lukasz.rajewski@orange.com> | 2019-04-08 15:05:22 +0200 |
---|---|---|
committer | Lukasz Rajewski <lukasz.rajewski@orange.com> | 2019-04-18 17:05:54 +0200 |
commit | fc3ead31e631f69fabf0baaa20c10bf955ce374b (patch) | |
tree | 5227f20b49628ddf2e3ac533d0cd1dcb9d32a9e8 /osdf/optimizers/placementopt/conductor/translation.py | |
parent | 2d59800cf61a90e2a80902186bdce3b28e5ae14d (diff) |
Traffic Distributtion support added
* New local polcies for vFW TD use case
* Fixed encoding for conductor_request template and parameters
section modified to accept all requestParameters
* Conductor request can have many attributes in the
'attributes' section - all that are defined in the vnf policy file
* Conductor request can have many request parameters in the
'requestParameters' section. The parameters come from QueryPolicies.
Before list of suppoted parameters was hardcoded
* Optional 'unique' parameter added to the placementDemand section.
It is already supported by conductor for all inventory types
* Improved debug logs for local policies
* Unit tests added for expanded request format
Change-Id: I41f219c366a3a77881c7096e64a6272edbada23b
Issue-ID: OPTFRA-443
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Diffstat (limited to 'osdf/optimizers/placementopt/conductor/translation.py')
-rw-r--r-- | osdf/optimizers/placementopt/conductor/translation.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/osdf/optimizers/placementopt/conductor/translation.py b/osdf/optimizers/placementopt/conductor/translation.py index 93b80bf..d14f3e1 100644 --- a/osdf/optimizers/placementopt/conductor/translation.py +++ b/osdf/optimizers/placementopt/conductor/translation.py @@ -18,6 +18,7 @@ import copy import json import yaml +import re from osdf.utils.data_conversion import text_to_symbol from osdf.utils.programming_utils import dot_notation @@ -227,6 +228,8 @@ def get_demand_properties(demand, policies): inventory_type=policy_property['inventoryType'], service_type=demand['serviceResourceId'], service_resource_id=demand['serviceResourceId']) + + prop.update({'unique': demand['unique']} if demand.get('unique') else {}) prop['attributes'] = dict() prop['attributes'].update({'global-customer-id': policy_property['customerId']} if policy_property['customerId'] else {}) @@ -236,11 +239,35 @@ def get_demand_properties(demand, policies): if demand['resourceModelInfo']['modelVersionId'] else {}) prop['attributes'].update({'equipment-role': policy_property['equipmentRole']} if policy_property['equipmentRole'] else {}) + + if policy_property.get('attributes'): + for attr_key, attr_val in policy_property['attributes'].items(): + update_converted_attribute(attr_key, attr_val, prop) + prop.update(get_candidates_demands(demand)) demand_properties.append(prop) return demand_properties +def update_converted_attribute(attr_key, attr_val, properties): + """ + Updates dictonary of attributes with one specified in the arguments. + Automatically translates key namr from camelCase to hyphens + :param attr_key: key of the attribute + :param attr_val: value of the attribute + :param properties: dictionary with attributes to update + :return: + """ + if attr_val: + remapping = policy_config_mapping['attributes'] + if remapping.get(attr_key): + key_value = remapping.get(attr_key) + else: + key_value = re.sub('(.)([A-Z][a-z]+)', r'\1-\2', attr_key) + key_value = re.sub('([a-z0-9])([A-Z])', r'\1-\2', key_value).lower() + properties['attributes'].update({key_value: attr_val}) + + def gen_demands(req_json, vnf_policies): """Generate list of demands based on request and VNF policies :param req_json: Request object from the client (e.g. MSO) |