Beispiel #1
0
def run_docker_container_daemon(tunnel,
                                container_name,
                                image,
                                docker_run_args=None):
    """Run a Docker container with the given name on the host at tunnel."""
    docker_run_args = docker_run_args or []
    tunnel.remote_cmd(
        ['docker', 'run', '--name', container_name, '--detach=true'] +
        docker_run_args + [image])
Beispiel #2
0
    def upgrade_host(tunnel, role, bootstrap_url):
        # Download the install script for the new DC/OS.
        tunnel.remote_cmd(curl_cmd + ['--remote-name', bootstrap_url + '/dcos_install.sh'])

        # Remove the old DC/OS.
        tunnel.remote_cmd(['sudo', '-i', '/opt/mesosphere/bin/pkgpanda', 'uninstall'])
        tunnel.remote_cmd(['sudo', 'rm', '-rf', '/opt/mesosphere', '/etc/mesosphere'])

        # Install the new DC/OS.
        tunnel.remote_cmd(['sudo', 'bash', 'dcos_install.sh', '-d', role])
Beispiel #3
0
    def upgrade_host(tunnel, role, bootstrap_url):
        # Download the install script for the new DC/OS.
        tunnel.remote_cmd(
            curl_cmd + ['--remote-name', bootstrap_url + '/dcos_install.sh'])

        # Remove the old DC/OS.
        tunnel.remote_cmd(
            ['sudo', '-i', '/opt/mesosphere/bin/pkgpanda', 'uninstall'])
        tunnel.remote_cmd(
            ['sudo', 'rm', '-rf', '/opt/mesosphere', '/etc/mesosphere'])

        # Install the new DC/OS.
        tunnel.remote_cmd(['sudo', 'bash', 'dcos_install.sh', '-d', role])
Beispiel #4
0
    def mesos_metrics_snapshot(self, host):
        """Return a snapshot of the Mesos metrics for host."""
        if host in self.masters:
            port = 5050
        else:
            port = 5051

        with self.ssher.tunnel(host) as tunnel:
            return json.loads(
                tunnel.remote_cmd(
                    curl_cmd +
                    ['{}:{}/metrics/snapshot'.format(host.private_ip, port)]).
                decode('utf-8'))
Beispiel #5
0
    def mesos_metrics_snapshot(self, host):
        """Return a snapshot of the Mesos metrics for host."""
        if host in self.masters:
            port = 5050
        else:
            port = 5051

        with self.ssher.tunnel(host) as tunnel:
            return json.loads(
                tunnel.remote_cmd(
                    curl_cmd + ['{}:{}/metrics/snapshot'.format(host.private_ip, port)]
                ).decode('utf-8')
            )
Beispiel #6
0
 def zk_mode(self, host):
     """Return the mode of the ZooKeeper instance on host."""
     with self.ssher.tunnel(host) as tunnel:
         stat_out = tunnel.remote_cmd([
             'echo', 'stat', '|', '/opt/mesosphere/bin/toybox', 'nc', 'localhost', '2181'
         ])
     for message in (l.strip().split(b':', 2) for l in stat_out.split(b'\n')):
         if message[0] != b'Mode':
             continue
         mode = message[1].strip()
         if mode not in (b'leader', b'follower', b'standalone'):
             raise Exception('Unexpected ZooKeeper mode {} on host {}'.format(mode, host))
         return mode.decode('utf-8')
     raise Exception('ZooKeeper mode not found on host {}'.format(host))
Beispiel #7
0
 def zk_mode(self, host):
     """Return the mode of the ZooKeeper instance on host."""
     with self.ssher.tunnel(host) as tunnel:
         stat_out = tunnel.remote_cmd([
             'echo', 'stat', '|', '/opt/mesosphere/bin/toybox', 'nc',
             'localhost', '2181'
         ])
     for message in (l.strip().split(b':', 2)
                     for l in stat_out.split(b'\n')):
         if message[0] != b'Mode':
             continue
         mode = message[1].strip()
         if mode not in (b'leader', b'follower', b'standalone'):
             raise Exception(
                 'Unexpected ZooKeeper mode {} on host {}'.format(
                     mode, host))
         return mode.decode('utf-8')
     raise Exception('ZooKeeper mode not found on host {}'.format(host))
Beispiel #8
0
 def remote_cmd(self, hosts, cmd):
     with self.tunnels(hosts) as tunnels:
         for tunnel in tunnels:
             tunnel.remote_cmd(cmd)
Beispiel #9
0
 def remote_cmd(self, hosts, cmd):
     with self.tunnels(hosts) as tunnels:
         for tunnel in tunnels:
             tunnel.remote_cmd(cmd)
Beispiel #10
0
def run_docker_container_daemon(tunnel, container_name, image, docker_run_args=None):
    """Run a Docker container with the given name on the host at tunnel."""
    docker_run_args = docker_run_args or []
    tunnel.remote_cmd(
        ['docker', 'run', '--name', container_name, '--detach=true'] + docker_run_args + [image]
    )
Beispiel #11
0
    def upgrade_host(tunnel, role, bootstrap_url, upgrade_script_path):
        # Download the upgrade script for the new DC/OS.
        tunnel.remote_cmd(curl_cmd + ['--remote-name', upgrade_script_path])

        # Upgrade to the new DC/OS.
        tunnel.remote_cmd(['sudo', 'bash', 'dcos_node_upgrade.sh'])