(opts, args) = getopts()
chkopts(opts)
self.up_progress(10)
-
+
conn = KaresansuiVirtConnection(readonly=False)
try:
active_networks = conn.list_active_network()
inactive_networks = conn.list_inactive_network()
- if opts.name in active_networks or opts.name in inactive_networks:
- try:
- self.up_progress(10)
- conn.delete_network(opts.name)
- self.up_progress(30)
- except:
- self.logger.error('Failed to delete network. - net=%s' % (opts.name))
- raise
+ if not (opts.name in active_networks or opts.name in inactive_networks):
+ raise KssCommandException('Could not find the specified network. - net=%s' % (opts.name))
+
+ self.up_progress(10)
+ try:
+ conn.delete_network(opts.name)
+ except:
+ raise KssCommandException('Failed to delete network. - net=%s' % (opts.name))
- self.up_progress(20)
- active_networks = conn.list_active_network()
- inactive_networks = conn.list_inactive_network()
- if not opts.name in active_networks and not opts.name in inactive_networks:
- self.logger.info('Deleted network. - net=%s' % (opts.name))
- print >>sys.stderr, _('Deleted network. - net=%s') % (opts.name)
- return True
- else:
- raise KssCommandException('network not found. - net=%s' % (opts.name))
+ self.up_progress(20)
+ active_networks = conn.list_active_network()
+ inactive_networks = conn.list_inactive_network()
+ if opts.name in active_networks or opts.name in inactive_networks:
+ raise KssCommandException('Failed to delete the network. - net=%s' % (opts.name))
+ self.logger.info('Deleted network. - net=%s' % (opts.name))
+ print >>sys.stdout, _('Deleted network. - net=%s') % (opts.name)
return True
finally:
conn.close()