change pipelib to work with projects
This commit is contained in:
@@ -38,37 +38,37 @@ class VpnCommands(object):
|
|||||||
self.pipe = pipelib.CloudPipe(cloud.CloudController())
|
self.pipe = pipelib.CloudPipe(cloud.CloudController())
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
print "%-12s\t" % 'user',
|
print "%-12s\t" % 'project',
|
||||||
print "%-12s\t" % 'ip:port',
|
print "%-12s\t" % 'ip:port',
|
||||||
print "%s" % 'state'
|
print "%s" % 'state'
|
||||||
for user in self.manager.get_users():
|
for project in self.manager.get_projects():
|
||||||
print "%-12s\t" % user.name,
|
print "%-12s\t" % project.name,
|
||||||
print "%s:%s\t" % (user.vpn_ip, user.vpn_port),
|
print "%s:%s\t" % (project.vpn_ip, project.vpn_port),
|
||||||
|
|
||||||
vpn = self.__vpn_for(user.name)
|
vpn = self.__vpn_for(project.id)
|
||||||
if vpn:
|
if vpn:
|
||||||
print vpn['instance_id'],
|
print vpn['instance_id'],
|
||||||
print vpn['state']
|
print vpn['state']
|
||||||
else:
|
else:
|
||||||
print None
|
print None
|
||||||
|
|
||||||
def __vpn_for(self, username):
|
def __vpn_for(self, project_id):
|
||||||
for instance in self.instdir.all:
|
for instance in self.instdir.all:
|
||||||
if (instance.state.has_key('image_id')
|
if (instance.state.has_key('image_id')
|
||||||
and instance['image_id'] == FLAGS.vpn_image_id
|
and instance['image_id'] == FLAGS.vpn_image_id
|
||||||
and not instance['state'] in ['shutting_down', 'shutdown']
|
and not instance['state'] in ['shutting_down', 'shutdown']
|
||||||
and instance['owner_id'] == username):
|
and instance['project_id'] == project_id):
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
def spawn(self):
|
def spawn(self):
|
||||||
for u in reversed(self.manager.get_users()):
|
for p in reversed(self.manager.get_projects()):
|
||||||
if not self.__vpn_for(u.id):
|
if not self.__vpn_for(p.id):
|
||||||
print 'spawning %s' % u.id
|
print 'spawning %s' % p.id
|
||||||
self.pipe.launch_vpn_instance(u.id)
|
self.pipe.launch_vpn_instance(p.id)
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
def run(self, username):
|
def run(self, project_id):
|
||||||
self.pipe.launch_vpn_instance(username)
|
self.pipe.launch_vpn_instance(project_id)
|
||||||
|
|
||||||
|
|
||||||
class UserCommands(object):
|
class UserCommands(object):
|
||||||
|
|||||||
@@ -474,9 +474,6 @@ class UserManager(object):
|
|||||||
signed_cert = crypto.sign_csr(csr, Project.safe_id(project))
|
signed_cert = crypto.sign_csr(csr, Project.safe_id(project))
|
||||||
return (private_key, signed_cert)
|
return (private_key, signed_cert)
|
||||||
|
|
||||||
def sign_cert(self, csr, uid):
|
|
||||||
return crypto.sign_csr(csr, uid)
|
|
||||||
|
|
||||||
def __cert_subject(self, uid):
|
def __cert_subject(self, uid):
|
||||||
# FIXME(ja) - this should be pulled from a global configuration
|
# FIXME(ja) - this should be pulled from a global configuration
|
||||||
return "/C=US/ST=California/L=Mountain View/O=Anso Labs/OU=Nova Dev/CN=%s-%s" % (uid, str(datetime.datetime.utcnow().isoformat()))
|
return "/C=US/ST=California/L=Mountain View/O=Anso Labs/OU=Nova Dev/CN=%s-%s" % (uid, str(datetime.datetime.utcnow().isoformat()))
|
||||||
|
|||||||
Reference in New Issue
Block a user