X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=openmanoclient.py;h=19a430d4014b64828eac1dcf63f4c5ea4e351dc5;hb=867ffe95de6cadcc001e0a57ed26750ba8c01a32;hp=0d9aa4ae3438309cfe9c96896c39dcaf35dea4f7;hpb=392f28583d8750e7e2c2c5f2341688ec5acdf824;p=osm%2FRO.git diff --git a/openmanoclient.py b/openmanoclient.py index 0d9aa4ae..19a430d4 100644 --- a/openmanoclient.py +++ b/openmanoclient.py @@ -25,10 +25,10 @@ ''' openmano python client used to interact with openmano-server ''' -__author__="Alfonso Tierno" +__author__="Alfonso Tierno, Pablo Montes" __date__ ="$09-Mar-2016 09:09:48$" -__version__="0.0.1-r467" -version_date="Mar 2016" +__version__="0.0.2-r468" +version_date="Feb 2017" import requests import json @@ -74,7 +74,7 @@ class openmanoclient(): self.datacenter_id = kwargs.get("datacenter_id") self.datacenter_name = kwargs.get("datacenter_name") self.datacenter = None - self.logger = logging.getLogger('manoclient') + self.logger = logging.getLogger(kwargs.get('logger','manoclient')) if kwargs.get("debug"): self.logger.setLevel(logging.DEBUG) @@ -424,7 +424,10 @@ class openmanoclient(): Return: Raises an exception on error, not found, found several, not free Obtain a dictionary with format {'result': text indicating deleted} ''' - return self._del_item("datacenters", uuid, name, all_tenants=True) + if not uuid: + # check that exist + uuid = self._get_item_uuid("datacenters", uuid, name, all_tenants=True) + return self._del_item("datacenters", uuid, name, all_tenants=None) def create_datacenter(self, descriptor=None, descriptor_format=None, name=None, vim_url=None, **kwargs): #, type="openvim", public=False, description=None): @@ -832,9 +835,14 @@ class openmanoclient(): Return: Raises an exception on error Obtain a dictionary with format {'tenant':{new_tenant_info}} ''' - if item not in ("tenants", "networks"): - raise OpenmanoBadParamsException("Unknown value for item '{}', must be 'tenants' or 'nets'".format(str(item))) - + if item not in ("tenants", "networks", "images"): + raise OpenmanoBadParamsException("Unknown value for item '{}', must be 'tenants', 'nets' or " + "images".format(str(item))) + + image_actions = ['list','get','show','delete'] + if item == "images" and action not in image_actions: + raise OpenmanoBadParamsException("Only available actions for item '{}' are {}\n" + "Requested action was '{}'".format(item, ', '.join(image_actions), action)) if all_tenants: tenant_text = "/any" else: