Exemplo n.º 1
0
 def setup(self):
     time.sleep(1)
     DockerContainer.setup(self)
     util.shell_call(
         'docker cp XcontainerBolt {0:s}:/home/XcontainerBolt'.format(
             self.name), True)
     BenchmarkContainer.setup(self)
Exemplo n.º 2
0
def setup_containers(args):
    if args.container == 'xcontainer':
        util.shell_call('xl cpupool-numa-split')
    if 'same-container' in args.test:
        m = create_application_container(args, True)
        b = None
    else:
        m = create_application_container(args)
        b = create_benchmark_container(args)

    if args.destroy:
        m.destroy()
        if b is not None:
            b.destroy()
    else:
        m.start()
        m.setup()

        if b is not None:
            b.start()
            b.setup()
    #    b.benchmark()

        if args.container == 'xcontainer':
            balance_xcontainer(b, m, get_benchmark_processor(args.test))
Exemplo n.º 3
0
def setup_linux(args):
  install_linux_dependencies()
  if args.process == "nginx":
    name = NGINX_CONTAINER_NAME
    container_ip = get_linux_container_ip(name)
    container_port = NGINX_CONTAINER_PORT
    machine_port = NGINX_MACHINE_PORT
    if container_ip is None:
      setup_linux_nginx_container()
  elif args.process == "memcached":
    name = MEMCACHED_CONTAINER_NAME
    container_ip = get_linux_container_ip(name)
    container_port = MEMCACHED_CONTAINER_PORT
    machine_port = MEMCACHED_MACHINE_PORT

    if container_ip is None:
      setup_linux_memcached_container()
      util.shell_call("sudo lxc-cgroup -n {0:s} memory.limit_in_bytes 1G".format(name))
  else:
    raise "setup_linux: Not implemented"

  container_ip = get_linux_container_ip(name)
  if args.cores > 1:
    raise Exception("Error need to implement logic for multiple cores")

  util.shell_call("sudo lxc-cgroup -n {0:s} cpuset.cpus {1:d}".format(name, util.processor(0)))
  check_processor(args, name)
  machine_ip = get_ip_address('eno1')
  bridge_ip = get_ip_address('lxcbr0')
  print("machine", machine_ip, machine_port, "container", container_ip, container_port, "bridge", bridge_ip)
  setup_port_forwarding(machine_ip, machine_port, container_ip, container_port, bridge_ip)
  print("To benchmark run 'python docker_setup.py -c linux -p {0:s} -b {1:s}:{2:d}'".format(args.process, machine_ip, machine_port))
Exemplo n.º 4
0
def create_docker_nginx_container(args, docker_filter, is_xcontainer=False):
  configuration_file_path = '/dev/nginx.conf'
  setup_nginx_configuration(configuration_file_path)

  print(NGINX_CONTAINER_NAME, docker_filter)
  address = docker_ip(NGINX_CONTAINER_NAME, docker_filter)
  if args.cores > 1:
    raise "multi-core not implemented"
  cpu = "--cpuset-cpus={0:d}".format(util.processor(0))
  if is_xcontainer:
    cpu = ""
  if address is None:
    command = 'docker run --name {0:s} -P {1:s} -v {2:s}:/etc/nginx/nginx.conf:ro -d nginx'
    print(command)
    util.shell_call(command.format(NGINX_CONTAINER_NAME, cpu, configuration_file_path))
    container_sleep(5)
    address = docker_ip(NGINX_CONTAINER_NAME, docker_filter)
  ports = nginx_docker_port()
  if is_xcontainer:
    machine_ip = get_ip_address('em1')
  else:
    machine_ip = get_ip_address('eno1')
  bridge_ip = get_ip_address('docker0')
  setup_port_forwarding(machine_ip, int(ports[1]), address, int(ports[0]), bridge_ip)
  print("To benchmark run 'python docker_setup.py -c docker -p nginx -b {0:s}:{1:s}'".format(machine_ip, ports[1]))
  return ports
Exemplo n.º 5
0
def setup_xcontainer(args):
  if args.process == "nginx":
    name = NGINX_CONTAINER_NAME
    container_port = NGINX_CONTAINER_PORT
    machine_port = NGINX_MACHINE_PORT
    create_docker_nginx_container(args, XCONTAINER_INSPECT_FILTER, True)
  elif args.process == "memcached":
    name = MEMCACHED_CONTAINER_NAME
    container_port = MEMCACHED_CONTAINER_PORT
    machine_port = MEMCACHED_MACHINE_PORT
    setup_docker_memcached_container(args, XCONTAINER_INSPECT_FILTER, True)
  else:
    raise Exception("setup_xcontainer: not implemented")

  docker_id = util.shell_output('docker inspect --format="{{{{.Id}}}}" {0:s}'.format(name)).strip()
  bridge_ip = get_ip_address('xenbr0')
  xcontainer_ip = generate_xcontainer_ip(bridge_ip)
  util.shell_call('docker stop {0:s}'.format(name))
  machine_ip = get_ip_address('em1')
  util.shell_call('tmux new -s xcontainer -d')
  tmux_command('xcontainer', 'cd /root/experiments/native/compute06/docker')
  tmux_command('xcontainer', 'python run.py --id {0:s} --ip {1:s} --hvm --name {2:s} --cpu={3:d}'.format(docker_id, xcontainer_ip, name, args.cores))
  container_sleep(5)
  setup_port_forwarding(machine_ip, machine_port, xcontainer_ip, container_port, bridge_ip)
  print('Setup {0:s} X-Container on {1:s}:{2:d}'.format(args.process, machine_ip, machine_port))
  util.shell_call('xl vcpu-pin memcached_container 0 {0:d}'.format(util.processor(0)))
  util.shell_call('python /root/x-container/irq-balance.py')
  util.shell_call('python /root/x-container/cpu-balance.py')
Exemplo n.º 6
0
 def setup(self):
     time.sleep(10)
     util.shell_call("service docker restart")
     #util.shell_call('sudo docker stop {0:s}'.format(self.name))  # TODO: Replace
     XContainer.setup(self)
     time.sleep(10)
     BenchmarkContainer.setup(self, False)
     BenchmarkContainer.benchmark(self)
Exemplo n.º 7
0
    def __init__(self, sameContainer=False, metric=None, intensity=None):
        DockerContainer.__init__(self, 'memcached_container', 'memcached')
        util.shell_call('tmux new -s {0:s} -d'.format("benchmark"))
        self.sameContainer = sameContainer

        if sameContainer:
            BenchmarkContainer.__init__(self, metric, intensity, self.name,
                                        'docker', 'memcached', 'default')
Exemplo n.º 8
0
def check_git():
  util.shell_call('git remote update')
  output = util.shell_output("git status --untracked-files=no").strip().split("\n")
  # Clean state should look like
  # On branch master
  # Your branch is up-to-date with 'origin/master'
  # nothing to commit (use -u to show untracked files)
  if len(output) > 3:
    raise Exception("Commit your code before you run this script!")
Exemplo n.º 9
0
 def setup(self):
     util.shell_call('docker stop {0:s}'.format(self.name))
     time.sleep(1)
     self.create_xconfig()
     util.tmux_command(self.tmux_name,
                       'cd /root/experiments/native/compute06/docker')
     util.tmux_command(
         self.tmux_name,
         'python run.py --id {0:s} --ip {1:s} --hvm --name {2:s} --cpu=1'.
         format(DockerContainer.id(self), self.ip(), self.name))
     time.sleep(10)
Exemplo n.º 10
0
    def __init__(self, sameContainer=False, metric=None, intensity=None):
        self.config_file = '/dev/nginx.conf'
        self.docker_tmux_name = 'nginx_docker'
        util.shell_call('tmux new -s {0:s} -d'.format(self.docker_tmux_name))
        util.shell_call('tmux new -s {0:s} -d'.format("benchmark"))
        DockerContainer.__init__(self, 'nginx_container', 'nginx')
        self.sameContainer = sameContainer

        if sameContainer:
            BenchmarkContainer.__init__(self, metric, intensity, self.name,
                                        'docker', 'nginx', 'default')
Exemplo n.º 11
0
 def start(self):
     util.shell_call('lxc-create --name {0:s} -t ubuntu'.format(self.name),
                     True)
     util.shell_call('lxc-start --name {0:s} -d'.format(self.name), True)
     util.shell_call(
         "lxc-cgroup -n {0:s} cpuset.cpus {1:d}".format(
             self.name, self.processor), True)
     util.shell_call(
         "lxc-cgroup -n {0:s} cpuset.mems {1:d}".format(
             self.name, self.mem), True)
     util.shell_call('tmux new -s {0:s} -d'.format(self.tmux_name), True)
     # Need to sleep to let container establish network connection
     time.sleep(5)
Exemplo n.º 12
0
    def start(self):
        v = ''
        if self.config() != '':
            v = '-v {0:s}'.format(self.config())

        p = ''
        if self.ports() != '':
            p = '-p {0:s}'.format(self.ports())

        util.shell_call(
            'docker run -it --entrypoint /bin/bash --name {0:s} {1:s} {2:s} {3:s} -d {4:s} {5:s}'
            .format(self.name, self.cpuset(), v, p, self.application,
                    self.args()), True)
        time.sleep(5)
Exemplo n.º 13
0
def setup_linux_memcached_container():
  start_linux_container(MEMCACHED_CONTAINER_NAME)
  container_sleep(5)
  linux_container_execute_command(MEMCACHED_CONTAINER_NAME, 'sudo apt-get update')
  linux_container_execute_command(MEMCACHED_CONTAINER_NAME, 'sudo apt-get install -y memcached')
  container_ip = get_linux_container_ip(MEMCACHED_CONTAINER_NAME)
  linux_container_execute_command(MEMCACHED_CONTAINER_NAME, '/etc/init.d/memcached stop')
  linux_container_execute_command(MEMCACHED_CONTAINER_NAME, "sudo truncate -s0 /etc/memcached.conf")
  for line in get_memcached_configuration().split("\n"):
    linux_container_execute_command(MEMCACHED_CONTAINER_NAME, "sudo echo '{0:s}' >> /etc/memcached.conf".format(line))
  util.shell_call('tmux new -s linux -d')
  tmux_command('linux', 'sudo lxc-attach -n {0:s}'.format(MEMCACHED_CONTAINER_NAME))
  container_sleep(5)
  tmux_command('linux', 'memcached -m {0:d} -u root -p {1:d} -l {2:s} -t {3:d} &'.format(MEMCACHED_SIZE, MEMCACHED_CONTAINER_PORT, container_ip, MEMCACHED_THREADS))
Exemplo n.º 14
0
def run_nginx_benchmark(args, num_connections, num_threads, duration):
  instance_folder = create_benchmark_folder(args)
  create_readme(args, instance_folder)
  print("Putting NGINX benchmarks in {0:s}".format(instance_folder))

  rates = get_rates(args)
  results = []
  for rate in rates:
    benchmark_file = "{0:s}/r{1:d}-t{2:d}-c{3:d}-d{4:d}".format(instance_folder, rate, num_threads, num_connections, duration)
    util.shell_call('XcontainerBolt/wrk2/wrk -R{0:d} -t{1:d} -c{2:d} -d{3:d}s -L http://{4:s} > {5:s}'
               .format(rate, num_threads, num_connections, duration, args.benchmark_address, benchmark_file), True)
    results.append((rate, parse_nginx_benchmark(benchmark_file)))
    print(results[-1])

  result_files = ["avg_latency", "tail_latency", "throughput"]
  save_benchmark_results(instance_folder, result_files, results)
Exemplo n.º 15
0
 def setup(self):
     LinuxContainer.setup(self)
     LinuxContainer.execute_command(self, 'apt-get install -y memcached')
     util.tmux_command(self.tmux_name,
                       'lxc-attach -n {0:s}'.format(self.name))
     time.sleep(1)
     util.tmux_command(self.tmux_name,
                       Memcached.start_command(self, self.ip()))
     time.sleep(1)
     util.shell_call("lxc-cgroup -n {0:s} cpuset.cpus {1:d}".format(
         self.name, self.processor))
     if self.sameContainer:
         LinuxContainer.copy_folder(self, 'XcontainerBolt')
         self.setup_benchmark()
     ApplicationContainer.setup_port_forwarding(self, self.machine_ip(),
                                                self.port, self.ip(),
                                                self.port, self.bridge_ip())
     ApplicationContainer.benchmark_message(self)
