X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=vimconn.py;h=814be65a40d5ab0b2e477fb2749ae1008f611b81;hb=bba83c837c93bada304f2cb31925c59c0afb82c8;hp=e6e042154198aece5328a239c1b52d68eef5c7c0;hpb=73ad9e4d8ceff08bd6a9e799cb8b48ad914cd35a;p=osm%2FRO.git diff --git a/vimconn.py b/vimconn.py index e6e04215..814be65a 100644 --- a/vimconn.py +++ b/vimconn.py @@ -82,7 +82,18 @@ class vimconnector(): These plugins must implement a vimconnector class derived from this and all these methods ''' - def __init__(self, uuid, name, tenant_id, tenant_name, url, url_admin=None, user=None, passwd=None, log_level="ERROR", config={}): + def __init__(self, uuid, name, tenant_id, tenant_name, url, url_admin=None, user=None, passwd=None, log_level=None, config={}): + """Constructor of VIM + "uuid": id asigned to this VIM + "name": name assigned to this VIM, can be used for logging + "tenant_id", tenant_name: VIM tenant to be used + "url_admin": optional, url used for administrative tasks + "user", "passwd": credentials of the VIM user + "log_level": if must use a different log_level than the general one + "config": dictionary with extra VIM information. This contains a consolidate version of general VIM config at create + and particular VIM config at attach + Returns can raise an exception if some check is done and fails + """ self.id = uuid self.name = name self.url = url @@ -93,7 +104,8 @@ class vimconnector(): self.passwd = passwd self.config = config self.logger = logging.getLogger('openmano.vim') - self.logger.setLevel( getattr(logging, log_level) ) + if log_level: + self.logger.setLevel( getattr(logging, log_level) ) if not self.url_admin: #try to use normal url self.url_admin = self.url @@ -140,33 +152,45 @@ class vimconnector(): raise KeyError("Invalid key '%s'" %str(index)) def new_tenant(self,tenant_name,tenant_description): - '''Adds a new tenant to VIM with this name and description, - returns the tenant identifier''' + """Adds a new tenant to VIM with this name and description, this is done using admin_url if provided + "tenant_name": string max lenght 64 + "tenant_description": string max length 256 + returns the tenant identifier or raise exception + """ raise vimconnNotImplemented( "Should have implemented this" ) def delete_tenant(self,tenant_id,): - '''Delete a tenant from VIM''' - '''Returns the tenant identifier''' + """Delete a tenant from VIM + tenant_id: returned VIM tenant_id on "new_tenant" + Returns None on success. Raises and exception of failure. If tenant is not found raises vimconnNotFoundException + """ raise vimconnNotImplemented( "Should have implemented this" ) def get_tenant_list(self, filter_dict={}): '''Obtain tenants of VIM - filter_dict can contain the following keys: + filter_dict dictionary that can contain the following keys: name: filter by tenant name id: filter by tenant uuid/id - Returns the tenant list of dictionaries: + Returns the tenant list of dictionaries, and empty list if no tenant match all the filers: [{'name':', 'id':', ...}, ...] ''' raise vimconnNotImplemented( "Should have implemented this" ) def new_network(self,net_name, net_type, ip_profile=None, shared=False): - '''Adds a tenant network to VIM + """Adds a tenant network to VIM net_name is the name net_type can be 'bridge','data'.'ptp'. TODO: this need to be revised - ip_profile is a dict containing the IP parameters of the network + ip_profile is a dict containing the IP parameters of the network + "ip-version": {"type":"string", "enum":["IPv4","IPv6"]}, + "subnet-address": ip_prefix_schema, + "gateway-address": ip_schema, + "dns-address": ip_schema, + "dhcp": dhcp_schema + shared is a boolean - Returns the network identifier''' + Returns the network identifier on success or raises and exeption on failure + """ raise vimconnNotImplemented( "Should have implemented this" ) def get_network_list(self, filter_dict={}): @@ -263,15 +287,23 @@ class vimconnector(): raise vimconnNotImplemented( "Should have implemented this" ) def get_image_id_from_path(self, path): - '''Get the image id from image path in the VIM database''' - '''Returns: - 0,"Image not found" if there are no images with that path - 1,image-id if there is one image with that path - <0,message if there was an error (Image not found, error contacting VIM, more than 1 image with that path, etc.) - ''' + '''Get the image id from image path in the VIM database. Returns the image_id''' raise vimconnNotImplemented( "Should have implemented this" ) - def new_vminstance(self,name,description,start,image_id,flavor_id,net_list,cloud_config=None): + def get_image_list(self, filter_dict={}): + '''Obtain tenant images from VIM + Filter_dict can be: + name: image name + id: image uuid + checksum: image checksum + location: image path + Returns the image list of dictionaries: + [{}, ...] + List can be empty + ''' + raise vimconnNotImplemented( "Should have implemented this" ) + + def new_vminstance(self,name,description,start,image_id,flavor_id,net_list,cloud_config=None,disk_list=None): '''Adds a VM instance to VIM Params: start: indicates if VM must start or boot in pause mode. Ignored