Commit f51f1b48 authored by Marco Mariani's avatar Marco Mariani

console: ipython support

parent 845e7fb6
...@@ -46,6 +46,7 @@ setup(name=name, ...@@ -46,6 +46,7 @@ setup(name=name,
'zc.buildout', 'zc.buildout',
'cliff', 'cliff',
'requests', 'requests',
'ipython',
] + additional_install_requires, ] + additional_install_requires,
extra_requires={'docs': ( extra_requires={'docs': (
'Sphinx', 'Sphinx',
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import textwrap
from slapos.cli.config import ClientConfigCommand from slapos.cli.config import ClientConfigCommand
from slapos.client import init, do_console, ClientConfig from slapos.client import init, do_console, ClientConfig
...@@ -38,4 +40,27 @@ class ConsoleCommand(ClientConfigCommand): ...@@ -38,4 +40,27 @@ class ConsoleCommand(ClientConfigCommand):
configp = self.fetch_config(args) configp = self.fetch_config(args)
conf = ClientConfig(args, configp) conf = ClientConfig(args, configp)
local = init(conf) local = init(conf)
try:
import IPython
do_ipython_console(local)
except ImportError:
do_console(local) do_console(local)
def do_ipython_console(local):
from IPython import embed
embed(banner1=textwrap.dedent("""\
slapos console allows you interact with slap API. You can play with the global
"slap" object and with the global request() and supply() methods.
examples :
>>> # Request instance
>>> request(kvm, "myuniquekvm")
>>> # Request software installation on owned computer
>>> supply(kvm, "mycomputer")
>>> # Fetch instance informations on already launched instance
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")
"""),
#exit_msg='BYE.',
user_ns=local)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment