Example #1
0
    def post(self, url_path, **kwargs):
        try:
            response = yield self.http_client.post(url_path, **kwargs)
        except HTTPError as http_error:
            raise KubernetesException(self.format_error(http_error), http_error.code)

        raise Return(json.loads(response.body))
Example #2
0
    def watch(self, url_path, on_data, **kwargs):
        try:
            return self.http_client.watch(url_path, on_data, **kwargs)
        except HTTPError as http_error:
            message = self.format_error(http_error)

            if http_error.code == 404:
                raise ResourceNotFoundException(message)
            elif http_error.code == 599:
                raise WatchDisconnectedException(message)
            else:
                raise KubernetesException(message, http_error.code)
Example #3
0
    def patch(self, url_path, **kwargs):
        try:
            response = yield self.http_client.patch(url_path, **kwargs)
        except HTTPError as http_error:
            message = self.format_error(http_error)

            if http_error.code == 404:
                raise ResourceNotFoundException(message)
            else:
                raise KubernetesException(message, http_error.code)

        raise Return(json.loads(response.body))
Example #4
0
    def update(self, document):
        logging.info("Updating Setting document with _id: %s", document["_id"])

        saml_config = document[u'authentication'].get('saml', None)
        if saml_config is not None:
            try:
                idp_entity_id, idp_domain, idp_cert, idp_sso = Saml2LoginHandler.get_metadata_info(
                    saml_config.get('metadata', None))
            except Exception as error:
                logging.exception("Error parsing metadata")
                raise KubernetesException(
                    "Invalid SAML IdP metadata file {0}".format(
                        saml_config.get('metadata_file', "")), 400)

            saml_config['idp_entity_id'] = idp_entity_id
            saml_config['idp_domain'] = idp_domain
            saml_config['idp_cert'] = idp_cert
            saml_config['idp_sso'] = idp_sso

        setting = yield Query(self.database, "Settings").update(document)
        raise Return(setting)