Always use got instead of request.

This commit is contained in:
Julien Fontanet 2015-10-05 17:31:47 +02:00
parent 45da6fb39f
commit b48521950e
3 changed files with 11 additions and 17 deletions

View File

@ -86,7 +86,6 @@
"passport-local": "^1.0.0",
"proxy-http-request": "0.1.0",
"redis": "^2.0.1",
"request": "^2.53.0",
"schema-inspector": "^1.5.1",
"serve-static": "^1.9.2",
"source-map-support": "^0.3.2",

View File

@ -3,12 +3,11 @@ $find = require 'lodash.find'
$findIndex = require 'lodash.findindex'
$forEach = require 'lodash.foreach'
endsWith = require 'lodash.endswith'
got = require('got')
startsWith = require 'lodash.startswith'
{coroutine: $coroutine} = require 'bluebird'
{parseXml, promisify} = require '../utils'
$request = promisify(require('request'))
#=====================================================================
set = $coroutine (params) ->
@ -278,11 +277,10 @@ stats = $coroutine ({host, granularity}) ->
granularity = {0:0, 1:1, 2:4, 3:7}[granularity]
xapi = @getXAPI host
[response, body] = yield $request {
method: 'get'
rejectUnauthorized: false
url: 'https://'+host.address+'/host_rrd?session_id='+xapi.sessionId
}
{body} = response = yield got(
"https://#{host.address}/host_rrd?session_id=#{xapi.sessionId}",
{ rejectUnauthorized: false }
)
if response.statusCode isnt 200
throw new Error('Cannot fetch the RRDs')

View File

@ -8,6 +8,7 @@ $result = require 'lodash.result'
endsWith = require 'lodash.endswith'
escapeStringRegexp = require 'escape-string-regexp'
eventToPromise = require 'event-to-promise'
got = require('got')
map = require 'lodash.map'
sortBy = require 'lodash.sortby'
startsWith = require 'lodash.startswith'
@ -16,13 +17,10 @@ startsWith = require 'lodash.startswith'
{
formatXml: $js2xml,
parseXml,
pFinally,
promisify
pFinally
} = require '../utils'
{isVmRunning: $isVMRunning} = require('../xapi')
$request = promisify(require('request'))
#=====================================================================
# TODO: Implement ACLs
@ -788,11 +786,10 @@ stats = $coroutine ({vm, granularity}) ->
else unless type is 'host'
throw new Error "unexpected type: got #{type} instead of host"
[response, body] = yield $request {
method: 'get'
rejectUnauthorized: false
url: 'https://'+host.address+'/vm_rrd?session_id='+xapi.sessionId+'&uuid='+vm.id
}
{body} = response = yield got(
"https://#{host.address}/vm_rrd?session_id=#{xapi.sessionId}&uuid=#{vm.id}",
{ rejectUnauthorized: false }
)
if response.statusCode isnt 200
throw new Error('Cannot fetch the RRDs')