Exemplo n.º 16
0
 def setup(self):
     LinuxContainer.setup(self)
     LinuxContainer.execute_command(self, 'apt-get install -y nginx')
     time.sleep(15)
     LinuxContainer.execute_command(self,
                                    'truncate -s0 /etc/nginx/nginx.conf')
     for line in get_nginx_configuration().split("\n"):
         LinuxContainer.execute_command(
             self, "echo '{0:s}' >> /etc/nginx/nginx.conf".format(line))
     LinuxContainer.execute_command(self, '/etc/init.d/nginx restart')
     util.shell_call("lxc-cgroup -n {0:s} cpuset.cpus {1:d}".format(
         self.name, self.processor))
     if self.sameContainer:
         LinuxContainer.copy_folder(self, 'XcontainerBolt')
         self.setup_benchmark()
     ApplicationContainer.setup_port_forwarding(self, self.machine_ip(),
                                                self.port, self.ip(),
                                                self.port, self.bridge_ip())
     ApplicationContainer.benchmark_message(self)
Exemplo n.º 17
0
def run_memcached_benchmark(args):
  num_connections = get_num_connections(args)

  instance_folder = create_benchmark_folder(args)
  create_readme(args, instance_folder)
  print("Putting Memcached benchmarks in {0:s}".format(instance_folder))

  if not args.dry_run:
    util.shell_call('{0:s}load_memcache -z {1:d} -v {2:d} {3:s}'.format(MUTATED_FOLDER, NUM_MEMCACHED_KEYS, MEMCACHED_VALUE_SIZE, args.benchmark_address))

  rates = get_rates(args)
  results = []
  cores = util.physical_processors(args.cores)

  if not args.dry_run:
    for rate in rates:
      mem_funs = []
      for i in range(args.cores):
        mem_funs.append(functools.partial(memcached_benchmark, results, instance_folder, num_connections, args.benchmark_address, rate, cores[i], args.duration))
      run_parallel_instances(mem_funs)
  parse_memcached_results(args, instance_folder, num_connections, cores)
Exemplo n.º 18
0
 def setup(self):
     NginxDockerContainer.setup_config(self)
     #    if self.sameContainer:
     #      util.shell_call('docker cp XcontainerBolt {0:s}:/home/XcontainerBolt'.format(self.name), True)
     #      NginxDockerContainer.setup_benchmark(self, True)
     util.shell_call("service docker restart")
     XContainer.setup(self)
     NginxDockerContainer.setup_port_forwarding(self, self.machine_ip(),
                                                self.port, self.ip(),
                                                self.port, self.bridge_ip())
     NginxDockerContainer.benchmark_message(self)
     util.tmux_command(
         self.tmux_name,
         "echo 'nameserver 8.8.8.8' | tee /etc/resolv.conf > /dev/null")
     util.tmux_command(self.tmux_name, 'apt-get update')
     time.sleep(20)
     util.tmux_command(self.tmux_name, 'apt-get install -y curl')
     time.sleep(30)
     util.tmux_command(self.tmux_name, "nginx")
     if self.sameContainer:
         BenchmarkContainer.setup(self, False)
         BenchmarkContainer.benchmark(self)
