Add more DB calls, catch InputError
Change-Id: Ib80daaa1455e38dce82ca6ac476f57f1b28e0ee3
diff --git a/admin.py b/admin.py
index f6c551e..60e2ec0 100644
--- a/admin.py
+++ b/admin.py
@@ -255,14 +255,34 @@
print line
count += 1
print '%d entries' % count
+elif opts.list_all_ports:
+ result = db.all_ports()
+ count = 0;
+ for line in result:
+ print line
+ count += 1
+ print '%d entries' % count
+elif opts.list_all_vlans:
+ result = db.all_vlans()
+ count = 0;
+ for line in result:
+ print line
+ count += 1
+ print '%d entries' % count
elif opts.create_switch is not None:
- switch_id = db.create_switch(opts.create_switch, 'bar', 'baz')
- print 'Created switch_id %d' % switch_id
+ try:
+ switch_id = db.create_switch(opts.create_switch)
+ print 'Created switch_id %d' % switch_id
+ except InputError as inst:
+ print 'Failed: %s' % inst
elif opts.create_port is not None:
- port_id = db.create_port(opts.create_port[0],
- opts.create_port[1],
- default_vlan_id, default_vlan_id)
- print 'Created port_id %d' % port_id
+ try:
+ port_id = db.create_port(opts.create_port[0],
+ opts.create_port[1],
+ default_vlan_id, default_vlan_id)
+ print 'Created port_id %d' % port_id
+ except InputError as inst:
+ print 'Failed: %s' % inst
elif opts.create_vlan is not None:
is_base = False
if opts.create_vlan[2] in ('1', 'y', 'Y'):