]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Addressing comments from Dan
authorSalvatore Orlando <salvatore.orlando@eu.citrix.com>
Fri, 26 Aug 2011 08:41:19 +0000 (09:41 +0100)
committerSalvatore Orlando <salvatore.orlando@eu.citrix.com>
Fri, 26 Aug 2011 08:41:19 +0000 (09:41 +0100)
Also solved issue with output from plug_iface and unplug_iface

bin/cli
quantum/cli_lib.py
quantum/cli_output.template
quantum/client.py
tests/unit/client_tools/stubs.py
tests/unit/test_cli.py
tools/pip-requires

diff --git a/bin/cli b/bin/cli
index 20ef7b2aeb78e675b9cf8f672647e7c7913a4099..6fd3e3ad544a1e86674089e0f45fb3f2f1d7c2cc 100755 (executable)
--- a/bin/cli
+++ b/bin/cli
@@ -55,8 +55,8 @@ commands = {
   "delete_net": {
     "func": cli_lib.delete_net,
     "args": ["tenant-id", "net-id"]},
-  "detail_net": {
-    "func": cli_lib.detail_net,
+  "show_net": {
+    "func": cli_lib.show_net,
     "args": ["tenant-id", "net-id"]},
   "rename_net": {
     "func": cli_lib.rename_net,
@@ -73,8 +73,8 @@ commands = {
   "set_port_state": {
     "func": cli_lib.set_port_state,
     "args": ["tenant-id", "net-id", "port-id", "new_state"]},
-  "detail_port": {
-    "func": cli_lib.detail_port,
+  "show_port": {
+    "func": cli_lib.show_port,
     "args": ["tenant-id", "net-id", "port-id"]},
   "plug_iface": {
     "func": cli_lib.plug_iface,
index cea8d3ae72141eba68a1b7ada4a15f1204659083..bffda703b2721cda60e966167f97ecaaf4ea9444 100755 (executable)
@@ -95,22 +95,14 @@ def delete_net(client, *args):
         _handle_exception(ex)
 
 
-def detail_net(client, *args):
+def show_net(client, *args):
     tenant_id, network_id = args
     try:
-        #NOTE(salvatore-orlando): Implementing non-efficient version
-        #for now, at least until plugins will not provide correct behaviour
-        #for the show_network_details operation
+        #NOTE(salvatore-orlando) changed for returning exclusively
+        # output for GET /networks/{net-id} API operation
         res = client.show_network_details(network_id)["network"]
         LOG.debug("Operation 'show_network_details' executed.")
-        ports = client.list_ports(network_id)
-        LOG.debug("Operation 'list_ports' executed.")
-        res.update(ports)
-        for port in ports['ports']:
-            att_data = client.show_port_attachment(network_id, port['id'])
-            LOG.debug("Operation 'show_port_attachment' executed.")
-            port['attachment'] = att_data['attachment'].get('id', None)
-        output = prepare_output("detail_net", tenant_id, dict(network=res))
+        output = prepare_output("show_net", tenant_id, dict(network=res))
         print output
     except Exception as ex:
         _handle_exception(ex)
@@ -171,7 +163,7 @@ def delete_port(client, *args):
         return
 
 
-def detail_port(client, *args):
+def show_port(client, *args):
     tenant_id, network_id, port_id = args
     try:
         port = client.show_port_details(network_id, port_id)["port"]
@@ -180,7 +172,7 @@ def detail_port(client, *args):
         #return attachment with GET operation on port. Once API alignment
         #branch is merged, update client to use the detail action
         port['attachment'] = '<unavailable>'
-        output = prepare_output("detail_port", tenant_id,
+        output = prepare_output("show_port", tenant_id,
                                 dict(network_id=network_id,
                                      port=port))
         print output
@@ -209,7 +201,7 @@ def plug_iface(client, *args):
         data = {'attachment': {'id': '%s' % attachment}}
         client.attach_resource(network_id, port_id, data)
         LOG.debug("Operation 'attach_resource' executed.")
-        output = prepare_output("plug_interface", tenant_id,
+        output = prepare_output("plug_iface", tenant_id,
                                 dict(network_id=network_id,
                                      port_id=port_id,
                                      attachment=attachment))
@@ -223,7 +215,7 @@ def unplug_iface(client, *args):
     try:
         client.detach_resource(network_id, port_id)
         LOG.debug("Operation 'detach_resource' executed.")
-        output = prepare_output("unplug_interface", tenant_id,
+        output = prepare_output("unplug_iface", tenant_id,
                                 dict(network_id=network_id,
                                      port_id=port_id))
         print output
index 12f394e19e4e9353f74f91e3f143c30d919991e6..107dceb93c2ca0073dafc477ac741c9d302f1a32 100644 (file)
@@ -1,45 +1,48 @@
 ## Cheetah template for cli output
 #if $cmd == 'list_nets'
-Virtual Networks on Tenant $tenant_id
+Virtual Networks for Tenant $tenant_id
 #for $network in $networks
     Network ID: $network.id
 #end for 
 #elif $cmd == 'create_net'
-Created a new Virtual Network with ID: $network_id for Tenant $tenant_id
+Created a new Virtual Network with ID: $network_id
+for Tenant $tenant_id
 #elif $cmd == 'delete_net'
-Deleted Virtual Network with ID: $network_id for Tenant $tenant_id
-#elif $cmd == 'detail_net'
-Network: $network.name ($network.id)
-Remote Interfaces on Virtual Network
-#for $port in $network.ports
-    Logical Port $port.id: $port.attachment
-#end for
+Deleted Virtual Network with ID: $network_id
+for Tenant $tenant_id
+#elif $cmd == 'show_net'
+Network ID: $network.id
+Network Name: $network.name 
+for Tenant: $tenant_id
 #elif $cmd == 'rename_net'
-Renamed Virtual Network with ID: $network.id for Tenant $tenant_id, 
+Renamed Virtual Network with ID: $network.id 
 New name is: $network.name
+for Tenant $tenant_id,
 #elif $cmd == 'list_ports'
 Ports on Virtual Network: $network_id
+for Tenant: $tenant_id
 #for $port in $ports
     Logical Port: $port.id
 #end for
 #elif $cmd == 'create_port'
 Created new Logical Port with ID: $port_id 
 on Virtual Network: $network_id 
-for tenant: $tenant_id 
+for Tenant: $tenant_id 
 #elif $cmd == 'delete_port'
 Deleted Logical Port with ID: $port_id
 on Virtual Network: $network_id
-for tenant: $tenant_id
+for Tenant: $tenant_id
 #elif $cmd == 'set_port_state'
 Updated state for Logical Port with ID: $port.id
-New state is: $port.state
+new state is: $port.state
 on Virtual Network: $network_id
 for tenant: $tenant_id
-#elif $cmd == 'detail_port'
+#elif $cmd == 'show_port'
 Logical Port ID: $port.id
-On Virtual Network: $network_id
-Administrative State: $port.state
-Remote Interface: $port.attachment
+administrative State: $port.state
+interface: $port.attachment
+on Virtual Network: $network_id
+for Tenant: $tenant_id
 #elif $cmd == 'plug_iface'
 Plugged interface $attachment
 into Logical Port: $port_id 
index f55244c6e61b94a4599e76c7dd2d4ae713f19a56..92c1be23d10721a7c5aee885da91a515add45be2 100644 (file)
@@ -230,7 +230,6 @@ class Client(object):
         """
         if status_code in (202, 204):
             return data
-        #server.networks.Controller._serialization_metadata
         return Serializer(self._serialization_metadata).\
                     deserialize(data, self.content_type())
 
index 8a01a8fb57bc5685a2b9812f1824bdf92a9cb6e8..081436bd1adab282e3f63251fb2b09855db5f472 100644 (file)
@@ -55,7 +55,7 @@ class FakeHTTPConnection:
         res = self._req.get_response(self._api)
 
         def _fake_read():
-            """ Trick for macking a webob.Response look like a
+            """ Trick for making a webob.Response look like a
                 httplib.Response
 
             """
index 6c71e2cbade79ccc09661d4f002daa9cdf61909a..ba7838c9431976fa8ada962986531d6fdaf08cea 100644 (file)
@@ -107,19 +107,12 @@ class CLITest(unittest.TestCase):
             # Must add newline at the end to match effect of print call
             self.assertEquals(self.fake_stdout.make_string(), output + '\n')
 
-    def _verify_detail_network(self):
+    def _verify_show_network(self):
             # Verification - get raw result from db
             nw = db.network_list(self.tenant_id)[0]
             network = dict(id=nw.uuid, name=nw.name)
-            ports = db.port_list(nw['uuid'])
-            for port in ports:
-                port = db.port_get(port['uuid'], nw['uuid'])
-            network['ports'] = [dict(id=port['uuid'],
-                                     state=port['state'],
-                                     attachment=port['interface_id'])
-                                for port in ports]
             # Fill CLI template
-            output = cli.prepare_output('detail_net', self.tenant_id,
+            output = cli.prepare_output('show_net', self.tenant_id,
                                         dict(network=network))
             # Verify!
             # Must add newline at the end to match effect of print call
@@ -177,7 +170,7 @@ class CLITest(unittest.TestCase):
             # Must add newline at the end to match effect of print call
             self.assertEquals(self.fake_stdout.make_string(), output + '\n')
 
-    def _verify_detail_port(self, network_id, port_id):
+    def _verify_show_port(self, network_id, port_id):
             # Verification - get raw result from db
             # TODO(salvatore-orlando): Must resolve this issue with
             # attachment in separate bug fix.
@@ -185,7 +178,7 @@ class CLITest(unittest.TestCase):
             port_data = {'id': port.uuid, 'state': port.state,
                          'attachment': '<unavailable>'}
             # Fill CLI template
-            output = cli.prepare_output('detail_port', self.tenant_id,
+            output = cli.prepare_output('show_port', self.tenant_id,
                                         dict(network_id=network_id,
                                              port=port_data))
             # Verify!
@@ -196,7 +189,7 @@ class CLITest(unittest.TestCase):
             # Verification - get raw result from db
             port = db.port_get(port_id, network_id)
             # Fill CLI template
-            output = cli.prepare_output("plug_interface", self.tenant_id,
+            output = cli.prepare_output("plug_iface", self.tenant_id,
                                         dict(network_id=network_id,
                                              port_id=port['uuid'],
                                              attachment=port['interface_id']))
@@ -208,7 +201,7 @@ class CLITest(unittest.TestCase):
             # Verification - get raw result from db
             port = db.port_get(port_id, network_id)
             # Fill CLI template
-            output = cli.prepare_output("unplug_interface", self.tenant_id,
+            output = cli.prepare_output("unplug_iface", self.tenant_id,
                                         dict(network_id=network_id,
                                              port_id=port['uuid']))
             # Verify!
@@ -254,22 +247,18 @@ class CLITest(unittest.TestCase):
         LOG.debug(self.fake_stdout.content)
         self._verify_delete_network(network_id)
 
-    def test_detail_network(self):
+    def test_show_network(self):
         try:
             # Load some data into the datbase
             net = db.network_create(self.tenant_id, self.network_name_1)
-            db.port_create(net['uuid'])
-            # Create a 2nd port and plug attachment in it
-            port = db.port_create(net['uuid'])
-            db.port_set_attachment(port['uuid'], net['uuid'], "test_iface_id")
-            cli.detail_net(self.client, self.tenant_id, net['uuid'])
+            cli.show_net(self.client, self.tenant_id, net['uuid'])
         except:
             LOG.exception("Exception caught: %s", sys.exc_info())
             self.fail("test_detail_network failed due to an exception")
 
         LOG.debug("Operation completed. Verifying result")
         LOG.debug(self.fake_stdout.content)
-        self._verify_detail_network()
+        self._verify_show_network()
 
     def test_rename_network(self):
         try:
@@ -351,7 +340,7 @@ class CLITest(unittest.TestCase):
         LOG.debug(self.fake_stdout.content)
         self._verify_set_port_state(network_id, port_id)
 
-    def test_detail_port(self):
+    def test_show_port(self):
         network_id = None
         port_id = None
         try:
@@ -360,14 +349,14 @@ class CLITest(unittest.TestCase):
             network_id = net['uuid']
             port = db.port_create(network_id)
             port_id = port['uuid']
-            cli.detail_port(self.client, self.tenant_id, network_id, port_id)
+            cli.show_port(self.client, self.tenant_id, network_id, port_id)
         except:
             LOG.exception("Exception caught: %s", sys.exc_info())
             self.fail("test_detail_port failed due to an exception")
 
         LOG.debug("Operation completed. Verifying result")
         LOG.debug(self.fake_stdout.content)
-        self._verify_detail_port(network_id, port_id)
+        self._verify_show_port(network_id, port_id)
 
     def test_plug_iface(self):
         network_id = None
index 6a4d430838d690f4df102e41ef56802586bdf24d..baa07210c10b875fa4f83f2e960b9f3fbe0c755e 100644 (file)
@@ -1,7 +1,6 @@
 eventlet>=0.9.12
 Routes>=1.12.3
 Cheetah>=2.0.1
-mox==0.5.3
 nose
 Paste
 PasteDeploy