Exemplo n.º 19
0
def setup_docker_memcached_container(args, docker_filter, is_xcontainer=False):
  address = docker_ip(MEMCACHED_CONTAINER_NAME, docker_filter)
  configuration_file_path = '/dev/memcached.conf'
  setup_memcached_configuration(configuration_file_path)

  address = docker_ip(MEMCACHED_CONTAINER_NAME, docker_filter)
  if args.cores > 1 and not is_xcontainer:
    raise "multi-core not implemented"
  cpu = "--cpuset-cpus={0:d}".format(util.processor(0))
  if is_xcontainer:
    cpu = ""

  if address is None:
    # TODO: Way to pass in memcached parameters like memory size
    util.shell_call('docker run --name {0:s} -P {1:s} -p 0.0.0.0:{2:d}:{3:d} -d memcached memcached -m {4:d} -u root -t {5:d}'
                    .format(MEMCACHED_CONTAINER_NAME, cpu, MEMCACHED_MACHINE_PORT, MEMCACHED_CONTAINER_PORT, MEMCACHED_SIZE, MEMCACHED_THREADS)
                   )
    address = docker_ip(MEMCACHED_CONTAINER_NAME, docker_filter)
  else:
    util.shell_call('docker start --name {0:s}'.format(MEMCACHED_CONTAINER_NAME))

  check_processor(args, MEMCACHED_CONTAINER_NAME)
  ports = memcached_docker_port()
  print(ports)
  if is_xcontainer:
    container = "xcontainer"
    machine_ip = get_ip_address('em1')
  else:
    container = "docker"
    machine_ip = get_ip_address('eno1')
  bridge_ip = get_ip_address('docker0')
  setup_port_forwarding(machine_ip, MEMCACHED_MACHINE_PORT, address, int(ports[0]), bridge_ip)

  if not is_xcontainer:
    print("To benchmark run 'python docker_setup.py -c {0:s} -p memcached -b {1:s}:{2:d}'".format(container, machine_ip, MEMCACHED_MACHINE_PORT))
  return ports
Exemplo n.º 20
0
def build(package=None):
    """
    Builds a rpm package

    :param package: str full package name
    """
    rpm_topdir = os.path.expanduser('~') + '/rpmbuild'
    rpm_sources = rpm_topdir + '/SOURCES'

    # get version and build
    version, bld = get_version_and_build()

    # get arch
    arch = shell_call('uname -m').split('\n')[0]

    # install pip
    install_pip()

    try:
        # delete previous build
        shell_call('rm -rf %s' % rpm_sources)

        # create default rpmbuild dir
        try:
            os.makedirs(rpm_sources)
        except:
            pass

        # create a weird setup file, because on _64 machines python will be installed weirdly
        if arch.endswith('_64'):
            """
            [install]
            install-purelib=$base/lib64/python
            """
            shell_call("echo '[install]' > setup.cfg")
            shell_call(
                "echo 'install-purelib=$base/lib64/python' >> setup.cfg")

        # install all dependencies
        install_pip_deps(package=package)

        # remove weird file
        shell_call('rm -rf setup.cfg', important=False)

        # create python package
        shell_call('cp packages/%s/setup.py ./' % package)
        shell_call('python setup.py sdist --formats=gztar')

        # copy gz file to rpmbuild/SOURCES/
        shell_call('cp -r dist/*.gz %s/' % rpm_sources)

        # create rpm package
        shell_call('cp packages/%s/rpm/%s.service %s' %
                   (package, package, rpm_sources))
        shell_call(
            'rpmbuild -D "_topdir %s" -bb packages/%s/rpm/%s.spec --define "amplify_version %s" --define "amplify_release %s"'
            % (rpm_topdir, package, package, version, bld))

        # clean
        shell_call('rm -r dist', important=False)
        shell_call('rm -r *.egg-*', important=False)
        shell_call('rm setup.py', important=False)
    except:
        print(traceback.format_exc())
Exemplo n.º 21
0
def balance_xcontainer(b, m, p):
    util.shell_call('python /root/x-container/irq-balance.py')
    util.shell_call('xl cpupool-migrate {0:s} Pool-node0'.format(m.name))
    util.shell_call('xl vcpu-pin {0:s} 0 {1:d}'.format(m.name, m.processor),
                    True)
    if b is not None:
        if p == 'logical':
            util.shell_call(
                'xl cpupool-migrate {0:s} Pool-node1'.format(b.name), True)
        else:
            util.shell_call(
                'xl cpupool-migrate {0:s} Pool-node0'.format(b.name), True)
        util.shell_call(
            'xl vcpu-pin {0:s} 0 {1:d}'.format(b.name, b.processor), True)
Exemplo n.º 22
0
 def execute_command(self, command):
     util.shell_call(
         'lxc-attach --name {0:s} -- /bin/sh -c "{1:s}"'.format(
             self.name, command), True)
