1
2 import sys
3
4 import starcluster
5 from starcluster import utils
6 from starcluster.logger import log
7
8 from base import CmdBase
9
10
12 """
13 shell
14
15 Load an interactive IPython shell configured for starcluster development
16
17 The following objects are automatically available at the prompt:
18
19 cfg - starcluster.config.StarClusterConfig instance
20 ec2 - starcluster.awsutils.EasyEC2 instance
21 s3 - starcluster.awsutils.EasyS3 instance
22
23 All starcluster modules are automatically imported in the IPython session
24 along with the boto and paramiko modules
25 """
26 names = ['shell', 'sh']
27
29 local_ns = dict(cfg=self.cfg, ec2=self.ec2, s3=self.s3, cm=self.cm,
30 starcluster=starcluster)
31 modules = [(starcluster.__name__ + '.' + module, module) \
32 for module in starcluster.__all__]
33 modules += [('boto', 'boto'), ('paramiko', 'paramiko'),
34 ('workerpool', 'workerpool'), ('jinja2', 'jinja2')]
35 for fullname, modname in modules:
36 log.info('Importing module %s' % modname)
37 try:
38 __import__(fullname)
39 local_ns[modname] = sys.modules[fullname]
40 except ImportError, e:
41 log.error("Error loading module %s: %s" % (modname, e))
42 utils.ipy_shell(local_ns=local_ns)
43