def create_node(kwargs):
    '''
    Convenience function to make the rest api call for node creation.
    '''
    if not isinstance(kwargs, dict):
        kwargs = {}

    # Required parameters
    params = {
        'Action': 'CreateInstance',
        'InstanceType': kwargs.get('size_id', ''),
        'RegionId': kwargs.get('region_id', DEFAULT_LOCATION),
        'ImageId': kwargs.get('image_id', ''),
        'SecurityGroupId': kwargs.get('securitygroup_id', ''),
        'InstanceName': kwargs.get('name', ''),
    }

    # Optional parameters'
    optional = [
        'InstanceName', 'InternetChargeType',
        'InternetMaxBandwidthIn', 'InternetMaxBandwidthOut',
        'HostName', 'Password', 'SystemDisk.Category', 'VSwitchId'
        # 'DataDisk.n.Size', 'DataDisk.n.Category', 'DataDisk.n.SnapshotId'
    ]

    for item in optional:
        if item in kwargs:
            params.update({item: kwargs[item]})

    # invoke web call
    result = query(params)
    return result['InstanceId']
def create_node ( kwargs ) : if not isinstance ( kwargs , dict ) : kwargs = { } params = { 'Action' : 'CreateInstance' , 'InstanceType' : kwargs . get ( 'size_id' , '' ) , 'RegionId' : kwargs . get ( 'region_id' , DEFAULT_LOCATION ) , 'ImageId' : kwargs . get ( 'image_id' , '' ) , 'SecurityGroupId' : kwargs . get ( 'securitygroup_id' , '' ) , 'InstanceName' : kwargs . get ( 'name' , '' ) , } optional = [ 'InstanceName' , 'InternetChargeType' , 'InternetMaxBandwidthIn' , 'InternetMaxBandwidthOut' , 'HostName' , 'Password' , 'SystemDisk.Category' , 'VSwitchId' ] for item in optional : if item in kwargs : params . update ( { item : kwargs [ item ] } ) result = query ( params ) return result [ 'InstanceId' ]
Convenience function to make the rest api call for node creation.