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:
- self.up_progress(10)
- conn.stop_network(opts.name)
- self.up_progress(50)
+ if not (opts.name in active_networks or opts.name in inactive_networks):
+ raise KssCommandException('Network not found. - net=%s' % (opts.name))
- if not opts.name in conn.list_active_network():
- self.logger.info('Stopped network. - net=%s' % (opts.name))
- print >>sys.stderr, _('Stopped network. - net=%s') % (opts.name)
+ self.up_progress(10)
+ conn.stop_network(opts.name)
+ self.up_progress(40)
- else:
- raise KssCommandException('Network not found. - net=%s' % (opts.name))
+ if opts.name in conn.list_active_network():
+ raise KssCommandException('Failed to stop network. - net=%s' % (opts.name))
+
+ self.logger.info('Stopped network. - net=%s' % (opts.name))
+ print >>sys.stderr, _('Stopped network. - net=%s') % (opts.name)
return True
finally: