Tidy up API.

pull/35/head
David Wilson 7 years ago
parent 4969d7ba61
commit f9df857a57

@ -78,22 +78,19 @@ to your network topology**.
.. code::
bastion_host = router.connect(
econtext.ssh.Stream,
bastion_host = router.ssh(
hostname='jump-box.mycorp.com'
)
ssh_account = router.proxy_connect(
bastion_host,
econtext.sudo.Stream,
ssh_account = router.sudo(
username='user_with_magic_ssh_key',
password='sudo password',
via=bastion_host,
)
internal_box = router.proxy_connect(
ssh_account,
econtext.ssh.Stream,
internal_box = router.ssh(
hostname='billing0.internal.mycorp.com'
via=ssh_account,
)
internal_box.call(os.system, './run-nightly-billing.py')

@ -450,7 +450,19 @@ class Router(econtext.core.Router):
self.register(context, stream)
return context
def sudo(self, **kwargs):
import econtext.sudo
return self.connect(econtext.sudo.Stream, **kwargs)
def ssh(self, **kwargs):
import econtext.ssh
return self.connect(econtext.ssh.Stream, **kwargs)
def connect(self, klass, name=None, **kwargs):
via = kwargs.pop('via', None)
if via is not None:
return self.proxy_connect(via, klass, name=name, **kwargs)
context_id = self.alloc_slave_id()
return self._connect(context_id, klass, name=name, **kwargs)

Loading…
Cancel
Save