Exemplo n.º 23
0
 def destroy(self):
     util.shell_call('tmux kill-session -t {0:s}'.format(self.tmux_name))
     util.shell_call('lxc-stop --name {0:s}'.format(self.name))
     util.shell_call('lxc-destroy --name {0:s}'.format(self.name))
Exemplo n.º 24
0
def build():
    full_package_name = "nginx-amplify-agent"
    pkg_root = os.path.expanduser('~') + '/agent-pkg-root'
    pkg_final = os.path.expanduser('~') + '/agent-package'

    # get version and build
    version, bld = get_version_and_build()

    # get architecture
    arch = shell_call("dpkg-architecture -c 'echo ${DEB_BUILD_ARCH}'").split('\n')[0]

    # get codename
    shell_call("lsb_release -c")  # checks that lsb_release is installed
    codename = shell_call("lsb_release -c | awk '{print $2}'").split('\n')[0]

    # install pip
    install_pip()

    try:
        # delete previous build
        shell_call('rm -rf %s' % pkg_root)
        shell_call('rm -rf %s && mkdir %s' % (pkg_final, pkg_final))

        # install all dependencies
        install_pip_deps()

        # sed build to control
        shell_call("sed -i 's/^Version: .*$/Version: %s-%s~%s/' packages/deb/DEBIAN/control" % (version, bld, codename))
        shell_call("sed -i 's/^Architecture: .*$/Architecture: %s/' packages/deb/DEBIAN/control" % arch)

        # sed first line of changelog
        changelog_first_line = '%s (%s-%s~%s) unstable; urgency=low' % (full_package_name, version, bld, codename)
        change_first_line('packages/deb/DEBIAN/changelog', changelog_first_line)

        # create python package
        shell_call('python setup.py install --install-layout=deb --prefix=/usr --root=%s' % pkg_root)

        # copy debian files to pkg-root
        shell_call('cp -r packages/deb/DEBIAN %s/' % pkg_root)

        # create deb package
        package_file = '%s_%s-%s~%s_%s.deb' % (full_package_name, version, bld, codename, arch)
        shell_call('fakeroot dpkg --build %s %s/%s' % (pkg_root, pkg_final, package_file))

        # clean
        shell_call('rm -r build', important=False)
        shell_call('rm -r *.egg-*', important=False)
    except:
        print(traceback.format_exc())
Exemplo n.º 25
0
 def setup_port_forwarding(self, machine_ip, machine_port, container_ip,
                           container_port, bridge_ip):
     util.shell_call(
         'iptables -I FORWARD -p tcp -d {0:s} -j ACCEPT'.format(
             container_ip), True)
     time.sleep(1)
     util.shell_call(
         'iptables -I FORWARD -p tcp -s {0:s} -j ACCEPT'.format(
             container_ip), True)
     time.sleep(1)
     util.shell_call(
         'iptables -I INPUT -m state --state NEW -p tcp -m multiport --dport {0:d} -s 0.0.0.0/0 -j ACCEPT'
         .format(machine_port), True)
     time.sleep(1)
     command = 'iptables -t nat -I PREROUTING --dst {0:s} -p tcp --dport {1:d} -j DNAT --to-destination {2:s}:{3:d}'
     util.shell_call(
         command.format(machine_ip, machine_port, container_ip,
                        container_port), True)
     time.sleep(1)
     command = 'iptables -t nat -I POSTROUTING -p tcp --dst {0:s} --dport {1:d} -j SNAT --to-source {2:s}'
     util.shell_call(
         command.format(container_ip, container_port, bridge_ip), True)
     time.sleep(1)
     command = 'iptables -t nat -I OUTPUT --dst {0:s} -p tcp --dport {1:d} -j DNAT --to-destination {2:s}:{3:d}'
     util.shell_call(
         command.format(machine_ip, machine_port, container_ip,
                        container_port), True)
     time.sleep(1)
Exemplo n.º 26
0
 def copy_folder(self, folder):
     util.shell_call(
         'find {0:s} | cpio -o | lxc-attach --name {1:s} -- cpio -i -d -v'.
         format(folder, self.name), True)
     self.execute_command('mv {0:s} home/{0:s}'.format(folder))
