Mock of how the proxy base class will be used

This commit is contained in:
YuviPanda
2016-11-11 11:57:22 -08:00
committed by Min RK
parent 7b944a3a3f
commit a98bab8b5e
2 changed files with 13 additions and 24 deletions

View File

@@ -171,23 +171,17 @@ class Proxy(Base):
service.name, service.proxy_path, service.server.host, service.name, service.proxy_path, service.server.host,
) )
yield self.api_request(service.proxy_path, yield self.proxy.add_route(
method='POST', service.proxy_path,
body=dict( service.server.host,
target=service.server.host, {'service': service.name}
service=service.name,
),
client=client,
) )
@gen.coroutine @gen.coroutine
def delete_service(self, service, client=None): def delete_service(self, service, client=None):
"""Remove a service's server from the proxy table.""" """Remove a service's server from the proxy table."""
self.log.info("Removing service %s from proxy", service.name) self.log.info("Removing service %s from proxy", service.name)
yield self.api_request(service.proxy_path, yield self.proxy.delete_route(service.proxy_path)
method='DELETE',
client=client,
)
# FIX-ME # FIX-ME
# we need to add a reference to a specific server # we need to add a reference to a specific server
@@ -202,22 +196,18 @@ class Proxy(Base):
raise RuntimeError( raise RuntimeError(
"User %s's spawn is pending, shouldn't be added to the proxy yet!", user.name) "User %s's spawn is pending, shouldn't be added to the proxy yet!", user.name)
yield self.api_request(user.proxy_path, yield self.proxy.add_route(
method='POST', user.proxy_path,
body=dict( user.server.host,
target=user.server.host, {'user': user.name}
user=user.name,
),
client=client,
) )
@gen.coroutine @gen.coroutine
def delete_user(self, user, client=None): def delete_user(self, user, client=None):
"""Remove a user's server from the proxy table.""" """Remove a user's server from the proxy table."""
self.log.info("Removing user %s from proxy", user.name) self.log.info("Removing user %s from proxy", user.name)
yield self.api_request(user.proxy_path, yield self.proxy.delete_route(
method='DELETE', user.proxy_path
client=client,
) )
@gen.coroutine @gen.coroutine
@@ -255,8 +245,7 @@ class Proxy(Base):
@gen.coroutine @gen.coroutine
def get_routes(self, client=None): def get_routes(self, client=None):
"""Fetch the proxy's routes""" """Fetch the proxy's routes"""
resp = yield self.api_request('', client=client) return (yield self.proxy.get_all_routes())
return json.loads(resp.body.decode('utf8', 'replace'))
# FIX-ME # FIX-ME
# we need to add a reference to a specific server # we need to add a reference to a specific server

View File

@@ -23,7 +23,7 @@ class Proxy(LoggingConfigurable):
""" """
pass pass
def fetch_all_routes(self): def get_all_routes(self):
""" """
Fetch and return all the routes associated by JupyterHub from the proxy Fetch and return all the routes associated by JupyterHub from the proxy