2 # -*- coding: utf-8 -*-
4 # This file is part of Karesansui.
6 # Copyright (C) 2009-2010 HDE, Inc.
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
17 from optparse import OptionParser
19 from ksscommand import KssCommand, KssCommandOptException
25 from karesansui import __version__
26 from karesansui.lib.virt.virt import KaresansuiVirtConnection
27 from karesansui.lib.utils import load_locale
29 print >>sys.stderr, "[Error] karesansui package was not found."
34 usage = '%prog [options]'
37 optp = OptionParser(usage=usage, version=__version__)
38 optp.add_option('-n', '--name', dest='name', help=_('Domain name'))
39 optp.add_option('-m', '--mac', dest='mac', help=_('MAC address'))
40 return optp.parse_args()
44 raise KssCommandOptException('ERROR: %s option is required.' % '-n or --name')
46 KssCommandOptException('ERROR: %s option is required.' % '-m or --mac')
48 class DeleteNIC(KssCommand):
51 (opts, args) = getopts()
55 conn = KaresansuiVirtConnection(readonly=False)
57 conn.set_domain_name(opts.name)
58 conn.guest.delete_interface(opts.mac)
61 self.logger.info('Deleted interface device. - dom=%s mac=%s' % (opts.name,opts.mac))
62 print >>sys.stderr, _('Deleted interface device. - dom=%s mac=%s') % (opts.name, opts.mac)
68 if __name__ == "__main__":
70 sys.exit(target.run())