1 # -*- coding: utf-8 -*-
4 # Copyright 2017 Telefónica Digital España S.L.U.
5 # This file is part of ETSI OSM
8 # Licensed under the Apache License, Version 2.0 (the "License"); you may
9 # not use this file except in compliance with the License. You may obtain
10 # a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18 # License for the specific language governing permissions and limitations
21 # For those usages not covered by the Apache License, Version 2.0 please
22 # contact with: patent-office@telefonica.com
26 vimconnector implements all the methods to interact with OpenNebula using the XML-RPC API.
28 __author__
= "Jose Maria Carmona Perez,Juan Antonio Hernando Labajo, Emilio Abraham Garrido Garcia,Alberto Florez " \
29 "Pages, Andres Pozo Muñoz, Santiago Perez Marin, Onlife Networks Telefonica I+D Product Innovation "
30 __date__
= "$13-dec-2017 11:09:29$"
40 class vimconnector(vimconn
.vimconnector
):
41 def __init__(self
, uuid
, name
, tenant_id
, tenant_name
, url
, url_admin
=None, user
=None, passwd
=None,
42 log_level
="DEBUG", config
={}, persistent_info
={}):
43 vimconn
.vimconnector
.__init
__(self
, uuid
, name
, tenant_id
, tenant_name
, url
, url_admin
, user
, passwd
, log_level
,
46 self
.headers_req
= {'content-type': 'application/json'}
47 self
.logger
= logging
.getLogger('openmano.vim.opennebula')
48 self
.persistent_info
= persistent_info
50 self
.tenant
= tenant_id
52 def __setitem__(self
, index
, value
):
53 """Set individuals parameters
54 Throw TypeError, KeyError
56 if index
== 'tenant_id':
58 elif index
== 'tenant_name':
60 vimconn
.vimconnector
.__setitem
__(self
, index
, value
)
62 def new_tenant(self
, tenant_name
, tenant_description
):
63 # '''Adds a new tenant to VIM with this name and description, returns the tenant identifier'''
65 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
66 group_list
= oca
.GroupPool(client
)
67 user_list
= oca
.UserPool(client
)
70 create_primarygroup
= 1
72 for group
in group_list
:
73 if str(group
.name
) == str(tenant_name
):
74 create_primarygroup
= 0
76 if create_primarygroup
== 1:
77 oca
.Group
.allocate(client
, tenant_name
)
79 # set to primary_group the tenant_group and oneadmin to secondary_group
80 for group
in group_list
:
81 if str(group
.name
) == str(tenant_name
):
82 for user
in user_list
:
83 if str(user
.name
) == str(self
.user
):
84 if user
.name
== "oneadmin":
87 self
._add
_secondarygroup
(user
.id, group
.id)
90 except Exception as e
:
91 self
.logger
.error("Create new tenant error: " + str(e
))
92 raise vimconn
.vimconnException(e
)
94 def _add_secondarygroup(self
, id_user
, id_group
):
95 # change secondary_group to primary_group
96 params
= '<?xml version="1.0"?> \
98 <methodName>one.user.addgroup</methodName>\
101 <value><string>{}:{}</string></value>\
104 <value><int>{}</int></value>\
107 <value><int>{}</int></value>\
110 </methodCall>'.format(self
.user
, self
.passwd
, (str(id_user
)), (str(id_group
)))
111 requests
.post(self
.url
, params
)
113 def delete_tenant(self
, tenant_id
):
114 """Delete a tenant from VIM. Returns the old tenant identifier"""
116 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
117 group_list
= oca
.GroupPool(client
)
118 user_list
= oca
.UserPool(client
)
121 for group
in group_list
:
122 if str(group
.id) == str(tenant_id
):
123 for user
in user_list
:
124 if str(user
.name
) == str(self
.user
):
125 self
._delete
_secondarygroup
(user
.id, group
.id)
128 raise vimconn
.vimconnNotFoundException("Group {} not found".format(tenant_id
))
129 except Exception as e
:
130 self
.logger
.error("Delete tenant " + str(tenant_id
) + " error: " + str(e
))
131 raise vimconn
.vimconnException(e
)
133 # to be used in future commits
134 def _delete_secondarygroup(self
, id_user
, id_group
):
135 params
= '<?xml version="1.0"?> \
137 <methodName>one.user.delgroup</methodName>\
140 <value><string>{}:{}</string></value>\
143 <value><int>{}</int></value>\
146 <value><int>{}</int></value>\
149 </methodCall>'.format(self
.user
, self
.passwd
, (str(id_user
)), (str(id_group
)))
150 requests
.post(self
.url
, params
)
152 # to be used in future commits
153 # def get_tenant_list(self, filter_dict={}):
156 # to be used in future commits
157 # def _check_tenant(self):
159 # client = oca.Client(self.user + ':' + self.passwd, self.url)
160 # group_list = oca.GroupPool(client)
161 # user_list = oca.UserPool(client)
164 # for group in group_list:
165 # if str(group.name) == str(self.tenant_name):
166 # for user in user_list:
167 # if str(user.name) == str(self.user):
168 # self._add_secondarygroup(user.id, group.id)
169 # user.chgrp(group.id)
170 # except vimconn.vimconnException as e:
171 # self.logger.error(e)
173 # to be used in future commits, needs refactor to manage networks
174 # def _create_bridge_host(self, vlan):
175 # file = open('manage_bridge_OSM', 'w')
176 # # password_path = self.config["password"]["path"]
177 # a = "#! /bin/bash\nsudo brctl addbr br_osm_{vlanused}\n" \
178 # "sudo ip link add link veth1 name veth1.{vlanused} type vlan id {vlanused}\n" \
179 # "sudo brctl addif br_osm_{vlanused} veth1.{vlanused}\n" \
180 # "sudo ip link set dev br_osm_{vlanused} up\n" \
181 # "sudo ip link set dev veth1.{vlanused} up\n".format(vlanused=vlan)
182 # # a = "#! /bin/bash\nsudo brctl addbr br_osm\nsudo ip link set dev br_osm up\n"
185 # for host in self.config["cluster"]["ip"]:
186 # file_scp = "/usr/bin/scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {} manage_bridge_OSM {}@{}:/home/{}".format(
187 # self.config["cluster"]["password_path"][host], self.config["cluster"]["login"][host],
188 # self.config["cluster"]["ip"][host], self.config["cluster"]["login"][host])
189 # os.system(file_scp)
190 # file_permissions = "/usr/bin/ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {} {}@{} sudo chmod 700 manage_bridge_OSM".format(
191 # self.config["cluster"]["password_path"][host], self.config["cluster"]["login"][host],
192 # self.config["cluster"]["ip"][host])
193 # os.system(file_permissions)
194 # exec_script = "/usr/bin/ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {} {}@{} sudo ./manage_bridge_OSM".format(
195 # self.config["cluster"]["password_path"][host], self.config["cluster"]["login"][host],
196 # self.config["cluster"]["ip"][host])
197 # os.system(exec_script)
198 # os.remove("manage_bridge_OSM")
200 # to be used to manage networks with vlan
201 # def delete_bridge_host(self, vlan):
202 # file = open('manage_bridge_OSM', 'w')
203 # a = "#! /bin/bash\nsudo ip link set dev veth1.3142 down\nsudo ip link set dev br_3142 down\nsudo brctl delbr br_3142\n"
206 # os.system("/usr/bin/scp -i onlife manage_bridge_OSM sysadmin@10.95.84.12:/home/sysadmin")
207 # os.system("/usr/bin/ssh -i onlife sysadmin@10.95.84.12 sudo chmod 700 manage_bridge_OSM")
208 # os.system("/usr/bin/ssh -i onlife sysadmin@10.95.84.12 sudo ./manage_bridge_OSM")
209 # os.remove("manage_bridge_OSM")
211 def new_network(self
, net_name
, net_type
, ip_profile
=None, shared
=False, vlan
=None): # , **vim_specific):
212 """Returns the network identifier"""
213 # oca library method cannot be used in this case (problem with cluster parameters)
215 # vlan = str(random.randint(self.config["vlan"]["start-range"], self.config["vlan"]["finish-range"]))
216 # self.create_bridge_host(vlan)
217 bridge_config
= self
.config
["bridge_service"]
220 if ip_profile
is None:
221 random_number_ipv4
= random
.randint(1, 255)
222 ip_start
= "192.168." + str(random_number_ipv4
) + ".1" # random value
224 index
= ip_profile
["subnet_address"].find("/")
225 ip_start
= ip_profile
["subnet_address"][:index
]
226 if "dhcp_count" in ip_profile
.keys() and ip_profile
["dhcp_count"] is not None:
227 size
= str(ip_profile
["dhcp_count"])
228 elif not ("dhcp_count" in ip_profile
.keys()) and ip_profile
["ip_version"] == "IPv4":
229 prefix
= ip_profile
["subnet_address"][index
+ 1:]
230 size
= int(math
.pow(2, 32 - prefix
))
231 if "dhcp_start_address" in ip_profile
.keys() and ip_profile
["dhcp_start_address"] is not None:
232 ip_start
= str(ip_profile
["dhcp_start_address"])
233 if ip_profile
["ip_version"] == "IPv6":
235 if ip_version
== "IP6":
239 AR = [TYPE = {}, GLOBAL_PREFIX = {}, SIZE = {}]".format(net_name
, bridge_config
, ip_version
,
242 config
= 'NAME = "{}"\
245 AR = [TYPE = {}, IP = {}, SIZE = {}]'.format(net_name
, bridge_config
, ip_version
, ip_start
,
248 params
= '<?xml version="1.0"?> \
250 <methodName>one.vn.allocate</methodName>\
253 <value><string>{}:{}</string></value>\
256 <value><string>{}</string></value>\
259 <value><int>{}</int></value>\
262 </methodCall>'.format(self
.user
, self
.passwd
, config
, self
.config
["cluster"]["id"])
263 r
= requests
.post(self
.url
, params
)
264 obj
= untangle
.parse(str(r
.content
))
265 return obj
.methodResponse
.params
.param
.value
.array
.data
.value
[1].i4
.cdata
.encode('utf-8')
266 except Exception as e
:
267 self
.logger
.error("Create new network error: " + str(e
))
268 raise vimconn
.vimconnException(e
)
270 def get_network_list(self
, filter_dict
={}):
271 """Obtain tenant networks of VIM
277 admin_state_up: boolean
279 Returns the network list of dictionaries
282 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
283 networkList
= oca
.VirtualNetworkPool(client
)
286 if "name" in filter_dict
.keys():
287 network_name_filter
= filter_dict
["name"]
289 network_name_filter
= None
290 if "id" in filter_dict
.keys():
291 network_id_filter
= filter_dict
["id"]
293 network_id_filter
= None
294 for network
in networkList
:
296 if network
.name
== network_name_filter
and str(network
.id) == str(network_id_filter
):
298 if network_name_filter
is None and str(network
.id) == str(network_id_filter
):
300 if network_id_filter
is None and network
.name
== network_name_filter
:
303 net_dict
= {"name": network
.name
, "id": str(network
.id)}
304 response
.append(net_dict
)
306 except Exception as e
:
307 self
.logger
.error("Get network list error: " + str(e
))
308 raise vimconn
.vimconnException(e
)
310 def get_network(self
, net_id
):
311 """Obtain network details of network id"""
313 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
314 networkList
= oca
.VirtualNetworkPool(client
)
317 for network
in networkList
:
318 if str(network
.id) == str(net_id
):
320 net
['name'] = network
.name
321 net
['status'] = "ACTIVE"
326 raise vimconn
.vimconnNotFoundException("Network {} not found".format(net_id
))
327 except Exception as e
:
328 self
.logger
.error("Get network " + str(net_id
) + " error): " + str(e
))
329 raise vimconn
.vimconnException(e
)
331 def delete_network(self
, net_id
):
332 """Deletes a tenant network from VIM
333 Returns the network identifier
336 # self.delete_bridge_host()
337 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
338 networkList
= oca
.VirtualNetworkPool(client
)
340 network_deleted
= False
341 for network
in networkList
:
342 if str(network
.id) == str(net_id
):
343 oca
.VirtualNetwork
.delete(network
)
344 network_deleted
= True
348 raise vimconn
.vimconnNotFoundException("Network {} not found".format(net_id
))
349 except Exception as e
:
350 self
.logger
.error("Delete network " + str(net_id
) + "error: " + str(e
))
351 raise vimconn
.vimconnException(e
)
353 def get_flavor(self
, flavor_id
): # Esta correcto
354 """Obtain flavor details from the VIM"""
356 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
357 listaTemplate
= oca
.VmTemplatePool(client
)
359 for template
in listaTemplate
:
360 if str(template
.id) == str(flavor_id
):
361 return {'id': template
.id, 'name': template
.name
}
362 raise vimconn
.vimconnNotFoundException("Flavor {} not found".format(flavor_id
))
363 except Exception as e
:
364 self
.logger
.error("get flavor " + str(flavor_id
) + " error: " + str(e
))
365 raise vimconn
.vimconnException(e
)
367 def new_flavor(self
, flavor_data
):
368 """Adds a tenant flavor to VIM
369 Returns the flavor identifier"""
371 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
372 template_name
= flavor_data
["name"][:-4]
373 name
= 'NAME = "{}" '.format(template_name
)
374 cpu
= 'CPU = "{}" '.format(flavor_data
["vcpus"])
375 memory
= 'MEMORY = "{}" '.format(flavor_data
["ram"])
376 context
= 'CONTEXT = [NETWORK = "YES",SSH_PUBLIC_KEY = "$USER[SSH_PUBLIC_KEY]" ] '
377 graphics
= 'GRAPHICS = [ LISTEN = "0.0.0.0", TYPE = "VNC" ] '
378 sched_requeriments
= 'CLUSTER_ID={}'.format(self
.config
["cluster"]["id"])
379 template
= name
+ cpu
+ memory
+ context
+ graphics
+ sched_requeriments
380 template_id
= oca
.VmTemplate
.allocate(client
, template
)
382 except Exception as e
:
383 self
.logger
.error("Create new flavor error: " + str(e
))
384 raise vimconn
.vimconnException(e
)
386 def delete_flavor(self
, flavor_id
):
387 """ Deletes a tenant flavor from VIM
388 Returns the old flavor_id
391 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
392 listaTemplate
= oca
.VmTemplatePool(client
)
394 self
.logger
.info("Deleting VIM flavor DELETE {}".format(self
.url
))
395 for template
in listaTemplate
:
396 if str(template
.id) == str(flavor_id
):
399 raise vimconn
.vimconnNotFoundException("Flavor {} not found".format(flavor_id
))
400 except Exception as e
:
401 self
.logger
.error("Delete flavor " + str(flavor_id
) + " error: " + str(e
))
402 raise vimconn
.vimconnException(e
)
404 def get_image_list(self
, filter_dict
={}):
405 """Obtain tenant images from VIM
409 checksum: image checksum
411 Returns the image list of dictionaries:
412 [{<the fields at Filter_dict plus some VIM specific>}, ...]
415 # IMPORTANT!!!!! Modify python oca library path pool.py line 102
418 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
419 image_pool
= oca
.ImagePool(client
)
422 if "name" in filter_dict
.keys():
423 image_name_filter
= filter_dict
["name"]
425 image_name_filter
= None
426 if "id" in filter_dict
.keys():
427 image_id_filter
= filter_dict
["id"]
429 image_id_filter
= None
430 for image
in image_pool
:
432 if str(image_name_filter
) == str(image
.name
) and str(image
.id) == str(image_id_filter
):
434 if image_name_filter
is None and str(image
.id) == str(image_id_filter
):
436 if image_id_filter
is None and str(image_name_filter
) == str(image
.name
):
439 images_dict
= {"name": image
.name
, "id": str(image
.id)}
440 images
.append(images_dict
)
442 except Exception as e
:
443 self
.logger
.error("Get image list error: " + str(e
))
444 raise vimconn
.vimconnException(e
)
446 def new_vminstance(self
, name
, description
, start
, image_id
, flavor_id
, net_list
, cloud_config
=None, disk_list
=None,
447 availability_zone_index
=None, availability_zone_list
=None):
448 """Adds a VM instance to VIM
450 start: indicates if VM must start or boot in pause mode. Ignored
451 image_id,flavor_id: image and flavor uuid
452 net_list: list of interfaces, each one is a dictionary with:
454 net_id: network uuid to connect
455 vpci: virtual vcpi to assign
456 model: interface model, virtio, e2000, ...
458 use: 'data', 'bridge', 'mgmt'
459 type: 'virtual', 'PF', 'VF', 'VFnotShared'
460 vim_id: filled/added by this function
461 #TODO ip, security groups
462 Returns the instance identifier
465 "new_vminstance input: image='{}' flavor='{}' nics='{}'".format(image_id
, flavor_id
, str(net_list
)))
467 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
468 listaTemplate
= oca
.VmTemplatePool(client
)
470 for template
in listaTemplate
:
471 if str(template
.id) == str(flavor_id
):
472 cpu
= ' CPU = "{}"'.format(template
.template
.cpu
)
473 memory
= ' MEMORY = "{}"'.format(template
.template
.memory
)
474 context
= ' CONTEXT = [NETWORK = "YES",SSH_PUBLIC_KEY = "$USER[SSH_PUBLIC_KEY]" ]'
475 graphics
= ' GRAPHICS = [ LISTEN = "0.0.0.0", TYPE = "VNC" ]'
476 disk
= ' DISK = [ IMAGE_ID = {}]'.format(image_id
)
477 sched_requeriments
= ' SCHED_REQUIREMENTS = "CLUSTER_ID={}"'.format(self
.config
["cluster"]["id"])
478 template_updated
= cpu
+ memory
+ context
+ graphics
+ disk
+ sched_requeriments
479 networkListVim
= oca
.VirtualNetworkPool(client
)
480 networkListVim
.info()
483 network_found
= False
484 for network_existingInVim
in networkListVim
:
485 if str(net
["net_id"]) == str(network_existingInVim
.id):
486 net
["vim_id"] = network_existingInVim
["id"]
487 network
= 'NIC = [NETWORK = "{}",NETWORK_UNAME = "{}" ]'.format(
488 network_existingInVim
.name
, network_existingInVim
.uname
)
491 if not network_found
:
492 raise vimconn
.vimconnNotFoundException("Network {} not found".format(net
["net_id"]))
493 template_updated
+= network
494 oca
.VmTemplate
.update(template
, template_updated
)
496 "Instanciating in OpenNebula a new VM name:{} id:{}".format(template
.name
, template
.id))
497 vminstance_id
= template
.instantiate(name
=name
)
498 return str(vminstance_id
), None
499 raise vimconn
.vimconnNotFoundException("Flavor {} not found".format(flavor_id
))
500 except Exception as e
:
501 self
.logger
.error("Create new vm instance error: " + str(e
))
502 raise vimconn
.vimconnException(e
)
504 def delete_vminstance(self
, vm_id
, created_items
=None):
505 """Removes a VM instance from VIM, returns the deleted vm_id"""
507 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
508 vm_pool
= oca
.VirtualMachinePool(client
)
512 if str(i
.id) == str(vm_id
):
516 self
.logger
.info("The vm " + str(vm_id
) + " does not exist or is already deleted")
517 raise vimconn
.vimconnNotFoundException("The vm {} does not exist or is already deleted".format(vm_id
))
518 params
= '<?xml version="1.0"?> \
520 <methodName>one.vm.recover</methodName>\
523 <value><string>{}:{}</string></value>\
526 <value><int>{}</int></value>\
529 <value><int>{}</int></value>\
532 </methodCall>'.format(self
.user
, self
.passwd
, str(vm_id
), str(3))
533 r
= requests
.post(self
.url
, params
)
534 obj
= untangle
.parse(str(r
.content
))
535 response_success
= obj
.methodResponse
.params
.param
.value
.array
.data
.value
[0].boolean
.cdata
.encode('utf-8')
536 response
= obj
.methodResponse
.params
.param
.value
.array
.data
.value
[1].i4
.cdata
.encode('utf-8')
537 # response can be the resource ID on success or the error string on failure.
538 response_error_code
= obj
.methodResponse
.params
.param
.value
.array
.data
.value
[2].i4
.cdata
.encode('utf-8')
539 if response_success
.lower() == "true":
542 raise vimconn
.vimconnException("vm {} cannot be deleted with error_code {}: {}".format(vm_id
, response_error_code
, response
))
543 except Exception as e
:
544 self
.logger
.error("Delete vm instance " + str(vm_id
) + " error: " + str(e
))
545 raise vimconn
.vimconnException(e
)
547 def refresh_vms_status(self
, vm_list
):
548 """Refreshes the status of the virtual machines"""
551 client
= oca
.Client(self
.user
+ ':' + self
.passwd
, self
.url
)
552 vm_pool
= oca
.VirtualMachinePool(client
)
554 for vm_id
in vm_list
:
555 vm
= {"interfaces": []}
559 if str(i
.id) == str(vm_id
):
564 self
.logger
.info("The vm " + str(vm_id
) + " does not exist.")
565 vm
['status'] = "DELETED"
566 vm
['error_msg'] = ("The vm " + str(vm_id
) + " does not exist.")
569 vm
["vim_info"] = None
570 VMstatus
= vm_element
.str_lcm_state
571 if VMstatus
== "RUNNING":
572 vm
['status'] = "ACTIVE"
573 elif "FAILURE" in VMstatus
:
574 vm
['status'] = "ERROR"
575 vm
['error_msg'] = "VM failure"
577 vm
['status'] = "BUILD"
579 for red
in vm_element
.template
.nics
:
580 interface
= {'vim_info': None, "mac_address": str(red
.mac
), "vim_net_id": str(red
.network_id
),
581 "vim_interface_id": str(red
.network_id
)}
582 # maybe it should be 2 different keys for ip_address if an interface has ipv4 and ipv6
583 if hasattr(red
, 'ip'):
584 interface
["ip_address"] = str(red
.ip
)
585 if hasattr(red
, 'ip6_global'):
586 interface
["ip_address"] = str(red
.ip6_global
)
587 vm
["interfaces"].append(interface
)
588 except Exception as e
:
589 self
.logger
.error("Error getting vm interface_information " + type(e
).__name
__ + ":" + str(e
))
590 vm
["status"] = "VIM_ERROR"
591 vm
["error_msg"] = "Error getting vm interface_information " + type(e
).__name
__ + ":" + str(e
)
594 except Exception as e
:
597 vm_dict
[k
]["status"] = "VIM_ERROR"
598 vm_dict
[k
]["error_msg"] = str(e
)
601 def refresh_nets_status(self
, net_list
):
602 """Get the status of the networks
603 Params: the list of network identifiers
604 Returns a dictionary with:
605 net_id: #VIM id of this network
606 status: #Mandatory. Text with one of:
607 # DELETED (not found at vim)
608 # VIM_ERROR (Cannot connect to VIM, VIM response error, ...)
609 # OTHER (Vim reported other status not understood)
610 # ERROR (VIM indicates an ERROR status)
611 # ACTIVE, INACTIVE, DOWN (admin down),
612 # BUILD (on building process)
614 error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR
615 vim_info: #Text with plain information obtained from vim (yaml.safe_dump)
619 for net_id
in net_list
:
622 net_vim
= self
.get_network(net_id
)
623 net
["status"] = net_vim
["status"]
624 net
["vim_info"] = None
625 except vimconn
.vimconnNotFoundException
as e
:
626 self
.logger
.error("Exception getting net status: {}".format(str(e
)))
627 net
['status'] = "DELETED"
628 net
['error_msg'] = str(e
)
629 except vimconn
.vimconnException
as e
:
631 net
["status"] = "VIM_ERROR"
632 net
["error_msg"] = str(e
)
633 net_dict
[net_id
] = net
635 except vimconn
.vimconnException
as e
:
638 net_dict
[k
]["status"] = "VIM_ERROR"
639 net_dict
[k
]["error_msg"] = str(e
)
642 # to be used and fixed in future commits... not working properly
643 # def action_vminstance(self, vm_id, action_dict):
644 # """Send and action over a VM instance from VIM
645 # Returns the status"""
647 # if "console" in action_dict:
648 # console_dict = {"protocol": "http",
649 # "server": "10.95.84.42",
651 # "suffix": "?token=4hsb9cu9utruakon4p3z"
653 # return console_dict
654 # except vimconn.vimconnException as e:
655 # self.logger.error(e)