"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,
"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,
_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)
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"]
#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
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))
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
## 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
"""
if status_code in (202, 204):
return data
- #server.networks.Controller._serialization_metadata
return Serializer(self._serialization_metadata).\
deserialize(data, self.content_type())
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
"""
# 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
# 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.
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!
# 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']))
# 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!
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:
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:
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
eventlet>=0.9.12
Routes>=1.12.3
Cheetah>=2.0.1
-mox==0.5.3
nose
Paste
PasteDeploy