From d6aa31b1c8dce7e628af7365fe0b070d306fca52 Mon Sep 17 00:00:00 2001 From: Aaron Rosen Date: Wed, 3 Oct 2012 21:52:43 -0700 Subject: [PATCH] correct nvplib to update device_id Fixes bug 1061391 Change-Id: Ide8efdfb12dd0f403d7e4f468b1c9f3cc024f9a9 --- .../plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py | 2 ++ quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py b/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py index a753a479bd..284a9f831f 100644 --- a/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py +++ b/quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py @@ -811,6 +811,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2): params["cluster"] = cluster params["port"] = port["port"] + params["port"]["id"] = quantum_db["id"] + params["port"]["tenant_id"] = quantum_db["tenant_id"] result = nvplib.update_port(quantum_db["network_id"], port_nvp["uuid"], **params) LOG.debug("update_port() completed for tenant: %s" % context.tenant_id) diff --git a/quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py b/quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py index 16da282ccf..96aaf60dfc 100644 --- a/quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py +++ b/quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py @@ -373,11 +373,20 @@ def update_port(network, port_id, **params): admin_state_up = params['port'].get('admin_state_up') name = params["port"].get("name") + device_id = params["port"].get("device_id") if admin_state_up: lport_obj["admin_status_enabled"] = admin_state_up if name: lport_obj["display_name"] = name + if device_id: + # device_id can be longer than 40 so we rehash it + device_id = hashlib.sha1(device_id).hexdigest() + lport_obj["tags"] = ( + [dict(scope='os_tid', tag=params["port"].get("tenant_id")), + dict(scope='q_port_id', tag=params["port"]["id"]), + dict(scope='vm_id', tag=device_id)]) + uri = "/ws.v1/lswitch/" + network + "/lport/" + port_id try: resp_obj = do_single_request("PUT", uri, json.dumps(lport_obj), @@ -394,8 +403,6 @@ def update_port(network, port_id, **params): def create_port(tenant, **params): - print "create_port_nvplib" - print params clusters = params["clusters"] dest_cluster = clusters[0] # primary cluster