update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b second try
[osm/SO.git] / rwcal / plugins / vala / rwcal_openmano / rwcal_openmano.py
1
2 #
3 # Copyright 2016 RIFT.IO Inc
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17
18 import logging
19 from gi import require_version
20 require_version('RwCal', '1.0')
21
22 from gi.repository import (
23 GObject,
24 RwCal,
25 RwTypes,
26 RwcalYang)
27
28 import rw_status
29 import rwlogger
30
31 logger = logging.getLogger('rwcal.openmano')
32
33 class UnknownAccountError(Exception):
34 pass
35
36
37 class MissingFileError(Exception):
38 pass
39
40
41 class ImageLocationError(Exception):
42 pass
43
44
45 rwstatus = rw_status.rwstatus_from_exc_map({
46 IndexError: RwTypes.RwStatus.NOTFOUND,
47 KeyError: RwTypes.RwStatus.NOTFOUND,
48 UnknownAccountError: RwTypes.RwStatus.NOTFOUND,
49 MissingFileError: RwTypes.RwStatus.NOTFOUND,
50 })
51
52
53 class RwcalOpenmanoPlugin(GObject.Object, RwCal.Cloud):
54 """Stub implementation the CAL VALA methods for Openmano. """
55
56 def __init__(self):
57 GObject.Object.__init__(self)
58
59 @rwstatus
60 def do_init(self, rwlog_ctx):
61 if not any(isinstance(h, rwlogger.RwLogger) for h in logger.handlers):
62 logger.addHandler(
63 rwlogger.RwLogger(
64 category="rw-cal-log",
65 subcategory="openmano",
66 log_hdl=rwlog_ctx,
67 )
68 )
69
70 @rwstatus(ret_on_failure=[None])
71 def do_validate_cloud_creds(self, account):
72 """
73 Validates the cloud account credentials for the specified account.
74 If creds are not valid, returns an error code & reason string
75 Arguments:
76 account - a cloud account to validate
77
78 Returns:
79 Validation Code and Details String
80 """
81 status = RwcalYang.YangData_Rwcal_ConnectionStatus(
82 status="success",
83 details=""
84 )
85 print("Returning status: %s", str(status))
86 return status
87
88 @rwstatus(ret_on_failure=[None])
89 def do_get_management_network(self, account):
90 raise NotImplementedError()
91
92 @rwstatus
93 def do_create_tenant(self, account, name):
94 raise NotImplementedError()
95
96 @rwstatus
97 def do_delete_tenant(self, account, tenant_id):
98 raise NotImplementedError()
99
100 @rwstatus(ret_on_failure=[[]])
101 def do_get_tenant_list(self, account):
102 raise NotImplementedError()
103
104 @rwstatus
105 def do_create_role(self, account, name):
106 raise NotImplementedError()
107
108 @rwstatus
109 def do_delete_role(self, account, role_id):
110 raise NotImplementedError()
111
112 @rwstatus(ret_on_failure=[[]])
113 def do_get_role_list(self, account):
114 raise NotImplementedError()
115
116 @rwstatus(ret_on_failure=[None])
117 def do_create_image(self, account, image):
118 logger.warning("Creating image on openmano not supported")
119
120 @rwstatus
121 def do_delete_image(self, account, image_id):
122 raise NotImplementedError()
123
124 @rwstatus(ret_on_failure=[None])
125 def do_get_image(self, account, image_id):
126 raise NotImplementedError()
127
128 @rwstatus(ret_on_failure=[[]])
129 def do_get_image_list(self, account):
130 raise NotImplementedError()
131
132 @rwstatus
133 def do_create_vm(self, account, vm):
134 raise NotImplementedError()
135
136 @rwstatus
137 def do_start_vm(self, account, vm_id):
138 raise NotImplementedError()
139
140 @rwstatus
141 def do_stop_vm(self, account, vm_id):
142 raise NotImplementedError()
143
144 @rwstatus
145 def do_delete_vm(self, account, vm_id):
146 raise NotImplementedError()
147
148 @rwstatus
149 def do_reboot_vm(self, account, vm_id):
150 raise NotImplementedError()
151
152 @rwstatus(ret_on_failure=[[]])
153 def do_get_vm_list(self, account):
154 return RwcalYang.YangData_RwProject_Project_VimResources()
155
156 @rwstatus
157 def do_create_flavor(self, account, flavor):
158 raise NotImplementedError()
159
160 @rwstatus
161 def do_delete_flavor(self, account, flavor_id):
162 raise NotImplementedError()
163
164 @rwstatus(ret_on_failure=[None])
165 def do_get_flavor(self, account, flavor_id):
166 raise NotImplementedError()
167
168 @rwstatus(ret_on_failure=[[]])
169 def do_get_flavor_list(self, account):
170 raise NotImplementedError()
171
172 @rwstatus
173 def do_add_host(self, account, host):
174 raise NotImplementedError()
175
176 @rwstatus
177 def do_remove_host(self, account, host_id):
178 raise NotImplementedError()
179
180 @rwstatus(ret_on_failure=[None])
181 def do_get_host(self, account, host_id):
182 raise NotImplementedError()
183
184 @rwstatus(ret_on_failure=[[]])
185 def do_get_host_list(self, account):
186 raise NotImplementedError()
187
188 @rwstatus
189 def do_create_port(self, account, port):
190 raise NotImplementedError()
191
192 @rwstatus
193 def do_delete_port(self, account, port_id):
194 raise NotImplementedError()
195
196 @rwstatus(ret_on_failure=[None])
197 def do_get_port(self, account, port_id):
198 raise NotImplementedError()
199
200 @rwstatus(ret_on_failure=[[]])
201 def do_get_port_list(self, account):
202 return RwcalYang.YangData_RwProject_Project_VimResources()
203
204 @rwstatus
205 def do_create_network(self, account, network):
206 raise NotImplementedError()
207
208 @rwstatus
209 def do_delete_network(self, account, network_id):
210 raise NotImplementedError()
211
212 @rwstatus(ret_on_failure=[None])
213 def do_get_network(self, account, network_id):
214 raise NotImplementedError()
215
216 @rwstatus(ret_on_failure=[[]])
217 def do_get_network_list(self, account):
218 return RwcalYang.YangData_RwProject_Project_VimResources()
219
220 @rwstatus(ret_on_failure=[""])
221 def do_create_virtual_link(self, account, link_params):
222 raise NotImplementedError()
223
224 @rwstatus
225 def do_delete_virtual_link(self, account, link_id):
226 raise NotImplementedError()
227
228 @rwstatus(ret_on_failure=[None])
229 def do_get_virtual_link(self, account, link_id):
230 raise NotImplementedError()
231
232 @rwstatus(ret_on_failure=[None])
233 def do_get_virtual_link_by_name(self, account, link_name):
234 raise NotImplementedError()
235
236 @rwstatus(ret_on_failure=[""])
237 def do_get_virtual_link_list(self, account):
238 raise NotImplementedError()
239
240 @rwstatus(ret_on_failure=[""])
241 def do_create_vdu(self, account, vdu_init):
242 raise NotImplementedError()
243
244 @rwstatus
245 def do_modify_vdu(self, account, vdu_modify):
246 raise NotImplementedError()
247
248 @rwstatus
249 def do_delete_vdu(self, account, vdu_id):
250 raise NotImplementedError()
251
252 @rwcalstatus(ret_on_failure=[None])
253 def do_get_vdu(self, account, vdu_id, mgmt_network):
254 # mgmt_network - Added due to need for mgmt network.
255 # TO DO: Investigate the need for aws.
256 raise NotImplementedError()
257
258 @rwcalstatus(ret_on_failure=[None])
259 def do_get_vdu_list(self, account):
260 raise NotImplementedError()