Exemplo n.º 27
0
 def start(self):
     util.shell_call('tmux new -s {0:s} -d'.format(self.tmux_name))
Exemplo n.º 28
0
 def destroy(self):
     DockerContainer.destroy(self)
     util.shell_call('tmux kill-session -t {0:s}'.format(
         self.docker_tmux_name))
     util.shell_call('tmux kill-session -t {0:s}'.format("benchmark"))
Exemplo n.º 29
0
def build():
    full_name = "nginx-amplify-agent"
    rpm_sources = os.path.expanduser('~') + '/rpmbuild/SOURCES'

    # get version and build
    version, bld = get_version_and_build()

    # get arch
    arch = shell_call('uname -m').split('\n')[0]

    # install pip
    install_pip()

    try:
        # delete previous build
        shell_call('rm -rf %s' % rpm_sources)

        # create default rpmbuild dir
        try:
            os.makedirs(rpm_sources)
        except:
            pass

        # create a weird setup file
        if arch.endswith('_64'):
            """
            [install]
            install-purelib=$base/lib64/python
            """
            shell_call("echo '[install]' > setup.cfg")
            shell_call("echo 'install-purelib=$base/lib64/python' >> setup.cfg")

        # install all dependencies
        install_pip_deps()

        # remove weird file
        shell_call('rm -rf setup.cfg', important=False)

        # create python package
        shell_call('python setup.py sdist --formats=gztar')

        # copy gz file to rpmbuild/SOURCES/
        shell_call('cp -r dist/*.gz %s/' % rpm_sources)

        # create rpm package
        shell_call(
            'rpmbuild -bb packages/rpm/%s.spec --define "amplify_version %s" --define "amplify_release %s"' % (
                full_name, version, bld
            )
        )

        # clean
        shell_call('rm -r dist', important=False)
        shell_call('rm -r *.egg-*', important=False)
    except:
        print traceback.format_exc()
Exemplo n.º 30
0
 def start(self):
     util.shell_call('tmux new -s {0:s} -d'.format(self.tmux_name), True)
     DockerContainer.start(self)
Exemplo n.º 31
0
def build():
    full_name = "nginx-amplify-agent"
    rpm_topdir = os.path.expanduser('~') + '/rpmbuild'
    rpm_sources = rpm_topdir + '/SOURCES'
    python = '/usr/bin/python2.7'

    # get version and build
    version, bld = get_version_and_build()

    # get arch
    arch = shell_call('uname -m').split('\n')[0]

    # install pip
    install_pip(python=python)

    try:
        # delete previous build
        shell_call('rm -rf %s' % rpm_sources)

        # create default rpmbuild dir
        try:
            os.makedirs(rpm_sources)
        except:
            pass

        # create a weird setup file
        if arch.endswith('_64'):
            """
            [install]
            install-purelib=$base/lib64/python
            """
            shell_call("echo '[install]' > setup.cfg")
            shell_call(
                "echo 'install-purelib=$base/lib64/python' >> setup.cfg")

        # install all dependencies
        install_pip_deps()

        # remove weird file
        shell_call('rm -rf setup.cfg', important=False)

        # provide a new one - to create a package that will work with the strange amazon linux rpm
        shell_call("echo '[install]' > setup.cfg")
        shell_call(
            "echo 'install_lib = /usr/lib/python2.7/dist-packages' >> setup.cfg"
        )

        # create python package
        shell_call('%s setup.py sdist --formats=gztar' % python)

        # copy gz file to rpmbuild/SOURCES/
        shell_call('cp -r dist/*.gz %s/' % rpm_sources)

        # create rpm package
        shell_call(
            'rpmbuild -D "_topdir %s" -bb packages/rpm/%s.spec --define "amplify_version %s" --define "amplify_release %s"'
            % (rpm_topdir, full_name, version, bld))

        # clean
        shell_call('rm -r dist', important=False)
        shell_call('rm -r *.egg-*', important=False)
        shell_call('rm -rf setup.cfg', important=False)
    except:
        print(traceback.format_exc())
Exemplo n.º 32
0
 def destroy(self):
     util.shell_call('tmux kill-session -t {0:s}'.format(self.tmux_name))