def list_instances(version, acs_access_key_id, private_key, response_format,
                   timestamp, rndguid):
    """
    This method enables the you to retrieve the list of currently active cloud 
    servers.
    """
    
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    return read_api_url(API_METHOD_URLS['list-instances'], url_data)
def describe_instance(version, acs_access_key_id, private_key, response_format,
                      timestamp, rndguid, instanceid):
    """
    This method enables the you to retrieve the details of a specific Cloud 
    Server.
    """
    
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    url_data['instanceid'] = instanceid
    return read_api_url(API_METHOD_URLS['describe-instance'], url_data)
def terminate_instance(version, acs_access_key_id, private_key, response_format,
                      timestamp, rndguid, list_instances):
    """
    This method enables the you to retrieve the details of a specific Cloud 
    Server.
    """
    
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    for index, value in enumerate(list_instances):
        url_data['InstanceId_%s' % (index+1)] = value
        
    return read_api_url(API_METHOD_URLS['terminate-instance'], url_data)
def describe_image(version, acs_access_key_id, private_key, response_format,
                   timestamp, rndguid, imageid=""):
    """
    This method enables the client to retrieve a list of available cloud server 
    images & narrow the listing down optionally by a specific image.
    """
    
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    #add additional params
    if imageid:
        url_data['imageid'] = imageid
    return read_api_url(API_METHOD_URLS['describe-images'], url_data)
def run_instance(version, acs_access_key_id, private_key, response_format,
                 timestamp, rndguid, planname, imageid, server_qty, 
                 servername):
    """
    This method enables you to create new Cloud Servers by specifying a flexible 
    set of configuration parameters.
    """
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    url_data['planname'] = planname
    url_data['imageid'] = imageid
    url_data['server_qty'] = server_qty
    url_data['servername'] = servername
    
    return read_api_url(API_METHOD_URLS['run-instance'], url_data)
示例#6
0
 def __get_auth(self):
     '''Return auth headers. Will use API Keys if present in settings.'''
     if self.api_key:
         # To auth to the WS using an API key, we generate a signature of a nonce and
         # the WS API endpoint.
         nonce = generate_nonce()
         return {
             "api-nonce":
             str(nonce),
             "api-signature":
             generate_signature(self.api_secret, 'GET', '/realtime', nonce,
                                ''),
             "api-key":
             self.api_key
         }
     else:
         return {}
def describe_available_plan(version, acs_access_key_id, private_key, 
                            response_format, timestamp, rndguid, plan_name, 
                            platform):
    
    """
    This method enables the client to retrieve a list of available cloud server 
    plans & narrow the listing down optionally by server platform (windows, 
    linux, etc ) or get information about just one specific plan (e.g. extra 
    small plan XXS)
    """    
    
    signature = generate_signature(timestamp, rndguid, private_key)
    url_data = generate_url_data(version, acs_access_key_id, response_format, 
                                 timestamp, rndguid, signature)
    
    #add additional params
    url_data['plan_name'] = plan_name
    url_data['platform'] = platform
    
    return read_api_url(API_METHOD_URLS['describe-plan'], url_data)
from util import generate_signature, get_seconds_since_epoch, generate_guid, \
    encode_signature


#make a request

#get encoded signature

signature = generate_signature(get_seconds_since_epoch(), 
                                       generate_guid())

encoded_signature = "YTczMmQ4ZjUyZTMxYWMxNGI4MTljNjg2MTE4MmExMzc2MTJkNzBlZDg4NmRmNTI5MDkxYWU1NjNhNDk0MDRjMA==" #encode_signature(signature)

print encoded_signature