Esempio n. 1
0
    def _logging_environment(persistent_environment):
        cmd = r'echo {\"debug\": true} > ' \
              r'/root/bin/node/data/gui_static/app-config.json'

        for worker in chain(persistent_environment['op_worker_nodes'],
                            persistent_environment['oz_worker_nodes']):
            docker_name = worker.split('@')[1]
            docker.exec_(docker_name, cmd)
Esempio n. 2
0
 def fin():
     docker.exec_(container, [
         'btrfs', 'subvolume', 'delete', '/var/lib/ceph/osd/ceph-0/current'
     ])
     docker.exec_(container, [
         'btrfs', 'subvolume', 'delete', '/var/lib/ceph/osd/ceph-0/snap_1'
     ])
     docker.remove([container], force=True, volumes=True)
Esempio n. 3
0
    def _logging_environment(persistent_environment):
        cmd = r'echo {\"debug\": true} > ' \
              r'/root/bin/node/data/gui_static/app-config.json'

        for worker in chain(persistent_environment['op_worker_nodes'],
                            persistent_environment['oz_worker_nodes']):
            docker_name = worker.split('@')[1]
            docker.exec_(docker_name, cmd)
Esempio n. 4
0
 def cleanup(self):
     assert '' == docker.exec_(self.container,
                               swift_server.SWIFT_COMMAND.format(
                                   self.ip, 'delete {0} -q'.format(
                                       self.container_name)).split(),
                               output=True,
                               stdout=sys.stderr)
     assert '' == docker.exec_(self.container,
                               swift_server.SWIFT_COMMAND.format(
                                   self.ip, 'post ' +
                                   self.container_name).split(),
                               output=True,
                               stdout=sys.stderr)
Esempio n. 5
0
def run_cmd(user, client, cmd, detach=False, output=False, error=False):
    """Run command in docker
    :param user: command will be run as given user
    :param client: instance of utils.client_utils.Client class
    :param cmd: command to be run, can be string or list of strings
    :param detach: argument passed to docker.exec_, if true process started in
    docker will be in detached mode
    :param output: argument passed to docker.exec_, if false function will
    return exit code of run command, otherwise its output
    :param error: argument passed to docker.exec_, if true stderr will be
    redirected to stdout
    """
    # convert command into ascii string or list of ascii strings
    if isinstance(cmd, basestring):
        cmd = str(cmd)
    elif isinstance(cmd, list):
        cmd = [str(x) for x in cmd]

    if user != 'root' and isinstance(cmd, str):
        cmd = ['su', '-c', cmd, str(user)]
    elif user != 'root' and isinstance(cmd, list):
        cmd = ["su", "-c"] + cmd + [str(user)]

    return docker.exec_(container=client.docker_name,
                        command=cmd,
                        output=output,
                        tty=True,
                        stderr=subprocess.STDOUT if error else None,
                        detach=detach)
Esempio n. 6
0
    def test_installation(self):
        gr_node = self.result['gr_nodes'][0]
        (_, _, gr_dockername) = gr_node.partition('@')

        command = 'apt-get update && ' \
                  'apt-get install -y python && ' \
                  'python /root/data/deb_install_script.py'

        container = docker.run(tty=True,
                               interactive=True,
                               detach=True,
                               image='ubuntu:vivid',
                               hostname='devel.localhost.local',
                               workdir="/root",
                               run_params=['--privileged=true'],
                               link={gr_dockername: 'onedata.org'},
                               volumes=[(package_dir, '/root/pkg', 'ro'),
                                        (scripts_dir, '/root/data', 'ro')],
                               reflect=[('/sys/fs/cgroup', 'rw')])

        try:
            assert 0 == docker.exec_(container,
                                     command=command,
                                     interactive=True,
                                     tty=True)
        finally:
            docker.remove([container], force=True, volumes=True)
Esempio n. 7
0
 def list(self, file_id):
     res = docker.exec_(self.container,
                        swift_server.SWIFT_COMMAND.format(
                            self.ip, 'list {0} -p {1}'.format(
                                self.container_name, file_id)).split(),
                        output=True, stdout=sys.stderr)
     return res.split()
Esempio n. 8
0
def run_cmd(user, client, cmd, detach=False, output=False, error=False):
    """Run command in docker
    :param user: command will be run as given user
    :param client: instance of utils.client_utils.Client class
    :param cmd: command to be run, can be string or list of strings
    :param detach: argument passed to docker.exec_, if true process started in
    docker will be in detached mode
    :param output: argument passed to docker.exec_, if false function will
    return exit code of run command, otherwise its output
    :param error: argument passed to docker.exec_, if true stderr will be
    redirected to stdout
    """
    # convert command into ascii string or list of ascii strings
    if isinstance(cmd, basestring):
        cmd = str(cmd)
    elif isinstance(cmd, list):
        cmd = [str(x) for x in cmd]

    if user != 'root' and isinstance(cmd, str):
        cmd = ['su', '-c', cmd, str(user)]
    elif user != 'root' and isinstance(cmd, list):
        cmd = ["su", "-c"] + cmd + [str(user)]

    return docker.exec_(container=client.docker_name, command=cmd, output=output,
                        tty=True, stderr=subprocess.STDOUT if error else None,
                        detach=detach)
