Catch exception.NotFound when getting project VPN data.
This commit is contained in:
		| @@ -89,11 +89,16 @@ class VpnCommands(object): | |||||||
|     def list(self): |     def list(self): | ||||||
|         """Print a listing of the VPNs for all projects.""" |         """Print a listing of the VPNs for all projects.""" | ||||||
|         print "%-12s\t" % 'project', |         print "%-12s\t" % 'project', | ||||||
|         print "%-12s\t" % 'ip:port', |         print "%-20s\t" % 'ip:port', | ||||||
|         print "%s" % 'state' |         print "%s" % 'state' | ||||||
|         for project in self.manager.get_projects(): |         for project in self.manager.get_projects(): | ||||||
|             print "%-12s\t" % project.name, |             print "%-12s\t" % project.name, | ||||||
|             print "%s:%s\t" % (project.vpn_ip, project.vpn_port), |  | ||||||
|  |             try: | ||||||
|  |                 s = "%s:%s" % (project.vpn_ip, project.vpn_port) | ||||||
|  |             except exception.NotFound: | ||||||
|  |                 s = "None" | ||||||
|  |             print "%-20s\t" % s, | ||||||
|  |  | ||||||
|             vpn = self._vpn_for(project.id) |             vpn = self._vpn_for(project.id) | ||||||
|             if vpn: |             if vpn: | ||||||
|   | |||||||
| @@ -653,7 +653,10 @@ class AuthManager(object): | |||||||
|         zippy.writestr(FLAGS.credential_key_file, private_key) |         zippy.writestr(FLAGS.credential_key_file, private_key) | ||||||
|         zippy.writestr(FLAGS.credential_cert_file, signed_cert) |         zippy.writestr(FLAGS.credential_cert_file, signed_cert) | ||||||
|  |  | ||||||
|  |         try: | ||||||
|             (vpn_ip, vpn_port) = self.get_project_vpn_data(project) |             (vpn_ip, vpn_port) = self.get_project_vpn_data(project) | ||||||
|  |         except exception.NotFound: | ||||||
|  |             vpn_ip = None | ||||||
|         if vpn_ip: |         if vpn_ip: | ||||||
|             configfile = open(FLAGS.vpn_client_template, "r") |             configfile = open(FLAGS.vpn_client_template, "r") | ||||||
|             s = string.Template(configfile.read()) |             s = string.Template(configfile.read()) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ewan Mellor
					Ewan Mellor