Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[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 # Variables to be used by the testsuite
19 VIM_ACCOUNT_TYPE = ""
20 VIM_NAME_PREFIX = ""
21 VIM_USER = ""
22 VIM_PASSWORD = ""
23 VIM_AUTH_URL = ""
24 VIM_TENANT = ""
25 VIM_CONFIG = ""
26
27 # VIM configuration
28 cloud_type = os.environ.get("CLOUD_TYPE", "openstack")
29 if cloud_type == "openstack":
30 # Openstack VIM
31 VIM_ACCOUNT_TYPE = "openstack"
32 VIM_NAME_PREFIX = "basic01"
33 # Get credentias from Openstack Clouds file
34 cloud, os_cloud = get_values_from_cloud()
35 (
36 VIM_USER,
37 VIM_PASSWORD,
38 VIM_AUTH_URL,
39 VIM_TENANT,
40 vim_user_domain_name,
41 vim_project_domain_name,
42 vim_insecure,
43 ) = get_vim_values(cloud, os_cloud)
44 # Extra config
45 vim_config_dict = {}
46 vim_config_dict["vim_network_name"] = os.environ.get("VIM_MGMT_NET")
47 if vim_project_domain_name:
48 vim_config_dict["project_domain_name"] = vim_project_domain_name
49 if vim_user_domain_name:
50 vim_config_dict["user_domain_name"] = vim_user_domain_name
51 if vim_insecure:
52 vim_config_dict["insecure"] = True
53 VIM_CONFIG = "'{}'".format(
54 yaml.safe_dump(vim_config_dict, default_flow_style=True, width=10000).rstrip(
55 "\r\n"
56 )
57 )
58
59 elif cloud_type == "azure":
60 # Azure VIM
61 VIM_ACCOUNT_TYPE = "azure"
62 VIM_NAME_PREFIX = "basic01"
63 VIM_AUTH_URL = "http://www.azure.com"
64 VIM_USER = os.environ.get("AZURE_CLIENT_ID")
65 VIM_PASSWORD = os.environ.get("AZURE_SECRET")
66 VIM_TENANT = os.environ.get("AZURE_TENANT")
67
68 # Extra config
69 vim_config_dict = {}
70 if "RESOURCE_GROUP" in os.environ:
71 vim_config_dict["resource_group"] = os.environ.get("RESOURCE_GROUP")
72 if "AZURE_REGION" in os.environ:
73 vim_config_dict["region_name"] = os.environ.get("AZURE_REGION")
74 if "AZURE_SUBSCRIPTION_ID" in os.environ:
75 vim_config_dict["subscription_id"] = os.environ.get("AZURE_SUBSCRIPTION_ID")
76 if "VNET_NAME" in os.environ:
77 vim_config_dict["vnet_name"] = os.environ.get("VNET_NAME")
78 if "AZURE_FLAVORS_PATTERN" in os.environ:
79 vim_config_dict["flavors_pattern"] = os.environ.get("AZURE_FLAVORS_PATTERN")
80 VIM_CONFIG = "'{}'".format(
81 yaml.safe_dump(vim_config_dict, default_flow_style=True, width=10000).rstrip(
82 "\r\n"
83 )
84 )
85
86 else:
87 raise Exception("VIM type not supported: '" + cloud_type + "'")