Esempio n. 1
0
def get_periodic_spot_price(image_type,instance_type,regions,zones,filter_type,response_type,job_exec_time,job_period_time,job_start_time,job_stop_time):
    """API function
    image_type $string see help -h 
    instance_type $string see help -h 
    regions @array of strings see help -h 
    zones @array of strings see help -h 
    filter_type $string see help -h 
    response_type $string see help -h 
    job_exec_time integer see help -h
    job_period_time integer see help -h
    job_start_time ISO 9801 DateTime string see help -h
    job_stop_time ISO 9801 DateTime string see help -h
    """
    args = []
    args.append( {"ImageTypes":image_type} )  
    args.append({"InstanceTypes":  instance_type })
    args.append({"Regions": regions})
    args.append({"ZONES": zones })
    other_args={}
    other_args['job_exec_time']=job_exec_time
    other_args['job_period_time']=job_period_time
    other_args['job_start_time']=job_start_time
    other_args['job_stop_time']=job_stop_time
    json_req = json_factory.create_request('periodic_spot_price',filter_type,response_type,other_args,args)
    json_response_data = json.loads(requests.post(URL,data={"jsonMsg":json.dumps(json_req)},cookies=None).text)
    logging.debug(json_req)
    #print(json_response_data)
    return json_response_data['response_data']
Esempio n. 2
0
def _main(argv): 
    """main function
    argv @array of command line arguments
    """
    state = 0
    req_type = ''
    for arg in argv:
        if arg == '-h':
            _show_help()
            sys.exit(0)
        if arg == '-rt':
            state = 1
        else:
            if state == 1:
                req_type = arg
            state = 0
    logging.info("Request Type %s"%req_type)
    if req_type == 'current_spot_price':
        [args,filter_type,response_type]=_generate_args([],argv)
        json_req = json_factory.create_request(req_type,filter_type,response_type,{},args)
        json_response_data = json.loads(requests.post(URL,data={"jsonMsg":json.dumps(json_req)},cookies=None).text)
        logging.debug(json_req)
        print(json_response_data['response_data'])
    elif req_type == 'list_all_spot_price':
        [args,filter_type,response_type]=_generate_args([],argv)
        other_args={}
        other_args['job_exe_time']=int(_get_arg(argv,'-je')[0])
        json_req = json_factory.create_request(req_type,filter_type,response_type,other_args,args)
        json_response_data = json.loads(requests.post(URL,data={"jsonMsg":json.dumps(json_req)},cookies=None).text)
        logging.debug(json_req)
        print(json_response_data)        
    elif req_type == 'periodic_spot_price':
        [args,filter_type,response_type]=_generate_args([],argv)
        other_args={}
        other_args['job_exec_time']=int(_get_arg(argv,'-je')[0])
        other_args['job_period_time']=int(_get_arg(argv,'-jp')[0])
        other_args['job_start_time']=_get_arg(argv,'-jt')[0]
        other_args['job_stop_time']=_get_arg(argv,'-jo')[0]
        json_req = json_factory.create_request(req_type,filter_type,response_type,other_args,args)
        json_response_data = json.loads(requests.post(URL,data={"jsonMsg":json.dumps(json_req)},cookies=None).text)
        logging.debug(json_req)
        print(json_response_data)
        
    pass
Esempio n. 3
0
def get_current_spot_price(image_type,instance_type,regions,zones,filter_type,response_type):
    """API function
    image_type $string see help -h 
    instance_type $string see help -h 
    regions @array of strings see help -h 
    zones @array of strings see help -h 
    filter_type $string see help -h 
    response_type $string see help -h 
    """
    args = []
    args.append( {"ImageTypes":image_type} )  
    args.append({"InstanceTypes":  instance_type })
    args.append({"Regions": regions})
    args.append({"ZONES": zones })
    json_req = json_factory.create_request('current_spot_price',filter_type,response_type,{},args)
    json_response_data = json.loads(requests.post(URL,data={"jsonMsg":json.dumps(json_req)},cookies=None).text)
    logging.debug(json_req)
    #print(json_response_data['response_data'])
    return json_response_data['response_data']