Beispiel #1
0
class Udb:
    def __init__(self, region, project_id, public_key, private_key):
        self.region = region
        self.project_id = project_id
        self.client = Client({
            "region": self.region,
            "project_id": self.project_id,
            "public_key": public_key,
            "private_key": private_key
        })

    def get_id(self, offset=0, limit=1, dbid="udbha-eb3sqldt"):
        return self.client.udb().describe_udb_backup({
            "ProjectId": self.project_id,
            "Offset": offset,
            "Limit": limit,
            "DBId": dbid
        })

    def down_url(self, id, dbid="udbha-eb3sqldt", zone="cn-bj2-03"):
        return self.client.udb().describe_udb_instance_backup_url({
            "ProjectId":
            self.project_id,
            "Region":
            self.region,
            "BackupId":
            id,
            "DBId":
            dbid,
            "Zone":
            "cn-bj2-03"
        })
Beispiel #2
0
    def permission_auth(access_id,
                        access_key,
                        region,
                        project_id,
                        offset=1,
                        limit=1):
        """
        请求一台机器做权限测试
        :param access_id:
        :param access_key:
        :param region:
        :param project_id:
        :param offset:
        :param limit:
        :return:
        """

        client = Client({
            "region": region,
            "project_id": project_id,
            "public_key": access_id,
            "private_key": access_key
        })
        response = client.udb().describe_udb_instance({
            "ClassType": "SQL",
            "Offset": offset,
            "Limit": limit
        })
        return response
Beispiel #3
0
 def get_region_udb(self, offset=0, limit=50):
     try:
         client = Client({
             "region": self.region,
             "project_id": self.project_id,
             "public_key": self.access_id,
             "private_key": self.access_key
         })
         response = client.udb().describe_udb_instance({
             "ClassType": "SQL",
             "Offset": offset,
             "Limit": limit
         })
         return response
     except exc.UCloudException as uerr:
         ins_log.read_log('error', '请求Ucloud接口出错:{0}'.format(uerr))
         return False
     except Exception as err:
         ins_log.read_log('error', err)
         return False