From: Brad Hall Date: Sun, 5 Jun 2011 01:46:44 +0000 (-0700) Subject: Remove get_all_interfaces and fix detail_network commands X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2265c84a30644160a983bc2aaf48fae020f373e3;p=openstack-build%2Fneutron-build.git Remove get_all_interfaces and fix detail_network commands --- diff --git a/quantum/cli.py b/quantum/cli.py index 2fa2b0281..7daa5de69 100644 --- a/quantum/cli.py +++ b/quantum/cli.py @@ -137,20 +137,32 @@ def api_delete_net(client, *args): def detail_net(manager, *args): tid, nid = args - network = manager.get_network_details(tid, nid) - network_id = network["net-id"] - network_name = network["net-name"] - print "\tNetwork id:%s\n\tNetwork name:%s\n" % (network_id, network_name) + iface_list = manager.get_all_attached_interfaces(tid, nid) + print "Remote Interfaces on Virtual Network:%s\n" % nid + for iface in iface_list: + print "\tRemote interface:%s" % iface + def api_detail_net(client, *args): tid, nid = args - res = client.do_request(tid, 'GET', "/networks/" + nid + "." + FORMAT) + res = client.do_request(tid, 'GET', + "/networks/%s/ports.%s" % (nid, FORMAT)) output = res.read() + if res.status != 200: + LOG.error("Failed to list ports: %s" % output) + return rd = simplejson.loads(output) LOG.debug(rd) - network_id = rd["networks"]["network"]["id"] - network_name = rd["networks"]["network"]["name"] - print "\tNetwork id:%s\n\tNetwork name:%s\n" % (network_id, network_name) + print "Remote Interfaces on Virtual Network:%s\n" % nid + for port in rd["ports"]: + pid = port["id"] + res = client.do_request(tid, 'GET', + "/networks/%s/ports/%s/attachment.%s" % (nid, pid, FORMAT)) + output = res.read() + rd = simplejson.loads(output) + LOG.debug(rd) + remote_iface = rd["attachment"] + print "\tRemote interface:%s" % remote_iface def rename_net(manager, *args): tid, nid, name = args @@ -286,53 +298,6 @@ def api_unplug_iface(client, *args): return print "Unplugged interface from port:%s on network:%s" % (pid, nid) -def detail_iface(manager, *args): - tid, nid, pid = args - remote_iface = manager.get_interface_details(tid, nid, pid) - print "Remote interface on Virtual Port:%s " \ - "Virtual Network:%s is %s" % (pid, nid, remote_iface) - -def api_detail_iface(manager, *args): - tid, nid, pid = args - res = client.do_request(tid, 'GET', - "/networks/%s/ports/%s/attachment.%s" % (nid, pid, FORMAT)) - output = res.read() - rd = simplejson.loads(output) - LOG.debug(rd) - remote_iface = rd["attachment"] - print "Remote interface on Virtual Port:%s " \ - "Virtual Network:%s is %s" % (pid, nid, remote_iface) - -def list_iface(manager, *args): - tid, nid = args - iface_list = manager.get_all_attached_interfaces(tid, nid) - print "Remote Interfaces on Virtual Network:%s\n" % nid - for iface in iface_list: - print "\tRemote interface:%s" % iface - -# TODO(bgh): I'm not sure how the api maps to manager.get_all_interfaces so -# I'm just doing this the manual way for now. -def api_list_iface(client, *args): - tid, nid = args - res = client.do_request(tid, 'GET', - "/networks/%s/ports.%s" % (nid, FORMAT)) - output = res.read() - if res.status != 200: - LOG.error("Failed to list ports: %s" % output) - return - rd = simplejson.loads(output) - LOG.debug(rd) - print "Remote Interfaces on Virtual Network:%s\n" % nid - for port in rd["ports"]: - pid = port["id"] - res = client.do_request(tid, 'GET', - "/networks/%s/ports/%s/attachment.%s" % (nid, pid, FORMAT)) - output = res.read() - rd = simplejson.loads(output) - LOG.debug(rd) - remote_iface = rd["attachment"] - print "\tRemote interface:%s" % remote_iface - commands = { "list_nets": { "func": list_nets, @@ -389,16 +354,6 @@ commands = { "api_func": api_unplug_iface, "args": ["tenant-id", "net-id", "port-id"] }, - "detail_iface": { - "func": detail_iface, - "api_func": api_detail_iface, - "args": ["tenant-id", "net-id", "port-id"] - }, - "list_iface": { - "func": list_iface, - "api_func": api_list_iface, - "args": ["tenant-id", "net-id"] - }, } def help(): diff --git a/quantum/plugins/openvswitch/ovs_quantum_plugin.py b/quantum/plugins/openvswitch/ovs_quantum_plugin.py index 036c3c830..75619cae6 100644 --- a/quantum/plugins/openvswitch/ovs_quantum_plugin.py +++ b/quantum/plugins/openvswitch/ovs_quantum_plugin.py @@ -129,12 +129,11 @@ class OVSQuantumPlugin(QuantumPluginBase): return d def get_network_details(self, tenant_id, net_id): - network = db.network_get(net_id) - d = {} - d["net-id"] = str(network.uuid) - d["net-name"] = network.name - d["net-ports"] = self.get_all_ports(tenant_id, net_id) - return d + ports = db.port_list(net_id) + ifaces = [] + for p in ports: + ifaces.append(p.interface_id) + return ifaces def rename_network(self, tenant_id, net_id, new_name): try: @@ -188,13 +187,6 @@ class OVSQuantumPlugin(QuantumPluginBase): "net-id": port.network_id, "port-state": "UP"} return rv - def get_all_attached_interfaces(self, tenant_id, net_id): - ports = db.port_list(net_id) - ifaces = [] - for p in ports: - ifaces.append(p.interface_id) - return ifaces - def plug_interface(self, tenant_id, net_id, port_id, remote_iface_id): db.port_set_attachment(port_id, remote_iface_id) ovs_db.update_network_binding(net_id, remote_iface_id)