aboutsummaryrefslogtreecommitdiff
path: root/admin.py
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2014-12-05 16:03:03 +0000
committerSteve McIntyre <steve.mcintyre@linaro.org>2014-12-05 16:03:03 +0000
commit11e4cbd6f0443e53f03e899020f06ba72ce1a898 (patch)
treea8073099f1bc686402e6d05e4f149445ad5177ed /admin.py
parenta132c368a3ffcc08ed3ca97f17efe3ed80baaa9e (diff)
Implement list_switch_ports
For now, simply list port IDs Change-Id: I134f34bedfd63f7171bcfe5f3fea990664eee070
Diffstat (limited to 'admin.py')
-rw-r--r--admin.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/admin.py b/admin.py
index 4b3b513..a9a2444 100644
--- a/admin.py
+++ b/admin.py
@@ -38,6 +38,9 @@ banner = "Linaro VLANd admin interface, version %s" % version
def dump_switch(switch):
print switch
+def dump_port(port):
+ print port
+
#print '%s' % banner
#print 'Connecting to DB...'
@@ -113,7 +116,7 @@ switch_group.add_option("--list_switch_ports",
dest = "list_switch_ports",
action = "store",
type = "int",
- help = "List the ports of an existing switch in the system",
+ help = "List the IDs of the ports on an existing switch in the system",
default = None,
nargs = 1,
metavar = "<switch_id>")
@@ -323,6 +326,16 @@ elif opts.show_switch is not None:
print 'No switch found for switch_id %d' % opts.show_switch
except InputError as inst:
print 'Failed: %s' % inst
+elif opts.list_switch_ports is not None:
+ try:
+ ports = db.get_ports_by_switch(opts.list_switch_ports)
+ if ports is not None:
+ for port in ports:
+ dump_port(port)
+ else:
+ print 'No ports found for switch_id %d' % opts.list_switch_ports
+ except InputError as inst:
+ print 'Failed: %s' % inst
else:
print 'No recognised command given. Try -h for help'