コード例 #1
0
def openstack_molecule_instance(temp_dir, temp_files, state_path_without_data):
    c = temp_files(fixtures=['molecule_openstack_v1_config'])
    m = core.Molecule(config.ConfigV1(configs=c), {})
    m.state = state.State(state_file=state_path_without_data)
    m.main()

    return m
コード例 #2
0
def molecule_instance(temp_dir, temp_files, state_path_without_data):
    c = temp_files(fixtures=['molecule_docker_config'])
    m = core.Molecule({})
    m.config = config.Config(configs=c)
    m.state = state.State(state_file=state_path_without_data)

    return m
コード例 #3
0
    def main(self):
        if not os.path.exists(self.config.config['molecule']['molecule_dir']):
            os.makedirs(self.config.config['molecule']['molecule_dir'])

        self.state = state.State(
            state_file=self.config.config.get('molecule').get('state_file'))

        try:
            self.driver = self._get_driver()
        except basedriver.InvalidDriverSpecified:
            LOG.error("Invalid driver '{}'".format(self._get_driver_name()))
            # TODO(retr0h): Print valid drivers.
            util.sysexit()
        except basedriver.InvalidProviderSpecified:
            LOG.error("Invalid provider '{}'".format(self.args['provider']))
            self.args['provider'] = None
            self.args['platform'] = None
            self.driver = self._get_driver()
            self.print_valid_providers()
            util.sysexit()
        except basedriver.InvalidPlatformSpecified:
            LOG.error("Invalid platform '{}'".format(self.args['platform']))
            self.args['provider'] = None
            self.args['platform'] = None
            self.driver = self._get_driver()
            self.print_valid_platforms()
            util.sysexit()

        self.config.populate_instance_names(self.driver.platform)
        self._add_or_update_vars('group_vars')
        self._add_or_update_vars('host_vars')
コード例 #4
0
def molecule_instance(temp_files, state_path_without_data):
    c = temp_files(fixtures=['molecule_vagrant_config'])
    m = core.Molecule(dict())
    m.config = config.Config(configs=c)
    m.state = state.State(state_file=state_path_without_data)

    return m
コード例 #5
0
ファイル: test_state.py プロジェクト: corserp/corserp
def test_get_data_loads_existing_state_file(temp_dir, molecule_data):
    molecule_directory = pytest.helpers.molecule_directory()
    scenario_directory = os.path.join(molecule_directory, 'default')
    molecule_file = pytest.helpers.get_molecule_file(scenario_directory)
    ephemeral_directory = pytest.helpers.molecule_ephemeral_directory()
    state_file = os.path.join(ephemeral_directory, 'state.yml')

    os.makedirs(ephemeral_directory)

    data = {
        'converged': False,
        'created': True,
        'driver': None,
        'prepared': None,
    }
    util.write_file(state_file, util.safe_dump(data))

    pytest.helpers.write_molecule_file(molecule_file, molecule_data)
    c = config.Config(molecule_file)
    s = state.State(c)

    assert not s.converged
    assert s.created
    assert not s.driver
    assert not s.prepared
コード例 #6
0
def molecule_instance(temp_files, state_path):
    c = temp_files(fixtures=['molecule_openstack_config'])
    m = core.Molecule(dict())
    m.config = config.Config(configs=c)
    m._state = state.State(state_file=state_path)

    return m
コード例 #7
0
ファイル: conftest.py プロジェクト: omadahealth/molecule
def molecule_default_provider_instance(temp_files, state_path_without_data,
                                       molecule_args):
    c = temp_files(fixtures=['molecule_vagrant_config'])
    m = core.Molecule(molecule_args)
    m.config = config.Config(configs=c)
    m.state = state.State(state_file=state_path_without_data)
    m.main()

    return m
コード例 #8
0
def molecule_instance_with_env_expansion(temp_dir, temp_files,
                                         state_path_without_data):
    os.environ['MOLECULE_TEST_01'] = 'vagrant'
    os.environ['MOLECULE_TEST_02'] = 'ubuntu'
    os.environ['MOLECULE_TEST_03'] = 'trusty64'
    os.environ['MOLECULE_TEST_04'] = 'example1'
    os.environ['MOLECULE_TEST_05'] = 'append_platform_to_hostname'
    c = temp_files(fixtures=['molecule_vagrant_v1_config_using_env'])
    m = core.Molecule(config.ConfigV1(configs=c), {})
    m.state = state.State(state_file=state_path_without_data)
    m.main()

    return m
コード例 #9
0
ファイル: test_state.py プロジェクト: yemo-memeda/molecule
def test_get_data_loads_existing_state_file(_instance, molecule_data,
                                            config_instance):
    data = {
        "converged": False,
        "created": True,
        "driver": None,
        "prepared": None
    }
    util.write_file(_instance._state_file, util.safe_dump(data))

    s = state.State(config_instance)

    assert not s.converged
    assert s.created
    assert not s.driver
    assert not s.prepared
コード例 #10
0
    def main(self):
        if not os.path.exists(self.config.config['molecule']['molecule_dir']):
            os.makedirs(self.config.config['molecule']['molecule_dir'])

        self.state = state.State(
            state_file=self.config.config.get('molecule').get('state_file'))

        try:
            self.driver = self._get_driver()
        except basedriver.InvalidDriverSpecified:
            LOG.error("Invalid driver '{}'".format(self._get_driver_name()))
            # TODO(retr0h): Print valid drivers.
            util.sysexit()
        except basedriver.InvalidProviderSpecified:
            LOG.error("Invalid provider '{}'".format(self.args['provider']))
            self.args['provider'] = None
            self.args['platform'] = None
            self.driver = self._get_driver()
            self.print_valid_providers()
            util.sysexit()
        except basedriver.InvalidPlatformSpecified:
            LOG.error("Invalid platform '{}'".format(self.args['platform']))
            self.args['provider'] = None
            self.args['platform'] = None
            self.driver = self._get_driver()
            self.print_valid_platforms()
            util.sysexit()

        # updates instances config with full machine names
        self.config.populate_instance_names(self.driver.platform)

        if self.args.get('debug'):
            util.print_debug(
                'RUNNING CONFIG',
                yaml.dump(self.config.config,
                          default_flow_style=False,
                          indent=2))

        self._add_or_update_vars('group_vars')
        self._add_or_update_vars('host_vars')
コード例 #11
0
ファイル: config.py プロジェクト: yves-vogl/molecule
 def state(self):
     return state.State(self)
コード例 #12
0
ファイル: test_state.py プロジェクト: yemo-memeda/molecule
def _instance(config_instance):
    return state.State(config_instance)
コード例 #13
0
ファイル: test_state.py プロジェクト: robtec/molecule
def state_instance_without_data(state_path_without_data):
    return state.State(state_file=state_path_without_data)
コード例 #14
0
ファイル: test_state.py プロジェクト: rjfellman/molecule
def state_instance(state_path):
    return state.State(state_file=state_path)
コード例 #15
0
ファイル: test_state.py プロジェクト: rjfellman/molecule
def test_get_data_loads_existing_state_file():
    d = os.path.dirname(os.path.abspath(__file__))
    f = os.path.join(d, 'support', 'state.yml')
    s = state.State(state_file=f)

    assert 'test' == s.created