summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMichael Gundlach <michael.gundlach@rackspace.com>2010-09-29 09:39:24 -0400
committerMichael Gundlach <michael.gundlach@rackspace.com>2010-09-29 09:39:24 -0400
commit0f69422a47dfc837297c4853bbcea9da9b7dd809 (patch)
tree59faf12e6036251d60b84e6b91227092e9dea196 /bin
parent05e3e188e03624884ed019fe9cd8f216c9262f98 (diff)
parent43ce84290964b433fd9d9898772d29bffc385dd8 (diff)
downloadnova-0f69422a47dfc837297c4853bbcea9da9b7dd809.tar.gz
nova-0f69422a47dfc837297c4853bbcea9da9b7dd809.tar.xz
nova-0f69422a47dfc837297c4853bbcea9da9b7dd809.zip
Merge from trunk
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nova-manage73
1 files changed, 62 insertions, 11 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index baa1cb4db..7a9a4c3d1 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -135,15 +135,48 @@ class VpnCommands(object):
class ShellCommands(object):
- def run(self):
- "Runs a Python interactive interpreter. Tries to use IPython, if it's available."
- try:
- import IPython
- # Explicitly pass an empty list as arguments, because otherwise IPython
- # would use sys.argv from this script.
- shell = IPython.Shell.IPShell(argv=[])
- shell.mainloop()
- except ImportError:
+ def bpython(self):
+ """Runs a bpython shell.
+
+ Falls back to Ipython/python shell if unavailable"""
+ self.run('bpython')
+
+ def ipython(self):
+ """Runs an Ipython shell.
+
+ Falls back to Python shell if unavailable"""
+ self.run('ipython')
+
+ def python(self):
+ """Runs a python shell.
+
+ Falls back to Python shell if unavailable"""
+ self.run('python')
+
+ def run(self, shell=None):
+ """Runs a Python interactive interpreter.
+
+ args: [shell=bpython]"""
+ if not shell:
+ shell = 'bpython'
+
+ if shell == 'bpython':
+ try:
+ import bpython
+ bpython.embed()
+ except ImportError:
+ shell = 'ipython'
+ if shell == 'ipython':
+ try:
+ import IPython
+ # Explicitly pass an empty list as arguments, because otherwise IPython
+ # would use sys.argv from this script.
+ shell = IPython.Shell.IPShell(argv=[])
+ shell.mainloop()
+ except ImportError:
+ shell = 'python'
+
+ if shell == 'python':
import code
try: # Try activating rlcompleter, because it's handy.
import readline
@@ -156,6 +189,11 @@ class ShellCommands(object):
readline.parse_and_bind("tab:complete")
code.interact()
+ def script(self, path):
+ """Runs the script from the specifed path with flags set properly.
+ arguments: path"""
+ exec(compile(open(path).read(), path, 'exec'), locals(), globals())
+
class RoleCommands(object):
"""Class for managing roles."""
@@ -228,6 +266,19 @@ class UserCommands(object):
for user in self.manager.get_users():
print user.name
+ def modify(self, name, access_key, secret_key, is_admin):
+ """update a users keys & admin flag
+ arguments: accesskey secretkey admin
+ leave any field blank to ignore it, admin should be 'T', 'F', or blank
+ """
+ if not is_admin:
+ is_admin = None
+ elif is_admin.upper()[0] == 'T':
+ is_admin = True
+ else:
+ is_admin = False
+ print "is_admin: %r" % is_admin
+ self.manager.modify_user(name, access_key, secret_key, is_admin)
class ProjectCommands(object):
"""Class for managing projects."""
@@ -253,7 +304,7 @@ class ProjectCommands(object):
def environment(self, project_id, user_id, filename='novarc'):
"""Exports environment variables to an sourcable file
arguments: project_id user_id [filename='novarc]"""
- rc = self.manager.get_environment_rc(project_id, user_id)
+ rc = self.manager.get_environment_rc(user_id, project_id)
with open(filename, 'w') as f:
f.write(rc)
@@ -316,7 +367,7 @@ class FloatingIpCommands(object):
for floating_ip in floating_ips:
instance = None
if floating_ip['fixed_ip']:
- instance = floating_ip['fixed_ip']['instance']['str_id']
+ instance = floating_ip['fixed_ip']['instance']['ec2_id']
print "%s\t%s\t%s" % (floating_ip['host'],
floating_ip['address'],
instance)