From ad0199a73c280279d7aac7f390f597b0c365975f Mon Sep 17 00:00:00 2001 From: Sumit Naiksatam Date: Wed, 17 Aug 2011 19:47:10 -0700 Subject: [PATCH 1/6] VIF driver for 802.1qbh and Quantum aware scheduler. --- quantum/plugins/cisco/nova/__init__.py | 18 ++++ .../cisco/nova/quantum_aware_scheduler.py | 77 ++++++++++++++++ quantum/plugins/cisco/nova/vifdirect.py | 88 +++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 quantum/plugins/cisco/nova/__init__.py create mode 100644 quantum/plugins/cisco/nova/quantum_aware_scheduler.py create mode 100644 quantum/plugins/cisco/nova/vifdirect.py diff --git a/quantum/plugins/cisco/nova/__init__.py b/quantum/plugins/cisco/nova/__init__.py new file mode 100644 index 0000000000..db695fb0af --- /dev/null +++ b/quantum/plugins/cisco/nova/__init__.py @@ -0,0 +1,18 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright 2011 Cisco Systems, Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Sumit Naiksatam, Cisco Systems, Inc. +# diff --git a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py new file mode 100644 index 0000000000..8a2213d0da --- /dev/null +++ b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py @@ -0,0 +1,77 @@ +""" +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright 2011 Cisco Systems, Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Sumit Naiksatam, Cisco Systems, Inc. +# +""" + +from nova import flags +from nova import log as logging +from nova.scheduler import driver +from quantum.client import Client +from quantum.common.wsgi import Serializer + +LOG = logging.getLogger('nova.scheduler.quantum_aware_scheduler') + +FLAGS = flags.FLAGS +flags.DEFINE_string('quantum_host', "127.0.0.1", + 'IP address of the quantum network service.') +flags.DEFINE_integer('quantum_port', 9696, + 'Listening port for Quantum network service') + +HOST = FLAGS.quantum_host +PORT = FLAGS.quantum_port +USE_SSL = False +TENANT_ID = 'nova' + + +class QuantumScheduler(driver.Scheduler): + """ + Quantum network service dependent scheduler + Obtains the hostname from Quantum using an extension API + """ + + def schedule(self, context, topic, *_args, **_kwargs): + """Gets the host name from the Quantum service""" + instance_id = _kwargs['instance_id'] + user_id = \ + _kwargs['request_spec']['instance_properties']['user_id'] + project_id = \ + _kwargs['request_spec']['instance_properties']['project_id'] + + instance_data_dict = \ + {'novatenant': \ + {'instance-id': instance_id, + 'instance-desc': \ + {'user_id': user_id, + 'project_id': project_id + }}} + client = Client(HOST, PORT, USE_SSL) + content_type = "application/" + "json" + body = Serializer().serialize(instance_data_dict, content_type) + request_url = "/novatenants/" + project_id + "/get_host.json" + res = client.do_request(TENANT_ID, 'PUT', request_url, body=body) + content = res.read() + data = Serializer().deserialize(content, content_type) + hostname = data["host_list"]["host_1"] + if not hostname: + raise driver.NoValidHost(_("Scheduler was unable to locate a host" + " for this request. Is the appropriate" + " service running?")) + + LOG.debug(_("Quantum service returned host: %s\n") % hostname) + return hostname diff --git a/quantum/plugins/cisco/nova/vifdirect.py b/quantum/plugins/cisco/nova/vifdirect.py new file mode 100644 index 0000000000..b9a48441c5 --- /dev/null +++ b/quantum/plugins/cisco/nova/vifdirect.py @@ -0,0 +1,88 @@ +""" +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# Copyright 2011 Cisco Systems, Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Sumit Naiksatam, Cisco Systems, Inc. +# +""" +"""VIF drivers for interface type direct.""" + +from nova import flags +from nova import log as logging +from nova import utils +from nova.network import linux_net +from nova.virt.libvirt import netutils +from nova.virt.vif import VIFDriver +from quantum.client import Client +from quantum.common.wsgi import Serializer + +LOG = logging.getLogger('nova.virt.libvirt.vif') + +FLAGS = flags.FLAGS +flags.DEFINE_string('quantum_host', "127.0.0.1", + 'IP address of the quantum network service.') +flags.DEFINE_integer('quantum_port', 9696, + 'Listening port for Quantum network service') + +HOST = FLAGS.quantum_host +PORT = FLAGS.quantum_port +USE_SSL = False +TENANT_ID = 'nova' + + +class Libvirt802dot1QbhDriver(VIFDriver): + """VIF driver for Linux bridge.""" + + def _get_configurations(self, instance, network, mapping): + """Gets the device name and the profile name from Quantum""" + + instance_id = instance['id'] + user_id = instance['user_id'] + project_id = instance['project_id'] + + instance_data_dict = \ + {'novatenant': \ + {'instance-id': instance_id, + 'instance-desc': \ + {'user_id': user_id, + 'project_id': project_id + }}} + client = Client(HOST, PORT, USE_SSL) + content_type = "application/" + "json" + body = Serializer().serialize(instance_data_dict, content_type) + request_url = "/novatenants/" + project_id + "/get_instance_port.json" + res = client.do_request(TENANT_ID, 'PUT', request_url, body=body) + content = res.read() + data = Serializer().deserialize(content, content_type) + device = data['vif_desc']['device'] + portprofile = data['vif_desc']['portprofile'] + LOG.debug(_("Quantum returned device: %s\n") % device) + LOG.debug(_("Quantum returned portprofile: %s\n") % portprofile) + mac_id = mapping['mac'].replace(':', '') + + result = { + 'id': mac_id, + 'mac_address': mapping['mac'], + 'device_name': device, + 'profile_name': portprofile, + } + + return result + + def plug(self, instance, network, mapping): + return self._get_configurations(instance, network, mapping) + + def unplug(self, instance, network, mapping): + pass From 8ce8639f50ab48fffae8c99212570a30d5d18478 Mon Sep 17 00:00:00 2001 From: Sumit Naiksatam Date: Wed, 17 Aug 2011 19:52:52 -0700 Subject: [PATCH 2/6] Removed extra spaces to satisfy pep8. --- quantum/plugins/cisco/nova/quantum_aware_scheduler.py | 4 +--- quantum/plugins/cisco/nova/vifdirect.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py index 8a2213d0da..b83dd698c0 100644 --- a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py +++ b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py @@ -57,9 +57,7 @@ class QuantumScheduler(driver.Scheduler): {'novatenant': \ {'instance-id': instance_id, 'instance-desc': \ - {'user_id': user_id, - 'project_id': project_id - }}} + {'user_id': user_id, 'project_id': project_id}}} client = Client(HOST, PORT, USE_SSL) content_type = "application/" + "json" body = Serializer().serialize(instance_data_dict, content_type) diff --git a/quantum/plugins/cisco/nova/vifdirect.py b/quantum/plugins/cisco/nova/vifdirect.py index b9a48441c5..0d2369a787 100644 --- a/quantum/plugins/cisco/nova/vifdirect.py +++ b/quantum/plugins/cisco/nova/vifdirect.py @@ -56,9 +56,7 @@ class Libvirt802dot1QbhDriver(VIFDriver): {'novatenant': \ {'instance-id': instance_id, 'instance-desc': \ - {'user_id': user_id, - 'project_id': project_id - }}} + {'user_id': user_id, 'project_id': project_id}}} client = Client(HOST, PORT, USE_SSL) content_type = "application/" + "json" body = Serializer().serialize(instance_data_dict, content_type) From 9939bc6748752852244b6e7165ccc161d3585c18 Mon Sep 17 00:00:00 2001 From: Sumit Naiksatam Date: Thu, 18 Aug 2011 16:53:57 -0700 Subject: [PATCH 3/6] Removed concatenation per review comments. --- quantum/plugins/cisco/nova/quantum_aware_scheduler.py | 2 +- quantum/plugins/cisco/nova/vifdirect.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py index b83dd698c0..c82db878b7 100644 --- a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py +++ b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py @@ -59,7 +59,7 @@ class QuantumScheduler(driver.Scheduler): 'instance-desc': \ {'user_id': user_id, 'project_id': project_id}}} client = Client(HOST, PORT, USE_SSL) - content_type = "application/" + "json" + content_type = "application/json" body = Serializer().serialize(instance_data_dict, content_type) request_url = "/novatenants/" + project_id + "/get_host.json" res = client.do_request(TENANT_ID, 'PUT', request_url, body=body) diff --git a/quantum/plugins/cisco/nova/vifdirect.py b/quantum/plugins/cisco/nova/vifdirect.py index 0d2369a787..f3c3699576 100644 --- a/quantum/plugins/cisco/nova/vifdirect.py +++ b/quantum/plugins/cisco/nova/vifdirect.py @@ -58,7 +58,7 @@ class Libvirt802dot1QbhDriver(VIFDriver): 'instance-desc': \ {'user_id': user_id, 'project_id': project_id}}} client = Client(HOST, PORT, USE_SSL) - content_type = "application/" + "json" + content_type = "application/json" body = Serializer().serialize(instance_data_dict, content_type) request_url = "/novatenants/" + project_id + "/get_instance_port.json" res = client.do_request(TENANT_ID, 'PUT', request_url, body=body) From efcbdde237cec0ca9689c9353cbc87596973f911 Mon Sep 17 00:00:00 2001 From: Sumit Naiksatam Date: Fri, 19 Aug 2011 18:46:34 -0700 Subject: [PATCH 4/6] Code refactored, made changes are per reviwer's suggestions. --- .../plugins/cisco/nova/quantum_aware_scheduler.py | 12 +++++------- quantum/plugins/cisco/nova/vifdirect.py | 13 ++++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py index c82db878b7..b5f21ac820 100644 --- a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py +++ b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py @@ -58,14 +58,12 @@ class QuantumScheduler(driver.Scheduler): {'instance-id': instance_id, 'instance-desc': \ {'user_id': user_id, 'project_id': project_id}}} - client = Client(HOST, PORT, USE_SSL) - content_type = "application/json" - body = Serializer().serialize(instance_data_dict, content_type) - request_url = "/novatenants/" + project_id + "/get_host.json" - res = client.do_request(TENANT_ID, 'PUT', request_url, body=body) - content = res.read() - data = Serializer().deserialize(content, content_type) + client = Client(HOST, PORT, USE_SSL, format='json') + request_url = "/novatenants/" + project_id + "/get_host" + data = client.do_request(TENANT_ID, 'PUT', request_url, + body=instance_data_dict) hostname = data["host_list"]["host_1"] + if not hostname: raise driver.NoValidHost(_("Scheduler was unable to locate a host" " for this request. Is the appropriate" diff --git a/quantum/plugins/cisco/nova/vifdirect.py b/quantum/plugins/cisco/nova/vifdirect.py index f3c3699576..1565bfe57e 100644 --- a/quantum/plugins/cisco/nova/vifdirect.py +++ b/quantum/plugins/cisco/nova/vifdirect.py @@ -57,15 +57,14 @@ class Libvirt802dot1QbhDriver(VIFDriver): {'instance-id': instance_id, 'instance-desc': \ {'user_id': user_id, 'project_id': project_id}}} - client = Client(HOST, PORT, USE_SSL) - content_type = "application/json" - body = Serializer().serialize(instance_data_dict, content_type) - request_url = "/novatenants/" + project_id + "/get_instance_port.json" - res = client.do_request(TENANT_ID, 'PUT', request_url, body=body) - content = res.read() - data = Serializer().deserialize(content, content_type) + + client = Client(HOST, PORT, USE_SSL, format='json') + request_url = "/novatenants/" + project_id + "/get_instance_port" + data = client.do_request(TENANT_ID, 'PUT', request_url, + body=instance_data_dict) device = data['vif_desc']['device'] portprofile = data['vif_desc']['portprofile'] + LOG.debug(_("Quantum returned device: %s\n") % device) LOG.debug(_("Quantum returned portprofile: %s\n") % portprofile) mac_id = mapping['mac'].replace(':', '') From ec9c06cf84fb9566035fc6f4cac5f2847de1c6d4 Mon Sep 17 00:00:00 2001 From: Sumit Naiksatam Date: Wed, 24 Aug 2011 03:15:54 -0700 Subject: [PATCH 5/6] Changes to incorporate reviwer's comments. Also changed client.py to handle extension URLs. --- quantum/client.py | 7 ++- quantum/plugins/cisco/nova/__init__.py | 18 ------- .../cisco/nova/quantum_aware_scheduler.py | 54 +++++++++++++------ quantum/plugins/cisco/nova/vifdirect.py | 54 ++++++++++++++----- 4 files changed, 83 insertions(+), 50 deletions(-) diff --git a/quantum/client.py b/quantum/client.py index 2e55dfb3ec..74ac1958ba 100644 --- a/quantum/client.py +++ b/quantum/client.py @@ -63,8 +63,6 @@ class Client(object): """A base client class - derived from Glance.BaseClient""" - action_prefix = '/v0.1/tenants/{tenant_id}' - # Action query strings networks_path = "/networks" network_path = "/networks/%s" @@ -74,7 +72,7 @@ class Client(object): def __init__(self, host="127.0.0.1", port=9696, use_ssl=False, tenant=None, format="xml", testingStub=None, key_file=None, cert_file=None, - logger=None): + logger=None, action_prefix="/v0.1/tenants/{tenant_id}"): """ Creates a new client to some service. @@ -97,6 +95,7 @@ class Client(object): self.key_file = key_file self.cert_file = cert_file self.logger = logger + self.action_prefix = action_prefix def get_connection_type(self): """ @@ -130,7 +129,7 @@ class Client(object): # Add format and tenant_id action += ".%s" % self.format - action = Client.action_prefix + action + action = self.action_prefix + action action = action.replace('{tenant_id}', self.tenant) if type(params) is dict: diff --git a/quantum/plugins/cisco/nova/__init__.py b/quantum/plugins/cisco/nova/__init__.py index db695fb0af..e69de29bb2 100644 --- a/quantum/plugins/cisco/nova/__init__.py +++ b/quantum/plugins/cisco/nova/__init__.py @@ -1,18 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# -# Copyright 2011 Cisco Systems, Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# @author: Sumit Naiksatam, Cisco Systems, Inc. -# diff --git a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py index b5f21ac820..4d30ccd4a1 100644 --- a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py +++ b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py @@ -1,4 +1,3 @@ -""" # vim: tabstop=4 shiftwidth=4 softtabstop=4 # # Copyright 2011 Cisco Systems, Inc. All rights reserved. @@ -17,15 +16,15 @@ # # @author: Sumit Naiksatam, Cisco Systems, Inc. # -""" +from nova import exception as excp from nova import flags from nova import log as logging from nova.scheduler import driver from quantum.client import Client from quantum.common.wsgi import Serializer -LOG = logging.getLogger('nova.scheduler.quantum_aware_scheduler') +LOG = logging.getLogger('quantum.plugins.cisco.nova.quantum_aware_scheduler') FLAGS = flags.FLAGS flags.DEFINE_string('quantum_host', "127.0.0.1", @@ -36,7 +35,11 @@ flags.DEFINE_integer('quantum_port', 9696, HOST = FLAGS.quantum_host PORT = FLAGS.quantum_port USE_SSL = False +ACTION_PREFIX_EXT = '/v0.1' +ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \ + '/extensions/csco/tenants/{tenant_id}' TENANT_ID = 'nova' +CSCO_EXT_NAME = 'Cisco Nova Tenant' class QuantumScheduler(driver.Scheduler): @@ -44,26 +47,47 @@ class QuantumScheduler(driver.Scheduler): Quantum network service dependent scheduler Obtains the hostname from Quantum using an extension API """ + def __init__(self): + # We have to send a dummy tenant name here since the client + # needs some tenant name, but the tenant name will not be used + # since the extensions URL does not require it + client = Client(HOST, PORT, USE_SSL, format='json', + action_prefix=ACTION_PREFIX_EXT, tenant="dummy") + request_url = "/extensions" + data = client.do_request('GET', request_url) + LOG.debug("Obtained supported extensions from Quantum: %s" % data) + for ext in data['extensions']: + name = ext['name'] + if name == CSCO_EXT_NAME: + LOG.debug("Quantum plugin supports required \"%s\" extension" + "for the scheduler." % name) + return + LOG.error("Quantum plugin does not support required \"%s\" extension" + " for the scheduler. Scheduler will quit." % CSCO_EXT_NAME) + raise excp.ServiceUnavailable() - def schedule(self, context, topic, *_args, **_kwargs): + def schedule(self, context, topic, *args, **kwargs): """Gets the host name from the Quantum service""" - instance_id = _kwargs['instance_id'] + instance_id = kwargs['instance_id'] user_id = \ - _kwargs['request_spec']['instance_properties']['user_id'] + kwargs['request_spec']['instance_properties']['user_id'] project_id = \ - _kwargs['request_spec']['instance_properties']['project_id'] + kwargs['request_spec']['instance_properties']['project_id'] instance_data_dict = \ {'novatenant': \ - {'instance-id': instance_id, - 'instance-desc': \ - {'user_id': user_id, 'project_id': project_id}}} - client = Client(HOST, PORT, USE_SSL, format='json') - request_url = "/novatenants/" + project_id + "/get_host" - data = client.do_request(TENANT_ID, 'PUT', request_url, - body=instance_data_dict) - hostname = data["host_list"]["host_1"] + {'instance_id': instance_id, + 'instance_desc': \ + {'user_id': user_id, + 'project_id': project_id + }}} + client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID, + action_prefix=ACTION_PREFIX_CSCO) + request_url = "/novatenants/" + project_id + "/get_host" + data = client.do_request('PUT', request_url, body=instance_data_dict) + + hostname = data["host_list"]["host_1"] if not hostname: raise driver.NoValidHost(_("Scheduler was unable to locate a host" " for this request. Is the appropriate" diff --git a/quantum/plugins/cisco/nova/vifdirect.py b/quantum/plugins/cisco/nova/vifdirect.py index 1565bfe57e..6581c32f3c 100644 --- a/quantum/plugins/cisco/nova/vifdirect.py +++ b/quantum/plugins/cisco/nova/vifdirect.py @@ -1,4 +1,3 @@ -""" # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2011 Cisco Systems, Inc. All rights reserved. # @@ -16,19 +15,20 @@ # # @author: Sumit Naiksatam, Cisco Systems, Inc. # -""" + """VIF drivers for interface type direct.""" +from nova import exception as excp from nova import flags from nova import log as logging -from nova import utils from nova.network import linux_net from nova.virt.libvirt import netutils +from nova import utils from nova.virt.vif import VIFDriver from quantum.client import Client from quantum.common.wsgi import Serializer -LOG = logging.getLogger('nova.virt.libvirt.vif') +LOG = logging.getLogger('quantum.plugins.cisco.nova.vifdirect') FLAGS = flags.FLAGS flags.DEFINE_string('quantum_host', "127.0.0.1", @@ -40,10 +40,34 @@ HOST = FLAGS.quantum_host PORT = FLAGS.quantum_port USE_SSL = False TENANT_ID = 'nova' +ACTION_PREFIX_EXT = '/v0.1' +ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \ + '/extensions/csco/tenants/{tenant_id}' +TENANT_ID = 'nova' +CSCO_EXT_NAME = 'Cisco Nova Tenant' class Libvirt802dot1QbhDriver(VIFDriver): """VIF driver for Linux bridge.""" + def __init__(self): + # We have to send a dummy tenant name here since the client + # needs some tenant name, but the tenant name will not be used + # since the extensions URL does not require it + client = Client(HOST, PORT, USE_SSL, format='json', + action_prefix=ACTION_PREFIX_EXT, tenant="dummy") + request_url = "/extensions" + data = client.do_request('GET', request_url) + LOG.debug("Obtained supported extensions from Quantum: %s" % data) + for ext in data['extensions']: + name = ext['name'] + if name == CSCO_EXT_NAME: + LOG.debug("Quantum plugin supports required \"%s\" extension" + "for the VIF driver." % name) + return + LOG.error("Quantum plugin does not support required \"%s\" extension" + " for the VIF driver. nova-compute will quit." \ + % CSCO_EXT_NAME) + raise excp.ServiceUnavailable() def _get_configurations(self, instance, network, mapping): """Gets the device name and the profile name from Quantum""" @@ -51,22 +75,26 @@ class Libvirt802dot1QbhDriver(VIFDriver): instance_id = instance['id'] user_id = instance['user_id'] project_id = instance['project_id'] + vif_id = mapping['vif_uuid'] instance_data_dict = \ {'novatenant': \ - {'instance-id': instance_id, - 'instance-desc': \ - {'user_id': user_id, 'project_id': project_id}}} + {'instance_id': instance_id, + 'instance_desc': \ + {'user_id': user_id, + 'project_id': project_id, + 'vif_id': vif_id + }}} - client = Client(HOST, PORT, USE_SSL, format='json') + client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID, + action_prefix=ACTION_PREFIX_CSCO) request_url = "/novatenants/" + project_id + "/get_instance_port" - data = client.do_request(TENANT_ID, 'PUT', request_url, - body=instance_data_dict) + data = client.do_request('PUT', request_url, body=instance_data_dict) + device = data['vif_desc']['device'] portprofile = data['vif_desc']['portprofile'] - - LOG.debug(_("Quantum returned device: %s\n") % device) - LOG.debug(_("Quantum returned portprofile: %s\n") % portprofile) + LOG.debug(_("Quantum provided the device: %s") % device) + LOG.debug(_("Quantum provided the portprofile: %s") % portprofile) mac_id = mapping['mac'].replace(':', '') result = { From 0bb571f24bd23ed9f4b38888ed05fd87c50301a8 Mon Sep 17 00:00:00 2001 From: Sumit Naiksatam Date: Wed, 24 Aug 2011 03:27:54 -0700 Subject: [PATCH 6/6] Noticed some pep8 errors, fixed them. --- quantum/plugins/cisco/nova/quantum_aware_scheduler.py | 5 ++--- quantum/plugins/cisco/nova/vifdirect.py | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py index 4d30ccd4a1..0f73618ee0 100644 --- a/quantum/plugins/cisco/nova/quantum_aware_scheduler.py +++ b/quantum/plugins/cisco/nova/quantum_aware_scheduler.py @@ -79,8 +79,7 @@ class QuantumScheduler(driver.Scheduler): {'instance_id': instance_id, 'instance_desc': \ {'user_id': user_id, - 'project_id': project_id - }}} + 'project_id': project_id}}} client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID, action_prefix=ACTION_PREFIX_CSCO) @@ -93,5 +92,5 @@ class QuantumScheduler(driver.Scheduler): " for this request. Is the appropriate" " service running?")) - LOG.debug(_("Quantum service returned host: %s\n") % hostname) + LOG.debug(_("Quantum service returned host: %s") % hostname) return hostname diff --git a/quantum/plugins/cisco/nova/vifdirect.py b/quantum/plugins/cisco/nova/vifdirect.py index 6581c32f3c..c1fd09af46 100644 --- a/quantum/plugins/cisco/nova/vifdirect.py +++ b/quantum/plugins/cisco/nova/vifdirect.py @@ -83,8 +83,7 @@ class Libvirt802dot1QbhDriver(VIFDriver): 'instance_desc': \ {'user_id': user_id, 'project_id': project_id, - 'vif_id': vif_id - }}} + 'vif_id': vif_id}}} client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID, action_prefix=ACTION_PREFIX_CSCO)