2 # -------------------------------------------------------------------------
3 # Copyright (C) 2020 Wipro Limited.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # -------------------------------------------------------------------------
20 VERSIONS = {'BASE': ["2016-11-01", "2017-10-10", "2018-02-01"],
21 'GENERIC': ["2020-08-13"]}
22 LOCATION_KEYS = ['latitude', 'longitude', 'host_name', 'clli_code']
23 INVENTORY_PROVIDERS = ['aai', 'generator']
24 INVENTORY_TYPES = ['cloud', 'service', 'transport', 'vfmodule', 'nssi', 'nsi', 'slice_profiles']
25 DEFAULT_INVENTORY_PROVIDER = INVENTORY_PROVIDERS[0]
26 CANDIDATE_KEYS = ['candidate_id', 'cost', 'inventory_type', 'location_id',
28 DEMAND_KEYS = ['filtering_attributes', 'passthrough_attributes', 'default_attributes', 'candidates', 'complex',
29 'conflict_identifier', 'customer_id', 'default_cost', 'excluded_candidates',
30 'existing_placement', 'flavor', 'inventory_provider',
31 'inventory_type', 'port_key', 'region', 'required_candidates',
32 'service_id', 'service_resource_id', 'service_subscription',
33 'service_type', 'subdivision', 'unique', 'vlan_key']
34 CONSTRAINT_KEYS = ['type', 'demands', 'properties']
37 # split: split into individual constraints, one per demand
38 # required: list of required property names,
39 # optional: list of optional property names,
40 # thresholds: dict of property/base-unit pairs for threshold parsing
41 # allowed: dict of keys and allowed values (if controlled vocab);
42 # only use this for Conductor-controlled values!
46 'required': ['evaluate'],
50 'required': ['evaluate'],
52 'distance_between_demands': {
53 'required': ['distance'],
55 'distance': 'distance'
58 'distance_to_location': {
60 'required': ['distance', 'location'],
62 'distance': 'distance'
67 'required': ['controller'],
68 'optional': ['request'],
70 'inventory_group': {},
73 'required': ['controller'],
74 'optional': ['request'],
77 'required': ['qualifier', 'category'],
78 'optional': ['location'],
79 'allowed': {'qualifier': ['same', 'different'],
80 'category': ['disaster', 'region', 'complex', 'country',
81 'time', 'maintenance']},
85 'required': ['controller'],
86 'optional': ['request'],
90 'required': ['evaluate'],
93 HPA_FEATURES = ['architecture', 'hpa-feature', 'hpa-feature-attributes',
94 'hpa-version', 'mandatory', 'directives']
95 HPA_OPTIONAL = ['score']
96 HPA_ATTRIBUTES = ['hpa-attribute-key', 'hpa-attribute-value', 'operator']
97 HPA_ATTRIBUTES_OPTIONAL = ['unit']
98 OPTIMIZATION_FUNCTIONS = {'distance_between': ['demand', 'location'],
99 'latency_between': ['demand', 'location'],
100 'attribute': ['demand', 'attribute']}
103 class TranslatorException(Exception):