Compare commits

..

179 Commits

Author SHA1 Message Date
Julien Fontanet
07945ef8a6 0.13.5 2017-06-29 15:09:17 +02:00
Julien Fontanet
35d7fa4a85 fix(Xapi#putResource): behave if close occurs before finish 2017-06-29 15:07:17 +02:00
Julien Fontanet
fbb6870310 0.13.4 2017-06-27 09:51:08 +02:00
Julien Fontanet
81efe25fbc chore(package): update http-request-plus to v0.4.0 2017-06-27 09:50:32 +02:00
Julien Fontanet
63d440677b fix(Xapi#*Resource): correctly link cancel token to tasks 2017-06-27 09:49:26 +02:00
Julien Fontanet
2e0df47581 chore(Xapi#putResource): no need to inject session_id in query again 2017-06-26 12:19:52 +02:00
Julien Fontanet
a84ced70a6 chore(package): update dependencies 2017-06-26 12:17:04 +02:00
Julien Fontanet
4a9498e25e 0.13.3 2017-06-26 10:03:34 +02:00
Julien Fontanet
1978e218f4 feat(Xapi#*Resource): task can be a ref to an existing task
Or a promise to a ref.
2017-06-23 21:24:27 +02:00
Julien Fontanet
2ab912c4f4 feat(Xapi#*Resource): link the cancel token with the task 2017-06-23 21:24:27 +02:00
Julien Fontanet
ca329fa2ff feat(Xapi#*Resource): use task by default if watching events 2017-06-23 21:24:27 +02:00
Julien Fontanet
db122ed8c5 0.13.2 2017-06-23 11:06:48 +02:00
Julien Fontanet
28d7f106b2 feat(Xapi#putResource): opt-in task creation and watching 2017-06-23 11:05:19 +02:00
Julien Fontanet
d6e46adfde feat(Xapi#getResource): opt-in task creation and watching 2017-06-23 11:05:19 +02:00
Julien Fontanet
93109fe9b8 chore(Xapi#watchTask): reject if task has been destroyed before settling 2017-06-22 19:03:52 +02:00
Julien Fontanet
439992d96f feat(Xapi#createTask): create an ephemeral task
Ephemeral means the task is automatically destroyed when settled.
2017-06-22 18:33:22 +02:00
Julien Fontanet
f94fe0b325 0.13.1 2017-06-22 15:39:31 +02:00
Julien Fontanet
cc543ae33a chore(examples): usage for --raw 2017-06-22 15:34:08 +02:00
Julien Fontanet
5df1e62d53 chore(Xapi#putResource): always close the connection when data has been sent 2017-06-22 15:29:08 +02:00
Julien Fontanet
1dff6f81fc feat(examples): also accept UUID and name labels 2017-06-21 14:33:15 +02:00
Julien Fontanet
ecf2d95318 fix(Xapi#watchTask): correctly handle already settled tasks 2017-06-20 15:06:43 +02:00
Julien Fontanet
a1af272180 chore(Xapi#putResource): avoid unnecessary function creation 2017-06-20 14:52:24 +02:00
Julien Fontanet
72f0793aeb fix(Xapi#putResource): consume the response stream 2017-06-20 14:42:36 +02:00
Julien Fontanet
e150be6a3e 0.13.0 2017-06-14 14:05:01 +02:00
Julien Fontanet
d71b13f2a2 feat(Xapi#putResource): handle redirects 2017-06-14 14:04:43 +02:00
Julien Fontanet
66c88b37a4 chore(package): update http-request-plus to v0.3.0 2017-06-13 17:43:30 +02:00
Julien Fontanet
a7198d2e83 chore(examples): various improvements and fixes 2017-06-13 17:40:50 +02:00
Julien Fontanet
d3584b5820 feat: expose isOpaqueRef() 2017-06-13 14:03:04 +02:00
Julien Fontanet
e2e6267dd7 fix(Xapi#putResource): handle aborted connection 2017-06-13 14:03:00 +02:00
Julien Fontanet
aa5baecdc3 feat(examples): moved into their own directory 2017-06-12 17:53:52 +02:00
Julien Fontanet
601b2aa6bb fix(Xapi#putResource): do not fail on early cancel hack 2017-06-12 17:36:48 +02:00
Julien Fontanet
d09ba38dbd feat(Xapi#constructor): url can contain credentials 2017-06-12 16:53:06 +02:00
Julien Fontanet
b847c2b7b5 chore(resources): add TODO 2017-06-12 16:53:06 +02:00
Julien Fontanet
30e44cb533 chore(Xapi#callAsync): use _sessionCall instead of call 2017-06-12 16:18:00 +02:00
Julien Fontanet
d43b83081b 0.12.3 2017-06-08 17:23:54 +02:00
Julien Fontanet
699363c548 chore(package): update promise-toolbox to v0.9.4
Fix an minor issue regarding Cancel#toString().
2017-06-08 17:21:16 +02:00
Julien Fontanet
6ea3eb4ba6 feat(Xapi#callAsync): cancellable async call 2017-06-08 17:21:16 +02:00
Julien Fontanet
4aa20b6f6a fix(Xapi#watchTask): handle already settled tasks 2017-06-08 17:21:16 +02:00
Julien Fontanet
9c8ea27238 feat(cli): auto Promise.all 2017-06-08 17:21:16 +02:00
Julien Fontanet
22c515b0e7 feat(Xapi#watchTask): returns a promise which settled when the task finishes 2017-06-08 17:21:16 +02:00
Julien Fontanet
7e2bd52f25 0.12.2 2017-05-31 18:06:27 +02:00
Julien Fontanet
e65dd15edc feat(transports): add plain XML-RPC as last fallback (#65) 2017-05-31 18:05:46 +02:00
Julien Fontanet
781ffa5574 0.12.1 2017-05-26 17:50:47 +02:00
Julien Fontanet
8fe3b1a368 feat(Xapi#putResource): accept buffers 2017-05-26 17:49:14 +02:00
Julien Fontanet
69c48e2770 0.12.0 2017-05-23 15:47:01 +02:00
Julien Fontanet
aa934ad725 chore(package): update all dependencies 2017-05-23 15:46:53 +02:00
Julien Fontanet
8596ca607d fix(Xapi#call): mark as disconnected on network failures (#64)
Related to vatesfr/xo-web#2099
2017-05-23 15:45:16 +02:00
Julien Fontanet
643ea9e523 feat: methods to get/put an HTTP resource (#63) 2017-05-22 15:51:41 +02:00
Julien Fontanet
26f630d9d6 0.11.0 2017-05-11 16:36:01 +02:00
Julien Fontanet
7481874ba2 feat(allowUnauthorized): accept self-signed certificates (#62)
Related to vatesfr/xo-web#2138
2017-05-11 16:35:02 +02:00
Julien Fontanet
a348585e76 chore(package): update all dependencies 2017-05-08 18:34:58 +02:00
Julien Fontanet
8d135bc1fc chore: remove invoke() 2017-05-03 11:02:59 +02:00
Julien Fontanet
2c00f0ffab chore: inline isString() 2017-05-03 11:02:46 +02:00
Julien Fontanet
5e1d627834 0.10.0 2017-04-28 16:26:08 +02:00
Julien Fontanet
37b23bdc47 feat: JSON-RPC with fallback to XML-RPC (#50)
Better performance for XS >=7.0
2017-04-28 16:22:35 +02:00
greenkeeper[bot]
47f3788f55 fix(package): update ms to version 1.0.0 (#61)
https://greenkeeper.io/
2017-03-19 22:48:05 +01:00
Julien Fontanet
63be8afd35 chore(README): reverse XenServer versions order 2017-03-08 15:00:01 +01:00
Olivier Lambert
1166db7834 chore(README): add 7.1 and fix XenServer (#60) 2017-03-08 14:59:03 +01:00
greenkeeper[bot]
3d96765b1f fix(package): update event-to-promise to version 0.8.0 (#57)
https://greenkeeper.io/
2017-03-01 11:15:07 +01:00
greenkeeper[bot]
4c52fe11d3 chore(package): update standard to version 9.0.0 (#56)
https://greenkeeper.io/
2017-03-01 00:18:56 +01:00
greenkeeper[bot]
6c4178e107 chore(package): update jest to version 19.0.0 (#54)
https://greenkeeper.io/
2017-02-21 10:54:36 +01:00
Julien Fontanet
02d1fb436d 0.10.0-2 2017-02-13 15:52:26 +01:00
Julien Fontanet
1c97bf9019 0.10.0-1 2017-02-13 15:50:45 +01:00
Julien Fontanet
bfc4bb1f4c fix(package): commitmsg hook 2017-02-13 15:50:22 +01:00
Julien Fontanet
ccdce32562 chore(package): update all dependencies 2017-02-13 15:50:09 +01:00
Julien Fontanet
87fdcf14e5 feat(Xapi#_rawCall): add method to error object 2017-02-13 15:47:09 +01:00
Julien Fontanet
c0c63f49b1 0.10.0-0 2017-01-09 18:30:20 +01:00
Julien Fontanet
4e1bef9537 feat: redirect event 2017-01-09 18:29:54 +01:00
Julien Fontanet
8b78727d20 chore: add yarn.lock 2017-01-09 18:29:38 +01:00
Julien Fontanet
4cd7025be4 chore(package): update all dependencies 2017-01-09 17:30:52 +01:00
Julien Fontanet
015ce2690d chore(package): simplify scripts 2017-01-09 15:12:04 +01:00
Julien Fontanet
3e7f552a63 chore(package): use husky instead of ghooks 2017-01-09 15:05:36 +01:00
greenkeeper[bot]
22882b1ff2 fix(package): update promise-toolbox to version 0.8.0 (#53)
https://greenkeeper.io/
2017-01-06 11:31:23 +01:00
Julien Fontanet
c7e6e72ce8 fix(events watching): stop if not connected
Fixes vatesfr/xo-web#1799
2016-12-07 23:18:05 +01:00
Julien Fontanet
27e0621ad8 0.9.6 2016-11-23 09:46:33 +01:00
Julien Fontanet
1987a8c68a chore(events): rely on event.from timeout instead of inject
Should be enough.
2016-11-23 09:42:11 +01:00
Julien Fontanet
1642798aa6 0.9.5 2016-11-02 14:04:15 +01:00
Julien Fontanet
36b589c2db chore(package): various updates 2016-10-28 11:44:11 +02:00
Greenkeeper
1f710b9b78 chore(package): update promise-toolbox to version 0.7.0 (#49)
https://greenkeeper.io/
2016-10-24 15:00:35 +02:00
Julien Fontanet
9b9f0e5607 fix(package): fix various URLs 2016-10-14 11:57:37 +02:00
Julien Fontanet
590f6cb7b3 chore(package): update all dependencies 2016-10-14 11:53:39 +02:00
Julien Fontanet
2c35ee11b3 fix(Xapi#_init): fix promisify() usage 2016-10-11 17:22:43 +02:00
Greenkeeper
bd0c747d98 chore(package): update promise-toolbox to version 0.6.0 (#48)
https://greenkeeper.io/
2016-10-11 17:20:32 +02:00
Greenkeeper
b12fd45df1 chore(package): update babel-eslint to version 7.0.0 (#47)
https://greenkeeper.io/
2016-09-27 23:26:52 +02:00
Greenkeeper
c21fef7c72 Update standard to version 8.0.0 🚀 (#46)
https://greenkeeper.io/
2016-08-24 11:50:04 -04:00
Julien Fontanet
b7f34b9da6 0.9.4 2016-08-18 09:39:28 +02:00
Julien Fontanet
f82a6efda1 feat(Xapi#_watchEvents): keep-alive, inject 1 event per minute (#45)
See vatesfr/xo-web#1384
2016-08-18 09:37:31 +02:00
Julien Fontanet
556ca71c3a 0.9.3 2016-08-16 19:02:24 +02:00
Julien Fontanet
42be2d5031 fix(Xapi#_watchEvent): timeouts are in ms 2016-08-16 19:01:49 +02:00
Julien Fontanet
876e22b092 0.9.2 2016-08-16 18:09:47 +02:00
Julien Fontanet
f9f9c16cb0 feat(Xapi#_watchEvents): timeout request after 10mins (#44) 2016-08-16 18:07:44 +02:00
Greenkeeper
a881090e65 chore(package): update clarify to version 2.0.0 (#37)
https://greenkeeper.io/
2016-08-16 15:09:59 +02:00
Greenkeeper
3d9fce02a4 chore(package): update promise-toolbox to version 0.5.0 (#43)
https://greenkeeper.io/
2016-08-16 12:22:21 +02:00
Julien Fontanet
ab6b1e2c32 chore(Xapi#_transportCall): simplify and improve code
It may even fixes some issues.
2016-08-15 16:36:18 +02:00
Greenkeeper
59d9b3c6b4 chore(package): update nyc to version 8.1.0 (#42)
https://greenkeeper.io/
2016-08-14 19:07:12 +02:00
Julien Fontanet
8851a661c0 0.9.1 2016-08-05 10:49:08 +02:00
Julien Fontanet
2d327961da fix(objects): use $$ to avoid conflict with reserverd keys 2016-08-05 10:42:33 +02:00
Greenkeeper
3a41efbea8 chore(package): update mocha to version 3.0.0 (#40)
https://greenkeeper.io/
2016-08-02 16:20:00 +02:00
Greenkeeper
45b8fd0100 chore(package): update nyc to version 7.0.0 (#38)
https://greenkeeper.io/
2016-07-15 11:29:14 +02:00
Julien Fontanet
155f2fc36c fix(Xapi#_sessionCall): must pCatch when there is a predicate 2016-05-17 10:40:59 +02:00
Julien Fontanet
c3dc136de4 0.9.0 2016-05-11 17:44:45 +02:00
Julien Fontanet
4cbc5c4e2f fix(memory leak): due to Bluebird#cancellable()
To be fair, it may be due to an incorrect usage of
Bluebird#cancellable().

Bluebird has been completely removed at the same occasion.
2016-05-11 17:42:01 +02:00
Julien Fontanet
68820aaf59 fix(cli): add babel-polyfill dep 2016-05-11 17:40:56 +02:00
Julien Fontanet
cd65bc7683 chore: simplify _watchEvents() and _watchEventsLegacy() implementation
I finally understood ES6 Temporal Dead Zone!
2016-05-11 15:23:57 +02:00
Julien Fontanet
6e0956f09f feat(memory-test): split into inject-events 2016-05-11 11:30:49 +02:00
Julien Fontanet
1191f0ba93 feat(events): it's possible not to watch them 2016-05-10 15:35:43 +02:00
Julien Fontanet
6534ffea26 perf(objects): memoize () => this._pool 2016-05-10 14:55:19 +02:00
Julien Fontanet
f9173c41d1 chore(package): remove unnecessary babel-runtime 2016-05-10 10:12:24 +02:00
Julien Fontanet
a2faedcacb fix(debounce): it can be changed at runtime 2016-05-09 18:40:27 +02:00
Julien Fontanet
cb56b3b9d0 chore: rewrite some code using invoke pattern 2016-05-09 18:11:14 +02:00
Julien Fontanet
a61b50548c feat: memory test 2016-05-09 18:00:09 +02:00
Julien Fontanet
75ad588e0b fix(package): clarify, source-map-support & trace are prod deps 2016-05-09 14:07:55 +02:00
Julien Fontanet
6564edcc32 chore(package): update all dependencies (except Bluebird) 2016-05-04 15:54:04 +02:00
Greenkeeper
c46c0018ea chore(package): update nyc to version 6.4.0 (#9)
https://greenkeeper.io/
2016-04-27 22:20:32 +02:00
Julien Fontanet
35e8dcc3be 0.8.0 2016-04-26 08:46:22 +02:00
Julien Fontanet
d1600fd058 fix: handle UUID changes (fix #5). (#7) 2016-04-26 08:46:04 +02:00
Julien Fontanet
1416fb0c71 Xapi#call(): only *.get_*() methods in readonly mode. 2016-04-19 16:32:18 +01:00
Julien Fontanet
2975db247d Do not attempt to fix JSON is parsing is successful. 2016-04-19 13:29:51 +01:00
Julien Fontanet
03eaa652ce Optional debounce for events. 2016-04-14 17:55:41 +02:00
Julien Fontanet
eac29993d3 0.7.4 2016-03-22 09:37:55 +01:00
Julien Fontanet
af2a9225b8 Fix invalid \t in JSON. 2016-03-09 17:41:55 +01:00
Julien Fontanet
a24de7fe3f Fix type case in README. 2016-02-29 18:02:30 +01:00
Julien Fontanet
16a9f44d4d Xapi#getObject(): behave nicely when a XAPI object is passed. 2016-01-28 10:08:26 +01:00
Julien Fontanet
6fcc148105 0.7.3 2016-01-05 16:09:19 +01:00
Julien Fontanet
3485cb4ec4 Guard against null/undefined error.res. 2016-01-05 16:09:06 +01:00
Julien Fontanet
b2a51bd658 0.7.2 2015-12-18 11:29:08 +01:00
Julien Fontanet
e5ab1dc154 Fix opaque ref detection in arrays. 2015-12-18 11:28:58 +01:00
Julien Fontanet
6274969635 0.7.1 2015-12-18 11:23:29 +01:00
Julien Fontanet
069c430346 Fix opaque ref detection. 2015-12-18 11:23:24 +01:00
Julien Fontanet
cbcc4dd21d 0.7.0 2015-12-17 16:33:55 +01:00
Julien Fontanet
b4cdf4d277 Minor optimizations. 2015-12-16 14:19:30 +01:00
Julien Fontanet
716d7bfcf6 Optimize opaque refs detection. 2015-12-16 14:15:37 +01:00
Julien Fontanet
b45a169a2f Read only mode can be altered after initial construction. 2015-12-16 13:58:33 +01:00
Julien Fontanet
720b9ef999 0.6.9 2015-12-03 12:40:31 +01:00
Julien Fontanet
9b9e4dddfc Gracefully fails if error.res does not exists. 2015-12-03 12:39:59 +01:00
Julien Fontanet
7434e0352f 0.6.8 2015-12-02 17:37:28 +01:00
Julien Fontanet
26d61af902 Fall back to legacy events on server failure (work around #2). 2015-12-02 17:36:29 +01:00
Julien Fontanet
5bd12c5f9e Fix XML-RPC error display. 2015-12-02 17:31:13 +01:00
Julien Fontanet
e07fae4290 Revert to Babel 5 for now. 2015-12-02 17:30:42 +01:00
Julien Fontanet
e304395179 Work around ESLint bug. 2015-11-11 15:58:15 +01:00
Julien Fontanet
6b83130853 Various updates. 2015-11-11 15:52:12 +01:00
Julien Fontanet
9565718699 Update deps. 2015-11-11 15:52:06 +01:00
Julien Fontanet
ac11885379 0.6.7 2015-10-23 16:53:53 +02:00
Julien Fontanet
277669a13c Fix events watching XenServer < 6.0. 2015-10-23 16:53:42 +02:00
Julien Fontanet
fcbc476462 Fix coding style. 2015-10-23 16:53:05 +02:00
Julien Fontanet
4944b415c7 0.6.6 2015-10-23 16:03:02 +02:00
Julien Fontanet
5da7312d2d Correctly publish .mocha.js 2015-10-23 16:02:42 +02:00
Julien Fontanet
954d19fe50 Fix objects collection in read-only mode. 2015-10-23 15:33:22 +02:00
Julien Fontanet
addd86f5d2 Better stack traces in CLI. 2015-10-23 15:33:02 +02:00
Julien Fontanet
1b90223210 0.6.5 2015-10-23 14:54:02 +02:00
Julien Fontanet
95989ff63b Add find() and findAll() in CLI. 2015-10-23 14:51:25 +02:00
Julien Fontanet
799f758dce Document constructor options. 2015-10-20 15:46:50 +02:00
Julien Fontanet
e075f1c08b 0.6.4 2015-10-06 14:35:33 +02:00
Julien Fontanet
7e0aa719b4 Use Collection.unset() instead of remove() to avoid exceptions. 2015-10-02 14:05:26 +02:00
Julien Fontanet
4ee352fdb2 Always use instances of Error for errors. 2015-09-14 16:45:17 +02:00
Julien Fontanet
96ea3ded4a Better stacktraces in CLI. 2015-09-14 16:02:09 +02:00
Julien Fontanet
8bbc6e9ff5 Initial read only mode (fix #3). 2015-09-14 16:01:46 +02:00
Julien Fontanet
af7029812c 0.6.3 2015-09-11 15:32:16 +02:00
Julien Fontanet
c517b59138 Enable testing on Node 4. 2015-09-10 15:22:09 +02:00
Julien Fontanet
5485e8a322 Test on iojs 3 and use containers on Travis. 2015-09-07 16:23:33 +02:00
Julien Fontanet
2540ac34b3 Be verbose on XML-RPC errors. 2015-08-28 08:51:38 +02:00
Julien Fontanet
76e5d41a34 Upgrade deps. 2015-08-28 08:51:15 +02:00
Julien Fontanet
2c32a4e912 0.6.2 2015-08-10 15:52:55 +02:00
Julien Fontanet
c66f7235b6 Fix master change. 2015-08-10 15:51:45 +02:00
Julien Fontanet
5444381f7d 0.6.1 2015-06-30 17:20:31 +02:00
Julien Fontanet
dc44679031 Optimize and clean _watchEvents() & _watchEventsLegacy(). 2015-06-30 14:24:43 +02:00
Julien Fontanet
2cbd17b745 Better traces. 2015-06-30 11:07:33 +02:00
Julien Fontanet
9ef13696d8 0.6.0 2015-06-23 10:39:55 +02:00
Julien Fontanet
c3f635fd12 Ask JSON encoded values to XenApi.
The XML is therefore much faster to parse (3-4 ×).
2015-06-23 10:39:04 +02:00
Julien Fontanet
e3d1380435 0.5.7 2015-06-23 10:38:41 +02:00
Julien Fontanet
f83737b538 Make objects immutable. 2015-06-23 09:17:42 +02:00
Julien Fontanet
bb1ea4e4d0 Optimization for empty arrays. 2015-06-23 09:13:43 +02:00
Julien Fontanet
9cb4de2ea8 Inline an only-used-once function. 2015-06-22 23:33:52 +02:00
Julien Fontanet
048cbf60ec Added tested Xen Server versions in README. 2015-06-22 16:23:38 +02:00
Julien Fontanet
36f40b4188 Support Xen Server < 6. 2015-06-22 16:19:32 +02:00
Julien Fontanet
a3bba92063 Remove duplicate source-map-support. 2015-06-19 15:53:23 +02:00
Julien Fontanet
ebcc6c9341 Remove unused lodash.{find,findkey,size}. 2015-06-19 15:51:22 +02:00
Julien Fontanet
95f765055e Fix invalid session handling. 2015-06-19 15:15:23 +02:00
Julien Fontanet
49aa5ffccc Password can be supplied on the command line. 2015-06-19 15:13:21 +02:00
28 changed files with 5170 additions and 383 deletions

View File

@@ -1,14 +0,0 @@
{
"comments": false,
"compact": true,
"optional": [
// Experimental features.
// "minification.constantFolding",
// "minification.deadCodeElimination",
"es7.asyncFunctions",
"es7.decorators",
"es7.functionBind",
"runtime"
]
}

View File

@@ -1,8 +1,12 @@
/bower_components/
/coverage/
/dist/
/examples/node_modules/
/node_modules/
npm-debug.log
npm-debug.log.*
pnpm-debug.log
pnpm-debug.log.*
yarn-error.log*
!node_modules/*
node_modules/*/
/plot.dat

View File

@@ -1,3 +0,0 @@
try { require('clarify') } catch (_) {}
try { require('trace') } catch (_) {}
try { require('source-map-support/register') } catch (_) {}

View File

@@ -1 +0,0 @@
--require ./.mocha.js

View File

@@ -1,9 +1,24 @@
/benchmark/
/benchmarks/
*.bench.js
*.bench.js.map
/examples/
example.js
example.js.map
*.example.js
*.example.js.map
/fixture/
/fixtures/
*.fixture.js
*.fixture.js.map
*.fixtures.js
*.fixtures.js.map
/test/
/tests/
*.spec.js
*.spec.js.map
__snapshots__/

View File

@@ -1,6 +1,9 @@
language: node_js
node_js:
- 'iojs-v2'
- 'iojs-v1'
- '0.12'
- '0.10'
- stable
- 6
- 4
# Use containers.
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

View File

@@ -1,7 +1,15 @@
# xen-api [![Build Status](https://travis-ci.org/julien-f/js-xen-api.png?branch=master)](https://travis-ci.org/julien-f/js-xen-api)
# xen-api [![Build Status](https://travis-ci.org/vatesfr/xen-api.png?branch=master)](https://travis-ci.org/vatesfr/xen-api)
> Connector to the Xen API
Tested with:
- XenServer 7.1
- XenServer 7
- XenServer 6.5
- XenServer 6.2
- XenServer 5.6
## Install
Installation of the [npm package](https://npmjs.org/package/xen-api):
@@ -22,9 +30,18 @@ var xapi = createClient({
auth: {
user: 'root',
password: 'important secret password'
}
},
readOnly: false
})
```
Options:
- `url`: address of a host in the pool we are trying to connect to
- `auth`: credentials used to sign in
- `readOnly = false`: if true, no methods with side-effects can be called
```js
// Force connection.
xapi.connect().catch(error => {
console.error(error)
@@ -36,7 +53,9 @@ xapi.objects.on('add', function (objects) {
})
```
Custom fields on objects (hidden and read-only):
> Note: all objects are frozen and cannot be altered!
Custom fields on objects (hidden ie. non enumerable):
- `$type`: the type of the object (`VM`, `task`, …);
- `$ref`: the (opaque) reference of the object;
- `$id`: the identifier of this object (its UUID if any, otherwise its reference);
@@ -65,26 +84,30 @@ root@xen1.company.net> xapi.pool.$master.name_label
'xen1'
```
To ease searches, `find()` and `findAll()` functions are available:
```
root@xen1.company.net> findAll({ $type: 'vm' }).length
183
```
## Development
### Installing dependencies
```
# Install dependencies
> npm install
```
### Compilation
# Run the tests
> npm test
The sources files are watched and automatically recompiled on changes.
```
# Continuously compile
> npm run dev
```
### Tests
# Continuously run the tests
> npm run dev-test
```
> npm run test-dev
# Build for production (automatically called by npm install)
> npm run build
```
## Contributions
@@ -94,7 +117,7 @@ the code.
You may:
- report any [issue](https://github.com/julien-f/js-xen-api/issues)
- report any [issue](https://github.com/pbdxen-api/issues)
you've encountered;
- fork and create a pull request.

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env node
process.env.DEBUG = '*'
const defer = require('golike-defer').default
const pump = require('pump')
const { fromCallback } = require('promise-toolbox')
const { createClient } = require('../')
const { createOutputStream, resolveRef } = require('./utils')
defer(async ($defer, args) => {
let raw = false
if (args[0] === '--raw') {
raw = true
args.shift()
}
if (args.length < 2) {
return console.log('Usage: export-vdi [--raw] <XS URL> <VDI identifier> [<VHD file>]')
}
const xapi = createClient({
allowUnauthorized: true,
url: args[0],
watchEvents: false
})
await xapi.connect()
$defer(() => xapi.disconnect())
// https://xapi-project.github.io/xen-api/snapshots.html#downloading-a-disk-or-snapshot
const exportStream = await xapi.getResource('/export_raw_vdi/', {
query: {
format: raw ? 'raw' : 'vhd',
vdi: await resolveRef(xapi, 'VDI', args[1])
}
})
console.warn('Export task:', exportStream.headers['task-id'])
await fromCallback(cb => pump(
exportStream,
createOutputStream(args[2]),
cb
))
})(process.argv.slice(2)).catch(
console.error.bind(console, 'error')
)

View File

@@ -0,0 +1,44 @@
#!/usr/bin/env node
process.env.DEBUG = '*'
const defer = require('golike-defer').default
const pump = require('pump')
const { fromCallback } = require('promise-toolbox')
const { createClient } = require('../')
const { createOutputStream, resolveRef } = require('./utils')
defer(async ($defer, args) => {
if (args.length < 2) {
return console.log('Usage: export-vm <XS URL> <VM identifier> [<XVA file>]')
}
const xapi = createClient({
allowUnauthorized: true,
url: args[0],
watchEvents: false
})
await xapi.connect()
$defer(() => xapi.disconnect())
// https://xapi-project.github.io/xen-api/importexport.html
const exportStream = await xapi.getResource('/export/', {
query: {
ref: await resolveRef(xapi, 'VM', args[1]),
use_compression: 'true'
}
})
console.warn('Export task:', exportStream.headers['task-id'])
await fromCallback(cb => pump(
exportStream,
createOutputStream(args[2]),
cb
))
})(process.argv.slice(2)).catch(
console.error.bind(console, 'error')
)

View File

@@ -0,0 +1,40 @@
#!/usr/bin/env node
process.env.DEBUG = '*'
const defer = require('golike-defer').default
const { createClient } = require('../')
const { createInputStream, resolveRef } = require('./utils')
defer(async ($defer, args) => {
let raw = false
if (args[0] === '--raw') {
raw = true
args.shift()
}
if (args.length < 2) {
return console.log('Usage: import-vdi [--raw] <XS URL> <VDI identifier> [<VHD file>]')
}
const xapi = createClient({
allowUnauthorized: true,
url: args[0],
watchEvents: false
})
await xapi.connect()
$defer(() => xapi.disconnect())
// https://xapi-project.github.io/xen-api/snapshots.html#uploading-a-disk-or-snapshot
await xapi.putResource(createInputStream(args[2]), '/import_raw_vdi/', {
query: {
format: raw ? 'raw' : 'vhd',
vdi: await resolveRef(xapi, 'VDI', args[1])
}
})
})(process.argv.slice(2)).catch(
console.error.bind(console, 'error')
)

View File

@@ -0,0 +1,31 @@
#!/usr/bin/env node
process.env.DEBUG = '*'
const defer = require('golike-defer').default
const { createClient } = require('../')
const { createInputStream, resolveRef } = require('./utils')
defer(async ($defer, args) => {
if (args.length < 1) {
return console.log('Usage: import-vm <XS URL> [<XVA file>] [<SR identifier>]')
}
const xapi = createClient({
allowUnauthorized: true,
url: args[0],
watchEvents: false
})
await xapi.connect()
$defer(() => xapi.disconnect())
// https://xapi-project.github.io/xen-api/importexport.html
await xapi.putResource(createInputStream(args[1]), '/import/', {
query: args[2] && { sr_id: await resolveRef(xapi, 'SR', args[2]) }
})
})(process.argv.slice(2)).catch(
console.error.bind(console, 'error')
)

View File

@@ -1,33 +1,37 @@
import forEach from 'lodash.foreach'
import size from 'lodash.size'
import {createClient} from './'
#!/usr/bin/env node
import sourceMapSupport from 'source-map-support'
sourceMapSupport.install()
require('source-map-support').install()
const { forEach, size } = require('lodash')
const { createClient } = require('../')
// ===================================================================
if (process.argv.length < 3) {
return console.log('Usage: log-events <XS URL>')
}
// ===================================================================
// Creation
const xapi = createClient({
url: 'https://192.168.1.1',
auth: {
user: 'root',
password: 'qwerty'
}
allowUnauthorized: true,
url: process.argv[2]
})
// ===================================================================
// Method call
const getAllVms = xapi.call('VM.get_all_records')
getAllVms()
xapi.connect().then(() => {
xapi.call('VM.get_all_records')
.then(function (vms) {
console.log('%s VMs fetched', size(vms))
})
.catch(function (error) {
console.error(error)
})
})
// ===================================================================
// Objects

View File

@@ -0,0 +1,6 @@
{
"dependencies": {
"golike-defer": "^0.1.0",
"pump": "^1.0.2"
}
}

View File

@@ -0,0 +1,41 @@
const { createReadStream, createWriteStream, statSync } = require('fs')
const { PassThrough } = require('stream')
const { isOpaqueRef } = require('../')
exports.createInputStream = path => {
if (path === undefined || path === '-') {
return process.stdin
}
const { size } = statSync(path)
const stream = createReadStream(path)
stream.length = size
return stream
}
exports.createOutputStream = path => {
if (path !== undefined && path !== '-') {
return createWriteStream(path)
}
// introduce a through stream because stdout is not a normal stream!
const stream = new PassThrough()
stream.pipe(process.stdout)
return stream
}
exports.resolveRef = (xapi, type, refOrUuidOrNameLabel) =>
isOpaqueRef(refOrUuidOrNameLabel)
? refOrUuidOrNameLabel
: xapi.call(`${type}.get_by_uuid`, refOrUuidOrNameLabel).catch(
() => xapi.call(`${type}.get_by_name_label`, refOrUuidOrNameLabel).then(
refs => {
if (refs.length === 1) {
return refs[0]
}
throw new Error(`no single match for ${type} with name label ${refOrUuidOrNameLabel}`)
}
)
)

View File

@@ -0,0 +1,30 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
end-of-stream@^1.1.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.0.tgz#7a90d833efda6cfa6eac0f4949dbb0fad3a63206"
dependencies:
once "^1.4.0"
golike-defer@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/golike-defer/-/golike-defer-0.1.0.tgz#70a3d8991cdfe41845956bfb578f69bc3e49f525"
once@^1.3.1, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
wrappy "1"
pump@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.2.tgz#3b3ee6512f94f0e575538c17995f9f16990a5d51"
dependencies:
end-of-stream "^1.1.0"
once "^1.3.1"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

View File

@@ -0,0 +1,4 @@
set yrange [ 0 : ]
set grid
plot for [i=2:4] "plot.dat" using 1:i with lines

View File

@@ -1,6 +1,6 @@
{
"name": "xen-api",
"version": "0.5.6",
"version": "0.13.5",
"license": "ISC",
"description": "Connector to the Xen API",
"keywords": [
@@ -10,11 +10,11 @@
"xenapi",
"xapi"
],
"homepage": "https://github.com/julien-f/js-xen-api",
"bugs": "https://github.com/julien-f/js-xen-api/issues",
"homepage": "https://github.com/vatesfr/xen-api",
"bugs": "https://github.com/vatesfr/xen-api/issues",
"repository": {
"type": "git",
"url": "https://github.com/julien-f/js-xen-api.git"
"url": "https://github.com/vatesfr/xen-api.git"
},
"author": {
"name": "Julien Fontanet",
@@ -28,49 +28,79 @@
"files": [
"dist/"
],
"engines": {
"node": ">=4"
},
"dependencies": {
"babel-runtime": "^5",
"blocked": "^1.1.0",
"bluebird": "^2.9.21",
"debug": "^2.1.3",
"event-to-promise": "^0.3.2",
"exec-promise": "^0.5.1",
"lodash.find": "^3.2.0",
"lodash.findkey": "^3.0.1",
"lodash.foreach": "^3.0.2",
"lodash.isarray": "^3.0.2",
"lodash.isobject": "^3.0.1",
"lodash.map": "^3.1.2",
"lodash.size": "^3.0.0",
"lodash.startswith": "^3.0.1",
"make-error": "^1.0.2",
"minimist": "^1.1.1",
"babel-polyfill": "^6.23.0",
"blocked": "^1.2.1",
"debug": "^2.6.8",
"event-to-promise": "^0.8.0",
"exec-promise": "^0.7.0",
"http-request-plus": "^0.4.0",
"json-rpc-protocol": "^0.11.2",
"kindof": "^2.0.0",
"lodash": "^4.17.4",
"make-error": "^1.3.0",
"minimist": "^1.2.0",
"ms": "^2.0.0",
"promise-toolbox": "^0.9.5",
"pw": "0.0.4",
"source-map-support": "^0.2.10",
"xmlrpc": "^1.3.0",
"xo-collection": "^0.3.0"
"xmlrpc": "^1.3.2",
"xo-collection": "^0.4.1"
},
"devDependencies": {
"babel": "^5.5.8",
"babel-eslint": "^3.1.16",
"clarify": "^1.0.5",
"mocha": "^2.2.5",
"must": "^0.12.0",
"source-map-support": "^0.3.1",
"standard": "^4.3.0",
"trace": "^1.2.0"
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-env": "^1.5.2",
"babel-preset-stage-0": "^6.24.1",
"cross-env": "^5.0.1",
"dependency-check": "^2.9.1",
"husky": "^0.14.1",
"jest": "^20.0.4",
"rimraf": "^2.6.1",
"standard": "^10.0.2"
},
"scripts": {
"build": "babel --source-maps --out-dir=dist/ src/",
"dev": "babel --watch --source-maps --out-dir=dist/ src/",
"lint": "standard",
"build": "cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/",
"commitmsg": "npm test",
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/",
"dev-test": "jest --bail --watch",
"plot": "gnuplot -p memory-test.gnu",
"posttest": "standard && dependency-check ./package.json",
"prebuild": "rimraf dist/",
"predev": "npm run prebuild",
"prepublish": "npm run build",
"test": "mocha --opts .mocha.opts \"dist/**/*.spec.js\"",
"test-dev": "mocha --opts .mocha.opts --watch --reporter=min \"dist/**/*.spec.js\""
"test": "jest"
},
"babel": {
"plugins": [
"lodash",
"transform-decorators-legacy"
],
"presets": [
[
"env",
{
"targets": {
"node": 4
}
}
],
"stage-0"
]
},
"jest": {
"roots": [
"<rootDir>/src"
],
"testRegex": "\\.spec\\.js$"
},
"standard": {
"ignore": [
"dist/**"
"dist"
],
"parser": "babel-eslint"
}

View File

@@ -1,34 +1,48 @@
#!/usr/bin/env node
import 'babel-polyfill'
import blocked from 'blocked'
import Bluebird, {coroutine} from 'bluebird'
import createDebug from 'debug'
import eventToPromise from 'event-to-promise'
import execPromise from 'exec-promise'
import minimist from 'minimist'
import pw from 'pw'
import {start as createRepl} from 'repl'
import { asCallback, fromCallback } from 'promise-toolbox'
import { filter, find, isArray } from 'lodash'
import { start as createRepl } from 'repl'
import {createClient} from './'
import { createClient } from './'
// ===================================================================
Bluebird.longStackTraces()
function askPassword (prompt = 'Password: ') {
if (prompt) {
process.stdout.write(prompt)
}
import createDebug from 'debug'
return new Promise(resolve => {
pw(resolve)
})
}
import sourceMapSupport from 'source-map-support'
sourceMapSupport.install()
function required (name) {
throw new Error(`missing required argument ${name}`)
}
// ===================================================================
const usage = `Usage: xen-api <url> <user>`
const usage = 'Usage: xen-api <url> <user> [<password>]'
const main = coroutine(function * (args) {
const main = async args => {
const opts = minimist(args, {
boolean: ['help', 'verbose'],
boolean: ['allow-unauthorized', 'help', 'read-only', 'verbose'],
alias: {
'allow-unauthorized': 'au',
debounce: 'd',
help: 'h',
'read-only': 'ro',
verbose: 'v'
}
})
@@ -44,15 +58,11 @@ const main = coroutine(function * (args) {
createDebug.enable('xen-api,xen-api:*')
}
const [url, user] = opts._
if (!url || !user) {
throw new Error('missing arguments')
}
process.stdout.write('Password: ')
const password = yield new Bluebird(resolve => {
pw(resolve)
})
const [
url = required('url'),
user = required('user'),
password = await askPassword()
] = opts._
{
const debug = createDebug('xen-api:perf')
@@ -61,31 +71,38 @@ const main = coroutine(function * (args) {
})
}
const xapi = createClient({url, auth: {user, password}})
yield xapi.connect()
const xapi = createClient({
url,
allowUnauthorized: opts.au,
auth: { user, password },
debounce: opts.debounce != null ? +opts.debounce : null,
readOnly: opts.ro
})
await xapi.connect()
const repl = createRepl({
prompt: `${xapi._humanId}> `
})
repl.context.xapi = xapi
// Make the REPL waits for promise completion.
{
const evaluate = Bluebird.promisify(repl.eval)
repl.eval = (cmd, context, filename, cb) => {
evaluate(cmd, context, filename)
// See https://github.com/petkaantonov/bluebird/issues/594
.then(result => result)
.nodeify(cb)
}
}
repl.context.find = predicate => find(xapi.objects.all, predicate)
repl.context.findAll = predicate => filter(xapi.objects.all, predicate)
yield eventToPromise(repl, 'exit')
// Make the REPL waits for promise completion.
repl.eval = (evaluate => (cmd, context, filename, cb) => {
fromCallback(cb => {
evaluate.call(repl, cmd, context, filename, cb)
}).then(value =>
isArray(value) ? Promise.all(value) : value
)::asCallback(cb)
})(repl.eval)
await eventToPromise(repl, 'exit')
try {
yield xapi.disconnect()
await xapi.disconnect()
} catch (error) {}
})
}
export default main
if (!module.parent) {

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +0,0 @@
/* eslint-env mocha */
import {createClient, Xapi} from './'
import expect from 'must'
// ===================================================================
describe('createClient()', function () {
it('is a function', function () {
expect(createClient).to.be.a.function()
})
it.skip('returns an instance of Xapi', function () {
expect(createClient('example.org')).to.be.a(Xapi)
})
})

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env node
import { delay as pDelay } from 'promise-toolbox'
import { createClient } from './'
const xapi = (() => {
const [ , , url, user, password ] = process.argv
return createClient({
auth: { user, password },
url,
watchEvents: false
})
})()
xapi.connect()
// Get the pool record's ref.
.then(() => xapi.call('pool.get_all'))
// Injects lots of events.
.then(([ poolRef ]) => {
const loop = () => xapi.call('event.inject', 'pool', poolRef)
::pDelay(10) // A small delay is required to avoid overloading the Xen API.
.then(loop)
return loop()
})

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env node
import { createClient } from './'
let i = 0
setInterval(() => {
const usage = process.memoryUsage()
console.log(
'%s %s %s %s',
i++,
Math.round(usage.rss / 1e6),
Math.round(usage.heapTotal / 1e6),
Math.round(usage.heapUsed / 1e6)
)
}, 1e2)
const [ , , url, user, password ] = process.argv
createClient({
auth: { user, password },
readOnly: true,
url
}).connect()

View File

@@ -0,0 +1,3 @@
import makeError from 'make-error'
export const UnsupportedTransport = makeError('UnsupportedTransport')

View File

@@ -0,0 +1,36 @@
import jsonRpc from './json-rpc'
import xmlRpc from './xml-rpc'
import xmlRpcJson from './xml-rpc-json'
import { UnsupportedTransport } from './_utils'
const factories = [ jsonRpc, xmlRpcJson, xmlRpc ]
const { length } = factories
export default opts => {
let i = 0
let call
function create () {
const current = factories[i++](opts)
if (i < length) {
const currentI = i
call = (method, args) => current(method, args).catch(
error => {
if (error instanceof UnsupportedTransport) {
if (currentI === i) { // not changed yet
create()
}
return call(method, args)
}
throw error
}
)
} else {
call = current
}
}
create()
return (method, args) => call(method, args)
}

View File

@@ -0,0 +1,38 @@
import httpRequestPlus from 'http-request-plus'
import { format, parse } from 'json-rpc-protocol'
import { UnsupportedTransport } from './_utils'
export default ({ allowUnauthorized, url }) => {
return (method, args) => httpRequestPlus.post(url, {
rejectUnauthorized: !allowUnauthorized,
body: format.request(0, method, args),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
path: '/jsonrpc'
}).readAll('utf8').then(
text => {
let response
try {
response = parse(text)
} catch (error) {
throw new UnsupportedTransport()
}
if (response.type === 'response') {
return response.result
}
throw response.error
},
error => {
if (error.response !== undefined) { // HTTP error
throw new UnsupportedTransport()
}
throw error
}
)
}

View File

@@ -0,0 +1,97 @@
import { createClient, createSecureClient } from 'xmlrpc'
import { promisify } from 'promise-toolbox'
import { UnsupportedTransport } from './_utils'
const logError = error => {
if (error.res) {
console.error(
'XML-RPC Error: %s (response status %s)',
error.message,
error.res.statusCode
)
console.error('%s', error.body)
}
throw error
}
const SPECIAL_CHARS = {
'\r': '\\r',
'\t': '\\t'
}
const SPECIAL_CHARS_RE = new RegExp(
Object.keys(SPECIAL_CHARS).join('|'),
'g'
)
const parseResult = result => {
const status = result.Status
// Return the plain result if it does not have a valid XAPI
// format.
if (status === undefined) {
return result
}
if (status !== 'Success') {
throw result.ErrorDescription
}
const value = result.Value
// XAPI returns an empty string (invalid JSON) for an empty
// result.
if (value === '') {
return ''
}
try {
return JSON.parse(value)
} catch (error) {
// XAPI JSON sometimes contains invalid characters.
if (!(error instanceof SyntaxError)) {
throw error
}
}
let replaced = false
const fixedValue = value.replace(SPECIAL_CHARS_RE, match => {
replaced = true
return SPECIAL_CHARS[match]
})
if (replaced) {
try {
return JSON.parse(fixedValue)
} catch (error) {
if (!(error instanceof SyntaxError)) {
throw error
}
}
}
throw new UnsupportedTransport()
}
export default ({
allowUnauthorized,
url: { hostname, path, port, protocol }
}) => {
const client = (
protocol === 'https:'
? createSecureClient
: createClient
)({
host: hostname,
path: '/json',
port,
rejectUnauthorized: !allowUnauthorized
})
const call = promisify(client.methodCall, client)
return (method, args) => call(method, args).then(
parseResult,
logError
)
}

View File

@@ -0,0 +1,52 @@
import { createClient, createSecureClient } from 'xmlrpc'
import { promisify } from 'promise-toolbox'
const logError = error => {
if (error.res) {
console.error(
'XML-RPC Error: %s (response status %s)',
error.message,
error.res.statusCode
)
console.error('%s', error.body)
}
throw error
}
const parseResult = result => {
const status = result.Status
// Return the plain result if it does not have a valid XAPI
// format.
if (status === undefined) {
return result
}
if (status !== 'Success') {
throw result.ErrorDescription
}
return result.Value
}
export default ({
allowUnauthorized,
url: { hostname, path, port, protocol }
}) => {
const client = (
protocol === 'https:'
? createSecureClient
: createClient
)({
host: hostname,
port,
rejectUnauthorized: !allowUnauthorized
})
const call = promisify(client.methodCall, client)
return (method, args) => call(method, args).then(
parseResult,
logError
)
}

3780
packages/xen-api/yarn.lock Normal file

File diff suppressed because it is too large Load Diff