コード例 #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(True)

        if azure_key is None:
            return ok(False)

        try:
            sms = CloudServiceAdapter(azure_key.subscription_id,
                                      azure_key.get_local_pem_url(),
                                      host=azure_key.management_host)
            sms.list_hosted_services()
            azure_key.verified = True
            azure_key.save()
        except Exception as e:

            return ok(False)

        return ok(True)