Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

bin/nova-manage uses libvirt_type here:

    if (FLAGS.connection_type != 'libvirt' or
       (FLAGS.connection_type == 'libvirt' and
        FLAGS.libvirt_type not in ['kvm', 'qemu'])):
        msg = _('Only KVM and QEmu are supported for now. Sorry!')
        raise exception.Error(msg)

in order for --libvirt_type to be parsed from the command line or the contents of the flagfile, the option has to be registered before it is referenced in the code above

the option is registered in nova/virt/libvirt/


FLAGS = flags.FLAGS FLAGS.add_options(libvirt_opts)

i.e. you need to import nova.virt.libvirt.connection in order for the option to be registered

Rather than import the module into the namespace, we use flags.DECLARE() to do this - all it does is import the module and check that the option has been registered:

def DECLARE(name, module_string, flag_values=FLAGS): if module_string not in sys.modules: __import__(module_string, globals(), locals()) if name not in flag_values: raise UnrecognizedFlag('%s not defined by %s' % (name, module_string))

We don't need to declare options like connection_type because that is registered when we import the nova.flags module