diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2017-09-29 09:15:02 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2017-09-29 09:15:02 +0800 |
commit | 6761e83a3352dcfc166949cf30365573571c0f1b (patch) | |
tree | 093f541a543f705ee53aa08721a360d74e0d198e /lcm | |
parent | 98d7251bed2598fbe019c37efa3d123942e1cdb0 (diff) |
Fix vnflcm vim api pep8 error
Change-Id: I9f7f8d7f97fd9703bfb649d08fe3473c76c8e646
Issue-Id: VFC-474
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r-- | lcm/lcm/pub/vimapi/api.py | 68 | ||||
-rw-r--r-- | lcm/lcm/pub/vimapi/exceptions.py | 1 |
2 files changed, 50 insertions, 19 deletions
diff --git a/lcm/lcm/pub/vimapi/api.py b/lcm/lcm/pub/vimapi/api.py index 4ad4230a..cebd7fce 100644 --- a/lcm/lcm/pub/vimapi/api.py +++ b/lcm/lcm/pub/vimapi/api.py @@ -19,14 +19,15 @@ from .exceptions import VimException VIM_DRIVER_BASE_URL = "api/multivim/v1" + def call(vim_id, tenant_id, res, method, data=''): if data and not isinstance(data, (str, unicode)): data = json.JSONEncoder().encode(data) - url = "{base_url}/{vim_id}{tenant_id}/{res}".format( - base_url=VIM_DRIVER_BASE_URL, - vim_id=vim_id, - tenant_id="/" + tenant_id if tenant_id else "", - res=res) + url_fmt = "{base_url}/{vim_id}{tenant_id}/{res}" + url = url_fmt.format(base_url=VIM_DRIVER_BASE_URL, + vim_id=vim_id, + tenant_id="/" + tenant_id if tenant_id else "", + res=res) ret = req_by_msb(url, method, data) if ret[0] > 0: raise VimException(ret[1], ret[2]) @@ -34,104 +35,133 @@ def call(vim_id, tenant_id, res, method, data=''): ###################################################################### + def create_image(vim_id, tenant_id, data): return call(vim_id, tenant_id, "images", "POST", data) + def delete_image(vim_id, tenant_id, image_id): return call(vim_id, tenant_id, "images/%s" % image_id, "DELETE") - + + def get_image(vim_id, tenant_id, image_id): return call(vim_id, tenant_id, "images/%s" % image_id, "GET") - + + def list_image(vim_id, tenant_id): return call(vim_id, tenant_id, "images", "GET") ###################################################################### + def create_network(vim_id, tenant_id, data): return call(vim_id, tenant_id, "networks", "POST", data) + def delete_network(vim_id, tenant_id, network_id): return call(vim_id, tenant_id, "networks/%s" % network_id, "DELETE") - + + def get_network(vim_id, tenant_id, network_id): return call(vim_id, tenant_id, "networks/%s" % network_id, "GET") - + + def list_network(vim_id, tenant_id): return call(vim_id, tenant_id, "networks", "GET") ###################################################################### + def create_subnet(vim_id, tenant_id, data): return call(vim_id, tenant_id, "subnets", "POST", data) + def delete_subnet(vim_id, tenant_id, subnet_id): return call(vim_id, tenant_id, "subnets/%s" % subnet_id, "DELETE") - + + def get_subnet(vim_id, tenant_id, subnet_id): return call(vim_id, tenant_id, "subnets/%s" % subnet_id, "GET") - + + def list_subnet(vim_id, tenant_id): return call(vim_id, tenant_id, "subnets", "GET") ###################################################################### + def create_port(vim_id, tenant_id, data): return call(vim_id, tenant_id, "ports", "POST", data) + def delete_port(vim_id, tenant_id, port_id): return call(vim_id, tenant_id, "ports/%s" % port_id, "DELETE") - + + def get_port(vim_id, tenant_id, port_id): return call(vim_id, tenant_id, "ports/%s" % port_id, "GET") - + + def list_port(vim_id, tenant_id): return call(vim_id, tenant_id, "ports", "GET") ###################################################################### + def create_flavor(vim_id, tenant_id, data): return call(vim_id, tenant_id, "flavors", "POST", data) + def delete_flavor(vim_id, tenant_id, flavor_id): return call(vim_id, tenant_id, "flavors/%s" % flavor_id, "DELETE") - + + def get_flavor(vim_id, tenant_id, flavor_id): return call(vim_id, tenant_id, "flavors/%s" % flavor_id, "GET") - + + def list_flavor(vim_id, tenant_id): return call(vim_id, tenant_id, "flavors", "GET") ###################################################################### + def create_vm(vim_id, tenant_id, data): return call(vim_id, tenant_id, "servers", "POST", data) + def delete_vm(vim_id, tenant_id, vm_id): return call(vim_id, tenant_id, "servers/%s" % vm_id, "DELETE") - + + def get_vm(vim_id, tenant_id, vm_id): return call(vim_id, tenant_id, "servers/%s" % vm_id, "GET") - + + def list_vm(vim_id, tenant_id): return call(vim_id, tenant_id, "servers", "GET") ###################################################################### + def create_volume(vim_id, tenant_id, data): return call(vim_id, tenant_id, "volumes", "POST", data) + def delete_volume(vim_id, tenant_id, volume_id): return call(vim_id, tenant_id, "volumes/%s" % volume_id, "DELETE") - + + def get_volume(vim_id, tenant_id, volume_id): return call(vim_id, tenant_id, "volumes/%s" % volume_id, "GET") - + + def list_volume(vim_id, tenant_id): return call(vim_id, tenant_id, "volumes", "GET") ###################################################################### + def list_tenant(vim_id, tenant_name=""): res = "tenants" if tenant_name: diff --git a/lcm/lcm/pub/vimapi/exceptions.py b/lcm/lcm/pub/vimapi/exceptions.py index 0d6ccec8..041ac3dc 100644 --- a/lcm/lcm/pub/vimapi/exceptions.py +++ b/lcm/lcm/pub/vimapi/exceptions.py @@ -14,6 +14,7 @@ from lcm.pub.exceptions import NFLCMException + class VimException(NFLCMException): def __init__(self, message='', http_code=''): self.message = message |