Esempio n. 9
0
 def list(self, file_id):
     res = docker.exec_(self.container,
                        swift_server.SWIFT_COMMAND.format(
                            self.ip, 'list {0} -p {1}'.format(
                                self.container_name, file_id)).split(),
                        output=True,
                        stdout=sys.stderr)
     return res.split()
Esempio n. 10
0
def test_oneprovider_installation(oneprovider):
    result = docker.exec_(oneprovider.container,
                             interactive=True,
                             tty=True,
                             command='python /root/data/install_oneprovider.py')
    config_file = tests.utils.path_utils.config_file('config.yml')
    tests.packaging.oneprovider_common.reset_oz_domain_in_config(config_file)
    assert 0 == result
Esempio n. 11
0
def onezone(request, setup_command):
    distribution = Distribution(request)

    assert 0 == docker.exec_(distribution.container,
                             interactive=True,
                             tty=True,
                             command=setup_command)

    return distribution
Esempio n. 12
0
def oneclient(request, setup_command):
    distribution = Distribution(request)
    command = setup_command.format(repo=distribution.repo, release=distribution.release)

    assert 0 == docker.exec_(distribution.container,
                             interactive=True,
                             tty=True,
                             command=command)

    return distribution
Esempio n. 13
0
def oneclient(request, setup_command):
    distribution = Distribution(request, privileged=True)
    command = setup_command.format(dist=distribution.name)

    assert 0 == docker.exec_(distribution.container,
                             interactive=True,
                             tty=True,
                             command=command)

    return distribution
Esempio n. 14
0
def oneprovider(request, onezone, setup_command):
    distribution = Distribution(request, link={onezone.domain: 'onedata.org'})
    command = setup_command.format(repo=distribution.repo)
    command = '{command} && ' \
        'yum -y install python-setuptools && ' \
        'easy_install requests'.format(command=command)

    assert 0 == docker.exec_(distribution.container,
                             interactive=True,
                             tty=True,
                             command=command)

    return distribution
Esempio n. 15
0
def oneprovider(request, onezone, setup_command):
    distribution = Distribution(request, link={onezone.domain: 'onedata.org'})
    command = setup_command.format(dist=distribution.name)
    command = '{command} && ' \
        'apt-get install -y python-setuptools && ' \
        'easy_install requests'.format(command=command)

    assert 0 == docker.exec_(distribution.container,
                             interactive=True,
                             tty=True,
                             command=command)

    return distribution
Esempio n. 16
0
def run_cmd(user, client, cmd, output=False):
    # convert command into ascii string or list of ascii strings
    if isinstance(cmd, basestring):
        cmd = str(cmd)
    elif isinstance(cmd, list):
        cmd = [str(x) for x in cmd]

    if user != 'root' and isinstance(cmd, str):
        cmd = 'su -c "' + cmd + '" ' + str(user)
    elif user != 'root' and isinstance(cmd, list):
        cmd = ["su", "-c"] + cmd + [str(user)]

    return docker.exec_(container=client.docker_id,
                        command=cmd,
                        output=output,
                        tty=True)
Esempio n. 17
0
def oneprovider(request, onezone, setup_command):
    onezone_node = onezone.domain
    # onezone_node is in format node.oz.1234.test, resolve domain (oz.1234.test)
    onezone_domain = tests.utils.utils.get_domain(onezone_node)
    # Put the domain in config so the provider knows where to register
    config_file = tests.utils.path_utils.config_file('config.yml')
    tests.packaging.oneprovider_common.update_oz_domain_in_config(
        config_file, onezone_domain)
    # Link provider docker to the OZ node (this way we do not need DNS here).
    # This link will cause connections to 'oz.1234.test' reach 'node.oz.1234.test'
    distribution = Distribution(request, link={onezone_node: onezone_domain})
    command = setup_command.format(repo=distribution.repo,
                                   release=distribution.release)
    command = '{command} && ' \
        'yum -y install python-setuptools scl-utils && ' \
        'easy_install requests'.format(command=command)

    assert 0 == docker.exec_(distribution.container,
                             interactive=True,
                             tty=True,
                             command=command)
    return distribution
Esempio n. 18
0
 def fin():
     docker.exec_(container, ['btrfs', 'subvolume', 'delete',
                              '/var/lib/ceph/osd/ceph-0/current'])
     docker.exec_(container, ['btrfs', 'subvolume', 'delete',
                              '/var/lib/ceph/osd/ceph-0/snap_1'])
     docker.remove([container], force=True, volumes=True)
Esempio n. 19
0
def test_onezone_installation(onezone):
    assert 0 == docker.exec_(onezone.container,
                             interactive=True,
                             tty=True,
                             command='python /root/data/install_onezone.py')
Esempio n. 20
0
 def list(self, file_id):
     cmd = 'list {0} -p {1}'.format(self.container_name, file_id)
     cmd = swift.SWIFT_COMMAND.format(self.ip, cmd).split()
     res = docker.exec_(self.container, cmd, output=True, stdout=sys.stderr)
     return res.split()
Esempio n. 21
0
def test_oneclient_installation(oneclient):
    assert 0 == docker.exec_(oneclient.container,
                             interactive=True,
                             tty=True,
                             command='python /root/data/install_oneclient.py')