Revert "Feature 11001: Robot framework linting for E2E tests"
[osm/tests.git] / robot-systest / resources / basic_01-crud_operations_on_vim_targets_data.py
1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12
13 import os
14 import yaml
15 from get_clouds_yaml_info import get_values_from_cloud, get_vim_values
16
17
18 # VIM configuration
19 cloud_type = os.environ.get("CLOUD_TYPE", "openstack")
20 if cloud_type == "openstack":
21 # Openstack VIM
22 vim_account_type = "openstack"
23 vim_name_prefix = "basic01"
24 # Get credentias from Openstack Clouds file
25 cloud, os_cloud = get_values_from_cloud()
26 (
27 vim_user,
28 vim_password,
29 vim_auth_url,
30 vim_tenant,
31 vim_user_domain_name,
32 vim_project_domain_name,
33 vim_insecure,
34 ) = get_vim_values(cloud, os_cloud)
35 # Extra config
36 vim_config_dict = {}
37 vim_config_dict["vim_network_name"] = os.environ.get("VIM_MGMT_NET")
38 if vim_project_domain_name:
39 vim_config_dict["project_domain_name"] = vim_project_domain_name
40 if vim_user_domain_name:
41 vim_config_dict["user_domain_name"] = vim_user_domain_name
42 if vim_insecure:
43 vim_config_dict["insecure"] = True
44 vim_config = "'{}'".format(
45 yaml.safe_dump(vim_config_dict, default_flow_style=True, width=10000).rstrip(
46 "\r\n"
47 )
48 )
49
50 elif cloud_type == "azure":
51 # Azure VIM
52 vim_account_type = "azure"
53 vim_name_prefix = "basic01"
54 vim_auth_url = "http://www.azure.com"
55 vim_user = os.environ.get("AZURE_CLIENT_ID")
56 vim_password = os.environ.get("AZURE_SECRET")
57 vim_tenant = os.environ.get("AZURE_TENANT")
58
59 # Extra config
60 vim_config_dict = {}
61 if "RESOURCE_GROUP" in os.environ:
62 vim_config_dict["resource_group"] = os.environ.get("RESOURCE_GROUP")
63 if "AZURE_REGION" in os.environ:
64 vim_config_dict["region_name"] = os.environ.get("AZURE_REGION")
65 if "AZURE_SUBSCRIPTION_ID" in os.environ:
66 vim_config_dict["subscription_id"] = os.environ.get("AZURE_SUBSCRIPTION_ID")
67 if "VNET_NAME" in os.environ:
68 vim_config_dict["vnet_name"] = os.environ.get("VNET_NAME")
69 if "AZURE_FLAVORS_PATTERN" in os.environ:
70 vim_config_dict["flavors_pattern"] = os.environ.get("AZURE_FLAVORS_PATTERN")
71 vim_config = "'{}'".format(
72 yaml.safe_dump(vim_config_dict, default_flow_style=True, width=10000).rstrip(
73 "\r\n"
74 )
75 )
76
77 else:
78 raise Exception("VIM type not supported: '" + cloud_type + "'")