projects
/
osm
/
RO.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
REMOVE some comments and unnecessary lines
[osm/RO.git]
/
osm_ro
/
vimconn_opennebula.py
diff --git
a/osm_ro/vimconn_opennebula.py
b/osm_ro/vimconn_opennebula.py
index
eaf3021
..
5a0ea87
100644
(file)
--- a/
osm_ro/vimconn_opennebula.py
+++ b/
osm_ro/vimconn_opennebula.py
@@
-1,7
+1,7
@@
# -*- coding: utf-8 -*-
##
# -*- coding: utf-8 -*-
##
-# Copyright 2017 Telef
ónica Digital España
S.L.U.
+# Copyright 2017 Telef
onica Digital Spain
S.L.U.
# This file is part of ETSI OSM
# All Rights Reserved.
#
# This file is part of ETSI OSM
# All Rights Reserved.
#
@@
-26,7
+26,7
@@
vimconnector implements all the methods to interact with OpenNebula using the XML-RPC API.
"""
__author__ = "Jose Maria Carmona Perez,Juan Antonio Hernando Labajo, Emilio Abraham Garrido Garcia,Alberto Florez " \
vimconnector implements all the methods to interact with OpenNebula using the XML-RPC API.
"""
__author__ = "Jose Maria Carmona Perez,Juan Antonio Hernando Labajo, Emilio Abraham Garrido Garcia,Alberto Florez " \
- "Pages, Andres Pozo Mu
ñ
oz, Santiago Perez Marin, Onlife Networks Telefonica I+D Product Innovation "
+ "Pages, Andres Pozo Mu
n
oz, Santiago Perez Marin, Onlife Networks Telefonica I+D Product Innovation "
__date__ = "$13-dec-2017 11:09:29$"
import vimconn
import requests
__date__ = "$13-dec-2017 11:09:29$"
import vimconn
import requests
@@
-293,9
+293,9
@@
class vimconnector(vimconn.vimconnector):
network_id_filter = None
for network in networkList:
match = False
network_id_filter = None
for network in networkList:
match = False
- if network.name == network_name_filter and
network.id == network_id_filter
:
+ if network.name == network_name_filter and
str(network.id) == str(network_id_filter)
:
match = True
match = True
- if network_name_filter is None and
network.id == network_id_filter
:
+ if network_name_filter is None and
str(network.id) == str(network_id_filter)
:
match = True
if network_id_filter is None and network.name == network_name_filter:
match = True
match = True
if network_id_filter is None and network.name == network_name_filter:
match = True
@@
-372,11
+372,12
@@
class vimconnector(vimconn.vimconnector):
template_name = flavor_data["name"][:-4]
name = 'NAME = "{}" '.format(template_name)
cpu = 'CPU = "{}" '.format(flavor_data["vcpus"])
template_name = flavor_data["name"][:-4]
name = 'NAME = "{}" '.format(template_name)
cpu = 'CPU = "{}" '.format(flavor_data["vcpus"])
+ vcpu = 'VCPU = "{}" '.format(flavor_data["vcpus"])
memory = 'MEMORY = "{}" '.format(flavor_data["ram"])
context = 'CONTEXT = [NETWORK = "YES",SSH_PUBLIC_KEY = "$USER[SSH_PUBLIC_KEY]" ] '
graphics = 'GRAPHICS = [ LISTEN = "0.0.0.0", TYPE = "VNC" ] '
sched_requeriments = 'CLUSTER_ID={}'.format(self.config["cluster"]["id"])
memory = 'MEMORY = "{}" '.format(flavor_data["ram"])
context = 'CONTEXT = [NETWORK = "YES",SSH_PUBLIC_KEY = "$USER[SSH_PUBLIC_KEY]" ] '
graphics = 'GRAPHICS = [ LISTEN = "0.0.0.0", TYPE = "VNC" ] '
sched_requeriments = 'CLUSTER_ID={}'.format(self.config["cluster"]["id"])
- template = name + cpu + memory + context + graphics + sched_requeriments
+ template = name + cpu +
vcpu +
memory + context + graphics + sched_requeriments
template_id = oca.VmTemplate.allocate(client, template)
return template_id
except Exception as e:
template_id = oca.VmTemplate.allocate(client, template)
return template_id
except Exception as e:
@@
-429,9
+430,9
@@
class vimconnector(vimconn.vimconnector):
image_id_filter = None
for image in image_pool:
match = False
image_id_filter = None
for image in image_pool:
match = False
- if str(image_name_filter) == str(image.name) and
image.id == image_id_filter
:
+ if str(image_name_filter) == str(image.name) and
str(image.id) == str(image_id_filter)
:
match = True
match = True
- if image_name_filter is None and
image.id == image_id_filter
:
+ if image_name_filter is None and
str(image.id) == str(image_id_filter)
:
match = True
if image_id_filter is None and str(image_name_filter) == str(image.name):
match = True
match = True
if image_id_filter is None and str(image_name_filter) == str(image.name):
match = True
@@
-453,7
+454,7
@@
class vimconnector(vimconn.vimconnector):
name:
net_id: network uuid to connect
vpci: virtual vcpi to assign
name:
net_id: network uuid to connect
vpci: virtual vcpi to assign
- model: interface model, virtio, e
2
000, ...
+ model: interface model, virtio, e
1
000, ...
mac_address:
use: 'data', 'bridge', 'mgmt'
type: 'virtual', 'PF', 'VF', 'VFnotShared'
mac_address:
use: 'data', 'bridge', 'mgmt'
type: 'virtual', 'PF', 'VF', 'VFnotShared'
@@
-470,12
+471,12
@@
class vimconnector(vimconn.vimconnector):
for template in listaTemplate:
if str(template.id) == str(flavor_id):
cpu = ' CPU = "{}"'.format(template.template.cpu)
for template in listaTemplate:
if str(template.id) == str(flavor_id):
cpu = ' CPU = "{}"'.format(template.template.cpu)
+ vcpu = ' VCPU = "{}"'.format(template.template.cpu)
memory = ' MEMORY = "{}"'.format(template.template.memory)
context = ' CONTEXT = [NETWORK = "YES",SSH_PUBLIC_KEY = "$USER[SSH_PUBLIC_KEY]" ]'
graphics = ' GRAPHICS = [ LISTEN = "0.0.0.0", TYPE = "VNC" ]'
disk = ' DISK = [ IMAGE_ID = {}]'.format(image_id)
memory = ' MEMORY = "{}"'.format(template.template.memory)
context = ' CONTEXT = [NETWORK = "YES",SSH_PUBLIC_KEY = "$USER[SSH_PUBLIC_KEY]" ]'
graphics = ' GRAPHICS = [ LISTEN = "0.0.0.0", TYPE = "VNC" ]'
disk = ' DISK = [ IMAGE_ID = {}]'.format(image_id)
- sched_requeriments = ' SCHED_REQUIREMENTS = "CLUSTER_ID={}"'.format(self.config["cluster"]["id"])
- template_updated = cpu + memory + context + graphics + disk + sched_requeriments
+ template_updated = cpu + vcpu + memory + context + graphics + disk
networkListVim = oca.VirtualNetworkPool(client)
networkListVim.info()
network = ""
networkListVim = oca.VirtualNetworkPool(client)
networkListVim.info()
network = ""
@@
-491,6
+492,13
@@
class vimconnector(vimconn.vimconnector):
if not network_found:
raise vimconn.vimconnNotFoundException("Network {} not found".format(net["net_id"]))
template_updated += network
if not network_found:
raise vimconn.vimconnNotFoundException("Network {} not found".format(net["net_id"]))
template_updated += network
+ if isinstance(cloud_config, dict):
+ if cloud_config.get("user-data"):
+ if isinstance(cloud_config["user-data"], str):
+ template_updated += cloud_config["user-data"]
+ else:
+ for u in cloud_config["user-data"]:
+ template_updated += u
oca.VmTemplate.update(template, template_updated)
self.logger.info(
"Instanciating in OpenNebula a new VM name:{} id:{}".format(template.name, template.id))
oca.VmTemplate.update(template, template_updated)
self.logger.info(
"Instanciating in OpenNebula a new VM name:{} id:{}".format(template.name, template.id))
@@
-506,9
+514,10
@@
class vimconnector(vimconn.vimconnector):
try:
client = oca.Client(self.user + ':' + self.passwd, self.url)
vm_pool = oca.VirtualMachinePool(client)
try:
client = oca.Client(self.user + ':' + self.passwd, self.url)
vm_pool = oca.VirtualMachinePool(client)
+ vm_pool.info()
vm_exist = False
for i in vm_pool:
vm_exist = False
for i in vm_pool:
- if
i.id == vm_id
:
+ if
str(i.id) == str(vm_id)
:
vm_exist = True
break
if not vm_exist:
vm_exist = True
break
if not vm_exist:
@@
-555,7
+564,7
@@
class vimconnector(vimconn.vimconnector):
vm_exist = False
vm_element = None
for i in vm_pool:
vm_exist = False
vm_element = None
for i in vm_pool:
- if
i.id == vm_id
:
+ if
str(i.id) == str(vm_id)
:
vm_exist = True
vm_element = i
break
vm_exist = True
vm_element = i
break
@@
-652,3
+661,4
@@
class vimconnector(vimconn.vimconnector):
# return console_dict
# except vimconn.vimconnException as e:
# self.logger.error(e)
# return console_dict
# except vimconn.vimconnException as e:
# self.logger.error(e)
+