Merge branch v1.0 (commit fb1987b) into master
[osm/RO.git] / vimconn.py
index 7e82590..b5f8b07 100644 (file)
@@ -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
@@ -92,8 +103,9 @@ class vimconnector():
         self.user      = user
         self.passwd    = passwd
         self.config    = config
-        self.logger = logging.getLogger('mano.vim')
-        self.logger.setLevel( getattr(logging, log_level) )
+        self.logger = logging.getLogger('openmano.vim')
+        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
             <other VIM specific>
-        Returns the tenant list of dictionaries
+        Returns the tenant list of dictionaries, and empty list if no tenant match all the filers:
             [{'name':'<name>, 'id':'<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,14 +287,22 @@ 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 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:
+            [{<the fields at Filter_dict plus some VIM specific>}, ...]
+            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):
         '''Adds a VM instance to VIM
         Params: