Esempio n. 1
0
 def get_driver(self):
     if 'vagrant' in self.config.config:
         return vagrantdriver.VagrantDriver(self)
     elif 'proxmox' in self.config.config:
         return proxmoxdriver.ProxmoxDriver(self)
     elif 'docker' in self.config.config:
         return dockerdriver.DockerDriver(self)
     elif 'openstack' in self.config.config:
         return openstackdriver.OpenstackDriver(self)
     else:
         return None
Esempio n. 2
0
    def _get_driver(self):
        driver = self._get_driver_name()

        if (self.state.driver is not None) and (self.state.driver != driver):
            msg = ("ERROR: Instance(s) were converged with the '{}' driver, "
                   "but the subcommand is using '{}' driver.")
            LOG.error(msg.format(self.state.driver, driver))
            util.sysexit()

        if driver == 'vagrant':
            return vagrantdriver.VagrantDriver(self)
        elif driver == 'docker':
            return dockerdriver.DockerDriver(self)
        elif driver == 'openstack':
            return openstackdriver.OpenstackDriver(self)
        raise basedriver.InvalidDriverSpecified()
Esempio n. 3
0
    def _get_driver(self):
        """
        Return an instance of the driver as returned by `_get_driver_name()`.

        .. todo:: Implement a pluggable solution vs inline imports.
        """
        driver = self._get_driver_name()

        if (self.state.driver is not None) and (self.state.driver != driver):
            msg = ("ERROR: Instance(s) were converged with the '{}' driver, "
                   "but the subcommand is using '{}' driver.")
            LOG.error(msg.format(self.state.driver, driver))
            util.sysexit()

        if driver == 'vagrant':
            from molecule.driver import vagrantdriver
            return vagrantdriver.VagrantDriver(self)
        elif driver == 'docker':
            from molecule.driver import dockerdriver
            return dockerdriver.DockerDriver(self)
        elif driver == 'openstack':
            from molecule.driver import openstackdriver
            return openstackdriver.OpenstackDriver(self)
        raise basedriver.InvalidDriverSpecified()
Esempio n. 4
0
def vagrant_instance(molecule_instance, request):
    return vagrantdriver.VagrantDriver(molecule_instance)