当前位置: 首页>>代码示例>>Python>>正文


Python UcloudApiClient.get方法代码示例

本文整理汇总了Python中sdk.UcloudApiClient.get方法的典型用法代码示例。如果您正苦于以下问题:Python UcloudApiClient.get方法的具体用法?Python UcloudApiClient.get怎么用?Python UcloudApiClient.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sdk.UcloudApiClient的用法示例。


在下文中一共展示了UcloudApiClient.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def create(tag=None, name=None, password='dangerous', cpu='1', memory=2, diskSpace=50, imageId="uimage-j4fbrn",
           uhostType='Normal',StorageType='LocalDisk'):
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "CreateUHostInstance",
        "Region": region,
        "Zone":zone,
        "ImageId": imageId,
        "LoginMode": "Password",
        "Password": base64.b64encode(password),
        "Tag": tag,
        "CPU": cpu,
        "Memory": int(memory) * 1024,
        "DiskSpace": int(diskSpace),
        "Name": name,
        "StorageType":StorageType,
        "UHostType": uhostType  # SATA_SSD ,BigData

    }
    response = ApiClient.get("/", Parameters)
    if 0 != response['RetCode']:
        print response
        exit(1)

    for i in range(120):
        time.sleep(1)
        host = get(name)
        if host and 'IPSet' in host and 'IP' in host['IPSet'][0]:  # and 'Running' in host['State']
            print host['IPSet'][0]['IP']
            return host
    raise TypeError("can not get host info")
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:33,代码来源:host_utils.py

示例2: flush_cdn

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def flush_cdn(DomainId,UrlList,Type='dir'):
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "RefreshUcdnDomainCache",
        "Region": region,
        "Zone":zone,
        "ProjectId":project_id,
        "DomainId": DomainId,
        "Type": Type,
        "UrlList.0": UrlList
    }
    response = ApiClient.get("/", Parameters)
    if 0 != response['RetCode']:
        print response
        exit(1)
    print response
    taskId=response['TaskId']
    for i in range(1200):
        status=flush_task_status_cdn(DomainId,taskId)
        print status
        if status=="success":
            return True
        elif status=="failure":
            return False
        time.sleep(1)
    return False
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:28,代码来源:cdn_utils.py

示例3: get_all

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def get_all():
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "DescribeUHostInstance",
        "Region": region,
        "Limit": '100000'
    }
    response = ApiClient.get("/", Parameters);

    print json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:12,代码来源:host_utils.py

示例4: delete

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def delete(ip):
    ip = get(ip)
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "ReleaseEIP",
        "Region": region,
        "EIPId": ip['EIPId']
    }
    response = ApiClient.get("/", Parameters);

    print json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:13,代码来源:ip_utils.py

示例5: get_ulb_list

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def get_ulb_list(region):
    """get one user's ulb list"""
    api_client = UcloudApiClient(config.base_url, config.public_key,
                                 config.private_key)

    params = {};
    params['Action'] = "DescribeULB"
    params['Region'] = "cn-bj1"

    response = api_client.get("/", params)
    pprint(response)
开发者ID:yuexizhaohong,项目名称:python,代码行数:13,代码来源:get_ulb_list.py

示例6: delete

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def delete(ip):
    host = get(ip=ip)
    stop(ip, check=True)
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "TerminateUHostInstance",
        "Region": region,
        "UHostId": host['UHostId']
    }
    response = ApiClient.get("/", Parameters);

    print json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:14,代码来源:host_utils.py

示例7: modify_eip_weight

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def modify_eip_weight(ip,weight=50):
    ip = get(ip)
    print 'start modify_eip_weight {} to weight{} '.format(ip,weight)
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "ModifyEIPWeight",
        "Region": region,
        'Weight':weight,
        "EIPId": ip['EIPId']
    }
    response = ApiClient.get("/", Parameters);

    print json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:15,代码来源:ip_utils.py

示例8: unbing

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def unbing(ip,hostId):
    ip = get(ip)
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "UnBindEIP",
        "Region": region,
        'ResourceType':'uhost',
        'ResourceId':hostId, #TODO
        "EIPId": ip['EIPId']
    }
    response = ApiClient.get("/", Parameters);

    print json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:15,代码来源:ip_utils.py

示例9: stop

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def stop(ip, check=False):
    host = get(ip=ip)
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "StopUHostInstance",
        "Region": region,
        "UHostId": host['UHostId']
    }
    response = ApiClient.get("/", Parameters);
    if check:
        checkStatus(ip, 'Stopped')

    print json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:15,代码来源:host_utils.py

