~gundlach/nova/servers_api

« back to all changes in this revision

Viewing changes to bin/nova-manage

  • Committer: Cerberus
  • Date: 2010-09-29 02:11:29 UTC
  • mfrom: (295.1.3 trunk)
  • Revision ID: matt.dietz@rackspace.com-20100929021129-v0wxf5yxcb12dllo
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
 
136
136
 
137
137
class ShellCommands(object):
138
 
    def run(self):
139
 
        "Runs a Python interactive interpreter. Tries to use IPython, if it's available."
140
 
        try:
141
 
            import IPython
142
 
            # Explicitly pass an empty list as arguments, because otherwise IPython
143
 
            # would use sys.argv from this script.
144
 
            shell = IPython.Shell.IPShell(argv=[])
145
 
            shell.mainloop()
146
 
        except ImportError:
 
138
    def bpython(self):
 
139
        """Runs a bpython shell.
 
140
 
 
141
        Falls back to Ipython/python shell if unavailable"""
 
142
        self.run('bpython')
 
143
 
 
144
    def ipython(self):
 
145
        """Runs an Ipython shell.
 
146
 
 
147
        Falls back to Python shell if unavailable"""
 
148
        self.run('ipython')
 
149
 
 
150
    def python(self):
 
151
        """Runs a python shell.
 
152
 
 
153
        Falls back to Python shell if unavailable"""
 
154
        self.run('python')
 
155
 
 
156
    def run(self, shell=None):
 
157
        """Runs a Python interactive interpreter.
 
158
 
 
159
        args: [shell=bpython]"""
 
160
        if not shell:
 
161
            shell = 'bpython'
 
162
 
 
163
        if shell == 'bpython':
 
164
            try:
 
165
                import bpython
 
166
                bpython.embed()
 
167
            except ImportError:
 
168
                shell = 'ipython'
 
169
        if shell == 'ipython':
 
170
            try:
 
171
                import IPython
 
172
                # Explicitly pass an empty list as arguments, because otherwise IPython
 
173
                # would use sys.argv from this script.
 
174
                shell = IPython.Shell.IPShell(argv=[])
 
175
                shell.mainloop()
 
176
            except ImportError:
 
177
                shell = 'python'
 
178
 
 
179
        if shell == 'python':
147
180
            import code
148
181
            try: # Try activating rlcompleter, because it's handy.
149
182
                import readline
156
189
                readline.parse_and_bind("tab:complete")
157
190
            code.interact()
158
191
 
 
192
    def script(self, path):
 
193
        """Runs the script from the specifed path with flags set properly.
 
194
        arguments: path"""
 
195
        exec(compile(open(path).read(), path, 'exec'), locals(), globals())
 
196
 
159
197
 
160
198
class RoleCommands(object):
161
199
    """Class for managing roles."""
316
354
        for floating_ip in floating_ips:
317
355
            instance = None
318
356
            if floating_ip['fixed_ip']:
319
 
                instance = floating_ip['fixed_ip']['instance']['str_id']
 
357
                instance = floating_ip['fixed_ip']['instance']['ec2_id']
320
358
            print "%s\t%s\t%s" % (floating_ip['host'],
321
359
                                  floating_ip['address'],
322
360
                                  instance)