Always use got instead of request.
This commit is contained in:
parent
45da6fb39f
commit
b48521950e
@ -86,7 +86,6 @@
|
|||||||
"passport-local": "^1.0.0",
|
"passport-local": "^1.0.0",
|
||||||
"proxy-http-request": "0.1.0",
|
"proxy-http-request": "0.1.0",
|
||||||
"redis": "^2.0.1",
|
"redis": "^2.0.1",
|
||||||
"request": "^2.53.0",
|
|
||||||
"schema-inspector": "^1.5.1",
|
"schema-inspector": "^1.5.1",
|
||||||
"serve-static": "^1.9.2",
|
"serve-static": "^1.9.2",
|
||||||
"source-map-support": "^0.3.2",
|
"source-map-support": "^0.3.2",
|
||||||
|
@ -3,12 +3,11 @@ $find = require 'lodash.find'
|
|||||||
$findIndex = require 'lodash.findindex'
|
$findIndex = require 'lodash.findindex'
|
||||||
$forEach = require 'lodash.foreach'
|
$forEach = require 'lodash.foreach'
|
||||||
endsWith = require 'lodash.endswith'
|
endsWith = require 'lodash.endswith'
|
||||||
|
got = require('got')
|
||||||
startsWith = require 'lodash.startswith'
|
startsWith = require 'lodash.startswith'
|
||||||
{coroutine: $coroutine} = require 'bluebird'
|
{coroutine: $coroutine} = require 'bluebird'
|
||||||
{parseXml, promisify} = require '../utils'
|
{parseXml, promisify} = require '../utils'
|
||||||
|
|
||||||
$request = promisify(require('request'))
|
|
||||||
|
|
||||||
#=====================================================================
|
#=====================================================================
|
||||||
|
|
||||||
set = $coroutine (params) ->
|
set = $coroutine (params) ->
|
||||||
@ -278,11 +277,10 @@ stats = $coroutine ({host, granularity}) ->
|
|||||||
granularity = {0:0, 1:1, 2:4, 3:7}[granularity]
|
granularity = {0:0, 1:1, 2:4, 3:7}[granularity]
|
||||||
xapi = @getXAPI host
|
xapi = @getXAPI host
|
||||||
|
|
||||||
[response, body] = yield $request {
|
{body} = response = yield got(
|
||||||
method: 'get'
|
"https://#{host.address}/host_rrd?session_id=#{xapi.sessionId}",
|
||||||
rejectUnauthorized: false
|
{ rejectUnauthorized: false }
|
||||||
url: 'https://'+host.address+'/host_rrd?session_id='+xapi.sessionId
|
)
|
||||||
}
|
|
||||||
|
|
||||||
if response.statusCode isnt 200
|
if response.statusCode isnt 200
|
||||||
throw new Error('Cannot fetch the RRDs')
|
throw new Error('Cannot fetch the RRDs')
|
||||||
|
@ -8,6 +8,7 @@ $result = require 'lodash.result'
|
|||||||
endsWith = require 'lodash.endswith'
|
endsWith = require 'lodash.endswith'
|
||||||
escapeStringRegexp = require 'escape-string-regexp'
|
escapeStringRegexp = require 'escape-string-regexp'
|
||||||
eventToPromise = require 'event-to-promise'
|
eventToPromise = require 'event-to-promise'
|
||||||
|
got = require('got')
|
||||||
map = require 'lodash.map'
|
map = require 'lodash.map'
|
||||||
sortBy = require 'lodash.sortby'
|
sortBy = require 'lodash.sortby'
|
||||||
startsWith = require 'lodash.startswith'
|
startsWith = require 'lodash.startswith'
|
||||||
@ -16,13 +17,10 @@ startsWith = require 'lodash.startswith'
|
|||||||
{
|
{
|
||||||
formatXml: $js2xml,
|
formatXml: $js2xml,
|
||||||
parseXml,
|
parseXml,
|
||||||
pFinally,
|
pFinally
|
||||||
promisify
|
|
||||||
} = require '../utils'
|
} = require '../utils'
|
||||||
{isVmRunning: $isVMRunning} = require('../xapi')
|
{isVmRunning: $isVMRunning} = require('../xapi')
|
||||||
|
|
||||||
$request = promisify(require('request'))
|
|
||||||
|
|
||||||
#=====================================================================
|
#=====================================================================
|
||||||
|
|
||||||
# TODO: Implement ACLs
|
# TODO: Implement ACLs
|
||||||
@ -788,11 +786,10 @@ stats = $coroutine ({vm, granularity}) ->
|
|||||||
else unless type is 'host'
|
else unless type is 'host'
|
||||||
throw new Error "unexpected type: got #{type} instead of host"
|
throw new Error "unexpected type: got #{type} instead of host"
|
||||||
|
|
||||||
[response, body] = yield $request {
|
{body} = response = yield got(
|
||||||
method: 'get'
|
"https://#{host.address}/vm_rrd?session_id=#{xapi.sessionId}&uuid=#{vm.id}",
|
||||||
rejectUnauthorized: false
|
{ rejectUnauthorized: false }
|
||||||
url: 'https://'+host.address+'/vm_rrd?session_id='+xapi.sessionId+'&uuid='+vm.id
|
)
|
||||||
}
|
|
||||||
|
|
||||||
if response.statusCode isnt 200
|
if response.statusCode isnt 200
|
||||||
throw new Error('Cannot fetch the RRDs')
|
throw new Error('Cannot fetch the RRDs')
|
||||||
|
Loading…
Reference in New Issue
Block a user