__author__ = "Alfonso Tierno, Igor D.C."
__date__ = "$14-aug-2017 23:59:59$"
-#Error variables
+#Error variables
HTTP_Bad_Request = 400
-HTTP_Unauthorized = 401
-HTTP_Not_Found = 404
-HTTP_Method_Not_Allowed = 405
+HTTP_Unauthorized = 401
+HTTP_Not_Found = 404
+HTTP_Method_Not_Allowed = 405
HTTP_Request_Timeout = 408
HTTP_Conflict = 409
HTTP_Not_Implemented = 501
-HTTP_Service_Unavailable = 503
-HTTP_Internal_Server_Error = 500
+HTTP_Service_Unavailable = 503
+HTTP_Internal_Server_Error = 500
class vimconnException(Exception):
class vimconnector():
"""Abstract base class for all the VIM connector plugins
- These plugins must implement a vimconnector class derived from this
+ These plugins must implement a vimconnector class derived from this
and all these privated methods
- """
+ """
def __init__(self, uuid, name, tenant_id, tenant_name, url, url_admin=None, user=None, passwd=None, log_level=None,
config={}, persitent_info={}):
"""
self.logger.setLevel(getattr(logging, log_level))
if not self.url_admin: # try to use normal url
self.url_admin = self.url
-
+
def __getitem__(self, index):
if index == 'tenant_id':
return self.tenant_id
return self.config
else:
raise KeyError("Invalid key '{}'".format(index))
-
+
def __setitem__(self, index, value):
if index == 'tenant_id':
self.tenant_id = value
"""
raise vimconnNotImplemented("Should have implemented this")
- def new_network(self, net_name, net_type, ip_profile=None, shared=False, vlan=None):
+ def new_network(self, net_name, net_type, ip_profile=None, shared=False, provider_network_profile=None):
"""Adds a tenant network to VIM
Params:
'net_name': name of the network
'dhcp_start_address': ip_schema, first IP to grant
'dhcp_count': number of IPs to grant.
'shared': if this network can be seen/use by other tenants/organization
- 'vlan': in case of a data or ptp net_type, the intended vlan tag to be used for the network
+ 'provider_network_profile': (optional) contains {segmentation-id: vlan, provider-network: vim_netowrk}
Returns a tuple with the network identifier and created_items, or raises an exception on error
created_items can be None or a dictionary where this method can include key-values that will be passed to
the method delete_network. Can be used to store created segments, created l2gw connections, etc.
- name: interface name
dedicated: yes|no|yes:sriov; for PT, SRIOV or only one SRIOV for the physical NIC
bandwidth: X Gbps; requested guarantee bandwidth
- vpci: requested virtual PCI address
+ vpci: requested virtual PCI address
disk: disk size
is_public:
#TODO to concrete
Returns the image_id or raises a vimconnNotFoundException
"""
raise vimconnNotImplemented("Should have implemented this")
-
+
def get_image_list(self, filter_dict={}):
"""Obtain tenant images from VIM
Filter_dict can be:
as not present.
"""
raise vimconnNotImplemented( "Should have implemented this" )
-
+
def get_vminstance(self,vm_id):
"""Returns the VM instance information from VIM"""
raise vimconnNotImplemented( "Should have implemented this" )
-
+
def delete_vminstance(self, vm_id, created_items=None):
"""
Removes a VM instance from VIM and its associated elements
vm_id: #VIM id of this Virtual Machine
status: #Mandatory. Text with one of:
# DELETED (not found at vim)
- # VIM_ERROR (Cannot connect to VIM, VIM response error, ...)
+ # VIM_ERROR (Cannot connect to VIM, VIM response error, ...)
# OTHER (Vim reported other status not understood)
# ERROR (VIM indicates an ERROR status)
- # ACTIVE, PAUSED, SUSPENDED, INACTIVE (not running),
+ # ACTIVE, PAUSED, SUSPENDED, INACTIVE (not running),
# BUILD (on building process), ERROR
# ACTIVE:NoMgmtIP (Active but any of its interface has an IP address
#
- error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR
+ error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR
vim_info: #Text with plain information obtained from vim (yaml.safe_dump)
interfaces: list with interface info. Each item a dictionary with:
vim_info: #Text with plain information obtained from vim (yaml.safe_dump)
vlan: #physical VLAN used for VF
"""
raise vimconnNotImplemented( "Should have implemented this" )
-
+
def action_vminstance(self, vm_id, action_dict, created_items={}):
"""
Send and action over a VM instance. Returns created_items if the action was successfully sent to the VIM.
:return: None, or a console dict
"""
raise vimconnNotImplemented( "Should have implemented this" )
-
+
def get_vminstance_console(self, vm_id, console_type="vnc"):
"""
Get a console for the virtual machine
Params:
vm_id: uuid of the VM
console_type, can be:
- "novnc" (by default), "xvpvnc" for VNC types,
+ "novnc" (by default), "xvpvnc" for VNC types,
"rdp-html5" for RDP types, "spice-html5" for SPICE types
Returns dict with the console parameters:
protocol: ssh, ftp, http, https, ...
- server: usually ip address
- port: the http, ssh, ... port
- suffix: extra text, e.g. the http path and query string
+ server: usually ip address
+ port: the http, ssh, ... port
+ suffix: extra text, e.g. the http path and query string
"""
raise vimconnNotImplemented( "Should have implemented this" )
"""
raise vimconnNotImplemented( "SFC support not implemented" )
+ def refresh_classifications_status(self, classification_list):
+ '''Get the status of the classifications
+ Params: the list of classification identifiers
+ Returns a dictionary with:
+ vm_id: #VIM id of this classifier
+ status: #Mandatory. Text with one of:
+ # DELETED (not found at vim)
+ # VIM_ERROR (Cannot connect to VIM, VIM response error, ...)
+ # OTHER (Vim reported other status not understood)
+ # ERROR (VIM indicates an ERROR status)
+ # ACTIVE,
+ # CREATING (on building process)
+ error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR
+ vim_info: #Text with plain information obtained from vim (yaml.safe_dump)
+ '''
+ raise vimconnNotImplemented("Should have implemented this")
+
def delete_classification(self, classification_id):
"""Deletes a classification from the VIM
Returns the classification ID (classification_id) or raises an exception upon error or when classification is not found
"""
raise vimconnNotImplemented( "SFC support not implemented" )
+ def refresh_sfis_status(self, sfi_list):
+ '''Get the status of the service function instances
+ Params: the list of sfi identifiers
+ Returns a dictionary with:
+ vm_id: #VIM id of this service function instance
+ status: #Mandatory. Text with one of:
+ # DELETED (not found at vim)
+ # VIM_ERROR (Cannot connect to VIM, VIM response error, ...)
+ # OTHER (Vim reported other status not understood)
+ # ERROR (VIM indicates an ERROR status)
+ # ACTIVE,
+ # CREATING (on building process)
+ error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR
+ vim_info: #Text with plain information obtained from vim (yaml.safe_dump)
+ '''
+ raise vimconnNotImplemented("Should have implemented this")
+
def new_sf(self, name, sfis, sfc_encap=True):
"""Creates (an abstract) service function in the VIM
Params:
"""
raise vimconnNotImplemented( "SFC support not implemented" )
+ def refresh_sfs_status(self, sf_list):
+ '''Get the status of the service functions
+ Params: the list of sf identifiers
+ Returns a dictionary with:
+ vm_id: #VIM id of this service function
+ status: #Mandatory. Text with one of:
+ # DELETED (not found at vim)
+ # VIM_ERROR (Cannot connect to VIM, VIM response error, ...)
+ # OTHER (Vim reported other status not understood)
+ # ERROR (VIM indicates an ERROR status)
+ # ACTIVE,
+ # CREATING (on building process)
+ error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR
+ vim_info: #Text with plain information obtained from vim (yaml.safe_dump)
+ '''
+ raise vimconnNotImplemented("Should have implemented this")
+
def new_sfp(self, name, classifications, sfs, sfc_encap=True, spi=None):
"""Creates a service function path
Params:
"""
raise vimconnNotImplemented( "SFC support not implemented" )
+ def refresh_sfps_status(self, sfp_list):
+ '''Get the status of the service function path
+ Params: the list of sfp identifiers
+ Returns a dictionary with:
+ vm_id: #VIM id of this service function path
+ status: #Mandatory. Text with one of:
+ # DELETED (not found at vim)
+ # VIM_ERROR (Cannot connect to VIM, VIM response error, ...)
+ # OTHER (Vim reported other status not understood)
+ # ERROR (VIM indicates an ERROR status)
+ # ACTIVE,
+ # CREATING (on building process)
+ error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR
+ vim_info: #Text with plain information obtained from vim (yaml.safe_dump)F
+ '''
+ raise vimconnNotImplemented("Should have implemented this")
+
def delete_sfp(self, sfp_id):
"""Deletes a service function path from the VIM
Returns the sfp ID (sfp_id) or raises an exception upon error or when sf is not found
def get_processor_rankings(self):
"""Get the processor rankings in the VIM database"""
raise vimconnNotImplemented( "Should have implemented this" )
-
+
@deprecated
def new_host(self, host_data):
"""Adds a new host to VIM"""
"""Returns status code of the VIM response"""
raise vimconnNotImplemented( "Should have implemented this" )
-
+
@deprecated
def new_external_port(self, port_data):
"""Adds a external port to VIM"""
"""Returns the port identifier"""
raise vimconnNotImplemented( "Should have implemented this" )
-
+
@deprecated
def new_external_network(self,net_name,net_type):
"""Adds a external network to VIM (shared)"""
"""Adds a VM instance to VIM"""
"""Returns the instance identifier"""
raise vimconnNotImplemented( "Should have implemented this" )
-