From ac9b37e619e85cf1c09a983b2698be6fe44c6c34 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 15 Aug 2016 16:54:30 +0100 Subject: [PATCH] plugins/xenserver: Resolve PEP8 issues Some files have regressed since '798058' ensured PEP8 compliance. Correct these regressions in preparation for enabled PEP8 checks. Change-Id: I2d0bae469673e4b5e2238978a7ba63f6bfe0358a Partial-Bug: #1302831 --- .../xenapi/etc/xapi.d/plugins/glance | 19 +++++++++---------- .../xenapi/etc/xapi.d/plugins/xenhost | 1 + 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index 0149b166601c..5219c9e5b75b 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance @@ -193,8 +193,7 @@ def _upload_tarball_v1(staging_path, image_id, glance_host, glance_port, def _upload_tarball_by_url_v1(staging_path, image_id, glance_endpoint, extra_headers, properties): - """ - Create a tarball of the image and then stream that into Glance v1 + """Create a tarball of the image and then stream that into Glance v1 using chunked-transfer-encoded HTTP. """ # NOTE(johngarbutt) By default, there is no timeout. @@ -320,26 +319,26 @@ def _update_image_meta_v2(conn, image_id, extra_headers, properties): headers = {'Content-Type': 'application/openstack-images-v2.1-json-patch'} headers.update(**extra_headers) - for key, value in properties.iteritems(): + for key, value in properties.items(): prop = {"path": "/%s" % key.replace('_', '-'), "value": key, "op": "add"} body.append(prop) body = json.dumps(body) - conn.request('PATCH', '/v2/images/%s' % image_id, body=body, headers=headers) + conn.request('PATCH', '/v2/images/%s' % image_id, + body=body, headers=headers) resp = conn.getresponse() resp.read() if resp.status == httplib.OK: return - logging.error("Image meta was not updated. Status: %s, Reason: %s" % - (resp.status, resp.reason)) + logging.error("Image meta was not updated. Status: %s, Reason: %s" % ( + resp.status, resp.reason)) def _upload_tarball_by_url_v2(staging_path, image_id, glance_endpoint, extra_headers, properties): - """ - Create a tarball of the image and then stream that into Glance v2 + """Create a tarball of the image and then stream that into Glance v2 using chunked-transfer-encoded HTTP. """ # NOTE(johngarbutt) By default, there is no timeout. @@ -364,7 +363,7 @@ def _upload_tarball_by_url_v2(staging_path, image_id, glance_endpoint, try: conn = _create_connection(parts[0], parts[1]) - except Exception, error: + except Exception, error: # noqa raise RetryableError(error) try: @@ -398,7 +397,7 @@ def _upload_tarball_by_url_v2(staging_path, image_id, glance_endpoint, callback_data['bytes_written'] += chunk_len try: conn.send("%x\r\n%s\r\n" % (chunk_len, chunk)) - except Exception, error: + except Exception, error: # noqa logging.exception('Failed to upload when sending chunks') raise RetryableError(error) diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost index 045f3623e6aa..f67def219e6a 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost @@ -271,6 +271,7 @@ def _ip_link_del_dev(args): cmd_args = ['ip', 'link', 'delete', device_name] return _run_command(cmd_args) + def _ip_link_add_veth_pair(args): dev1_name = pluginlib.exists(args, 'dev1_name') dev2_name = pluginlib.exists(args, 'dev2_name')