Add Juju Public Key
[osm/N2VC.git] / modules / libjuju / juju / errors.py
index ecd1c0d..da11cdb 100644 (file)
@@ -25,3 +25,25 @@ class JujuAPIError(JujuError):
 
 class JujuConnectionError(ConnectionError, JujuError):
     pass
+
+
+class JujuAuthError(JujuConnectionError):
+    pass
+
+
+class JujuRedirectException(Exception):
+    """Exception indicating that a redirection was requested"""
+    def __init__(self, redirect_info):
+        self.redirect_info = redirect_info
+
+    @property
+    def ca_cert(self):
+        return self.redirect_info['ca-cert']
+
+    @property
+    def endpoints(self):
+        return [
+            ('{value}:{port}'.format(**s), self.ca_cert)
+            for servers in self.redirect_info['servers']
+            for s in servers if s['scope'] == 'public'
+        ]