Added V0 Registry API
[multicloud/azure.git] / azure / multicloud_azure / pub / vim / vimapi / baseclient.py
1 # Copyright (c) 2018 Amdocs
2 #
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:
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
12
13 import logging
14
15 from multicloud_azure.pub.vim.vimsdk.azure_credentials import ClientObj
16 from azure.mgmt.compute import ComputeManagementClient
17 from azure.mgmt.resource import ResourceManagementClient
18
19 LOG = logging.getLogger(__name__)
20
21
22 class baseclient(object):
23
24     def __init__(self, **kwargs):
25         self._compute = None
26         self._resource = None
27
28     def get_compute_client(self, params):
29         if self._compute is not None:
30             return self._compute
31         credentials = ClientObj().get_client_obj(params)
32         self._compute = ComputeManagementClient(
33             credentials, params['subscription_id'])
34         return self._compute
35
36     def get_resource_client(self, params):
37         if self._resource is not None:
38             return self._resource
39         credentials = ClientObj.get_client_obj(params)
40         self._resource = ResourceManagementClient(
41             credentials, params['subscription_id'])
42         return self._resource