summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2010-11-06 00:02:36 +0000
committerVishvananda Ishaya <vishvananda@gmail.com>2010-11-06 00:02:36 +0000
commitf127d85d7790585d6e735648dfab13416d79fbde (patch)
tree14a8098004acad9ce916c78528e4d6cfb70e0bd5 /bin
parent671b712a5ad9034fa89761018203cc7c1ea0449b (diff)
Per-project vpns, certificates, and revocation
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nova-manage75
1 files changed, 52 insertions, 23 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 08b3da123..b788ee62d 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -69,6 +69,7 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
from nova import context
+from nova import crypto
from nova import db
from nova import exception
from nova import flags
@@ -93,32 +94,36 @@ class VpnCommands(object):
self.manager = manager.AuthManager()
self.pipe = pipelib.CloudPipe()
- def list(self):
- """Print a listing of the VPNs for all projects."""
+ def list(self, project=None):
+ """Print a listing of the VPN data for one or all projects.
+
+ args: [project=all]"""
print "%-12s\t" % 'project',
print "%-20s\t" % 'ip:port',
+ print "%-20s\t" % 'private_ip',
print "%s" % 'state'
- for project in self.manager.get_projects():
+ if project:
+ projects = [self.manager.get_project(project)]
+ else:
+ projects = self.manager.get_projects()
+ for project in projects:
print "%-12s\t" % project.name,
-
- try:
- s = "%s:%s" % (project.vpn_ip, project.vpn_port)
- except exception.NotFound:
- s = "None"
- print "%-20s\t" % s,
-
+ ipport = "%s:%s" % (project.vpn_ip, project.vpn_port)
+ print "%-20s\t" % ipport,
vpn = self._vpn_for(project.id)
if vpn:
- command = "ping -c1 -w1 %s > /dev/null; echo $?"
- out, _err = utils.execute(command % vpn['private_dns_name'],
- check_exit_code=False)
- if out.strip() == '0':
- net = 'up'
- else:
- net = 'down'
- print vpn['private_dns_name'],
- print vpn['node_name'],
- print vpn['instance_id'],
+ net = 'down'
+ address = None
+ if vpn.get('fixed_ip', None):
+ address = vpn['fixed_ip']['address']
+ command = "ping -c1 -w1 %s > /dev/null; echo $?"
+ out, _err = utils.execute(command % address,
+ check_exit_code=False)
+ if out.strip() == '0':
+ net = 'up'
+ print address,
+ print vpn['host'],
+ print vpn['ec2_id'],
print vpn['state_description'],
print net
@@ -127,11 +132,11 @@ class VpnCommands(object):
def _vpn_for(self, project_id):
"""Get the VPN instance for a project ID."""
- for instance in db.instance_get_all(context.get_admin_context()):
+ ctxt = context.get_admin_context()
+ for instance in db.instance_get_all_by_project(ctxt, project_id):
if (instance['image_id'] == FLAGS.vpn_image_id
and not instance['state_description'] in
- ['shutting_down', 'shutdown']
- and instance['project_id'] == project_id):
+ ['shutting_down', 'shutdown']):
return instance
def spawn(self):
@@ -146,6 +151,22 @@ class VpnCommands(object):
"""Start the VPN for a given project."""
self.pipe.launch_vpn_instance(project_id)
+ def change(self, project_id, ip, port):
+ """Change the ip and port for a vpn.
+
+ args: project, ip, port"""
+ project = self.manager.get_project(project_id)
+ if not project:
+ print 'No project %s' % (project_id)
+ return
+ admin = context.get_admin_context()
+ network_ref = db.project_get_network(admin, project_id)
+ db.network_update(admin,
+ network_ref['id'],
+ {'vpn_public_address': ip,
+ 'vpn_public_port': int(port)})
+
+
class ShellCommands(object):
def bpython(self):
@@ -292,6 +313,14 @@ class UserCommands(object):
is_admin = False
self.manager.modify_user(name, access_key, secret_key, is_admin)
+ def revoke(self, user_id, project_id=None):
+ """revoke certs for a user
+ arguments: user_id [project_id]"""
+ if project_id:
+ crypto.revoke_certs_by_user_and_project(user_id, project_id)
+ else:
+ crypto.revoke_certs_by_user(user_id)
+
class ProjectCommands(object):
"""Class for managing projects."""