Example #1
0
def container(request, salt_root):
    obj = ContainerFactory(
        config__image=request.config.getini('MINION_IMAGE') or request.config.getini('IMAGE'),
        config__salt_config=None,
        ssh_config={'user': '******', 'password': '******'})
    obj.run('zypper --non-interactive rm salt')  # Remove salt from the image!!
    request.addfinalizer(obj.remove)
    return obj
Example #2
0
def container(request, salt_root):
    obj = ContainerFactory(config__image=request.config.getini('MINION_IMAGE')
                           or request.config.getini('IMAGE'),
                           config__salt_config=None,
                           ssh_config={
                               'user': '******',
                               'password': '******'
                           })
    obj.run('zypper --non-interactive rm salt')  # Remove salt from the image!!
    request.addfinalizer(obj.remove)
    return obj
Example #3
0
def sshdcontainer(request, salt_root):
    fake = Faker()
    obj = ContainerFactory(
        config__name='ssdcontainer_{0}_{1}_{2}'.format(
            fake.word(), fake.word(), os.environ.get('ST_JOB_ID', '')),  # pylint: disable=no-member
        config__image=request.config.getini('MINION_IMAGE')
        or request.config.getini('IMAGE'),
        config__salt_config=None,
        ssh_config={
            'user': '******',
            'password': '******',
            'port': 22
        })
    obj.run('zypper --non-interactive rm salt')  # Remove salt from the image!!

    request.addfinalizer(obj.remove)
    return obj
Example #4
0
def container(request, docker_client):
    obj = ContainerFactory(config__docker_client=docker_client,
                           config__image=request.param,
                           config__salt_config=None,
                           config__volumes=None,
                           config__host_config=None)
    request.addfinalizer(obj.remove)
    return obj
Example #5
0
def container(request):
    fake = Faker()
    obj = ContainerFactory(
        config__name='container_{0}_{1}_{2}'.format(fake.word(), fake.word(), os.environ.get('ST_JOB_ID', '')),  # pylint: disable=no-member
        config__image=request.param,
        config__salt_config=None
    )
    request.addfinalizer(obj.remove)
    return obj
Example #6
0
def client(request):
    obj = ContainerFactory(config__image=request.param,
                           config__salt_config=None,
                           ssh_config={
                               'user': '******',
                               'password': '******'
                           })
    request.addfinalizer(obj.remove)
    return obj
def master_container(request, salt_root, master_container_extras,
                     salt_master_config):
    fake = Faker()
    obj = ContainerFactory(config__name='master_{0}_{1}_{2}'.format(
        fake.word(), fake.word(), os.environ.get('ST_JOB_ID', '')),
                           config__image=request.config.getini('IMAGE'),
                           config__salt_config__tmpdir=salt_root,
                           config__salt_config__conf_type='master',
                           config__salt_config__config=salt_master_config,
                           config__salt_config__post__id='{0}_{1}'.format(
                               fake.word(), fake.word()),
                           **master_container_extras)
    request.addfinalizer(obj.remove)
    return obj
def minion_container(request, salt_root, minion_container_extras,
                     salt_minion_config):
    fake = Faker()
    image = request.config.getini('MINION_IMAGE') or request.config.getini(
        'IMAGE')
    obj = ContainerFactory(
        config__name='minion_{0}_{1}_{2}'.format(
            fake.word(), fake.word(), os.environ.get('ST_JOB_ID', '')),
        config__image=image,
        config__salt_config__tmpdir=salt_root,
        config__salt_config__conf_type='minion',
        config__salt_config__config={'base_config': salt_minion_config},
        **minion_container_extras)
    request.addfinalizer(obj.remove)
    return obj
Example #9
0
def container(request, docker_client, tmpdir_factory):
    obj = ContainerFactory(
        config__docker_client=docker_client,
        config__image=request.config.getini('IMAGE'),
        config__environment={
            'ROOT_MOUNTPOINT': '/salt/src',
            'TOASTER_MOUNTPOINT': '/salt-toaster',
            'SALT_TESTS': '/salt/src/salt-2015.8.7/tests',
            'VERSION': 'sles12sp1',
        },
        config__salt_config=None,
        config__host_config=None
    )
    upload(obj, request.config.rootdir.parts()[-2].strpath, '/salt-toaster', tmpdir_factory)
    request.addfinalizer(obj.remove)
    return obj
Example #10
0
def proxy_server(request, salt_root, docker_client):
    fake = Faker()
    name = u'proxy_server_{0}_{1}'.format(fake.word(), fake.word())  # pylint: disable=no-member
    command = 'python -m tests.scripts.proxy_server {0}'.format(PROXY_PORT)
    obj = ContainerFactory(
        config__image=request.config.getini('IMAGE'),
        config__command=command,
        config__name=name,
        config__salt_config=None,
        config__host_config=docker_client.create_host_config(
            binds={os.getcwd(): {
                       'bind': "/salt-toaster/",
                       'mode': 'rw'
                   }}),
        config__volumes=[os.getcwd()])
    request.addfinalizer(obj.remove)
    return obj
Example #11
0
def container(request, docker_client, tmpdir_factory):
    fake = Faker()
    obj = ContainerFactory(
        config__name='proxy_container_{0}_{1}_{2}'.format(
            fake.word(), fake.word(), os.environ.get('ST_JOB_ID', '')),  # pylint: disable=no-member
        config__docker_client=docker_client,
        config__image=request.config.getini('IMAGE'),
        config__environment={
            'ROOT_MOUNTPOINT': '/salt/src',
            'TOASTER_MOUNTPOINT': '/salt-toaster',
            'SALT_TESTS': '/salt/src/salt-2015.8.7/tests',
            'VERSION': 'sles12sp1',
        },
        config__salt_config=None,
        config__host_config=None)
    upload(obj,
           request.config.rootdir.parts()[-2].strpath, '/salt-toaster',
           tmpdir_factory)
    request.addfinalizer(obj.remove)
    return obj
def setup(request, module_config, salt_root, pillar_root, file_root):
    config = dict(masters=[])
    for item in module_config['masters']:
        config_item = setup_master(request, salt_root, file_root, pillar_root,
                                   item)
        config['masters'].append(config_item)
        item.update(config_item)

    for item in module_config.get('containers', []):
        config_item = dict(id=None, fixture=None)
        container = ContainerFactory(
            config__image=request.config.getini('BASE_IMAGE'),
            config__salt_config__tmpdir=salt_root,
            config__salt_config=None,
            config__volumes=None,
            config__host_config=None)
        config_item['id'] = container['config']['name']
        config_item['fixture'] = container
        request.addfinalizer(container.remove)
        config['containers'].append(config_item)

    return config, module_config
Example #13
0
def sshdcontainer(request, salt_root, docker_client):
    obj = ContainerFactory(config__docker_client=docker_client,
                           config__image=request.config.getini('MINION_IMAGE')
                           or request.config.getini('IMAGE'),
                           config__salt_config=None)

    obj.run('ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -q -N ""')
    obj.run('ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -q -N ""')
    obj.run('ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -q -N ""')
    obj.run('./tests/scripts/chpasswd.sh {}:{}'.format(USER, PASSWORD))
    obj.run('/usr/sbin/sshd -p 2222')
    obj.run('zypper --non-interactive rm salt')  # Remove salt from the image!!

    request.addfinalizer(obj.remove)
    return obj
Example #14
0
def container(request):
    obj = ContainerFactory(config__image=request.param,
                           config__salt_config=None)
    request.addfinalizer(obj.remove)
    return obj