예제 #1
0
def Person(region_id, access_key_id, access_secret):
    profile = Profile(region_id, access_key_id, access_secret)
    client = Client(profile)
    request = Personal()
    request.set_method('GET')
    # 调用旧版request.set_old_version()
    # 调用v2新版request.set_v2_version(),默认是新版
    response = client.get_response(request)
    dict = json.loads(response)
    return dict
예제 #2
0
def Describe_Instance(region_id, access_key_id, access_secret):
    profile = Profile(region_id, access_key_id, access_secret)
    client = Client(profile)
    request = DescribeInstances()
    request.set_method('GET')
    # 调用旧版request.set_old_version()
    # 调用v2新版request.set_v2_version(),默认是新版
    response = client.get_response(request)
    dict = json.loads(response)
    Action = request.get_action()
    save_log(dict, Action)
    return dict
예제 #3
0
def Rebuild_Instance(region_id, access_key_id, access_secret,password,id):
    profile = Profile(region_id,access_key_id,access_secret)
    client = Client(profile)
    request = RebuildInstance()
    request.set_method('GET')
    request.set_id(id)
    # 调用旧版request.set_old_version()
    # 调用v2新版request.set_v2_version(),默认是新版
    response = client.get_response(request)
    dict = json.loads(response)
    Action=request.get_action()
    save_log(dict,Action)
    return dict
예제 #4
0
def Change_Instance_Firewall(region_id, access_key_id, access_secret,id,firewall_id):
    profile = Profile(region_id,access_key_id,access_secret)
    client = Client(profile)
    request = ChangeInstanceFirewall()
    request.set_method('GET')
    request.set_id(id)
    request.set_firewall_id(firewall_id)
    # 调用旧版request.set_old_version()
    # 调用v2新版request.set_v2_version(),默认是新版
    response = client.get_response(request)
    dict = json.loads(response)
    Action = request.get_action()
    save_log(dict, Action)
    return dict
예제 #5
0
def Modify_Instance_Attributes(region_id, access_key_id, access_secret, id,
                               name):
    profile = Profile(region_id, access_key_id, access_secret)
    client = Client(profile)
    request = ModifyInstanceAttributes()
    request.set_method('GET')
    request.set_id(id)
    request.set_name(name)
    # 调用旧版request.set_old_version()
    # 调用v2新版request.set_v2_version(),默认是新版
    response = client.get_response(request)
    dict = json.loads(response)
    Action = request.get_action()
    save_log(dict, Action)
    return dict
예제 #6
0
def Instance_Iops_Write_Monitor(region_id, access_key_id, access_secret,start_time,end_time,id):
    profile = Profile(region_id,access_key_id,access_secret)
    client = Client(profile)
    request = InstanceIopsWriteMonitor()
    request.set_id(id)
    request.set_start_time(start_time)
    request.set_end_time(end_time)
    request.set_method('GET')
    # 调用旧版request.set_old_version()
    # 调用v2新版request.set_v2_version(),默认是新版
    response = client.get_response(request)
    dict = json.loads(response)
    Action=request.get_action()
    save_log(dict,Action)
    return dict
예제 #7
0
def Reboot_Instance(region_id, access_key_id, access_secret, id):
    profile = Profile(region_id, access_key_id, access_secret)
    client = Client(profile)
    request = RebootInstance()
    request.set_method('GET')
    request.set_id(id)
    # 调用旧版request.set_old_version()
    # 调用v2新版request.set_v2_version(),默认是新版
    response = client.get_response(request)
    dict = json.loads(response)
    str = json.dumps(dict)

    Action = request.get_action()
    f = open('./action.log', 'w')  # 若是'wb'就表示写二进制文件
    f.write(str, Action)
    f.close()
    return dict
예제 #8
0
def Change_Instance_Interface(region_id, access_key_id, access_secret,
                              instance_id, old_network_id, new_network_id):
    profile = Profile(region_id, access_key_id, access_secret)
    client = Client(profile)
    request = ChangeInstanceInterface()
    request.set_method('GET')
    request.set_id(id)
    request.set_instance_id(instance_id)
    request.set_old_network_id(old_network_id)
    request.set_new_network_id(new_network_id)
    # 调用旧版request.set_old_version()
    # 调用v2新版request.set_v2_version(),默认是新版
    response = client.get_response(request)
    dict = json.loads(response)
    Action = request.get_action()
    save_log(dict, Action)
    return dict
예제 #9
0
def Run_Instance(region_id, access_key_id, access_secret, image_id,
                 instance_series, pay_type, period, instance_type,
                 interface0network_id, volumes0type, volumes0size):
    profile = Profile(region_id, access_key_id, access_secret)
    client = Client(profile)
    request = RunInstance()
    request.set_method('GET')
    request.set_image_id(image_id)
    request.set_instance_series(instance_series)
    request.set_pay_type(pay_type)
    request.set_period(period)
    request.set_instance_type(instance_type)
    request.set_interface0network_id(interface0network_id)
    request.set_volumes0type(volumes0type)
    request.set_volumes0size(volumes0size)
    # 调用旧版request.set_old_version()
    # 调用v2新版request.set_v2_version(),默认是新版
    response = client.get_response(request)
    dict = json.loads(response)
    Action = request.get_action()
    save_log(dict, Action)
    return dict
예제 #10
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from chinac_way_v3.core.profile.profile import Profile
from chinac_way_v3.core.client import Client
from chinac_way_v3.ecs.v10.describe_instances import DescribeInstances

if __name__ == '__main__':
    profile = Profile('region tag', 'your access key', 'your access secret')
    client = Client(profile)
    request = DescribeInstances()
    request.set_method('GET')
    response = client.get_response(request)
    print(response)