Пример #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 is_host_server_locked(self, docker_host):
     # todo which azure key to use?
     azure_key = docker_host.hackathon.azure_keys[0]
     cloudservice = CloudServiceAdapter(azure_key.subscription_id,
                                        azure_key.get_local_pem_url(),
                                        host=azure_key.management_host)
     service_name = docker_host.public_dns.split(".")[0]
     return cloudservice.is_cloud_service_locked(service_name)
Пример #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}
Пример #4
0
 def setUp(self):
     self.service = CloudServiceAdapter(test_conf.subscription_id,
                                        test_conf.pem_url,
                                        host=test_conf.management_host)