diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2010-08-04 18:37:00 -0700 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2010-08-04 18:37:00 -0700 |
| commit | d1709793045de2f77f4a1fb06f63d27cbcf640d1 (patch) | |
| tree | d57bb1e8ee52e5e6986c9f6625f41cca5767834b /nova | |
| parent | cc64a872c685b931bf76e2323986b427cad777c3 (diff) | |
| download | nova-d1709793045de2f77f4a1fb06f63d27cbcf640d1.tar.gz nova-d1709793045de2f77f4a1fb06f63d27cbcf640d1.tar.xz nova-d1709793045de2f77f4a1fb06f63d27cbcf640d1.zip | |
clean up nova-manage. If vpn data isn't set for user it skips it
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/auth/manager.py | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/nova/auth/manager.py b/nova/auth/manager.py index 463cfdf4a..312b569aa 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -58,6 +58,8 @@ flags.DEFINE_string('credentials_template', flags.DEFINE_string('vpn_client_template', utils.abspath('cloudpipe/client.ovpn.template'), 'Template for creating users vpn file') +flags.DEFINE_string('credential_vpn_file', 'nova-vpn.conf', + 'Filename of certificate in credentials zip') flags.DEFINE_string('credential_key_file', 'pk.pem', 'Filename of private key in credentials zip') flags.DEFINE_string('credential_cert_file', 'cert.pem', @@ -663,25 +665,27 @@ class AuthManager(object): rc = self.__generate_rc(user.access, user.secret, pid) private_key, signed_cert = self._generate_x509_cert(user.id, pid) - vpn = Vpn.lookup(pid) - if not vpn: - raise exception.Error("No vpn data allocated for project %s" % - project.name) - configfile = open(FLAGS.vpn_client_template,"r") - s = string.Template(configfile.read()) - configfile.close() - config = s.substitute(keyfile=FLAGS.credential_key_file, - certfile=FLAGS.credential_cert_file, - ip=vpn.ip, - port=vpn.port) - tmpdir = tempfile.mkdtemp() zf = os.path.join(tmpdir, "temp.zip") zippy = zipfile.ZipFile(zf, 'w') zippy.writestr(FLAGS.credential_rc_file, rc) zippy.writestr(FLAGS.credential_key_file, private_key) zippy.writestr(FLAGS.credential_cert_file, signed_cert) - zippy.writestr("nebula-client.conf", config) + + network_data = networkdata.NetworkData.lookup(pid) + if network_data: + configfile = open(FLAGS.vpn_client_template,"r") + s = string.Template(configfile.read()) + configfile.close() + config = s.substitute(keyfile=FLAGS.credential_key_file, + certfile=FLAGS.credential_cert_file, + ip=network_data.ip, + port=network_data.port) + zippy.writestr(FLAGS.credential_vpn_file, config) + else: + logging.warn("No vpn data for project %s" % + pid) + zippy.writestr(FLAGS.ca_file, crypto.fetch_ca(user.id)) zippy.close() with open(zf, 'rb') as f: @@ -690,6 +694,15 @@ class AuthManager(object): shutil.rmtree(tmpdir) return buffer + def get_environment_rc(self, user, project=None): + """Get credential zip for user in project""" + if not isinstance(user, User): + user = self.get_user(user) + if project is None: + project = user.id + pid = Project.safe_id(project) + return self.__generate_rc(user.access, user.secret, pid) + def __generate_rc(self, access, secret, pid): """Generate rc file for user""" rc = open(FLAGS.credentials_template).read() |
