1 # Copyright (c) 2018 Amdocs
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 from multicloud_azure.pub.utils.restcall import AAIClient
17 logger = logging.getLogger(__name__)
20 def split_vim_to_owner_region(vim_id):
21 split_vim = vim_id.split('_')
22 cloud_owner = split_vim[0]
23 cloud_region = "".join(split_vim[1:])
24 return cloud_owner, cloud_region
27 def get_vim_by_id(vim_id):
28 cloud_owner, cloud_region = split_vim_to_owner_region(vim_id)
29 client = AAIClient(cloud_owner, cloud_region)
30 ret = client.get_vim(get_all=True)
31 esrInfo = ret['esr-system-info-list']['esr-system-info'][0]
33 'type': ret['cloud-type'],
34 'version': ret['cloud-region-version'],
35 'cloud_extra_info': ret['cloud-extra-info'],
36 'cloud_region_id': ret['cloud-region-id'],
38 'username': esrInfo['user-name'],
39 'password': esrInfo['password'],
40 'default_tenant': esrInfo['default-tenant'],
41 'url': esrInfo['service-url'],
42 'domain': esrInfo['cloud-domain'],
43 'cacert': esrInfo.get('ssl-cacert', ""),
44 'insecure': esrInfo.get('ssl-insecure', False)