Example #1
0
 def _make_httpclient(self):
     if self.stage_config is None:
         raise RuntimeError("need stage config for communication")
     resolver = Resolver(ServiceRegistryClient(
             time, self.stage_config.service_registry))
     httpclient = requests.Session()
     httpclient.mount('http://', ResolveAdapter(HTTPAdapter(), resolver))
     httpclient.mount('ws://', ResolveAdapter(WebSocketAdapter(), resolver))
     return httpclient
Example #2
0
class _ProxyResolver(object):
    """Class that resolves host names for the proxy."""
    def __init__(self, registry):
        self.resolver = ServiceRegistryResolver(registry)

    def __call__(self, netloc):
        try:
            host, port = netloc.split(':', 1)
        except ValueError:
            host, port = netloc, 80
        host, port = self.resolver.resolve_host_port(host, int(port))
        return '%s:%d' % (host, port)
Example #3
0
class ProxyResolver(object):
    """Class that resolves host names for the proxy."""

    def __init__(self, registry):
        self.resolver = ServiceRegistryResolver(registry)

    def __call__(self, netloc):
        try:
            host, port = netloc.split(':', 1)
        except ValueError:
            host, port = netloc, 80
        host, port = self.resolver.resolve_host_port(host, int(port))
        return '%s:%d' % (host, port)
Example #4
0
def example():
    http = requests.Session()
    resolver = Resolver(make_client())
    http.mount('http://', ResolveAdapter(HTTPAdapter(), resolver))
    http.mount('ws://', ResolveAdapter(WebSocketAdapter(), resolver))

    client = ExecutorClient(http)
    reader = iter(partial(sys.stdin.read, 1), '')

    process = client.run('examples',
                         'ubuntu', {}, ['/bin/bash'],
                         tty=os.isatty(sys.stdin.fileno()))
    with console():
        _thread(process.attach, reader, sys.stdout, replay=True)
        exit_code = process.wait()

    sys.exit(exit_code)
Example #5
0
    def __init__(self, project_dir, stage_config, form_config, auth_config,
                 stage, formation):
        self.project_dir = project_dir
        self.stage_config = stage_config
        self.form_config = form_config
        self.auth_config = auth_config
        self.stage = stage
        self.formation = formation

        self.httpclient = requests.Session()
        self.service_registry = ServiceRegistryClient(
            time, stage_config.service_registry)
        self._resolver = Resolver(self.service_registry)
        self.httpclient.mount('http://',
                              ResolveAdapter(HTTPAdapter(), self._resolver))
        self.httpclient.mount(
            'ws://', ResolveAdapter(WebSocketAdapter(), self._resolver))

        self.scheduler = partial(SchedulerClient, self.httpclient)
        self.executor = partial(ExecutorClient, self.httpclient)
        self.builder = partial(BuilderClient, self.httpclient)
        self.router = partial(RouterClient, self.httpclient)
Example #6
0
 def __init__(self, registry):
     self.resolver = ServiceRegistryResolver(registry)
Example #7
0
 def __init__(self, registry):
     self.resolver = ServiceRegistryResolver(registry)
Example #8
0
 def handle(self, config, options):
     """Handle the command."""
     resolver = Resolver(config.service_registry)
     host, port = resolver.resolve_host_port(options.host, options.port)
     print "%s %d" % (host, port)