(redata, jdata, logger)
Perform actual call
Perform actual call
Perform actual call
def callDO(redata, jdata, logger):
    ''' Perform actual call '''
    headers = {'Authorization': 'Bearer ' + redata['data']['apikey'],
               'Content-Type': 'application/json'}
    url = "https://api.digitalocean.com/v2/droplets/%s/actions" % str(
        redata['data']['dropletid'])
    msg = {"type": "power_on"}
    payload = json.dumps(msg)
    try:
        req = requests.post(
            url, timeout=3.0, data=payload, headers=headers, verify=True)
    except:
        return False
    if req.status_code >= 200 and req.status_code < 300:
        line = "digitalocean-poweron: Reqeust to %s sent for monitor %s - Successful" % (url, jdata['cid'])
        logger.info(line)
        return True
    else:
        line = "digitalocean-poweron: Request to %s sent for monitor %s - False" % (url, jdata['cid'])
        logger.info(line)
        return False
def callDO ( redata , jdata , logger ) : headers = { 'Authorization' : 'Bearer ' + redata [ 'data' ] [ 'apikey' ] , 'Content-Type' : 'application/json' } url = "https://api.digitalocean.com/v2/droplets/%s/actions" % str ( redata [ 'data' ] [ 'dropletid' ] ) msg = { "type" : "power_on" } payload = json . dumps ( msg ) try : req = requests . post ( url , timeout = 3.0 , data = payload , headers = headers , verify = True ) except : return False if req . status_code >= 200 and req . status_code < 300 : line = "digitalocean-poweron: Reqeust to %s sent for monitor %s - Successful" % ( url , jdata [ 'cid' ] ) logger . info ( line ) return True else : line = "digitalocean-poweron: Request to %s sent for monitor %s - False" % ( url , jdata [ 'cid' ] ) logger . info ( line ) return False