1 # ============LICENSE_START=======================================================
2 # Copyright (C) 2020 Orange
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # ============LICENSE_END=========================================================
19 from onapsdk.so.so_element import SoElement
20 from onapsdk.onap_service import OnapService
21 from onapsdk.utils.headers_creator import headers_so_creator
24 class SoDBUpdate(SoElement, ABC):
27 def add_region_to_so_db(cls,
30 identity_service_id: str = None,
33 """Method to add cloud_site data with identity_service to SO db.
36 cloud_region_id: the name of cloud region
37 complex_id: name of complex
38 identity_service_id: optional - id of identity service
39 **kwargs: keyword arguments with parameters for identity service creation, like below
42 identity_services data will be overwrite, but in the same time
43 cloud_sites data will not (shouldn't) be overwrite!
49 if not identity_service_id:
50 identity_service_id = 'Keystone_K8s'
52 # params for identity_service creation
53 orchestrator = kwargs.get('orchestrator', 'multicloud')
54 identity_url = kwargs.get('identity_url', "http://1.2.3.4:5000/v2.0")
55 mso_id = kwargs.get('mso_id', 'onapsdk_user')
56 mso_pass = kwargs.get('mso_pass', 'mso_pass_onapsdk')
57 project_domain_name = kwargs.get("project_domain_name", None)
58 user_domain_name = kwargs.get("user_domain_name", None)
59 member_role = kwargs.get('member_role', 'admin')
60 admin_tenant = kwargs.get('admin_tenant', 'service')
61 identity_server_type = kwargs.get('identity_server_type', 'KEYSTONE')
62 identity_authentication_type = kwargs.get('identity_authentication_type', 'USERNAME_PASSWORD')
65 "id": cloud_region_id,
66 "region_id": cloud_region_id,
69 "orchestrator": orchestrator,
71 "id": identity_service_id,
72 "identityServerTypeAsString": "KEYSTONE",
73 "hibernateLazyInitializer": {},
74 "identity_url": identity_url,
77 "project_domain_name": project_domain_name,
78 "user_domain_name": user_domain_name,
79 "admin_tenant": admin_tenant,
80 "member_role": member_role,
81 "tenant_metadata": True,
82 "identity_server_type": identity_server_type,
83 "identity_authentication_type": identity_authentication_type
87 response = cls.send_message(
89 "Create a region in SO db",
90 f"{cls.base_url}/cloudSite",
92 headers=headers_so_creator(OnapService.headers),