예제 #1
0
 def __init__(self, params, common):
     
     if params == None:
         raise ProgrammingError("expecting params")
     if common == None:
         raise ProgrammingError("expecting common")
         
     self.p = params
     self.c = common
     
     adapter_conf = self.p.get_conf_or_none("libvirt", "vmm")
     
     if not adapter_conf:
         raise InvalidConfig("Missing or invalid 'vmm' configuration in libvirt.conf")
         
     if adapter_conf == "xen3":
         self.adapter = lvrt_adapter_xen3.vmmadapter(params, common)
         self.intakeadapter = lvrt_adapter_xen3.intakeadapter(params, common)
         self.xen3 = True
     elif adapter_conf == "kvm0":
         self.adapter = lvrt_adapter_kvm0.vmmadapter(params, common)
         self.intakeadapter = lvrt_adapter_kvm0.intakeadapter(params, common)
         self.kvm0 = True
     elif adapter_conf == "mock":
         self.adapter = lvrt_adapter_mock.vmmadapter(params, common)
         self.intakeadapter = lvrt_adapter_mock.intakeadapter(params, common)
         self.xen3 = True
     else:
         raise InvalidConfig("Unknown 'vmm' configuration in libvirt conf: '%s'" % adapter_conf)
예제 #2
0
 def __init__(self, params, common):
     
     self.xen3 = False
     self.kvm0 = False
     self.create_flock = False
     self.destroy_method = DESTROY_DESTROY
     
     if params == None:
         raise ProgrammingError("expecting params")
     if common == None:
         raise ProgrammingError("expecting common")
         
     self.p = params
     self.c = common
     
     adapter_conf = self.p.get_conf_or_none("libvirt", "vmm")
     
     if not adapter_conf:
         raise InvalidConfig("Missing or invalid 'vmm' configuration in libvirt.conf")
         
     if adapter_conf == "xen3":
         self.adapter = lvrt_adapter_xen3.vmmadapter(params, common)
         self.intakeadapter = lvrt_adapter_xen3.intakeadapter(params, common)
         self.xen3 = True
         # Because of a race between mount-alter.sh and Xen scripts for
         # accessing loopback devices, we need to flock the same lock as
         # mount-alter.sh
         self.create_flock = True
     elif adapter_conf == "kvm0":
         self.adapter = lvrt_adapter_kvm0.vmmadapter(params, common)
         self.intakeadapter = lvrt_adapter_kvm0.intakeadapter(params, common)
         self.kvm0 = True
     elif adapter_conf == "mock":
         self.adapter = lvrt_adapter_mock.vmmadapter(params, common)
         self.intakeadapter = lvrt_adapter_mock.intakeadapter(params, common)
         self.xen3 = True
     else:
         raise InvalidConfig("Unknown 'vmm' configuration in libvirt conf: '%s'" % adapter_conf)
         
     destroy_method = self.p.get_conf_or_none("libvirt", "destroy_method")
     if destroy_method is None:
         self.c.log.debug("no destroy_method configured, assuming %s" % DESTROY_DESTROY)
     elif destroy_method == DESTROY_DESTROY:
         self.c.log.debug("destroy_method: %s" % DESTROY_DESTROY)
     elif destroy_method == DESTROY_SHUTDOWN:
         self.c.log.debug("destroy_method: %s" % DESTROY_SHUTDOWN)
         self.destroy_method = DESTROY_SHUTDOWN
     else:
         raise InvalidConfig("Unknown 'destroy_method' configuration in libvirt conf: '%s'" % destroy_method)
     
     if self.destroy_method == DESTROY_SHUTDOWN:
         shutdown_grace = self.p.get_conf_or_none("libvirt", "shutdown_grace")
         try:
             self.shutdown_grace = int(shutdown_grace)
             self.c.log.debug("shutdown_grace: %d" % self.shutdown_grace)
         except ValueError:
             raise InvalidConfig("The 'shutdown_grace' configuration in libvirt conf is not an integer: '%s'" % shutdown_grace)
         if self.shutdown_grace < 1:
             raise InvalidConfig("The 'shutdown_grace' configuration in libvirt conf is illegal, must be >= 1: '%s'" % shutdown_grace)
