17a9f827d02a22e5447846aa04b84eb9993ca606
[optf/has.git] / conductor / conductor / controller / translator_utils.py
1 #
2 # -------------------------------------------------------------------------
3 #   Copyright (C) 2020 Wipro Limited.
4 #
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
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16 #
17 # -------------------------------------------------------------------------
18 #
19
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',
27                   'location_type']
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']
35 CONSTRAINTS = {
36     # constraint_type: {
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!
43     # }
44     'attribute': {
45         'split': True,
46         'required': ['evaluate'],
47     },
48     'threshold': {
49         'split': True,
50         'required': ['evaluate'],
51     },
52     'distance_between_demands': {
53         'required': ['distance'],
54         'thresholds': {
55             'distance': 'distance'
56         },
57     },
58     'distance_to_location': {
59         'split': True,
60         'required': ['distance', 'location'],
61         'thresholds': {
62             'distance': 'distance'
63         },
64     },
65     'instance_fit': {
66         'split': True,
67         'required': ['controller'],
68         'optional': ['request'],
69     },
70     'inventory_group': {},
71     'region_fit': {
72         'split': True,
73         'required': ['controller'],
74         'optional': ['request'],
75     },
76     'zone': {
77         'required': ['qualifier', 'category'],
78         'optional': ['location'],
79         'allowed': {'qualifier': ['same', 'different'],
80                     'category': ['disaster', 'region', 'complex', 'country',
81                                  'time', 'maintenance']},
82     },
83     'vim_fit': {
84         'split': True,
85         'required': ['controller'],
86         'optional': ['request'],
87     },
88     'hpa': {
89         'split': True,
90         'required': ['evaluate'],
91     },
92 }
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']}
101
102
103 class TranslatorException(Exception):
104     pass