summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorSoren Hansen <soren.hansen@rackspace.com>2010-09-29 11:51:01 +0200
committerSoren Hansen <soren.hansen@rackspace.com>2010-09-29 11:51:01 +0200
commit6a0bf3e048da0f7a0c0daf8e25167452cb86bf73 (patch)
treed51be981ac7e7b96af43091285de5352dcf28f9a /bin
parent687a90d6a7ad947c4a5851b1766a19209bb5e46f (diff)
parent43ce84290964b433fd9d9898772d29bffc385dd8 (diff)
downloadnova-6a0bf3e048da0f7a0c0daf8e25167452cb86bf73.tar.gz
nova-6a0bf3e048da0f7a0c0daf8e25167452cb86bf73.tar.xz
nova-6a0bf3e048da0f7a0c0daf8e25167452cb86bf73.zip
Merge with trunk.
Move network initialisation code into new init_host method on the network manager.
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)