Add tox
[pti/o2.git] / o2ims / adapter / clients / ocloud_sa_client.py
1 # Copyright (C) 2021 Wind River Systems, Inc.\r
2 #\r
3 #  Licensed under the Apache License, Version 2.0 (the "License");\r
4 #  you may not use this file except in compliance with the License.\r
5 #  You may obtain a copy of the License at\r
6 #\r
7 #      http://www.apache.org/licenses/LICENSE-2.0\r
8 #\r
9 #  Unless required by applicable law or agreed to in writing, software\r
10 #  distributed under the License is distributed on an "AS IS" BASIS,\r
11 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 #  See the License for the specific language governing permissions and\r
13 #  limitations under the License.\r
14 \r
15 # client talking to Stx standalone\r
16 \r
17 from service.client.base_client import BaseClient\r
18 from typing import List\r
19 # Optional,  Set\r
20 from o2ims.domain import stx_object as ocloudModel\r
21 from o2ims import config\r
22 \r
23 \r
24 class StxSaOcloudClient(BaseClient):\r
25     def __init__(self):\r
26         super().__init__()\r
27         self.driver = StxSaClientImp()\r
28 \r
29     # def list(self) -> List[ocloudModel.StxGenericModel]:\r
30     #     return self._list()\r
31 \r
32     # def get(self, id) -> ocloudModel.StxGenericModel:\r
33     #     return self._get(id)\r
34 \r
35     def _get(self, id) -> ocloudModel.StxGenericModel:\r
36         raise self.driver.getInstanceInfo()\r
37 \r
38     def _list(self):\r
39         return [self.driver.getInstanceInfo()]\r
40 \r
41 \r
42 class StxSaResourcePoolClient(BaseClient):\r
43     def __init__(self):\r
44         super().__init__()\r
45         self.driver = StxSaClientImp()\r
46 \r
47     def _get(self, id) -> ocloudModel.StxGenericModel:\r
48         return self.driver.getInstanceInfo()\r
49 \r
50     def _list(self):\r
51         return [self.driver.getInstanceInfo()]\r
52 \r
53 \r
54 class StxSaDmsClient(BaseClient):\r
55     def __init__(self):\r
56         super().__init__()\r
57         self.driver = StxSaClientImp()\r
58 \r
59     def _get(self, id) -> ocloudModel.StxGenericModel:\r
60         return self.driver.getK8sDetail(id)\r
61 \r
62     def _list(self):\r
63         return self.driver.getK8sList()\r
64 \r
65 # internal driver which implement client call to Stx Standalone instance\r
66 \r
67 # from keystoneauth1.identity import v3\r
68 # from keystoneauth1 import session\r
69 # # from keystoneclient.v3 import ksclient\r
70 # from starlingxclient.v3 import stxclient\r
71 \r
72 \r
73 class StxSaClientImp(object):\r
74     def __init__(self, access_info=None) -> None:\r
75         super().__init__()\r
76         self.access_info = access_info\r
77         if self.access_info is None:\r
78             self.access_info = config.get_stx_access_info()\r
79         # self.auth = auth = v3.Password(\r
80         #     auth_url="http://example.com:5000/v3", username="admin",\r
81         #     password="password", project_name="admin",\r
82         #     user_domain_id="default", project_domain_id="default")\r
83         # self.session = sess = session.Session(auth=auth)\r
84         # # self.keystone = ksclient.Client(session=sess)\r
85         # self.stx = stxclient.Client(session=sess)\r
86 \r
87     def getInstanceInfo(self) -> ocloudModel.StxGenericModel:\r
88         raise NotImplementedError\r
89 \r
90     def getK8sList(self) -> List[ocloudModel.StxGenericModel]:\r
91         raise NotImplementedError\r
92 \r
93     def getK8sDetail(self, id) -> ocloudModel.StxGenericModel:\r
94         raise NotImplementedError\r