(redata, jdata, logger)
Perform actual call
Perform actual call
Perform actual call
def call_linode(redata, jdata, logger):
    ''' Perform actual call '''
    url = 'https://api.linode.com/'
    if int(redata['data']['upper_limit']) > get_current_linodes(redata):
        params = {
            "api_action": "linode.create",
            "DatacenterID": int(redata['data']['datacenter_id']),
            "PlanID": int(redata['data']['plan_id']),
            "api_key": str(redata['data']['api_key'])
        }
        try:
            req = requests.post(url, timeout=10.0, data=params, verify=True)
        except Exception as e:
            line = 'linode-create: Request to {0} sent for monitor {1} - \
                False (error making API call: {2})'.format(url, jdata['cid'], e)
            logger.info(line)
            return False
        if req.status_code >= 200 and req.status_code < 300:
            if len(req.json()['ERRORARRAY']) > 0:
                line = 'linode-create: Request to {0} sent for monitor {1} - \
                    False'.format(url, jdata['cid'])
                logger.info(line)
                return False
            else:
                line = 'linode-create: Request to {0} sent for monitor {1} - \
                    Successful'.format(url, jdata['cid'])
                logger.info(line)
            return True
    else:
        line = 'linode-create: Request to {0} sent for monitor {1} - \
            Skipped (upper_limit < current linodes)'.format(url, jdata['cid'])
        logger.info(line)
        return None
def call_linode ( redata , jdata , logger ) : url = 'https://api.linode.com/' if int ( redata [ 'data' ] [ 'upper_limit' ] ) > get_current_linodes ( redata ) : params = { "api_action" : "linode.create" , "DatacenterID" : int ( redata [ 'data' ] [ 'datacenter_id' ] ) , "PlanID" : int ( redata [ 'data' ] [ 'plan_id' ] ) , "api_key" : str ( redata [ 'data' ] [ 'api_key' ] ) } try : req = requests . post ( url , timeout = 10.0 , data = params , verify = True ) except Exception as e : line = 'linode-create: Request to {0} sent for monitor {1} - \
                False (error making API call: {2})' . format ( url , jdata [ 'cid' ] , e ) logger . info ( line ) return False if req . status_code >= 200 and req . status_code < 300 : if len ( req . json ( ) [ 'ERRORARRAY' ] ) > 0 : line = 'linode-create: Request to {0} sent for monitor {1} - \
                    False' . format ( url , jdata [ 'cid' ] ) logger . info ( line ) return False else : line = 'linode-create: Request to {0} sent for monitor {1} - \
                    Successful' . format ( url , jdata [ 'cid' ] ) logger . info ( line ) return True else : line = 'linode-create: Request to {0} sent for monitor {1} - \
            Skipped (upper_limit < current linodes)' . format ( url , jdata [ 'cid' ] ) logger . info ( line ) return None