示例10: get_metric

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def get_metric(region, resource_type, resource_id, metric_name,
               timerange=1 * 60 * 60):
    """Get UCloud monitor data
    Region: "cn-east-01"|"cn-north-01"|"cn-south-01"|"hk-01"|"cn-north-02"
                华东       北京bgpa         华南      香港    北京bgpb
    ResourceType: 'uhost'|'udb'|'umem'|'ulb'
    MetricName:
        uhost:
            'NetworkIn'
            'NetworkOut'
            'CPUUtilization'
            'IORead'
            'IOWrite'
            'DiskReadOps'
            'DiskWriteOps'
            'NICIn'
            'NICOut'
            'MemUsage'
            'DataSpaceUsage'
            'RootSpaceUsage'
            'ReadonlyDiskCount'
            'RunnableProcessCount'
            'BlockProcessCount'
        udb:
            'CPUUtilization'
            'MemUsage'
            'QPS'
            'ExpensiveQuery'

        ulb:
            'NetworkOut'
            'CurrentConnections'

        umem:
            'Usage'
            'QPS'
            'InstanceCount'

    """
    api_client = UcloudApiClient(config.base_url, config.public_key,
                                 config.private_key)

    params = {};
    params['Region'] = region
    params['Action'] = 'GetMetric' 
    params['ResourceType'] = resource_type 
    params['ResourceID'] = resource_id 
    params['MetricName'] = metric_name
    params['TimeRange'] = timerange 
    response = api_client.get("/", params)
    pprint(response)
开发者ID:alkaiddiamond,项目名称:python-sdk-v2,代码行数:53,代码来源:get_metric.py

示例11: get

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def get(ip=None,tag=None):
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "DescribeEIP",
        "Region": region,
        "Limit": '100000'
    }
    ips = ApiClient.get("/", Parameters)
    #print ips
    for ip_tmp in ips['EIPSet']:
        if ip and  ip == ip_tmp['EIPAddr'][0]['IP'] :
            return ip_tmp
        if tag and tag == ip_tmp['Tag'] :
            return ip_tmp
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:16,代码来源:ip_utils.py

示例12: ReinstallUHostInstance

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def ReinstallUHostInstance(ip, password='dangerous', imageId='uimage-j4fbrn'):
    host = get(ip=ip)
    poweroff(ip, check=True)
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "ReinstallUHostInstance",
        "Region": region,
        "UHostId": host['UHostId'],
        "Password": base64.b64encode(password),
        "ImageId": imageId
    }
    response = ApiClient.get("/", Parameters);

    print json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:16,代码来源:host_utils.py

示例13: get_metric

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def get_metric(region, resource_type, resource_id, metric_name,
               timerange=1 * 60 * 60):
    """Get UCloud monitor data
    Region: "cn-east-01"|"cn-north-01"|"cn-south-01"|"hk-01"|"cn-north-02"
            East China   Bejing bgpa   South China  Hong Kong   Beijing bgpb
    ResourceType: 'uhost'|'udb'|'umem'|'ulb'
    MetricName:
        uhost:
            'NetworkIn'
            'NetworkOut'
            'CPUUtilization'
            'IORead'
            'IOWrite'
            'DiskReadOps'
            'DiskWriteOps'
            'NICIn'
            'NICOut'
            'MemUsage'
            'DataSpaceUsage'
            'RootSpaceUsage'
            'ReadonlyDiskCount'
            'RunnableProcessCount'
            'BlockProcessCount'
        udb:
            'CPUUtilization'
            'MemUsage'
            'QPS'
            'ExpensiveQuery'

        ulb:
            'NetworkOut'
            'CurrentConnections'

        umem:
            'Usage'
            'QPS'
            'InstanceCount'

    """
    api_client = UcloudApiClient(config.base_url, config.public_key,
                                 config.private_key)

    response = api_client.get("/", Action="GetMetric",
                              Region=region,
                              ResourceType=resource_type,
                              ResourceID=resource_id,
                              MetricName=metric_name,
                              TimeRange=timerange)
    pprint(response)
开发者ID:bragr,项目名称:python-sdk-v2,代码行数:51,代码来源:get_metric.py

示例14: get

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def get(host_name='', ip=''):
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "DescribeUHostInstance",
        "Region": region,
        "Limit": '100000'
    }
    hosts = ApiClient.get("/", Parameters)

    for host in hosts['UHostSet'] :
        if 'Name' in host and 'IPSet' in host and len(host['IPSet'])>0 and 'IP' in host['IPSet'][0]:
            if host_name == host['Name'] or ip == host['IPSet'][0]['IP']:
                return host
        else:
            print "get host Describe err"
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:17,代码来源:host_utils.py

示例15: flush_task_status_cdn

# 需要导入模块: from sdk import UcloudApiClient [as 别名]
# 或者: from sdk.UcloudApiClient import get [as 别名]
def flush_task_status_cdn(DomainId,TaskId):
    ApiClient = UcloudApiClient(base_url, public_key, private_key)
    Parameters = {
        "Action": "DescribeRefreshCacheTask",
        "Region": region,
        "Zone":zone,
        "ProjectId":project_id,
        "DomainId": DomainId,
        "TaskId": TaskId
    }
    response = ApiClient.get("/", Parameters)
    if 0 != response['RetCode']:
        print response
        exit(1)
    return response['TaskSet'][0]['Status']
开发者ID:zgfh,项目名称:ucloud-cli,代码行数:17,代码来源:cdn_utils.py


注:本文中的sdk.UcloudApiClient.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。