Пример #1
0
    def check_sub_id(self, subscription_id):

        azure_key = AzureKey.objects(subscription_id=subscription_id).first()

        if self.util.is_local():
            if azure_key is not None:
                azure_key.verified = True
                azure_key.save()
            return ok("success")

        if azure_key is None:
            return internal_server_error(
                "No available azure key on the server side.")

        sms = CloudServiceAdapter(azure_key.subscription_id,
                                  azure_key.get_local_pem_url(),
                                  host=azure_key.management_host)
        if sms.ping():
            azure_key.verified = True
            azure_key.save()
        else:
            return bad_request(
                "Subscription id is not valid, check whether subscription id is valid and upload the right cer file to azure"
            )

        return ok("success")
Пример #2
0
 def report_health(self):
     azure_key = AzureKey.objects().first()
     if not azure_key:
         return {
             STATUS: HEALTH_STATUS.WARNING,
             DESCRIPTION: "No Azure key found"
         }
     service = CloudServiceAdapter(azure_key.id)
     if service.ping():
         return {STATUS: HEALTH_STATUS.OK, "type": "Azure Storage"}
     else:
         return {STATUS: HEALTH_STATUS.ERROR}
Пример #3
0
 def report_health(self):
     azure_key = AzureKey.objects().first()
     if not azure_key:
         return {
             STATUS: HEALTH_STATUS.WARNING,
             DESCRIPTION: "No Azure key found"
         }
     service = CloudServiceAdapter(azure_key.id)
     if service.ping():
         return {
             STATUS: HEALTH_STATUS.OK,
             "type": "Azure Storage"
         }
     else:
         return {
             STATUS: HEALTH_STATUS.ERROR
         }
    def check_sub_id(self, subscription_id):

        azure_key = AzureKey.objects(subscription_id=subscription_id).first()

        if self.util.is_local():
            if azure_key is not None:
                azure_key.verified = True
                azure_key.save()
            return ok("success")

        if azure_key is None:
            return internal_server_error("No available azure key on the server side.")

        sms = CloudServiceAdapter(azure_key.subscription_id,
                                  azure_key.get_local_pem_url(),
                                  host=azure_key.management_host)
        if sms.ping():
            azure_key.verified = True
            azure_key.save()
        else:
            return bad_request("Subscription id is not valid, check whether subscription id is valid and upload the right cer file to azure")

        return ok("success")