예제 #3
0
 def __init__(self, params, common):
     
     self.xen3 = False
     self.kvm0 = False
     self.create_flock = False
     
     if params == None:
         raise ProgrammingError("expecting params")
     if common == None:
         raise ProgrammingError("expecting common")
         
     self.p = params
     self.c = common
     
     adapter_conf = self.p.get_conf_or_none("libvirt", "vmm")
     
     if not adapter_conf:
         raise InvalidConfig("Missing or invalid 'vmm' configuration in libvirt.conf")
         
     if adapter_conf == "xen3":
         self.adapter = lvrt_adapter_xen3.vmmadapter(params, common)
         self.intakeadapter = lvrt_adapter_xen3.intakeadapter(params, common)
         self.xen3 = True
         # Because of a race between mount-alter.sh and Xen scripts for
         # accessing loopback devices, we need to flock the same lock as
         # mount-alter.sh
         self.create_flock = True
     elif adapter_conf == "kvm0":
         self.adapter = lvrt_adapter_kvm0.vmmadapter(params, common)
         self.intakeadapter = lvrt_adapter_kvm0.intakeadapter(params, common)
         self.kvm0 = True
     elif adapter_conf == "mock":
         self.adapter = lvrt_adapter_mock.vmmadapter(params, common)
         self.intakeadapter = lvrt_adapter_mock.intakeadapter(params, common)
         self.xen3 = True
     else:
         raise InvalidConfig("Unknown 'vmm' configuration in libvirt conf: '%s'" % adapter_conf)
예제 #4
0
    def __init__(self, params, common):

        self.xen3 = False
        self.kvm0 = False
        self.create_flock = False
        self.destroy_method = DESTROY_DESTROY

        if params == None:
            raise ProgrammingError("expecting params")
        if common == None:
            raise ProgrammingError("expecting common")

        self.p = params
        self.c = common

        adapter_conf = self.p.get_conf_or_none("libvirt", "vmm")

        if not adapter_conf:
            raise InvalidConfig(
                "Missing or invalid 'vmm' configuration in libvirt.conf")

        if adapter_conf == "xen3":
            self.adapter = lvrt_adapter_xen3.vmmadapter(params, common)
            self.intakeadapter = lvrt_adapter_xen3.intakeadapter(
                params, common)
            self.xen3 = True
            # Because of a race between mount-alter.sh and Xen scripts for
            # accessing loopback devices, we need to flock the same lock as
            # mount-alter.sh
            self.create_flock = True
        elif adapter_conf == "kvm0":
            self.adapter = lvrt_adapter_kvm0.vmmadapter(params, common)
            self.intakeadapter = lvrt_adapter_kvm0.intakeadapter(
                params, common)
            self.kvm0 = True
        elif adapter_conf == "mock":
            self.adapter = lvrt_adapter_mock.vmmadapter(params, common)
            self.intakeadapter = lvrt_adapter_mock.intakeadapter(
                params, common)
            self.xen3 = True
        else:
            raise InvalidConfig(
                "Unknown 'vmm' configuration in libvirt conf: '%s'" %
                adapter_conf)

        destroy_method = self.p.get_conf_or_none("libvirt", "destroy_method")
        if destroy_method is None:
            self.c.log.debug("no destroy_method configured, assuming %s" %
                             DESTROY_DESTROY)
        elif destroy_method == DESTROY_DESTROY:
            self.c.log.debug("destroy_method: %s" % DESTROY_DESTROY)
        elif destroy_method == DESTROY_SHUTDOWN:
            self.c.log.debug("destroy_method: %s" % DESTROY_SHUTDOWN)
            self.destroy_method = DESTROY_SHUTDOWN
        else:
            raise InvalidConfig(
                "Unknown 'destroy_method' configuration in libvirt conf: '%s'"
                % destroy_method)

        if self.destroy_method == DESTROY_SHUTDOWN:
            shutdown_grace = self.p.get_conf_or_none("libvirt",
                                                     "shutdown_grace")
            try:
                self.shutdown_grace = int(shutdown_grace)
                self.c.log.debug("shutdown_grace: %d" % self.shutdown_grace)
            except ValueError:
                raise InvalidConfig(
                    "The 'shutdown_grace' configuration in libvirt conf is not an integer: '%s'"
                    % shutdown_grace)
            if self.shutdown_grace < 1:
                raise InvalidConfig(
                    "The 'shutdown_grace' configuration in libvirt conf is illegal, must be >= 1: '%s'"
                    % shutdown_grace)