Compare commits

..

1552 Commits

Author SHA1 Message Date
Julien Fontanet
522d6eed92 5.3.2 2016-10-27 18:49:32 +02:00
Julien Fontanet
9d1d6ea4c5 feat(xo): export/import config (#427)
See vatesfr/xo-web#786
2016-10-27 18:48:19 +02:00
Julien Fontanet
0afd506a41 5.3.1 2016-10-27 18:25:16 +02:00
Julien Fontanet
9dfb837e3f fix(Xapi#importDeltaVm): gracefully handle missing vif.$network$uuid (#433) 2016-10-27 16:46:45 +02:00
fufroma
4ab63b569f fix(RemoteHandlerNfs): move mount points in /run/xo-server/mounts
Fixes vatesfr/xo-web#1405
2016-10-27 15:56:33 +02:00
Julien Fontanet
8d390d256d fix(http-request): handle redirections (#432) 2016-10-27 15:34:54 +02:00
Julien Fontanet
4eec5e06fc fix(package): test on Node 6, not 7 (#431) 2016-10-27 12:24:40 +02:00
Julien Fontanet
e4063b1ba8 feat(sample.config.yaml): add warning about YAML 2016-10-24 22:52:11 +02:00
Greenkeeper
0c3227cf8e chore(package): update promise-toolbox to version 0.7.0 (#428)
https://greenkeeper.io/
2016-10-24 15:01:17 +02:00
Pierre Donias
7bed200bf5 feat(pif): editVlan (#426)
Fix vatesfr/xo-web#1092
2016-10-24 10:24:44 +02:00
Julien Fontanet
4f763e2109 5.3.0 2016-10-20 16:01:53 +02:00
Pierre Donias
75167fb65b feat(pif): expose IP config modes (#424)
See vatesfr/xo-web#1651
2016-10-20 12:44:35 +02:00
Julien Fontanet
675588f780 feat(delta backups): force checksums refresh
See vatesfr/xo-web#1672
2016-10-20 12:38:26 +02:00
Julien Fontanet
2d6f94edd8 fix(vhd-merge/chainVhd): correctly await _write()
Fixes vatesfr/xo-web#1672
2016-10-20 12:31:20 +02:00
Julien Fontanet
247c66ef4b feat(IP pools): can be used in resource sets (#413)
See vatesfr/xo-web#1565
2016-10-19 11:17:05 +02:00
Greenkeeper
1076fac40f Update gulp-sourcemaps to version 2.1.1 🚀 (#422)
https://greenkeeper.io/
2016-10-14 10:44:27 +02:00
Julien Fontanet
14a4a415a2 5.2.6 2016-10-13 18:51:16 +02:00
Julien Fontanet
524355b59c fix(vhd-merge/chainVhd): correctly compute header checksum (#419)
Fixes vatesfr/xo-web#1656
2016-10-13 18:49:58 +02:00
Greenkeeper
36fe49f3f5 Update promise-toolbox to version 0.6.0 🚀 (#416)
https://greenkeeper.io/
2016-10-12 09:19:19 +02:00
Greenkeeper
c0c0af9b14 chore(package): update execa to version 0.5.0 (#411)
https://greenkeeper.io/
2016-10-05 10:40:31 +02:00
Julien Fontanet
d1e472d482 chore(package): use babel-plugin-lodash 2016-10-04 16:05:01 +02:00
Julien Fontanet
c80e43ad0d fix(vm.create): don't require view perm on VM template 2016-10-04 16:03:06 +02:00
Julien Fontanet
fdd395e2b6 fix(vm.create): correctly check resourceSet objects
Related to vatesfr/xo-web#1620
2016-10-04 15:51:04 +02:00
Julien Fontanet
e094437168 fix(package): update xo-acl-resolver to version 0.2.2
See vatesfr/xo-web#1620
2016-10-04 15:24:01 +02:00
Pierre Donias
2ee0be7466 fix(xapi/utils/makeEditObject): constraints works with user props (#410) 2016-10-04 15:02:27 +02:00
Julien Fontanet
2784a7cc92 Create ISSUE_TEMPLATE.md 2016-10-03 16:24:24 +02:00
Julien Fontanet
b09f998d6c 5.2.5 2016-10-03 09:39:52 +02:00
Nicolas Raynaud
bdeb5895f6 fix(deltaBackups): update checksum after altering VHD files (#408)
Fixes vatesfr/xo-web#1606
2016-09-30 14:31:33 +02:00
Pierre Donias
3944b8aaee feat(network): create a bonded network (#407)
Fixes vatesfr/xo-web#876
2016-09-30 13:51:33 +02:00
Nicolas Raynaud
6e66cffb92 feat(deltaBackups): correctly chain VHDs (#406)
The goal is for a tool like vhdimount to be able to mount any file and use it as a disk to recover specific file in it.
2016-09-29 17:31:36 +02:00
Pierre Donias
57092ee788 feat(vif.set): support for network, MAC and currently_attached (#403)
Fixes vatesfr/xo-web#1446
2016-09-28 15:09:17 +02:00
Julien Fontanet
70e9e1c706 chore(package): update human-format to version 0.7.0 2016-09-28 09:58:54 +02:00
Greenkeeper
9662b8fbee chore(package): update babel-eslint to version 7.0.0 (#404)
https://greenkeeper.io/
2016-09-27 23:39:30 +02:00
Julien Fontanet
9f66421ae7 fix(bootstrap): C-c twice force stop the server 2016-09-27 10:44:24 +02:00
Greenkeeper
50584c2e50 chore(package): update http-server-plus to version 0.7.0 (#402)
https://greenkeeper.io/
2016-09-27 09:30:16 +02:00
Julien Fontanet
7be4e1901a chore(package): use index-modules 2016-09-26 15:41:41 +02:00
Julien Fontanet
b47146de45 fix(pbd/attached): should be a boolean 2016-09-22 13:20:49 +02:00
Julien Fontanet
97b229b2c7 fix(vm.set): works with VM templates
Fixes vatesfr/xo-web#1569
2016-09-22 10:39:20 +02:00
Julien Fontanet
6bb5bb9403 5.2.4 2016-09-21 10:20:46 +02:00
Julien Fontanet
8c4b8271d8 fix(pool.setDefaultSr): remove pool param
Fixes vatesfr/xo-web#1558
2016-09-20 11:45:36 +02:00
Julien Fontanet
69291c0574 chore(package): update xo-vmdk-to-vhd to version 0.0.12
Fixes vatesfr/xo-web#1551
2016-09-20 10:41:42 +02:00
Julien Fontanet
2dc073dcd6 fix(vm.resourceSet): handle xo namespace 2016-09-19 13:15:23 +02:00
Julien Fontanet
1894cb35d2 feat(vm): expose resourceSet prop 2016-09-19 12:10:09 +02:00
Julien Fontanet
cd37420b07 Merge pull request #398 from vatesfr/greenkeeper-standard-8.1.0
Update standard to version 8.1.0 🚀
2016-09-18 05:17:41 +02:00
Julien Fontanet
55cb6b39db fix(Xo#removeSchedule): correctly test instance of SchedulerError 2016-09-18 05:12:36 +02:00
greenkeeperio-bot
89d13b2285 chore(package): update standard to version 8.1.0
https://greenkeeper.io/
2016-09-17 20:51:59 +02:00
Julien Fontanet
1b64b0468a fix(group.delete): remove associated ACLs
Fixes vatesfr/xo-web#899
2016-09-16 16:04:41 +02:00
Julien Fontanet
085fb83294 fix(user.delete): remove associated ACLs
See vatesfr/xo-web#899
2016-09-16 16:04:41 +02:00
Julien Fontanet
edd606563f feat(vm.revert): can snapshot before (#395)
See vatesfr/xo-web#1445
2016-09-15 14:59:43 +02:00
Julien Fontanet
fb804e99f0 5.2.3 2016-09-14 18:02:32 +02:00
Pierre Donias
1707cbcb54 feat(signin): use XO 5 style (#394)
Fixes vatesfr/xo-web#1161
2016-09-14 17:56:05 +02:00
Julien Fontanet
6d6a630c31 5.2.2 2016-09-14 17:37:42 +02:00
Julien Fontanet
ff2990e8e5 chore(package): update @marsaud/smb2-promise to version 0.2.1
Fixes vatesfr/xo-web#1511
2016-09-14 17:32:52 +02:00
Nicolas Raynaud
d679aff0fb chore(package): remove node-smb2 dependency (#393) 2016-09-14 16:23:28 +02:00
Julien Fontanet
603a444905 fix(Xapi#importVm): remove VM's VDIs on failure 2016-09-14 14:11:20 +02:00
Julien Fontanet
a002958448 fix(DR): remove previous VDIs
Fixes vatesfr/xo-web#1510
2016-09-14 14:11:20 +02:00
Julien Fontanet
cb4bc37424 fix(DR): delete VMs in all cases
Previous copies were not deleted when there were as many as the depth.

Fixes vatesfr/xo-web#1509
2016-09-14 14:11:19 +02:00
Julien Fontanet
0fc6f917e6 5.2.1 2016-09-13 16:44:35 +02:00
Julien Fontanet
ec0d012b24 feat(vm.set): support tags (#392)
Fixes vatesfr/xo-web#1431
2016-09-13 16:35:40 +02:00
Julien Fontanet
2cd4b171a1 chore(package): update json5 to version 0.5.0 2016-09-13 11:28:56 +02:00
Julien Fontanet
0cb6906c4d chore(package): is-my-json-valid to v2.13.1 2016-09-13 11:25:22 +02:00
Julien Fontanet
4c19b93c30 chore(package): update fs-promise to version 0.5.0 2016-09-13 11:23:42 +02:00
Julien Fontanet
6165f1b405 fix(vm.create): select SR of first disk-VDI (#391)
Fixes vatesfr/xo-web#1493
2016-09-12 16:32:43 +02:00
Julien Fontanet
37a4221e43 fix(vm.docker.containers): yes, again 2016-09-12 12:13:45 +02:00
Julien Fontanet
9831b222b5 fix(vm.docker.containers) 2016-09-12 12:11:15 +02:00
Julien Fontanet
7b6f44fb74 fix(vm.createInterface): syntax fix 2016-09-12 12:06:34 +02:00
Julien Fontanet
399f4d0ea3 feat(vm.docker.containers): like vm.docker.process.items but always an array 2016-09-12 11:43:36 +02:00
Julien Fontanet
26a668a875 fix(vm.createInterface): accept integers for position and mtu 2016-09-12 11:36:30 +02:00
Julien Fontanet
bf96262b6e feat(Xapi#createVif): default MTU is network's MTU 2016-09-12 11:05:31 +02:00
Julien Fontanet
1155fa1fe9 chore(vm.create): remove some console.log()s 2016-09-09 15:31:25 +02:00
Julien Fontanet
1875d31731 5.2.0 2016-09-09 15:16:03 +02:00
Julien Fontanet
6f855fd14e feat(IP pools): groups of IP addresses (#371) 2016-09-09 15:12:30 +02:00
Julien Fontanet
08e392bb46 fix(vm.create): correctly compute limits usage (#389)
Fixes vatesfr/xo-web#1365
2016-09-09 12:55:10 +02:00
Julien Fontanet
66d63e0546 fix(test.wait): fix setTimeout params order 2016-09-08 18:40:55 +02:00
Julien Fontanet
7ee56fe8bc feat(pool.installAllPatches): install all patches on a pool (#388)
See vatesfr/xo-web#1392
2016-09-07 17:54:00 +02:00
Julien Fontanet
669d04ee48 fix(vm.migrate): error on unused default SR
Fixes #1466
2016-09-05 14:21:17 +02:00
Julien Fontanet
cb1b37326e fix(vm.rollingDrCopy): avoid duplicates in VMs list (#387)
Fixes vatesfr/xo-web#1464
2016-09-05 13:41:20 +02:00
Julien Fontanet
7bb73bee67 feat(vm.rollingDrCopy): failure to destroy old copies is not fatal 2016-09-05 11:29:54 +02:00
Julien Fontanet
7286ddc338 chore(JobExecutor): use utils/serializeError() 2016-09-05 11:29:53 +02:00
Olivier Lambert
7d1f9e33fe feat(network): add defaultIsLocked to API (#385) 2016-09-01 14:49:20 +02:00
Ronan Abhamon
63c676ebfe feat(vm.import): supports OVA (#375)
See vatesfr/xo-web#709
2016-09-01 14:11:15 +02:00
Greenkeeper
fcaf6b7923 chore(package): update json-rpc-peer to version 0.12.0 (#383)
https://greenkeeper.io/
2016-08-25 11:56:54 -04:00
Julien Fontanet
9f347a170a fix(xapi/utils): correctly isPlainObject 2016-08-18 16:21:34 +02:00
Julien Fontanet
2f7cd4426d fix(xapi/utils/prepareXapiParam): array handling 2016-08-18 16:15:51 +02:00
Julien Fontanet
854f256470 fix(xapi/getNamespaceForType): add missing VIF 2016-08-18 15:27:47 +02:00
Julien Fontanet
5d0b40f752 fix(utils/camelToSnakeCase): better number handling 2016-08-18 15:23:57 +02:00
Julien Fontanet
27a2853ee8 fix(vif.set): add missing param 2016-08-18 15:13:46 +02:00
Julien Fontanet
67f6b80312 fix(vif.set): do not use an arrow function 2016-08-18 15:01:13 +02:00
Julien Fontanet
016037adc1 fix(user.set): can be used by non admins 2016-08-18 14:17:07 +02:00
Julien Fontanet
70d5c1034d 5.1.6 2016-08-18 10:54:36 +02:00
Greenkeeper
ed6fb8754f chore(package): update mocha to version 3.0.2 (#376)
https://greenkeeper.io/
2016-08-18 10:53:05 +02:00
Julien Fontanet
6d08a9b11c feat(JobExecutor): a current job will only run 2 calls at a time (#382)
Fixes vatesfr/xo-web#915
2016-08-18 10:52:29 +02:00
Julien Fontanet
cf6aa7cf79 fix(package): update xen-api to 0.9.4
Again, fixes vatesfr/xo-web#1384
2016-08-18 09:42:28 +02:00
Julien Fontanet
6c4e57aae0 chore(JobExecutor#_execCall): forEach+Array#push → mapToArray 2016-08-17 18:13:30 +02:00
Julien Fontanet
d08a04959c 5.1.5 2016-08-16 19:15:52 +02:00
Julien Fontanet
2762f74ce5 fix(package): update xen-api to 0.9.3 2016-08-16 19:12:46 +02:00
Julien Fontanet
6ebcf6eec5 5.1.4 2016-08-16 18:18:04 +02:00
Julien Fontanet
25b78fb7e1 fix(package): update xen-api to 0.9.2
Fixes vatesfr/xo-web#1384
2016-08-16 18:15:32 +02:00
Greenkeeper
670dd2dd96 chore(package): update promise-toolbox to version 0.5.0 (#381)
https://greenkeeper.io/
2016-08-16 12:22:57 +02:00
Julien Fontanet
1baf04f786 fix(NfsHandler#_unmount): use _getRealPath() (#380)
Fixes vatesfr/xo-web#1396.
2016-08-15 14:22:19 +02:00
Greenkeeper
ce05b7a041 chore(package): update nyc to version 8.1.0 (#379)
https://greenkeeper.io/
2016-08-14 19:06:00 +02:00
Olivier Lambert
290cc146c8 fix(xapi): allow to unplug VBDs when VM is running 2016-08-11 16:32:06 +02:00
Olivier Lambert
db4d46a584 fix(sr): don't share a local ISO SR. Fixes vatesfr/xo-web#1389 2016-08-10 14:39:05 +02:00
Olivier Lambert
8ed2e51dde feat(network): add network.set method 2016-08-08 14:54:23 +02:00
Olivier Lambert
33702c09a6 feat(vm copy): allow snapshot copy. Related to vatesfr/xo-web#1353 2016-08-08 14:07:27 +02:00
Olivier Lambert
45aeca3753 5.1.3 2016-08-05 11:08:11 +02:00
Olivier Lambert
deae7dfb4d fix(xen-api): avoid reserved key conflicts. Fixes vatesfr/xo-web#1369 2016-08-05 11:06:58 +02:00
Julien Fontanet
2af043ebdd chore(jshint): remove unused config file 2016-08-03 09:46:52 +02:00
Olivier Lambert
e121295735 Merge pull request #373 from nraynaud/next-release
fix (readme): fix installation documentation link
2016-08-02 12:32:05 +02:00
Nicolas Raynaud
7c1c405a64 fix installation documentation link 2016-08-02 12:22:39 +02:00
Olivier Lambert
5d7c95a34d fix(xapi): typo on host disable method. Fixes vatesfr/xo-web#1351 2016-07-30 20:22:12 +02:00
Julien Fontanet
504c934fc9 fix(JobExecutor#_execCall): xo.api.call() → xo.callApiMethod() 2016-07-29 15:28:24 +02:00
Julien Fontanet
81b0223f73 fix(JobExecutor#exec): forward the error 2016-07-29 15:27:58 +02:00
Julien Fontanet
6d1e410bfd fix(JobExecutor#exec): correctly log the error 2016-07-29 15:27:32 +02:00
Julien Fontanet
26c5c6152d fix(job-executor/map): paramName handling 2016-07-29 14:37:42 +02:00
Julien Fontanet
d83bf0ebaf fix(Xo#_watchObject): check for notify() 2016-07-29 14:29:57 +02:00
Julien Fontanet
5adfe9a552 chore(index): remove debug trace 2016-07-29 13:54:54 +02:00
ABHAMON Ronan
883f461dc7 feat(job-executor): supports dynamic param vectors (#369)
See vatesfr/xo-web#837
2016-07-29 13:26:53 +02:00
Julien Fontanet
8595ebc258 feat(api): generate logs on errors
See vatesfr/xo-web#1344
2016-07-29 10:32:48 +02:00
Julien Fontanet
2bd31f4560 chore(api): remove legacy helpers 2016-07-28 15:21:59 +02:00
Julien Fontanet
6df85ecadd fix(vm.*): add missing import 2016-07-28 15:21:59 +02:00
Julien Fontanet
07829918e4 5.1.2 2016-07-28 15:21:12 +02:00
Julien Fontanet
b0d400b6eb fix(Xapi#exportDeltaVm): better handling of removed VDIs (#370)
Fixes vatesfr/xo-web#1333
2016-07-28 15:19:44 +02:00
Julien Fontanet
706cb895ad 5.1.1 2016-07-27 16:36:51 +02:00
Julien Fontanet
45bf539b3c fix(user.delete): fix tokens deletion 2016-07-27 13:23:16 +02:00
Julien Fontanet
0923981f8d fix(user.set): typo in error message 2016-07-27 13:01:32 +02:00
Julien Fontanet
b0ac14363d 5.1.0 2016-07-26 16:52:49 +02:00
Julien Fontanet
5d346aba37 fix(vm.create): cloudConfig handling 2016-07-26 14:26:24 +02:00
Julien Fontanet
124cb15ebe fix(resource sets): fix VM resources computation
Fixes vatesfr/xo-web#1276
2016-07-25 17:08:09 +02:00
Julien Fontanet
a244ab898d fix(vm.create): correctly store the resource set 2016-07-25 17:08:08 +02:00
Julien Fontanet
3c551590eb fix(vm.set): correctly save memory in limits 2016-07-25 17:08:07 +02:00
ABHAMON Ronan
10e30cccbc feat(models/schedule): null properly remove timezone (#368)
Related to vatesfr/xo-web#1314
2016-07-25 15:54:27 +02:00
Julien Fontanet
806a6b86a2 fix(signin): fix styles when /v4 2016-07-25 13:40:57 +02:00
Julien Fontanet
9719fdf5cc fix(sr.probe*): correctly prepare port param 2016-07-23 16:18:03 +02:00
Julien Fontanet
6d8764f8cb fix(Xapi#createVm): add missing param 2016-07-23 15:49:27 +02:00
Julien Fontanet
d9fd9cb408 fix(vm.create): better VBDs creation (#361)
Fixes vatesfr/xo-web#1257
2016-07-23 15:31:15 +02:00
Julien Fontanet
7710ec0aba feat(schemas): add user schema 2016-07-20 12:10:23 +02:00
Julien Fontanet
c97bd78cd0 fix(VM): cpuCap & cpuWeight are integers 2016-07-20 10:57:15 +02:00
ABHAMON Ronan
728c5aa86e feat(plugins): supports predefined configurations (#365)
See vatesfr/xo-web#1289
2016-07-19 17:28:53 +02:00
Pierre Donias
83d68ca293 feat(vm.set): make cpuWeight and cpuCap nullable (#364) 2016-07-19 16:53:47 +02:00
Julien Fontanet
47d7561db4 fix(VM): cpuCap can be defined when cpuWeight is not 2016-07-19 15:37:07 +02:00
ABHAMON Ronan
7d993e8319 feat(schedules): schedules support timezones (#363)
Fixes vatesfr/xo-web#1258
2016-07-19 13:32:27 +02:00
Julien Fontanet
1d1a597b22 feat(VM): expose cpuCap 2016-07-19 11:02:38 +02:00
Julien Fontanet
23082f9300 feat(vm.set): support for cpuCap (#362) 2016-07-19 10:35:03 +02:00
Julien Fontanet
ea1a7f9376 chore(Xapi#_getXenUpdates): use ensureArray() 2016-07-15 12:57:20 +02:00
Greenkeeper
1796c7bab8 chore(package): update nyc to version 7.0.0 (#358)
https://greenkeeper.io/
2016-07-14 13:09:12 +02:00
Greenkeeper
65ad76479a chore(package): update base64url to version 2.0.0 (#360)
https://greenkeeper.io/
2016-07-14 11:33:12 +02:00
Olivier Lambert
422db04ec8 5.0.5 2016-07-13 15:20:56 +02:00
Olivier Lambert
d12f60fe37 Merge pull request #359 from vatesfr/pierre-fix-create-vm
fix(vm/create): missing single quotes
2016-07-13 09:37:23 +02:00
Pierre Donias
194c1c991c fix(vm/create): missing single quotes 2016-07-12 16:40:32 +02:00
Olivier Lambert
3e8e2222c1 Merge pull request #357 from vatesfr/marsaudf-fix-job-log-error
Add message to job log error
2016-07-07 15:26:15 +02:00
Fabrice Marsaud
1620327a33 Add message to job log error 2016-07-07 14:55:43 +02:00
Olivier Lambert
b1131e3667 5.0.4 2016-07-07 12:12:54 +02:00
Olivier Lambert
db0250ac08 Merge pull request #356 from vatesfr/marsaudf-fix-patch-conflicts
Fix(xapi): handle correctly single XML elements
2016-07-07 11:22:27 +02:00
Fabrice Marsaud
0a6b605760 Handle single patch elements in parsed XML 2016-07-07 10:11:21 +02:00
Olivier Lambert
81ac2375e5 5.0.3 2016-07-06 23:23:14 +02:00
Olivier Lambert
6bcaca6cd7 Merge pull request #355 from vatesfr/issue-1233
fix(Xapi#importDeltaVm): correctly handle missing network
2016-07-06 23:21:55 +02:00
Olivier Lambert
ec8375252e fix(Xapi#importDeltaVm): correctly handle missing network 2016-07-06 23:11:47 +02:00
Julien Fontanet
766aa1762f 5.0.2 2016-07-05 17:56:02 +02:00
Julien Fontanet
5165e0a54c feat(user.set): support preferences 2016-07-05 17:19:38 +02:00
Julien Fontanet
a2f7ad627e feat(Xapi#migrateVm): allow non-running VMs
Fixes vatesfr/xo-web#1216
2016-07-05 17:09:54 +02:00
Julien Fontanet
1176c162d4 5.0.1 2016-06-30 15:46:27 +02:00
Fabrice Marsaud
a4880cd017 feat(remote.test): perform a write/read test on a remote (#354)
See vatesfr/xo-web#1075
2016-06-30 15:00:00 +02:00
Julien Fontanet
383bdce416 fix(plugin.configure): fix undefined handling 2016-06-29 13:08:02 +02:00
Julien Fontanet
7cc300dd83 fix(Xapi#createVif): fix handling when neither device nor position is not provided 2016-06-28 17:36:24 +02:00
Fabrice Marsaud
687809db9d fix(user.set): cannot change self permission (#353) 2016-06-28 13:28:31 +02:00
Julien Fontanet
1127ec3a90 feat(vif.set): allowed IPv4/IPv6 addresses (#328) 2016-06-27 15:11:46 +02:00
Julien Fontanet
a797edfae9 chore(xapi/mixins/vm): simplify _editVm() specs 2016-06-27 12:10:57 +02:00
Julien Fontanet
938e106252 feat(xapi/utils/makeEditObject): support camelCase and snake_case aliases 2016-06-27 12:10:54 +02:00
Julien Fontanet
a0eb9caaa2 feat(xapi/utils/makeEditObject): set, set.get, set.set can be true 2016-06-27 11:54:13 +02:00
Julien Fontanet
442f53d45e fix(xapi/utils/makeEditObject): use deep equality 2016-06-27 09:52:02 +02:00
Greenkeeper
68de1ca248 chore(package): update ws to version 1.1.1 (#348)
https://greenkeeper.io/
2016-06-26 20:19:47 +02:00
Greenkeeper
e16061141e chore(package): update d3-time-format to version 2.0.0 (#350)
https://greenkeeper.io/
2016-06-26 20:18:24 +02:00
Julien Fontanet
64cbe3d209 feat(build): delete dist before building 2016-06-26 17:47:56 +02:00
Julien Fontanet
ebdc6376d8 5.0.0 2016-06-24 18:34:31 +02:00
Julien Fontanet
68335123a1 feat(vm.create): all vm.set params are supported (#340) 2016-06-24 18:33:43 +02:00
Julien Fontanet
25b18f4ef8 chore(package): update xo-acl-resolver to 0.2.1 2016-06-24 14:43:18 +02:00
Julien Fontanet
9ad615b0ff fix(Xapi#_waitObjectState): fix failure when object is initially missing 2016-06-22 12:20:22 +02:00
Julien Fontanet
12eaceb032 fix(xapi-objects-to-xo): fix CPUs.number when no tools 2016-06-21 13:19:29 +02:00
Julien Fontanet
3263511b72 fix(Xapi#snapshotVm): fallback if quiesce failed
Fixes vatesfr/xo-web#1088
2016-06-21 11:21:01 +02:00
Julien Fontanet
75cae8c647 fix(Xapi#_updateObjectMapProperty): prepare XAPI param 2016-06-21 11:21:00 +02:00
Julien Fontanet
9991ef624c feat(Xapi#getObject): accept objects with _xapiId property 2016-06-21 11:21:00 +02:00
Julien Fontanet
489e9fce27 fix(xapi/index): work around Babel T2877 2016-06-21 11:21:00 +02:00
Julien Fontanet
0655628073 fix(xapi/index): incorrect import 2016-06-21 11:20:59 +02:00
Fabrice Marsaud
9460822529 feat(vm.importBackup): returns the new VM id (#345) 2016-06-20 18:07:14 +02:00
Julien Fontanet
d02358ac0d chore(xapi): move utilities into dedicated module 2016-06-17 18:43:10 +02:00
ABHAMON Ronan
366237a625 fix(XapiStats): fix unit for host free memory (#339) 2016-06-17 10:16:58 +02:00
Julien Fontanet
2f2da18994 chore: remove some unnecessary logs 2016-06-16 09:22:26 +02:00
Greenkeeper
ecd30db215 chore(package): update d3-time-format to version 1.0.0 (#338)
https://greenkeeper.io/
2016-06-15 08:40:56 +02:00
ABHAMON Ronan
1980854f6f feat(Xapi#importDeltaVm): attach VIFs to original networks if available (#335)
Fixes vatesfr/xo-web#1016
2016-06-10 11:05:54 +02:00
Julien Fontanet
7d4f006c25 feat(Xapi#exportDeltaVm): inject network/SR UUIDs in VIF/VDI records 2016-06-09 17:25:02 +02:00
Julien Fontanet
b697be2383 fix(Xapi#_snapshotVm): returns the up-to-date snapshot record 2016-06-09 17:17:14 +02:00
Fabrice Marsaud
143e53c43f chore(package): update xo-remote-parser to version 0.3.0 (#333) 2016-06-08 17:26:08 +02:00
Julien Fontanet
6dde1ade01 fix(xo-server-logs): fix broken require since Babel 6 2016-06-08 11:12:45 +02:00
Greenkeeper
d4de391ac5 chore(package): update d3-time-format to version 0.4.0 (#332)
https://greenkeeper.io/
2016-06-08 09:05:45 +02:00
Greenkeeper
af15f4bc6a chore(package): update xo-acl-resolver to version 0.2.0 (#330)
https://greenkeeper.io/
2016-06-07 16:46:23 +02:00
Fabrice Marsaud
d4ace24caa fix(job.set): protects userId from modification (#329) 2016-06-07 09:25:15 +02:00
Julien Fontanet
c5ab47fa66 chore(package): fix deps order 2016-06-06 13:38:16 +02:00
Julien Fontanet
d60051b629 fix(package): update xo-remote-parser to 0.2.1 2016-06-06 13:37:47 +02:00
Julien Fontanet
22ff330ee7 fix(package): update @marsaud/smb2 to 0.7.1 2016-06-03 18:22:37 +02:00
Olivier Lambert
dd62bef66d feat(host): expose correct timestamp for license expiry value 2016-05-31 17:24:49 +02:00
Julien Fontanet
e7feb99f8d feat(vm.create): clone param may be use to disable cloning (#318)
See vatesfr/xo-web#960
2016-05-30 11:34:39 +02:00
Julien Fontanet
6358accece fix(plugin.configure): correctly handle undefined 2016-05-30 11:12:11 +02:00
Olivier Lambert
9ce8a24eea feat(sr): add disconnect and connect all PBDs to a SR (#324) 2016-05-27 18:31:09 +02:00
Julien Fontanet
4d0673f489 feat(sr.forget): automatically disconnect PBDs (#323) 2016-05-27 18:15:09 +02:00
Olivier Lambert
fbe1e6a7d5 fix(vm): missing parameters and wrong value for set_memory_static_max 2016-05-27 15:03:49 +02:00
Greenkeeper
4ed02ca501 chore(package): update cookie to version 0.3.0 (#322)
https://greenkeeper.io/
2016-05-27 04:36:35 +02:00
Julien Fontanet
af245ed9fe fix(log.delete): id can be an array 2016-05-26 13:34:47 +02:00
Julien Fontanet
fc86a3e882 fix(vm): always consider memory dynamic max when updating resource set 2016-05-24 16:22:55 +02:00
Julien Fontanet
f9109edcf1 fix(vm.set): memoryMax should update resource set 2016-05-24 16:21:21 +02:00
Julien Fontanet
ec100e1a91 fix(vm.set): memoryMax should change dynamic max 2016-05-24 16:20:25 +02:00
Julien Fontanet
746c5f4a79 fix(vm.set): cpusMax (shame) 2016-05-24 15:13:53 +02:00
Julien Fontanet
b2611728a1 fix(vm): fix indent 2016-05-24 14:38:11 +02:00
Julien Fontanet
fc6cc4234d chore(vm.set): fix some comments 2016-05-24 14:33:40 +02:00
Julien Fontanet
7706c1cb63 feat(vm.set): memoryStaticMax 2016-05-24 14:33:02 +02:00
Julien Fontanet
4d7a07220c feat(vm.set): memoryMax increase static max if necessary 2016-05-24 14:32:14 +02:00
Julien Fontanet
436875f7dc fix(vm.set): memoryMin should not change static min 2016-05-24 14:30:26 +02:00
Julien Fontanet
21c6f53ecc fix(vm.set): cpusMax 2016-05-24 14:23:21 +02:00
Julien Fontanet
5472be8b72 4.17.0 2016-05-24 11:51:15 +02:00
Julien Fontanet
d22542fcf3 Revert "fix(leveldown): fix leveldown to version 1.4.4"
This reverts commit 5fa4c95480.
2016-05-24 11:50:36 +02:00
Julien Fontanet
1d8341eb27 Merge branch 'next-release' into stable 2016-05-24 11:49:47 +02:00
Julien Fontanet
1897a7ada3 fix(log.get): only usable by admins 2016-05-23 16:18:21 +02:00
Julien Fontanet
a048698c66 feat(log.*): add params schemas 2016-05-23 16:17:54 +02:00
Julien Fontanet
f891e57f4a fix(xapi-objects-to-xo): a SR should always have a container 2016-05-23 16:00:51 +02:00
Olivier Lambert
fcc590e48a feat(vm.snapshot): name param is optional (#320) 2016-05-23 12:56:20 +02:00
Julien Fontanet
9a02a2a65b fix(vm.set): fix call to $isVmRunning
Fixes #319
2016-05-23 10:02:34 +02:00
Julien Fontanet
536a6c5c60 feat(vm.rollingDrCopy): accepts a sr param (#315)
See vatesfr/xo-web#955
2016-05-21 14:24:16 +02:00
Julien Fontanet
86a6871ee8 fix(vm.set): correctly change min dynamic memory if necessary (#317)
Fixes vatesfr/xo-web#970
2016-05-21 14:14:57 +02:00
Julien Fontanet
6046045151 feat(vm.createInterface): position param is now optional 2016-05-21 13:11:51 +02:00
Julien Fontanet
9c3ddd4ba4 fix(Xapi#_createVm()): license issue with Dundee (#316)
Fixes vatesfr/xo-web#964.
2016-05-20 12:22:42 +02:00
Julien Fontanet
6c9f55c1d7 style(utils): fix lightSet 2016-05-17 09:08:51 +02:00
Julien Fontanet
5bec3d7dcd fix(xapi-object-to-xo): correctly set host memory size 2016-05-16 11:50:01 +02:00
Julien Fontanet
a4c309efe8 fix(package): ship signin.pug 2016-05-12 18:18:56 +02:00
Jon Sands
4e22a208dd fix(autopoweron): set pool other_config entry to true instead of on (#310)
Fixes #309 
Fixes vatesfr/xo-web#937
2016-05-12 13:17:02 +02:00
Julien Fontanet
ff9e77118e fix(Xapi): VM creation on Dundee (#303) 2016-05-11 18:03:58 +02:00
Julien Fontanet
6c6dfa9ac4 perf(Promise): use Bluebird as default implementation 2016-05-11 18:01:52 +02:00
Greenkeeper
d60d5207d8 chore(package): update xen-api to version 0.9.0 (#308)
https://greenkeeper.io/
2016-05-11 17:55:35 +02:00
ABHAMON Ronan
8c0ae892f5 feat(api): rename <namespace> param to id (#305) 2016-05-11 14:35:49 +02:00
Greenkeeper
f570492a11 chore(package): update xo-remote-parser to version 0.2.0 (#307)
https://greenkeeper.io/
2016-05-11 14:07:23 +02:00
Julien Fontanet
cc447304f5 fix(bin/xo-server): remove ES6 syntax 2016-05-10 13:43:53 +02:00
Julien Fontanet
8f8c6366e3 chore(xo-mixins/backup): use default value for remote handler flags 2016-05-05 18:22:19 +02:00
Julien Fontanet
3b13bcb098 fix(Xapi#exportDeltaVm): make streams property non-enumerable 2016-05-05 18:19:41 +02:00
Julien Fontanet
df60784b51 chore(signin): jade renamed to pug 2016-05-04 16:00:28 +02:00
Julien Fontanet
bae3122bb5 chore: various updates 2016-05-04 12:16:02 +02:00
Julien Fontanet
0770aef4bf chore(package): update standard to version 7.0.0 2016-05-04 11:59:56 +02:00
ABHAMON Ronan
c198350bfa feat(remote-handlers): cannot overwrite files by default (#297) 2016-05-03 16:56:26 +02:00
Greenkeeper
a2ed388777 chore(package): update helmet to version 2.0.0 (#298)
https://greenkeeper.io/
2016-04-30 08:10:22 +02:00
Julien Fontanet
f6670c699a 4.16.1 2016-04-29 10:28:03 +02:00
Julien Fontanet
5fa4c95480 fix(leveldown): fix leveldown to version 1.4.4
Due to Level/leveldown#276.
2016-04-29 10:27:37 +02:00
Julien Fontanet
5b8608c186 feat(utils/streamToBuffer): rebase on get-stream and use everywhere (#295) 2016-04-29 09:52:36 +02:00
Julien Fontanet
bb75d42ede 4.16.0 2016-04-29 09:44:42 +02:00
Julien Fontanet
b4b6def07a Merge branch 'next-release' into stable 2016-04-29 09:43:30 +02:00
Greenkeeper
b305700987 chore(package): update get-stream to version 2.1.0 (#294)
https://greenkeeper.io/
2016-04-29 09:14:30 +02:00
Greenkeeper
40232b7eb1 chore(package): update fs-extra to version 0.30.0 (#293)
https://greenkeeper.io/
2016-04-28 18:17:34 +02:00
Julien Fontanet
67ff666db4 Use the new execa.stdout() 2016-04-28 10:18:05 +02:00
Greenkeeper
5960fd4fe0 chore(package): update fs-extra to version 0.29.0 (#292)
https://greenkeeper.io/
2016-04-28 09:04:39 +02:00
Greenkeeper
f8b28c519c chore(package): update xo-acl-resolver to version 0.1.0 (#291)
https://greenkeeper.io/
2016-04-28 08:56:31 +02:00
Julien Fontanet
ee1105b6dd fix(Xapi#importVdiContent): find first attached PBD (#279) 2016-04-27 09:37:30 +02:00
Julien Fontanet
4778274c97 fix(Xapi#call): retries on TOO_MANY_PENDING_TASKS
Fixes fix vatesfr/xo-web#861
2016-04-27 09:28:36 +02:00
Julien Fontanet
d7ecb32238 Xapi#snapshotVm(): wait for the uptodate obj on quiesce. (#282)
Fixes vatesfr/xo-web#904
2016-04-27 09:24:00 +02:00
Greenkeeper
744306fc50 chore(package): update execa to version 0.4.0 (#290)
https://greenkeeper.io/
2016-04-27 09:13:16 +02:00
Olivier Lambert
11bbb8ed4d add host startTime and agentStartTime 2016-04-26 11:30:57 +02:00
Julien Fontanet
b5092a4444 feat(toTimestamp): handle timestamps. 2016-04-26 11:27:26 +02:00
Greenkeeper
e2442c07a9 https://greenkeeper.io/Fixes vatesfr/xo-web#769
https://greenkeeper.io/

Fixes vatesfr/xo-web#769.
2016-04-26 09:07:33 +02:00
Julien Fontanet
6f924d4e83 fix(user.delete): fix vatesfr/xo-web#901. 2016-04-25 14:33:29 +02:00
Greenkeeper
faf1508914 chore(package): update execa to version 0.3.0 (#284)
https://greenkeeper.io/
2016-04-23 17:51:56 +01:00
Julien Fontanet
7eb8152835 4.15.3 2016-04-22 16:18:21 +02:00
Julien Fontanet
8f45905831 fix(vm.deltaCopy()): delete snapshot when import fails. 2016-04-22 16:18:03 +02:00
Julien Fontanet
4ba2ffce5b fix(vm.deltaCopy()): delete snapshot when import fails. 2016-04-22 13:39:21 +02:00
Greenkeeper
ffb3659ef5 chore(package): update fs-extra to version 0.28.0 (#280)
http://greenkeeper.io/
2016-04-18 12:09:06 +01:00
Julien Fontanet
6dec07d562 signin form: fix redirect on success. 2016-04-18 11:57:58 +01:00
Julien Fontanet
afb22f3279 Merge pull request #278 from vatesfr/greenkeeper-fs-extra-0.27.0
Update fs-extra to version 0.27.0 🚀
2016-04-15 14:14:31 +02:00
greenkeeperio-bot
f2f369db64 chore(package): update fs-extra to version 0.27.0
http://greenkeeper.io/
2016-04-15 14:05:41 +02:00
Julien Fontanet
635c76db93 Deprecate host#CPUs and introduce host#cpus. 2016-04-13 10:59:29 +02:00
Julien Fontanet
5f50f1928d Merge pull request #276 from vatesfr/fix-auto-poweron
Fix auto poweron (fix vatesfr/xo-web#879).
2016-04-11 15:53:37 +02:00
Julien Fontanet
32c9ed1dc2 Fix auto poweron (fix vatesfr/xo-web#879). 2016-04-11 15:31:59 +02:00
Julien Fontanet
0536926a1f 4.15.2 2016-04-08 11:17:47 +02:00
Julien Fontanet
3959c98479 Update xo-acl-resolver to 0.0.0. 2016-04-08 11:17:26 +02:00
Julien Fontanet
2ce5735676 Fix ACLs in API calls (fix vatesfr/xo-web#870). 2016-04-08 11:05:17 +02:00
Julien Fontanet
71741e144e Merge pull request #274 from vatesfr/abhamonr-set-vm-ram-min-max-values
api.vm: Set the min/max ram values.
2016-04-07 10:08:34 +02:00
wescoeur
f2e64cdd5e api.vm: Set the min/max ram values. 2016-04-07 09:25:45 +02:00
Julien Fontanet
afaa5d5e9e Merge pull request #275 from vatesfr/abhamonr-set-vm-cpus-max
api.vm: Set vcpus max.
2016-04-06 17:39:16 +02:00
wescoeur
d82861727d api.vm: Set vcpus max. 2016-04-06 17:32:51 +02:00
Julien Fontanet
90f0795416 Merge pull request #272 from vatesfr/abhamonr-fix-smb-backup-location
Ensure remote smb path is a directory. (fix vatesfr/xo-web#865)
2016-04-06 16:25:28 +02:00
Julien Fontanet
9efbe7771c Merge pull request #273 from vatesfr/abhamonr-consistent-stats-object
vm.stats(): Returns empty stats if none can be found.
2016-04-06 12:10:34 +02:00
wescoeur
a75caac13d Vm stats are consistents. Even without RRD stats. 2016-04-06 11:55:14 +02:00
wescoeur
279d0d20ea Ensure remote smb path is a directory. (fix vatesfr/xo-web#865) 2016-04-06 09:51:20 +02:00
Julien Fontanet
332ba96d34 ghooks: use commit-msg instead of pre-commit. 2016-04-04 11:33:30 +02:00
Julien Fontanet
3f6e5b7606 decorators/@autobind: Minor improvements. 2016-04-04 11:29:31 +02:00
Julien Fontanet
94703492fd Use http-proxy for HTTP/ws proxy. 2016-03-30 17:33:50 +02:00
Julien Fontanet
df78117617 Do not crash on error in the console proxy. 2016-03-30 17:33:50 +02:00
Julien Fontanet
909b9480e4 Better error message in console proxy. 2016-03-30 17:33:49 +02:00
Julien Fontanet
21762ac1aa Return to the correct page after sign in. 2016-03-30 17:33:49 +02:00
Julien Fontanet
412bc175b4 Merge pull request #270 from vatesfr/abhamonr-stats-object-contains-interval
Stats object contains interval attr.
2016-03-30 14:49:25 +02:00
wescoeur
dc0eb76e88 Stats object contains interval attr. 2016-03-30 14:34:37 +02:00
Julien Fontanet
2695941a3c Remove pFinally() tests, now implemented in promise-toolbox. 2016-03-29 18:05:32 +02:00
Julien Fontanet
3506be1a70 Update promise-toolbox to 0.3.2. 2016-03-29 09:54:24 +02:00
Julien Fontanet
cbf4786b39 Do not crash on unhandled error event. 2016-03-27 13:31:31 +02:00
Julien Fontanet
8dbf334208 Merge pull request #267 from vatesfr/back-to-babel-6
Back to babel 6
2016-03-25 17:37:52 +01:00
Julien Fontanet
60ba5fbc72 Merge pull request #268 from vatesfr/abhamonr-stats-with-halted-vm
Throw an error if a vm is halted and its stats are requested.
2016-03-25 17:37:27 +01:00
Julien Fontanet
c3ace0c44f Simply do npm test before git commit. 2016-03-25 17:36:37 +01:00
Olivier Lambert
8eceb90e63 add startTime 2016-03-25 17:33:34 +01:00
wescoeur
4754e19e83 Throw an error if a vm is halted and its stats are requested. 2016-03-25 15:49:52 +01:00
Julien Fontanet
a0559d0dc9 Revert "Work around Babel T7172."
This reverts commit ca8476d466.
2016-03-23 09:45:59 +01:00
Julien Fontanet
8d03ce19b0 Revert "Merge pull request #248 from vatesfr/babel-t7172"
This reverts commit f125b593bf, reversing
changes made to ca8476d466.
2016-03-23 09:43:30 +01:00
Julien Fontanet
2470d851e9 Revert "Merge pull request #266 from vatesfr/babel-5-workaround"
This reverts commit b77d3f123d, reversing
changes made to c10b0afaa8.
2016-03-23 09:41:54 +01:00
Julien Fontanet
df99f5c0a5 Revert "Merge pull request #265 from vatesfr/revert-babel-6"
This reverts commit 8907290d27, reversing
changes made to eb55cba34a.
2016-03-23 09:41:08 +01:00
Julien Fontanet
36f5084c52 4.15.1 2016-03-22 15:13:54 +01:00
Olivier Lambert
b77d3f123d Merge pull request #266 from vatesfr/babel-5-workaround
Xapi#migrateVm(): Babel 5 workaround. Fix vatesfr/xo-web/issues/831
2016-03-22 13:46:31 +01:00
Julien Fontanet
3c14405155 Xapi#migrateVm(): Babel 5 workaround. 2016-03-22 13:21:56 +01:00
Julien Fontanet
c10b0afaa8 Xapi#copyVm(): wait copy to finish before deleting snapshot. 2016-03-22 12:14:15 +01:00
Julien Fontanet
3f7a2d6bfb Xapi#copyVm(): fix snapshot deletion. 2016-03-22 12:07:35 +01:00
Julien Fontanet
f2a0d56e01 Update xen-api to 0.7.4. 2016-03-22 10:23:29 +01:00
Julien Fontanet
0736cc8414 4.15.0 2016-03-21 16:36:17 +01:00
Julien Fontanet
53240d40a0 vm.delete(): Fix :: usage in CoffeeScript. 2016-03-21 15:55:19 +01:00
Julien Fontanet
4137dd7cc8 Xo/ResourceSet#computeVmResourcesUsage(): fix access to Xo#getXapi(). 2016-03-21 15:29:41 +01:00
Julien Fontanet
8907290d27 Merge pull request #265 from vatesfr/revert-babel-6
Revert "Merge pull request #193 from vatesfr/babel-6"
2016-03-21 15:09:37 +01:00
Julien Fontanet
401dc1cb10 Revert "Minor fixes related to Babel 6."
This reverts commit a9a1472cb7.
2016-03-21 13:02:34 +01:00
Julien Fontanet
a6b5d26f56 Revert "Merge pull request #193 from vatesfr/babel-6"
This reverts commit 250b0eee28, reversing
changes made to 57ebd5bb7a.
2016-03-21 13:02:34 +01:00
Julien Fontanet
eb55cba34a Xapi#exportDeltaVm(): fix handling of empty VBDs. 2016-03-21 13:00:56 +01:00
Julien Fontanet
b0b41d984e Update @marsaud/smb2-promise to 0.2. 2016-03-21 12:38:12 +01:00
Julien Fontanet
947f64e32d SmbHandler: fix error normalization. 2016-03-18 16:54:58 +01:00
Julien Fontanet
24ccbfa9b6 Test before commit. 2016-03-18 16:40:15 +01:00
Olivier Lambert
8110acb795 removing the debug mode for Vhd merge 2016-03-18 16:30:48 +01:00
Olivier Lambert
7473aede60 Merge pull request #259 from vatesfr/abhamonr-delta-backups-with-smb
Delta backups works with samba
2016-03-18 16:28:44 +01:00
wescoeur
6f204f721b Delta backups works with samba.
Many fixes (linux paths, windows errors support...)
All options in smb handlers have a default value.
Remove the handler._remote.path usage.
...
2016-03-18 14:57:14 +01:00
Olivier Lambert
7b0e08094a Merge pull request #264 from vatesfr/abhamonr-delta-backup-with-quiesce
Delta backup works with quiesce. (fix vatesfr/xo-web#812)
2016-03-18 14:47:12 +01:00
wescoeur
322e1a75b9 Delta backup works with quiesce. (fix vatesfr/xo-web#812) 2016-03-18 10:20:49 +01:00
Olivier Lambert
a0806d98a1 Merge pull request #263 from vatesfr/pierre-feedback-when-error-on-sr
`GenericXoError` to throw errors with human readable message.
2016-03-16 17:48:33 +01:00
Olivier Lambert
182897d971 Merge branch 'next-release' into pierre-feedback-when-error-on-sr 2016-03-16 17:42:32 +01:00
Pierre
f90a639fcc Minor fix. 2016-03-16 15:52:29 +01:00
Pierre
d95d7208a2 Minor fix. 2016-03-16 15:42:53 +01:00
Pierre
bbac8ffe64 Substituted all JsonRpcErrors by GenericErrors. 2016-03-16 15:34:19 +01:00
Pierre
801a649fb1 GenericXoError: Error with human readable message property. Used on PBD.unplug 2016-03-16 14:59:32 +01:00
Olivier Lambert
7c09ceecfd Merge pull request #262 from vatesfr/pierre-network-management
PIFs and networks management (See vatesfr/xo-web#805)
2016-03-16 11:22:06 +01:00
Pierre
8c4954fb9b Camel case fixes in pif.js 2016-03-16 10:55:15 +01:00
Pierre
fbe892105b Cast. Removed unused pieces of code. Minor fixes. 2016-03-16 10:29:42 +01:00
Pierre
584e1bb847 reconfigureIp to set the IP, netmask, DNS and gateway of a PIF 2016-03-16 10:12:40 +01:00
Pierre
c437ab282e Detroy VLANs and destroy network 2016-03-16 10:12:40 +01:00
Pierre
42a100d138 Delete network 2016-03-16 10:12:40 +01:00
Pierre
65807bf35d Fixes. 2016-03-16 10:12:40 +01:00
Pierre
2995f48ede network.create instead of createNetwork for host and pool 2016-03-16 10:12:40 +01:00
Julien Fontanet
d452702aef Better error messages on web server failure. 2016-03-11 23:41:51 +01:00
Julien Fontanet
f8ed9c7357 Merge pull request #260 from vatesfr/pierre-pool-networks
`createNetwork` on pool: network creation on pool.master (See vatesfr/xo-web#226)
2016-03-11 15:26:37 +01:00
Pierre
9143120177 network.create instead of createNetwork for host and pool 2016-03-11 11:57:12 +01:00
Pierre
fd3b1bee92 Code mutualization between host and pool. 2016-03-11 11:57:11 +01:00
Pierre
bff42954d1 createNetwork on pool: network creation on pool.master 2016-03-11 11:57:11 +01:00
Julien Fontanet
6b74fd6a02 plugin.get(): Expose versions (see vatesfr/xo-web#807). 2016-03-09 14:51:34 +01:00
Julien Fontanet
0547cebfe2 Import package.json explicitely to make dependency-check happy. 2016-03-09 11:46:09 +01:00
Julien Fontanet
caefdf4300 system.getServerVersion() (see vatesfr/xo-web#807). 2016-03-09 11:37:03 +01:00
Olivier Lambert
a59df15994 Merge pull request #255 from vatesfr/olivierlambert-cifs-iso
Prepare user/pass for CIFS ISO share
2016-03-04 13:49:08 +01:00
Olivier Lambert
33304eb8d9 add type in the new SR API 2016-03-04 13:37:37 +01:00
Olivier Lambert
eb21a1bfb3 support SMB ISO SR 2016-03-04 13:37:37 +01:00
Olivier Lambert
ce0333b0a7 prepare user/pass for CIFS ISO share 2016-03-04 13:37:37 +01:00
Julien Fontanet
25a1b53a91 Prints unhandled rejection ASAP. 2016-03-04 11:46:15 +01:00
Julien Fontanet
6aba73f970 Use ::pCatch(noop) instead of .catch(noop).
Avoid hiding programmer errors.
2016-03-04 11:21:33 +01:00
Julien Fontanet
6406bb7fb6 FIXME: remote type gessing should be done in xo-remote-parser. 2016-03-03 17:32:09 +01:00
Julien Fontanet
2458107903 Merge pull request #258 from vatesfr/marsaudf-fix-nfsHandler
Fix NFS remote handler.
2016-03-03 12:41:42 +01:00
Fabrice Marsaud
628f9bd9b5 Fixed findmnt call 2016-03-03 12:32:22 +01:00
Julien Fontanet
2d791571d5 Merge pull request #257 from vatesfr/julien-f-remove-unnecessary-await
Remove unnecessary `await`s.
2016-03-03 12:28:50 +01:00
Olivier Lambert
ed57127a79 Merge pull request #251 from vatesfr/host-state-unknown
New host state: Unknown.
2016-03-03 12:25:00 +01:00
Julien Fontanet
6d9bcff8e1 Remove unnecessary awaits.
- slightly improve perf
- slightly better stack traces
2016-03-03 12:24:22 +01:00
Julien Fontanet
8126cd1879 New host state: Unknown. 2016-03-03 12:15:30 +01:00
Julien Fontanet
ab34c2261c server.getAll(): fix related to xen-servers mixin. 2016-03-03 11:25:20 +01:00
Olivier Lambert
6953f65970 Merge pull request #256 from vatesfr/fix-vm-recoveryStart
Xapi#startVmOnCd(): fix for HVM (fix vatesfr/xo-web#794).
2016-03-03 10:10:10 +01:00
Julien Fontanet
52073e79fa Xapi#startVmOnCd(): fix for HVM (fix vatesfr/xo-web#794). 2016-03-03 10:02:09 +01:00
Julien Fontanet
8e3484bb17 Merge pull request #252 from vatesfr/better-default-https
Better defaults HTTPs config.
2016-03-02 18:04:05 +01:00
Julien Fontanet
7110da8a36 Better defaults HTTPs config. 2016-03-02 17:12:32 +01:00
Julien Fontanet
7ffd6ded51 Merge pull request #250 from vatesfr/pierre-licenses
Host and pool licenses (Fix vatesfr/xo-web#763)
2016-03-02 16:12:04 +01:00
Julien Fontanet
5e04547ecf Merge pull request #249 from vatesfr/recompute-resource-sets-limits
resourceSet.recomputeAllLimits()
2016-03-02 15:43:40 +01:00
Julien Fontanet
7cbe5f64ce Fix Xo#getXapi(). 2016-03-02 15:41:27 +01:00
Julien Fontanet
47ed78031a Xo#getAllXenServers(). 2016-03-02 15:23:32 +01:00
Pierre
fd3d24b834 getLicenseState 2016-03-02 15:15:10 +01:00
Pierre
c2f607b452 license_params and license_servers in XO host object 2016-03-02 15:15:09 +01:00
Julien Fontanet
b1328bb6e2 resourceSet.recomputeAllLimits() 2016-03-02 15:09:16 +01:00
Julien Fontanet
2a02583e27 Fix Xo#getXapi() with identifier. 2016-03-02 13:48:33 +01:00
Julien Fontanet
cfb49f9136 Merge pull request #247 from vatesfr/too-many-storage-migrates
Xapi#migrateVm(): handle TOO_MANY_STORAGE_MIGRATES (fix vatesfr/xo-we…
2016-03-02 12:47:00 +01:00
Julien Fontanet
5f20091f24 Xapi#migrateVm(): handle TOO_MANY_STORAGE_MIGRATES (fix vatesfr/xo-web#783).
When this error occurs, simply wait 10 seconds and retry.
2016-03-02 12:45:25 +01:00
Julien Fontanet
a37b8e35a1 utils: isInteger(). 2016-03-02 11:30:23 +01:00
Julien Fontanet
84c980c3ea utils: isObject(). 2016-03-02 11:07:13 +01:00
Julien Fontanet
5823057b41 utils: isArray(), isBoolean(), isFunction() & isString(). 2016-03-02 11:02:42 +01:00
Julien Fontanet
024a9b1763 Merge pull request #246 from vatesfr/xo-mixins-2
Xo mixins 2
2016-03-02 10:50:17 +01:00
Julien Fontanet
0425780cd3 vm.create(): fix setting name/description for disks (vatesfr/xo-web#774). 2016-03-02 10:49:15 +01:00
Julien Fontanet
20734dc7f3 Move authorization to a new mixin. 2016-03-02 10:38:06 +01:00
Julien Fontanet
0574c58f16 Move ACLs management to a new mixin. 2016-03-02 10:38:06 +01:00
Julien Fontanet
31e3117190 Move Xen servers management to a new mixin. 2016-03-02 10:38:06 +01:00
Julien Fontanet
f780ba2c5a vm.create(): fix updating existing disks (vatesfr/xo-web#774). 2016-03-02 10:34:44 +01:00
Olivier Lambert
f125b593bf Merge pull request #248 from vatesfr/babel-t7172
Work around Babel T7172 (second attempt).
2016-03-02 10:22:47 +01:00
Julien Fontanet
baee4e185d Work around Babel T7172 (second attempt). 2016-03-02 10:14:50 +01:00
Julien Fontanet
ca8476d466 Work around Babel T7172. 2016-03-02 10:04:12 +01:00
Julien Fontanet
757bf82a78 Merge branch 'stable' into next-release 2016-02-29 09:31:12 +01:00
Olivier Lambert
644887f727 4.14.4 2016-02-28 17:20:17 +01:00
Olivier Lambert
563b643461 Fix NFS mount issues for Linux target 2016-02-28 17:20:02 +01:00
Julien Fontanet
0e4a6fd2e1 Merge pull request #245 from vatesfr/pierre-cpu-weight-in-resource-set
vm.set(): only admins can change cpuWeight if VM in a resource set
2016-02-26 12:29:31 +01:00
Pierre
d452bf1f1c vm.set(): only admins can change cpuWeight if VM in a resource set 2016-02-26 12:22:40 +01:00
Julien Fontanet
126828a813 http-request: another work around for the Babel issue 2016-02-26 11:26:02 +01:00
Julien Fontanet
03dc6fb73a http-request: work around Babel issue. 2016-02-26 11:16:43 +01:00
Julien Fontanet
3653e89714 Merge branch 'stable' into next-release 2016-02-26 10:23:51 +01:00
Julien Fontanet
318dd14e42 4.14.3 2016-02-26 10:23:27 +01:00
Julien Fontanet
2d13844b5d Disable npm {pre,post}version magic for now. 2016-02-26 10:23:20 +01:00
Julien Fontanet
b777b7432a Merge pull request #244 from vatesfr/olivierlambert-nfs-fix
Add v3 parameter for NFS. Fix vatesfr/xo-web/issues/771
2016-02-26 10:12:24 +01:00
Olivier Lambert
6f91c225c2 Add v3 parameter for NFS. Fix vatesfr/xo-web/issues/771 2016-02-26 10:06:18 +01:00
Julien Fontanet
c355e9ca4a Xo/subjects: fix access to Xo private props (fix #755). 2016-02-25 11:36:52 +01:00
Julien Fontanet
4514ea8123 Minor fixes related to promise-toolbox. 2016-02-24 18:22:18 +01:00
Julien Fontanet
a9a1472cb7 Minor fixes related to Babel 6. 2016-02-24 18:22:00 +01:00
Julien Fontanet
250b0eee28 Merge pull request #193 from vatesfr/babel-6
Upgrade to Babel 6.
2016-02-24 16:18:36 +01:00
Julien Fontanet
5cd7527937 Upgrade to Babel 6. 2016-02-24 16:11:35 +01:00
Julien Fontanet
57ebd5bb7a Merge pull request #242 from vatesfr/use-promise-toolbox
Use promise-toolbox.
2016-02-24 16:11:13 +01:00
Julien Fontanet
c18a697d6b Use promise-toolbox. 2016-02-24 15:17:11 +01:00
Julien Fontanet
ad40b72508 4.14.2 2016-02-24 13:51:49 +01:00
Julien Fontanet
3a72e5910d Add preversion/postversion scripts. 2016-02-24 13:50:47 +01:00
Julien Fontanet
8f3eb65a05 Various fixes. 2016-02-24 13:34:12 +01:00
Julien Fontanet
700cd83ff5 4.14.1 2016-02-24 10:34:10 +01:00
Julien Fontanet
0c27881eaf vm.create(): register up-to-date VM object (fix vatesfr/xo-web#749 2016-02-24 10:21:53 +01:00
Julien Fontanet
f7fdc6acd2 4.14.0 2016-02-23 19:10:57 +01:00
Julien Fontanet
2c5f844edc Merge pull request #229 from vatesfr/resource-sets
Resource sets
2016-02-23 19:03:34 +01:00
Julien Fontanet
a253de43c5 vm.create(): correctly handle updating SR on existing disks. 2016-02-23 18:57:00 +01:00
Julien Fontanet
dbaf67a986 vm.set(): correctly count limits for CPUs. 2016-02-23 18:03:54 +01:00
Julien Fontanet
5175d06e37 vm.create(): handle limits on template disks. 2016-02-23 17:53:41 +01:00
Julien Fontanet
651a27b558 resource set: limit.available cannot be > limit.total. 2016-02-23 17:16:13 +01:00
Julien Fontanet
fd41f8def6 vm.delete(): correctly free resource set limits. 2016-02-23 17:12:19 +01:00
Julien Fontanet
208ea04fd5 resourceSet.set(): better handling of limits. 2016-02-23 15:20:20 +01:00
Julien Fontanet
5ee83a1af9 Merge pull request #241 from vatesfr/a-schedule-links-a-function
Scheduler is now in scheduling.js and use ScheduleFn function.
2016-02-23 15:06:55 +01:00
wescoeur
901c7704f4 Scheduler is now in scheduling.js and use ScheduleFn function. 2016-02-23 15:01:30 +01:00
Julien Fontanet
c6f7290f92 resourceSet.{create,set}(): limits are optional. 2016-02-23 13:11:40 +01:00
Julien Fontanet
5368eda98b vm.set(): works with resource sets. 2016-02-23 13:06:36 +01:00
Julien Fontanet
7b9be209c8 resourceSet: initial limits. 2016-02-23 10:33:50 +01:00
Julien Fontanet
cee05fea7c Some permission fixes fro vm.*(). 2016-02-22 19:23:32 +01:00
Julien Fontanet
b87acb47e2 Lots of TODOs in vm.*(). 2016-02-22 18:44:18 +01:00
Julien Fontanet
cb192bf9ea vm.convertToTemplate(): require pool admin permission. 2016-02-22 18:30:28 +01:00
Julien Fontanet
16351ba7f3 Merge pull request #236 from vatesfr/abhamonr-vhd-util-without-binary
Remove dependency on vhd-util for VHD merging
2016-02-22 14:02:40 +01:00
wescoeur
96ba128942 Remove vhd-util dependency. Merging vhd works with a node script. (fix vatesfr/xo-web#646) 2016-02-22 13:59:33 +01:00
Julien Fontanet
76c8d4af25 API: fix various permissions. 2016-02-19 16:37:27 +01:00
Julien Fontanet
3ea2b3cc00 vm.createCloudInitConfigDrive(): disable permission check on SR. 2016-02-19 16:37:27 +01:00
Julien Fontanet
0df0936022 resourceSet: fix getAll() and checkConstraints(). 2016-02-19 16:37:27 +01:00
Julien Fontanet
4fc11a7fd3 resourceSet.{add,remove}Subject(): minor fixes. 2016-02-19 16:37:27 +01:00
Julien Fontanet
8c509271a6 resourceSet.getAll(): code has been refactored around streamToArray(). 2016-02-19 16:37:27 +01:00
Julien Fontanet
67d5b63ef9 vm.create(): works with resource sets. 2016-02-19 16:37:27 +01:00
Julien Fontanet
4f999511a6 resourceSet.getAll(): code has been refactored around lightSet(). 2016-02-19 16:37:27 +01:00
Julien Fontanet
cfbf239175 resourceSet.getAll(): works also for non-admins. 2016-02-19 16:37:27 +01:00
Julien Fontanet
1aedf9bb07 resourceSet: fix deletion. 2016-02-19 16:37:27 +01:00
Julien Fontanet
c2d4423720 Fix: start event instead of starting. 2016-02-19 16:37:27 +01:00
Julien Fontanet
c2f7a2620c api: fix access to private Xo properties. 2016-02-19 16:37:27 +01:00
Julien Fontanet
6f0cda34b4 Xo/Subjects: Fix admin user creation. 2016-02-19 16:37:27 +01:00
Julien Fontanet
1a472fdf1f Xo: subjects managements moved into new mixin. 2016-02-19 16:37:27 +01:00
Julien Fontanet
0551f61228 Resource sets: use store. 2016-02-19 16:37:27 +01:00
Julien Fontanet
b900adfddd Promisify store. 2016-02-19 16:37:27 +01:00
Julien Fontanet
0e339daef5 Typo. 2016-02-19 16:37:27 +01:00
Julien Fontanet
5f5733e8b9 Various fixes and additions to resourceSet API. 2016-02-19 16:37:27 +01:00
Julien Fontanet
1372050a7b LevelDbLogger: avoid increments in keys when not necessary. 2016-02-19 16:37:27 +01:00
Julien Fontanet
1960951c5e Initial resource sets. 2016-02-19 16:37:27 +01:00
Julien Fontanet
bc070407c7 generate-indexes: rewritten in Node
- cross-platform
- properly camel-cases identifiers
2016-02-19 16:37:27 +01:00
Julien Fontanet
0172ee0b6b Remove unused import. 2016-02-19 16:37:27 +01:00
Julien Fontanet
2953bc6bb8 loggers: LevelDbLogger now inherits from AbstractLogger. 2016-02-19 16:37:27 +01:00
Julien Fontanet
c0ed3a9e3c Xo#getStore(namespace). 2016-02-19 16:37:27 +01:00
Julien Fontanet
5456e4fe75 Merge branch 'stable' into next-release 2016-02-19 16:36:59 +01:00
Julien Fontanet
867a1e960e Merge pull request #240 from vatesfr/stream-to-array
util: streamToArray(Stream, filter?: Predicate) => Promise.
2016-02-18 17:02:25 +01:00
Julien Fontanet
48dc68c3fe util: streamToArray(Stream, filter?: Predicate) => Promise. 2016-02-18 16:58:17 +01:00
Julien Fontanet
2c719f326b Xapi: lodash.pick() → lodash.pickBy(). 2016-02-18 15:45:28 +01:00
Julien Fontanet
201f92eb93 system.getMethodsInfo(): Fix breakage due to upgrade to Lodash v4. 2016-02-18 15:39:08 +01:00
Julien Fontanet
46f055b216 Merge pull request #137 from vatesfr/abhamonr-job-schema
Add: Job and crossProduct schemas.
2016-02-17 10:29:40 +01:00
Julien Fontanet
08305e679b http-proxy: agent is now the default export. 2016-02-17 09:53:00 +01:00
Julien Fontanet
e9e0b70199 Merge pull request #238 from bartekrutkowski/next-release
Correct the redis protocol in sample config.
2016-02-16 16:49:50 +01:00
Bartek Rutkowski
441d784027 Correct the redis protocol in sample config
The existing sample configuration file documents the Redis uri string with 'tcp://' prefix string, while xo-server actually expects it to be 'redis://' instead.
2016-02-16 15:47:21 +00:00
Julien Fontanet
558956bf55 Merge pull request #237 from vatesfr/http-proxy
HTTP proxy support (fix vatesfr/xo-web#737).
2016-02-16 15:57:29 +01:00
Julien Fontanet
0d8250a3ac HTTP proxy support (fix vatesfr/xo-web#737). 2016-02-16 15:50:28 +01:00
Julien Fontanet
dc1f5826f8 Lodash 4 iteration: no thisArg argument. 2016-02-16 15:50:10 +01:00
Julien Fontanet
06fb06829b Update lodash.* deps. 2016-02-16 11:53:53 +01:00
Julien Fontanet
bbf52d2611 Update deps. 2016-02-16 11:53:22 +01:00
Julien Fontanet
f55a6617e9 Remove graceful-fs: not used directly by xo-server. 2016-02-16 11:48:52 +01:00
Julien Fontanet
3bd273fbdd Merge pull request #235 from vatesfr/abhamonr-avoid-merge-delta-delta
Avoid merge between two delta vdi backups. (fix vatesfr/xo-web#702)
2016-02-11 17:32:28 +01:00
wescoeur
1b64a543f1 Avoid merge between two delta vdi backups. (fix vatesfr/xo-web#702) 2016-02-11 16:42:50 +01:00
Julien Fontanet
97b07f7d42 The main bug tracker is xo-web. 2016-02-08 15:34:13 +01:00
Olivier Lambert
ebb472b8f6 4.13.2 2016-02-05 13:01:49 +01:00
Olivier Lambert
1a2ef6479e Merge pull request #232 from vatesfr/fix-xapi-updateObjectMapProperty
Xapi#_updateObjectMapProperty(): fix major issue.
2016-02-05 13:00:58 +01:00
Olivier Lambert
876c63fe80 4.13.1 2016-02-05 13:00:02 +01:00
Julien Fontanet
32236962f5 Xapi#_updateObjectMapProperty(): fix major issue. 2016-02-05 12:53:39 +01:00
Julien Fontanet
ba66af922f 4.13.0 2016-02-04 19:43:43 +01:00
Julien Fontanet
28b9bbe54f 4.13.0-0 2016-02-04 18:01:04 +01:00
Julien Fontanet
bf6bd7cbdc Merge pull request #230 from vatesfr/pierre-vm-migration-details
Fix intra-pool migration on different SRs
2016-02-04 17:30:14 +01:00
Pierre
ddcb2468a6 Minor fixes 2016-02-04 17:26:27 +01:00
Pierre
f048b58935 Fix intra-pool migration on different SRs 2016-02-04 17:17:09 +01:00
Julien Fontanet
09f6200c2e Merge pull request #209 from vatesfr/abhamonr-checksum-verification-delta-backup
Create and verify checksums for VDI delta backups
2016-02-04 16:12:54 +01:00
wescoeur
354692fb06 Add checksum verification for delta backup on restore/merge. (fix vatesfr/xo-web#617) 2016-02-04 15:22:14 +01:00
Julien Fontanet
2c5858c2e0 Merge pull request #228 from vatesfr/pierre-vm-migration-details
Fix default migration
2016-02-04 15:18:31 +01:00
Pierre
1f41fd0436 Better handle of undefined maps 2016-02-04 11:36:04 +01:00
Pierre
e0bbefdfae Fix default migration 2016-02-04 11:02:43 +01:00
Julien Fontanet
bc6fbb2797 Xo#registerPlugin(): log errors. 2016-02-04 10:32:36 +01:00
Julien Fontanet
b579cf8128 Merge pull request #227 from vatesfr/https-redirect
Can redirect to HTTPs (fix vatesfr/xo-web#626).
2016-02-04 09:55:12 +01:00
Julien Fontanet
a94ed014b7 sample config: add redirectToHttps. 2016-02-04 09:52:37 +01:00
Julien Fontanet
0db991b668 Can redirect to HTTPs. 2016-02-03 17:39:39 +01:00
Julien Fontanet
347ced6942 Merge pull request #214 from vatesfr/better-https
Better https (fix vatesfr/xo-web#685)
2016-02-03 14:32:25 +01:00
Olivier Lambert
5d7a775b2b Merge pull request #225 from vatesfr/xo-acl-resolver
Use xo-acl-resolver.
2016-02-03 14:29:31 +01:00
Julien Fontanet
df732ab4bf Merge pull request #216 from vatesfr/vdi-snapshot-type
VDI-snapshot type
2016-02-03 14:14:42 +01:00
Fabrice Marsaud
31cd3953d6 Fixing VM object properties 2016-02-03 13:56:15 +01:00
Julien Fontanet
4666b13892 Use xo-acl-resolver. 2016-02-03 11:47:02 +01:00
Julien Fontanet
37d7ddb4b0 Merge pull request #224 from vatesfr/pierre-vm-migration-details
Custom VM migration (See vatesfr/xo-web#567)
2016-02-03 11:39:53 +01:00
Fabrice Marsaud
3abbaeb44b resolving VDI snapshots 2016-02-03 10:38:09 +01:00
Fabrice Marsaud
847ea49042 VDI-snapshot type 2016-02-03 09:57:42 +01:00
Julien Fontanet
779068c2ee HTTP security: use Helmet. 2016-02-02 20:49:33 +01:00
Julien Fontanet
140cd6882d Allows full TLS config. 2016-02-02 20:45:06 +01:00
Julien Fontanet
2e295c2391 Merge pull request #213 from vatesfr/fix-cpu-weight
Fixed cpuWeight removal for default
2016-02-02 10:24:32 +01:00
Fabrice Marsaud
596b0995f4 Prepare object values for xapi 2016-02-02 10:11:39 +01:00
Fabrice Marsaud
b61fe97893 Fixed cpuWeight removal for default 2016-02-02 09:55:40 +01:00
Julien Fontanet
209aa2ebe6 Add a TODO. 2016-02-01 17:14:05 +01:00
Julien Fontanet
c03a0e857e Merge pull request #188 from vatesfr/olivierlambert-cpu-weight
Ability to set vCPU weight
2016-02-01 16:00:21 +01:00
Olivier Lambert
2854d698e6 Implement vCPU weight 2016-02-01 15:56:36 +01:00
Pierre
944163be0e Bug fix: VDIs should be on chosen SRs. 2016-01-29 10:07:02 +01:00
Julien Fontanet
269a9eaff0 Xapi: small but important fix concerning imports. 2016-01-28 17:22:44 +01:00
Olivier Lambert
7f9c49cbc4 Merge pull request #208 from vatesfr/pierre-vm-migration-details
Custom VM migration. (See vatesfr/xo-web#567)
2016-01-28 17:02:28 +01:00
Julien Fontanet
2b6bfeeb15 Merge pull request #212 from vatesfr/contrep-better-snapshot-names
continous replication: clearer VM snapshot names.
2016-01-28 16:05:03 +01:00
Julien Fontanet
fa9742bc92 continous replication: clearer VM snapshot names. 2016-01-28 15:57:25 +01:00
Pierre
472e419abc Using forEach instead of for. Minor fixes. 2016-01-28 13:33:43 +01:00
Pierre
169d11387b Custom VM migration (See vatesfr/xo-web#567)
Optional parameters for migratePool:
- Migration network
- Map each VDI to an SR on destination host
- Map each VIF to a network on destination host
2016-01-28 13:33:43 +01:00
Julien Fontanet
e59ac6d947 Fixes regarding #660. 2016-01-28 11:42:06 +01:00
Olivier Lambert
e193b45562 Merge pull request #207 from vatesfr/abhamonr-avoid-metadata-imp-exp-delta-backups
Avoid metadata import/export in delta backups. (fix vatesfr/xo-web#651)
2016-01-28 11:35:04 +01:00
wescoeur
1ac34f810e Avoid metadata import/export in delta backups. (fix vatesfr/xo-web#651) 2016-01-28 11:12:21 +01:00
Olivier Lambert
e65e5c6e5f Merge pull request #211 from vatesfr/marsaudf-clear-logs#661
Marsaudf clear logs#661
2016-01-28 10:59:37 +01:00
Fabrice Marsaud
af6365c76a logger.delete 2016-01-28 09:00:15 +01:00
Julien Fontanet
8c672b23b5 Merge pull request #159 from vatesfr/marsaudf-smb-mounts#338
Remotes refactoring + SMB implementation.
2016-01-27 11:24:52 +01:00
Fabrice Marsaud
3b53f5ac11 fixes 2016-01-27 10:58:16 +01:00
Fabrice Marsaud
ccdc744748 fixes 2016-01-27 10:08:59 +01:00
Fabrice Marsaud
261f0b4bf0 typo fix 2016-01-27 09:11:45 +01:00
Fabrice Marsaud
495b59c2e5 update dependency 2016-01-26 17:34:00 +01:00
Fabrice Marsaud
d6e1c13c39 Handler and remotes reworked 2016-01-26 17:28:27 +01:00
Fabrice Marsaud
f7f13b9e07 PR feedback 2 2016-01-26 09:47:47 +01:00
Fabrice Marsaud
62564d747f Errors moved from API to core 2016-01-25 17:29:18 +01:00
Fabrice Marsaud
1d5d59c4c0 Remote handler reworked 2016-01-25 17:01:14 +01:00
Fabrice Marsaud
e8380b8a12 PR feedback 2016-01-25 11:45:53 +01:00
Fabrice Marsaud
c304d9cc62 No vdi merge through smb 2016-01-25 11:45:53 +01:00
Fabrice Marsaud
aad4ebf287 Remote handlers refactored, and adding a smb handler 2016-01-25 11:45:53 +01:00
Olivier Lambert
6c2f48181c Merge pull request #210 from vatesfr/handle-objects-conflicts
Properly handle multiple XAPI objects with the same XO id.
2016-01-22 16:02:19 +01:00
Julien Fontanet
480b6ff7d6 Properly handle multiple XAPI objects with the same XO id.
When there is a conflict, the existing object keep the place but when
it is removed, the other object (which is in the waiting list) will
take the new place.
2016-01-22 15:57:44 +01:00
Julien Fontanet
4bdd6f972c Remove node-inspector. 2016-01-21 16:44:42 +01:00
Olivier Lambert
6674d8456a Merge pull request #206 from vatesfr/olivierlambert-fixMigration
Correctly use destination host SR and network
2016-01-20 18:31:33 +01:00
Olivier Lambert
d1478ff694 select the correct migration network 2016-01-20 18:12:37 +01:00
Julien Fontanet
cb20d46b74 Merge pull request #205 from vatesfr/abhamonr-fix-avoid-errors-delta-backups
Delta backups: Fix various issues.
2016-01-20 17:36:33 +01:00
Olivier Lambert
9dd2538043 correctly use destination host SR and network 2016-01-20 17:26:47 +01:00
wescoeur
f25136a512 Avoid errors in delta backups. (fix)
- Wait the task end of vdi export.
- Now, in the error case of vdi backup,
  the current vdi snapshot is removed with catch(noop).
2016-01-20 17:19:41 +01:00
Julien Fontanet
03eb56ad2a Xapi#_updateObjectMapProperty(): do no hide remove errors. 2016-01-20 16:04:23 +01:00
Julien Fontanet
2508840701 4.12.1 2016-01-19 12:49:37 +01:00
Julien Fontanet
6e098f5a4f Merge pull request #203 from vatesfr/fix-scheduling
Scheduler: properly use Xo#runJobSequense() (fix vatesfr/xo-web#657).
2016-01-19 12:45:36 +01:00
Julien Fontanet
31b33406fd Scheduler: properly use Xo#runJobSequense() (fix vatesfr/xo-web#657). 2016-01-19 12:12:29 +01:00
Julien Fontanet
7ab7c763ed startup: ignore non existent paths in plugins lookup. 2016-01-19 11:49:07 +01:00
Julien Fontanet
06258e757a 4.12.0 2016-01-18 10:25:41 +01:00
Julien Fontanet
5919b43a21 @mixin(): compatibility with Node 0.12 (fix #202). 2016-01-18 10:18:02 +01:00
Julien Fontanet
7d4b9521e7 Merge pull request #199 from vatesfr/continuous-replication
Continuous VM replication.
2016-01-17 23:51:29 +01:00
Julien Fontanet
f9d2fd7997 Xapi: Ugly hack seems to be working. 2016-01-17 23:28:45 +01:00
Julien Fontanet
bdbc20c3c6 Xapi: fix private put() when length is known. 2016-01-17 21:05:18 +01:00
Julien Fontanet
69d6d03714 Better debugs in Xapi. 2016-01-17 21:03:19 +01:00
Julien Fontanet
f40e1e55b0 Xapi#importVdiContent(): revert to use Promise.all() instead of Promise.race(). 2016-01-17 12:52:41 +01:00
Julien Fontanet
b9082ed838 Xapi#deleteVm(): Correctly remove VDIs with more than one VBD on the same VM. 2016-01-17 12:52:04 +01:00
Julien Fontanet
4edfefa9a2 Homogenise task names. 2016-01-17 12:52:04 +01:00
Julien Fontanet
0f98ee5407 Xapi#importVdiContent(): better task name. 2016-01-17 12:50:44 +01:00
Julien Fontanet
7fdf119873 Temporarily disable the ugly put hack. 2016-01-17 12:50:44 +01:00
Julien Fontanet
3c054e6ea1 Various changes. 2016-01-17 12:50:42 +01:00
Julien Fontanet
98899ece72 Use $ to prefix injected params names. 2016-01-17 12:49:23 +01:00
Julien Fontanet
2061a006d0 Xapi#createDeltaVdi(): correctly set the source of cloned VDI. 2016-01-17 12:49:23 +01:00
Julien Fontanet
5496c2d7fd Various fixes. 2016-01-17 12:49:22 +01:00
Julien Fontanet
d6b862a4a9 Xapi#_createVif(): Various fixes. 2016-01-17 12:49:22 +01:00
Julien Fontanet
d581f8a852 Xapi#importDeltaVm(): explicit error when base VDI is not found. 2016-01-17 12:49:22 +01:00
Julien Fontanet
3a593ee35a Xapi#_createVm(): clearer type handling. 2016-01-17 12:49:22 +01:00
Julien Fontanet
415d34fdaa Xo#copyDeltaVm(): Cancel exports on failures. 2016-01-17 12:49:22 +01:00
Julien Fontanet
7d28191bb5 Xapi#exportDeltaVm(): full export if the base is not found. 2016-01-17 12:49:20 +01:00
Julien Fontanet
e2c7693370 Xapi#importVdiContent(): do not wait for connection closure. 2016-01-17 12:48:38 +01:00
Julien Fontanet
f17ff02f4d Continuous replication: do not rely on metadata import/export. 2016-01-17 12:48:35 +01:00
Julien Fontanet
225043e01d Properly identify last snapshot as future base. 2016-01-16 19:34:35 +01:00
Julien Fontanet
56f78349f8 Xen expects keys(other_config) to be snake or it will change them itself! 2016-01-16 19:34:35 +01:00
Julien Fontanet
8839d4f55a Delete exportDeltaVm() snapshot on failure. 2016-01-16 19:34:34 +01:00
Julien Fontanet
2562aec1d2 Missing space in utils.pDebug(). 2016-01-16 19:34:34 +01:00
Julien Fontanet
db2361be84 Fix createVbd(). 2016-01-16 19:34:34 +01:00
Julien Fontanet
d08fcbfef3 Various fixes. 2016-01-16 19:34:29 +01:00
Julien Fontanet
7601b93e65 Various fixes. 2016-01-16 19:19:51 +01:00
Julien Fontanet
1103ec40e0 Xapi#importDeltaVm(): clean after failure. 2016-01-16 19:19:51 +01:00
Julien Fontanet
af32c7e3db Properly exports vm.deltaCopy(). 2016-01-16 19:19:51 +01:00
Julien Fontanet
170918eb3b Initial continuous replication. 2016-01-16 19:19:51 +01:00
Julien Fontanet
a91e615a8d @deferrable.onSuccess() 2016-01-16 19:19:51 +01:00
Julien Fontanet
cc92c26fe3 Xapi#_importVdiContent() 2016-01-16 19:19:46 +01:00
Julien Fontanet
937135db32 Xapi#_exportVdi() 2016-01-16 18:57:15 +01:00
Julien Fontanet
01366558b4 Xapi#_deleteVbd() 2016-01-16 18:57:15 +01:00
Julien Fontanet
b0dbd54ea4 Xapi#_disconnectVbd() 2016-01-16 18:57:15 +01:00
Julien Fontanet
f113915307 Xapi#_updateObjectMapProperty() can remove a property. 2016-01-16 18:57:15 +01:00
Julien Fontanet
0a3c3d9bb1 Xapi#remoteCopyVm() falls back on local copy if possible. 2016-01-16 18:50:09 +01:00
Julien Fontanet
ba2e005c3e Merge pull request #201 from vatesfr/custom-http-request
Custom HTTP request implementation instead of got.
2016-01-16 18:31:21 +01:00
Julien Fontanet
b9ea52d65f Add missing space in forbidden operations description. 2016-01-16 18:27:23 +01:00
Julien Fontanet
f1e328d333 Better error handling in patch unzipping. 2016-01-16 18:13:13 +01:00
Julien Fontanet
23f1965398 Custom HTTP request implementation instead of got. 2016-01-16 18:13:04 +01:00
Olivier Lambert
fc82f185cb Merge pull request #200 from vatesfr/abhamonr-forever-forward-incremental-backup-fix
Old vdi bases must be removed at the backup end.
2016-01-15 14:31:04 +01:00
wescoeur
56b25f373f Old vdi bases must be removed at the backup end. 2016-01-15 14:20:11 +01:00
Olivier Lambert
1ac6add122 Merge pull request #196 from vatesfr/abhamonr-forever-forward-incremental-backup
Forever forward incremental backup (fix vatesfr/xo-web#576)
2016-01-15 14:13:02 +01:00
wescoeur
91b1a903f9 Fix rejected backup. 2016-01-15 13:48:15 +01:00
wescoeur
a8d6654ef5 Forever forward incremental backup (fix vatesfr/xo-web#576) 2016-01-15 13:12:05 +01:00
Olivier Lambert
63093b1be6 Merge pull request #198 from vatesfr/abhamonr-vbd-set-bootable-fix-getxapi
vbd.setBootable use xo.getXapi() instead of xo.getXAPI()
2016-01-14 16:28:16 +01:00
wescoeur
60abe8f37e vbd.setBootable use xo.getXapi() instead of xo.getXAPI() 2016-01-14 16:22:16 +01:00
Olivier Lambert
7ba3909aa1 Merge pull request #175 from vatesfr/abhamonr-button-bootable-disk
Add vbd.setBootable api call.
2016-01-14 16:04:30 +01:00
Julien Fontanet
eecdba2d05 Merge pull request #197 from vatesfr/deferrable-decorator
deferrable() decorator.
2016-01-14 14:33:20 +01:00
Julien Fontanet
7bdc005aa7 @deferrable() works with async functions. 2016-01-14 14:24:09 +01:00
Julien Fontanet
d46703fdc4 Cosmetic changes in decorators spec. 2016-01-14 11:58:18 +01:00
Julien Fontanet
e4aa85f603 Cosmetic changes in decorators. 2016-01-14 11:58:18 +01:00
Julien Fontanet
233124ef50 deferrable.onFailure() 2016-01-14 11:58:11 +01:00
Julien Fontanet
36a3012de2 deferrable() decorator. 2016-01-14 11:16:51 +01:00
Olivier Lambert
2b4ee96ed7 Fix issue vatesfr/xo-web/issues/643 2016-01-13 18:55:35 +01:00
Julien Fontanet
85a2afd55c Add --safe-mode which do not registers plugins. 2016-01-13 15:53:55 +01:00
Julien Fontanet
6cd0d8456a Fix plugins (broken by Xo split). 2016-01-13 15:22:14 +01:00
Julien Fontanet
7750a0a773 Integrate api/xo-mixins indexes to the build. 2016-01-13 15:21:03 +01:00
Julien Fontanet
a5364b9257 Camel case: Xo#getXAPI() → Xo#getXapi(). 2016-01-13 14:39:40 +01:00
Julien Fontanet
e0e7b1406d Fix backups listing (broken by Xo split). 2016-01-13 12:12:40 +01:00
Julien Fontanet
38b67a0002 Merge pull request #192 from vatesfr/mixins
Split Xo with mixins.
2016-01-13 11:47:49 +01:00
Julien Fontanet
18dd4f8a52 Print start/stop errors. 2016-01-13 11:40:52 +01:00
Julien Fontanet
879f9b4ea9 Remove listeners after start/stop. 2016-01-13 11:40:51 +01:00
Julien Fontanet
3db0dda67a Fix a race condition in the scheduler. 2016-01-13 11:40:51 +01:00
Julien Fontanet
ed9ee15b90 Expose Xo#scheduler. 2016-01-13 11:40:51 +01:00
Julien Fontanet
44ff85e8e9 Rename Xo {start,stop}{,ing} events. 2016-01-13 11:40:51 +01:00
Julien Fontanet
cb07e9ba11 Split Xo with mixins. 2016-01-13 11:40:48 +01:00
Julien Fontanet
bfe05ce5fc Merge pull request #184 from vatesfr/abhamonr-disable-vm-start-during-delta-import
Disable vm start during delta import and explicit notification.
2016-01-13 11:25:56 +01:00
wescoeur
64ee23cec0 Disable vm start during delta import and explicit notification. (fix vatesfr/xo-web#613) 2016-01-13 11:20:58 +01:00
Julien Fontanet
c022d3c4a4 Merge pull request #182 from vatesfr/abhamonr-properly-remove-vdi-backups
Only delete VDI exports when VM backup is successful.
2016-01-13 10:38:15 +01:00
wescoeur
69c764301f Only delete VDI exports when VM backup is successful (fix vatesfr/xo-web#644). 2016-01-13 10:33:44 +01:00
Julien Fontanet
2f777daef6 Merge pull request #168 from vatesfr/cleaner-xo-stop
xo-server should properly stops on SIGINT/SIGTERM.
2016-01-12 17:38:30 +01:00
Julien Fontanet
a10bf7330e xo-server should properly stops on SIGINT/SIGTERM. 2016-01-12 17:33:32 +01:00
Julien Fontanet
782bb5967d Update level-party to 3.0.4. 2016-01-12 15:17:15 +01:00
Olivier Lambert
aeb2f55f0d Merge pull request #191 from vatesfr/prevent-concurrent-schedule-runs
A schedule cannot have concurrent runs (fix vatesfr/xo-web#642).
2016-01-11 14:43:24 +01:00
Julien Fontanet
ae68749b1b A schedule cannot have concurrent runs (fix vatesfr/xo-web#642). 2016-01-11 14:00:52 +01:00
Julien Fontanet
a3c25d56a0 Update deps. 2016-01-08 18:39:59 +01:00
Julien Fontanet
d2b9cc8df9 Merge pull request #189 from vatesfr/olivierlambert-change-name-during-import
Change VM name during VM delta import. Fix vatesfr/xo-web/issues/641
2016-01-07 14:08:45 +01:00
Olivier Lambert
2027daa75c Change name during VM delta import. Fix vatesfr/xo-web/issues/641 2016-01-07 14:02:53 +01:00
Julien Fontanet
f3493a08bd Api#addMethod() returns a remover function. 2016-01-05 18:16:04 +01:00
Julien Fontanet
f3963269ae Initialize FAT buffer with null bytes. 2016-01-04 14:43:49 +01:00
Julien Fontanet
ae2212c245 Merge pull request #183 from vatesfr/pierre-delete-running-vm
Delete not halted VMs. (vatesfr/xo-web/issues/616)
2015-12-31 09:48:37 +01:00
Julien Fontanet
3a19ac4c93 Merge pull request #187 from vatesfr/olivierlambert-vif-deletion
VIF delete typo. Fix issue vatesfr/xo-web/issues/632
2015-12-30 20:01:49 +01:00
Olivier Lambert
666f546cf0 VIF delete typo. Fix issue vatesfr/xo-web/issues/632 2015-12-30 19:57:48 +01:00
Julien Fontanet
464f57d7da Merge pull request #186 from vatesfr/olivierlambert-custom-templates
add 'install_repository' support for vatesfr/xo-web/issues/627
2015-12-30 17:21:12 +01:00
Olivier Lambert
2a192f33a1 add 'install_repository' support for vatesfr/xo-web/issues/627 2015-12-30 17:12:26 +01:00
Julien Fontanet
9ca2674261 Make unhandled rejected promises visible on exit. 2015-12-29 10:39:26 +01:00
Julien Fontanet
24bc91dc0c Minor optimizations. 2015-12-23 13:57:29 +01:00
Julien Fontanet
cf2d5b502f Do not remove VDIs attached to other VMs. 2015-12-22 16:27:34 +01:00
Julien Fontanet
61450ef602 Typo. 2015-12-22 16:24:50 +01:00
Julien Fontanet
78f1d1738e Properly ignore snapshot deletion failures after export. 2015-12-22 16:24:00 +01:00
Pierre
9f595cf5f7 Delete not halted VMs. (See vatesfr/xo-web#616) 2015-12-22 15:45:13 +01:00
Julien Fontanet
25b8e49975 4.11.0 2015-12-22 13:35:24 +01:00
Julien Fontanet
d40086cd13 Merge branch 'next-release' into stable 2015-12-22 13:34:57 +01:00
Olivier Lambert
8f9d8d93b9 Merge pull request #181 from vatesfr/fix-vbd-state-after-metadata-import
Fix vbd state after metadata import
2015-12-22 12:23:38 +01:00
Julien Fontanet
1080c10004 Call VM.power_state_reset after a metadata import (fix vatesfr/xo-web#615). 2015-12-22 12:18:02 +01:00
Julien Fontanet
866aeca220 Revert "Snapshots running VM for metadata export (see vatesfr/xo-web#615)."
This reverts commit 121b3afc61.

It is not possible to export metadata of a snapshot.
2015-12-22 11:41:04 +01:00
Julien Fontanet
121b3afc61 Snapshots running VM for metadata export (see vatesfr/xo-web#615). 2015-12-22 11:26:03 +01:00
Julien Fontanet
e8406b04b4 Merge pull request #180 from vatesfr/fix-memory-issue-importVmBackup
Fix memory issue on Xo#importVmBackup().
2015-12-21 19:46:06 +01:00
Julien Fontanet
8e7fe81806 Disable async traces for now (fix vatesfr/xo-web#608). 2015-12-21 19:20:48 +01:00
Olivier Lambert
852807b5d7 Merge pull request #178 from vatesfr/abhamonr-incremental-backups-integration
Some corrections for integration.
2015-12-21 19:05:57 +01:00
Olivier Lambert
9928d47fa2 PR comment review 2015-12-21 19:00:36 +01:00
wescoeur
412a1bd62a Some corrections for delta integration in xo-web.
- List delta backups in subfolders.
- Fix unhandled exception. (ENOENT)
- ...
2015-12-21 17:48:34 +01:00
Julien Fontanet
b290520951 vm.import() accepts a SR id. 2015-12-21 11:13:42 +01:00
Olivier Lambert
dde677b6d3 do NOT backup a CD drive 2015-12-18 21:45:03 +01:00
Julien Fontanet
75030847bd Merge pull request #177 from vatesfr/abhamonr-fix-remote-importVm
The vm import call use a sr instead of a host.
2015-12-18 17:23:48 +01:00
wescoeur
e7b9cb76bc The vm import call use a sr instead of a host. 2015-12-18 17:18:39 +01:00
Olivier Lambert
e96c4c0dd3 restore accidently removed code 2015-12-18 16:56:25 +01:00
Julien Fontanet
b553b3fa50 Merge pull request #176 from vatesfr/olivierlambert-xenstorefix
Fix undefined xenstore_data sent to XAPI
2015-12-18 16:06:50 +01:00
Olivier Lambert
c6fb924b8f Fix undefined xenstore_data sent to XAPI 2015-12-18 16:00:06 +01:00
Julien Fontanet
b13844c4a6 Merge pull request #170 from vatesfr/pierre-read-only-connection
Connection to a Xen Server in read-only mode. (Fix vatesfr/xo-web#439)
2015-12-18 12:09:34 +01:00
Pierre
ab6c83a3fc Connection to a Xen Server in read-only mode. (Fix vatesfr/xo-web#439)
`updateXenServer` applies changes in database and also changes the connection's read-only status if the client is connected to this server.
2015-12-18 11:59:54 +01:00
Julien Fontanet
7e0a97973f Merge pull request #163 from vatesfr/abhamonr-incremental-backups
Implement rolling delta VM backup and import. (vatesfr/xo-web#494)
2015-12-18 11:24:31 +01:00
wescoeur
6a8a79bba5 Implement rolling delta VM backup and import. (vatesfr/xo-web#494) 2015-12-18 11:20:13 +01:00
wescoeur
4a0c58c50a Add vbd.setBootable api call. (fix vatesfr/xo-web/#583) 2015-12-17 17:07:35 +01:00
Julien Fontanet
eb0c963332 Coding style. 2015-12-17 16:21:25 +01:00
Julien Fontanet
023fe82932 Merge pull request #150 from vatesfr/olivierlambert-configdrive
Generic CloudConfig Drive
2015-12-16 18:19:51 +01:00
Julien Fontanet
2e1a06c7bf Generic Cloud Config drive. Fix vatesfr/xo-web/issues/549 2015-12-16 18:12:47 +01:00
Julien Fontanet
8b6961d40c VDI.resize{,_online} expect a string contrary to what the doc says. 2015-12-16 16:33:55 +01:00
Julien Fontanet
53351877da Fix typo: size → parseSize. 2015-12-16 15:48:33 +01:00
Julien Fontanet
522445894e Always parse sizes. 2015-12-16 15:36:01 +01:00
Julien Fontanet
550351bb16 Merge pull request #174 from vatesfr/abhamonr-import-vdi-content
Import VDI content is implemented.
2015-12-16 15:06:32 +01:00
wescoeur
328adbb56f Import VDI content is implemented. 2015-12-16 14:59:53 +01:00
Julien Fontanet
44a36bbba3 Use human-format v6 (much nicer with incorrect casing). 2015-12-16 13:17:07 +01:00
Julien Fontanet
4cc4adeda6 disk.{create,resize}() accept integers for size. 2015-12-16 11:34:46 +01:00
Julien Fontanet
c14e6f2a63 disk.resize() accepts human readable size. 2015-12-16 11:34:46 +01:00
Julien Fontanet
cfcb2d54d8 Merge pull request #172 from vatesfr/olivierlambert-vdimove
Allow offline VDI moving. Fix vatesfr/xo-web#591
2015-12-16 10:46:33 +01:00
Julien Fontanet
010d60e504 Coding style. 2015-12-16 09:46:39 +01:00
Julien Fontanet
eabde07ff6 Remove incorrect export. 2015-12-16 09:46:39 +01:00
Olivier Lambert
be19ad5f2a Allow offline VDI moving. Fix https://github.com/vatesfr/xo-web/issues/591 2015-12-15 19:07:20 +01:00
Julien Fontanet
d1d0816961 Merge pull request #171 from vatesfr/olivierlambert-existingdisks
allow edition of existing disks during VM creation
2015-12-15 17:56:38 +01:00
Olivier Lambert
7be7170504 allow edition of existing disks during VM creation 2015-12-15 17:51:03 +01:00
Julien Fontanet
478272f515 Merge pull request #167 from vatesfr/remoteCopyVm-set-nameLabel-asap
Xapi#remoteCopyVm() sets name label ASAP.
2015-12-15 13:49:13 +01:00
Julien Fontanet
09af6958c8 Xapi#remoteCopyVm() sets name label ASAP. 2015-12-15 11:35:03 +01:00
Julien Fontanet
adb3a2b64e Merge pull request #169 from vatesfr/olivierlambert-vdiresize
Clean VDI resize support
2015-12-14 17:09:12 +01:00
Olivier Lambert
1ee7e842dc Clean VDI resize support 2015-12-14 17:05:59 +01:00
Julien Fontanet
b080a57406 Merge pull request #162 from vatesfr/pierre-aborting-vm-export-cancels-operation
VM-export interruption properly transferred to Xen
2015-12-11 18:18:05 +01:00
Julien Fontanet
7c017e345a Minor updates. 2015-12-11 18:02:41 +01:00
Pierre
4b91343155 VM-export interruption properly transferred to Xen. (Fix vatesfr/xo-web#490)
When the connection with the client is lost, the export task is cancelled and the connection is closed.
As the task is over, the snapshot used for the export is deleted.

Cancelling the task is useless as it is cancelled by Xen
2015-12-11 18:02:41 +01:00
Julien Fontanet
02a3df8ad0 Merge pull request #164 from vatesfr/olivierlambert-import-metadata
Support VM metadata import. Fix vatesfr/xo-web#579
2015-12-11 17:01:47 +01:00
Olivier Lambert
6a7080f4ee Support VM metadata import. Fix vatesfr/xo-web#579 2015-12-11 16:56:56 +01:00
Julien Fontanet
4547042577 Fix issue in utils.createRawObject(). 2015-12-10 14:06:22 +01:00
Julien Fontanet
0e39eea7f8 Always use noop from utils. 2015-12-10 14:06:22 +01:00
Olivier Lambert
1e5aefea63 Merge pull request #161 from vatesfr/olivierlambert-set-default-sr
Set default sr
2015-12-10 12:14:27 +01:00
Olivier Lambert
02c4f333b0 minor fixes 2015-12-10 12:08:30 +01:00
Olivier Lambert
1e8fc4020b Add setDefaultSr, fix #572 2015-12-10 11:01:05 +01:00
Olivier Lambert
f969701ac1 Merge pull request #155 from vatesfr/pierre-plugins-autodiscovery
Installed plugins are detected even if the config file does not show …
2015-12-09 20:41:46 +01:00
Olivier Lambert
b236243857 Merge pull request #160 from vatesfr/marsaudf-no-backup-if-unmounted
Rolling backup fails immediatly if remote is disabled. Fix https://github.com/vatesfr/xo-web/issues/561
2015-12-09 19:13:01 +01:00
Fabrice Marsaud
39edc64922 Rolling backup fails immediatly if remote is disabled 2015-12-09 17:18:50 +01:00
Pierre
f22ece403f Installed plugins are automatically detected when the server starts. They are no more loaded from the config file.
Plugins (ie installed modules of which names start with `xo-server-`) are automatically detected and registered from `${__dirname}/node_modules/` and `/usr/local/lib/node_modules/`.
2015-12-09 16:56:48 +01:00
Julien Fontanet
f5423bb314 Merge pull request #158 from vatesfr/olivierlambert-recoveryStart
Generic recovery start (PV or HVM)
2015-12-07 18:11:03 +01:00
Julien Fontanet
b1e5945ebe Xapi#startVm() and Xapi#startVmOnCd() (fix vatesfr/xo-web#563). 2015-12-07 18:02:55 +01:00
Julien Fontanet
76b5be8171 Revert "Freeze config object before configuring plugin."
This reverts commit 789f51bd2a.

The change introduced issues with nodemailer used in xo-server-transport-email.
2015-12-03 16:00:32 +01:00
Julien Fontanet
804bca2041 Merge pull request #148 from vatesfr/abhamonr-purge-plugin-config
The plugins configurations can be cleaned.
2015-12-03 14:37:32 +01:00
Julien Fontanet
10602b47b4 4.10.2 2015-12-03 12:20:48 +01:00
Julien Fontanet
8d7c522596 Merge pull request #154 from vatesfr/julienf-fix-patches-for-6.1
Fix patches handling for XenServer 6.1.
2015-12-03 12:20:05 +01:00
Julien Fontanet
3ac455c5a7 Fix patches handling for XenServer 6.1. 2015-12-03 12:16:56 +01:00
Julien Fontanet
2b19a459df Merge pull request #152 from vatesfr/julienf-handle-xapiToXo-failures
Handle XAPI to XO objects failures.
2015-12-03 12:15:29 +01:00
Julien Fontanet
41ba2d9bf6 Properly schedule retry for the next loop. 2015-12-03 12:10:29 +01:00
Julien Fontanet
a7b5eb69d3 Handle XAPI to XO objects failures. 2015-12-03 11:13:00 +01:00
Julien Fontanet
67c209bb5e Properly handle the case where the pool object is not here yet. 2015-12-03 10:27:23 +01:00
Julien Fontanet
a6d436d9ea 4.10.1 2015-12-02 17:45:30 +01:00
Julien Fontanet
652c784e13 Update xen-api to 0.6.8 (fix vatesfr/xo-web#552). 2015-12-02 17:41:32 +01:00
wescoeur
a0a3b7a158 The plugins configurations can be cleaned. 2015-12-02 16:15:23 +01:00
Julien Fontanet
789f51bd2a Freeze config object before configuring plugin. 2015-12-02 15:20:38 +01:00
Olivier Lambert
c2f1a74f96 Merge pull request #149 from vatesfr/julienf-fix-vm-migration-collision
Use a different id (opaque ref) for VMs which are under migration.
2015-11-30 17:40:31 +01:00
Julien Fontanet
a9ed7a3f3b Use a different id (opaque ref) for VMs which are under migration. 2015-11-30 17:34:12 +01:00
Julien Fontanet
b348e88a5f 4.10.0 2015-11-27 14:24:08 +01:00
Julien Fontanet
1615395866 Merge branch 'next-release' into stable 2015-11-27 14:23:57 +01:00
Julien Fontanet
e483abcad0 Merge pull request #130 from vatesfr/marsaudf-generic-job-schedules
Enhancements to prepare generic job scheduling
2015-11-27 12:03:27 +01:00
Fabrice Marsaud
12b6760f6e Extend job & schedule API with job & schedule names, and job.runSequence 2015-11-27 11:56:37 +01:00
Julien Fontanet
6fde6d7eac Expose plugin config validation errors (vatesfr/xo-web#530). 2015-11-26 16:18:39 +01:00
Julien Fontanet
a7ef891217 Merge pull request #146 from vatesfr/abhamonr-abort-vm-export-import
Start VM export only when necessary.
2015-11-26 16:10:59 +01:00
wescoeur
8f22dfe87b Start VM export only when necessary. 2015-11-26 15:42:07 +01:00
Julien Fontanet
2dc7fab39a Merge pull request #134 from vatesfr/abhamonr-backup-jobs-notifications
Xo event `job:terminated` on job termination.
2015-11-26 15:29:39 +01:00
wescoeur
74cb2e3c63 'job:terminated' signal is emitted after job execution. (with one executionStatus object) 2015-11-26 11:07:37 +01:00
Julien Fontanet
6e763a58f1 Expose UUIDs on all Xapi objects which have one. 2015-11-25 16:53:25 +01:00
Julien Fontanet
a8e72ed410 Merge pull request #140 from vatesfr/julienf-xo-defineProperty
Xo#defineProperty() to properly expose attributes
2015-11-25 14:16:55 +01:00
Julien Fontanet
fcdfd5f936 Merge pull request #139 from vatesfr/abhamonr-remember-disabled-servers
Save enabled state for each server
2015-11-25 13:54:44 +01:00
Julien Fontanet
f1faa463c1 Xo#defineProperty() allows (plugins) to define property on Xo instance 2015-11-25 12:27:09 +01:00
wescoeur
a0f4952b54 Save enabled state for each server 2015-11-25 12:15:15 +01:00
Olivier Lambert
bd82ded07d automatically set autopoweron on the pool 2015-11-25 12:06:16 +01:00
Julien Fontanet
016e17dedb Merge pull request #145 from vatesfr/julienf-pool-autopoweron
Xapi#setPoolProperties() supports autoPowerOn.
2015-11-25 12:03:23 +01:00
Julien Fontanet
5cd3e1b368 Xapi#setPoolProperties() supports autoPowerOn. 2015-11-25 11:03:33 +01:00
Julien Fontanet
b2b39458da Merge pull request #144 from vatesfr/julienf-fix-redis-items-updates
Fix items updates in Redis.
2015-11-25 10:57:54 +01:00
wescoeur
556bbe394d Add: Job and params-vector schemas. 2015-11-25 10:44:40 +01:00
Julien Fontanet
07288b3f26 Fix items updates in Redis. 2015-11-25 10:39:50 +01:00
Julien Fontanet
90f79b7708 Shallow copy the configuration object before configuring a plugin. (fix vatesfr/xo-web#513) 2015-11-24 11:25:52 +01:00
Julien Fontanet
e220786a20 Merge pull request #142 from vatesfr/marsaudf-parameter-fix
Fix: group.getAll() has no params.
2015-11-24 10:49:51 +01:00
Fabrice Marsaud
f16b993294 Removed unwanted API parameter 2015-11-24 10:42:43 +01:00
Julien Fontanet
c241bea3bf Add vendor config file. 2015-11-20 18:28:32 +01:00
Julien Fontanet
084654cd3c Merge branch 'stable' into next-release 2015-11-20 18:17:08 +01:00
Julien Fontanet
d21742afb6 4.9.2 2015-11-20 18:05:26 +01:00
Julien Fontanet
b5259384e8 Merge pull request #138 from vatesfr/julienf-fix-tokens-expiration
Auth tokens expires after one month (side effect: remove old tokens).
2015-11-20 18:05:03 +01:00
Julien Fontanet
bf78ad9fbe Auth tokens expires after one month (side effect: remove old tokens). 2015-11-20 17:42:18 +01:00
Olivier Lambert
ab3577c369 Merge pull request #136 from vatesfr/olivierlambert-cloudconfig
Cloud config management for CoreOS
2015-11-20 17:30:53 +01:00
Olivier Lambert
6efb90c94e Merge pull request #135 from vatesfr/pierre-emergency-host-shutdown
emergencyHostShutdown(hostId) : suspends all the VMs running on the host
2015-11-20 17:30:27 +01:00
Olivier Lambert
cbcc400eb4 Cloud config management for CoreOS 2015-11-20 17:12:12 +01:00
Julien Fontanet
15aec7da7e vm.clone() requires permissions on SRs. 2015-11-20 16:19:33 +01:00
Julien Fontanet
46535e4f56 Utils: pAll() & pReflect() 2015-11-20 15:31:55 +01:00
Julien Fontanet
e3f945c079 Minor fixes. 2015-11-20 14:34:07 +01:00
Julien Fontanet
04239c57fe pSettle() returns an object for an object. 2015-11-20 11:42:49 +01:00
Pierre
ad4439ed55 emergencyHostShutdown(hostId) : suspends all the VMs running on the host and then shuts the host down 2015-11-20 11:26:03 +01:00
Julien Fontanet
9fe3ef430f More tests for pSettle(). 2015-11-20 10:43:56 +01:00
Julien Fontanet
ff30773097 Fix pSettle() to accept non-promises. 2015-11-20 10:43:56 +01:00
Julien Fontanet
f7531d1e18 pSettle() accepts either arrays or objects. 2015-11-20 10:43:56 +01:00
Olivier Lambert
658008ab64 add comment for quiesce 2015-11-19 16:03:28 +01:00
Olivier Lambert
b089d63112 allow snapshots on halted VMs 2015-11-19 16:01:08 +01:00
Julien Fontanet
ee9b1b7f57 Merge pull request #133 from vatesfr/abhamonr-validate-config-plugins-registration
Avoid plugin loading if config is not valid
2015-11-19 14:40:33 +01:00
wescoeur
cd0fc8176f Avoid plugin loading if config is not valid 2015-11-19 13:51:25 +01:00
Julien Fontanet
8e291e3e46 Define CoffeeScript API modules as ES6 (fix default value). 2015-11-19 13:13:53 +01:00
Julien Fontanet
e3024076cd Merge pull request #131 from vatesfr/abhamonr-delete-user-with-tokens
remove tokens on user deletion
2015-11-19 12:55:38 +01:00
wescoeur
6105874abc remove tokens on user deletion 2015-11-19 12:40:31 +01:00
Julien Fontanet
1855f7829d Advanced setting: verboseApiLogsOnErrors. 2015-11-19 11:11:54 +01:00
Julien Fontanet
456e8bd9c0 New FIXME. 2015-11-19 11:11:54 +01:00
Julien Fontanet
d5f2efac26 Merge pull request #132 from vatesfr/abhamonr-add-leveldown-dep
Add leveldown dep
2015-11-19 10:45:17 +01:00
wescoeur
21e692623c Add leveldown dep 2015-11-19 10:40:11 +01:00
Julien Fontanet
80e9589af5 Initial --repair command in xo-server-logs. 2015-11-19 10:11:01 +01:00
Julien Fontanet
b2b9ae0677 Quick fix for groups.getAll() attributes. 2015-11-19 09:26:34 +01:00
Julien Fontanet
63122905e6 Comments. 2015-11-18 18:36:27 +01:00
Julien Fontanet
f99b6f4646 Merge pull request #123 from vatesfr/abhamonr-logs-cli
CLI to explore xo-server's logs.
2015-11-18 17:01:26 +01:00
wescoeur
39090c2a22 Logs CLI:
- Can print logs for one namespace or all namespaces
- Can sort logs since one start timestamp/until one end timestamp
- The sort results can be limited by one value
2015-11-18 16:57:28 +01:00
Julien Fontanet
76baa8c791 Minor fix. 2015-11-18 16:40:08 +01:00
Julien Fontanet
74e4b9d6d2 Merge imports. 2015-11-18 15:24:38 +01:00
Julien Fontanet
bbfc5039f7 Merge pull request #129 from vatesfr/abhamonr-ghost-user
Avoid ghost user and ghost group.
2015-11-18 15:14:31 +01:00
wescoeur
b2fd694483 Avoid ghost user and ghost group. 2015-11-18 15:02:54 +01:00
Julien Fontanet
b03f38ff22 Include user name in console proxy logs. 2015-11-17 16:24:22 +01:00
Julien Fontanet
fe48811047 Include user name in API logs. 2015-11-17 16:24:07 +01:00
Julien Fontanet
bd9396b031 Ability to not create users on first sign in (fix #497). 2015-11-17 15:59:31 +01:00
Julien Fontanet
f0497ec16d Move default configuration to config.json. 2015-11-17 15:49:45 +01:00
Julien Fontanet
7e9e179fa7 Minor fixes. 2015-11-17 15:01:58 +01:00
Julien Fontanet
de62464ad8 Improve security: check token for console access. 2015-11-17 15:01:58 +01:00
Julien Fontanet
f6911ca195 Merge pull request #128 from vatesfr/olivierlambert-setbootorder
Rename vm.bootOrder() to vm.setBootOrder() and ensure VM is HVM.
2015-11-17 15:00:03 +01:00
Olivier Lambert
aec09ed8d2 Rename vm.bootOrder() to vm.setBootOrder() and ensure VM is HVM 2015-11-17 14:56:15 +01:00
Julien Fontanet
51a983e460 Logs clients IPs for WebSocket connections. 2015-11-17 13:24:07 +01:00
Julien Fontanet
0eb46e29c7 Merge pull request #122 from vatesfr/fix-poolPatches-removal
Properly remove objects for which `xo.id !== xapi.$id`.
2015-11-17 11:00:05 +01:00
Julien Fontanet
5ee11c7b6b Properly remove objects for which xo.id !== xapi.$id. 2015-11-17 10:33:56 +01:00
Olivier Lambert
b55accd76f add tag for quiesced snapshots 2015-11-16 12:41:16 +01:00
Julien Fontanet
fef2be1bc7 Merge pull request #125 from vatesfr/olivierlambert-snapquiesce
Add VM snapshot quiesce support
2015-11-16 10:59:39 +01:00
Olivier Lambert
0b3858f91d Add VM snapshot quiesce support 2015-11-16 10:55:51 +01:00
Julien Fontanet
d07ea1b337 Explicit Node versions compatibility. 2015-11-16 10:31:28 +01:00
Julien Fontanet
7e2dbc7358 4.9.1 2015-11-13 17:08:54 +01:00
Julien Fontanet
c676f08a7c Use correct host to import VM without known length. 2015-11-13 16:53:00 +01:00
Julien Fontanet
92f24b5728 Sets a long timeout for vm.import(). 2015-11-13 16:08:44 +01:00
Julien Fontanet
0254e71435 4.9.0 2015-11-13 11:27:40 +01:00
Julien Fontanet
2972fc5814 Merge pull request #124 from vatesfr/abhamonr-logs-avoid-sublevel
avoid sublevel for logs
2015-11-13 11:08:44 +01:00
wescoeur
975c96217c avoid sublevel for logs 2015-11-13 11:03:02 +01:00
Julien Fontanet
c30c1848bc Fix VM naming in vm.rollingDrCopy(). 2015-11-12 18:21:35 +01:00
Julien Fontanet
94615d3b36 Fix optional options in Xapi#remoteCopyVm(). 2015-11-12 18:21:12 +01:00
Julien Fontanet
37a00f0d16 Minor fixes. 2015-11-12 15:25:34 +01:00
Julien Fontanet
0dbe70f5af vm.copy() handles running VMs and compression can be disabled. 2015-11-12 11:02:05 +01:00
Fabrice Marsaud
7584374b0b Merge pull request #119 from vatesfr/marsaudf-DR-API
Disaster recovery feature
2015-11-12 10:24:57 +01:00
Fabrice Marsaud
71ca51dc1a Disaster recovery feature 2015-11-12 10:20:57 +01:00
Fabrice Marsaud
aa81e72e45 Merge pull request #115 from vatesfr/abhamonr-logger-module
Logger is implemented.
2015-11-12 10:16:04 +01:00
wescoeur
9954bb9c15 Logger is implemented.
Logger save jobs events : (start, end, call start, call end)
Logs can be obtained in api.
2015-11-12 09:59:56 +01:00
Julien Fontanet
e5c0250423 Xapi#importVm() crash on failure. 2015-11-10 21:28:01 +01:00
Olivier Lambert
135799ed5e Merge pull request #121 from vatesfr/marsaudf-backup-fix
Fixed rolling tag detection
2015-11-10 16:24:35 +01:00
Fabrice Marsaud
22c3b57960 Fixed backup rolling bug 2015-11-10 16:18:09 +01:00
Fabrice Marsaud
7054dd74a4 Merge pull request #120 from vatesfr/marsaudf-function-move
Moving rollingSnapshot form xapi to xo
2015-11-10 15:34:49 +01:00
Fabrice Marsaud
d4f1e52ef6 fix 2015-11-10 09:04:11 +01:00
Fabrice Marsaud
76a44459cf Moving rollingSnapshot form xapi to xo 2015-11-10 08:49:38 +01:00
Julien Fontanet
a5590b090c Merge pull request #116 from vatesfr/julien-f-vm-copy
vm.copy() can a copy a VM on a remote or local SR.
2015-11-09 15:14:04 +01:00
Julien Fontanet
74c9a57070 Replace lodash.assign() with ES2016 object spread. 2015-11-09 15:07:42 +01:00
Julien Fontanet
06e283e070 vm.copy() can a copy a VM on a remote or local SR. 2015-11-09 14:40:49 +01:00
Julien Fontanet
8ab2ca3f24 Remove unnecessary Bluebird-isms. 2015-11-09 12:05:18 +01:00
Julien Fontanet
0eb949ba39 Move often used lodash utils to utils.js 2015-11-09 12:03:34 +01:00
Julien Fontanet
be35693814 Minor rewrite in utils. 2015-11-09 11:20:41 +01:00
Julien Fontanet
1e5f13795c Merge pull request #117 from vatesfr/promise-settle
Implement utils.pSettle().
2015-11-06 14:51:56 +01:00
Julien Fontanet
cca2265633 Fix PV drivers detection. 2015-11-06 13:23:03 +01:00
Julien Fontanet
0f0d1ac370 Expose vm.xenTools property. 2015-11-06 13:08:03 +01:00
Julien Fontanet
d52d4ac183 Implement utils.pSettle(). 2015-11-06 11:17:35 +01:00
Julien Fontanet
841220fd01 Remove unused variable. 2015-11-05 16:42:17 +01:00
Julien Fontanet
ca5e10784b Only use absolute paths in redirects to ease reverse proxies. 2015-11-05 16:33:07 +01:00
Olivier Lambert
712319974b Merge pull request #114 from vatesfr/marsaudf-import-backup
Import a VM from a remote backup
2015-11-05 15:46:26 +01:00
Fabrice Marsaud
067a6d01bc List backup Files in remotes ans import them for restore 2015-11-05 15:38:09 +01:00
Julien Fontanet
27825f9e2e Unit tests for utils.pFinally(). 2015-11-04 15:36:07 +01:00
Julien Fontanet
425eb115dc Use ES2016 bind syntax for pFinally(). 2015-11-04 14:54:10 +01:00
Julien Fontanet
0a5ce55e2b Expose xapi.parseDateTime(). 2015-11-03 12:03:57 +01:00
Julien Fontanet
dbc8ed9d4c Update deps. 2015-11-03 10:54:14 +01:00
Julien Fontanet
e31e990684 Do not use ES6 method String#endsWith(). 2015-11-03 10:31:21 +01:00
Julien Fontanet
8618f56481 Support vm.import() without knowning the length. 2015-10-30 18:55:04 +01:00
Julien Fontanet
a39fc4667e Do not test on Node 5 for now. 2015-10-30 17:10:25 +01:00
Julien Fontanet
4c369e240b Merge pull request #112 from vatesfr/abhamonr-stats-use-server-time
The local xen orchestra timestamp is never used for get stats.
2015-10-30 14:32:56 +01:00
wescoeur
4e291d01d4 The local xen orchestra timestamp is never used for get stats.
Only the timestamp of one xenServer/rrd is used.
2015-10-30 14:18:37 +01:00
Julien Fontanet
b32fce46cb Merge pull request #111 from vatesfr/abhamonr-fixs-debugs-stats-messages
Fix debugs messages for stats
2015-10-29 18:14:13 +01:00
wescoeur
d1fcd45aac Fix debugs messages for stats 2015-10-29 16:49:13 +01:00
Julien Fontanet
ebdb92c708 4.8.1 2015-10-29 16:31:10 +01:00
Julien Fontanet
112909d35b Merge pull request #110 from vatesfr/julien-f-fix-password-rehash
Fix user password rehash.
2015-10-29 16:30:29 +01:00
Julien Fontanet
c6e2c559f1 Fix user password rehash. 2015-10-29 16:11:45 +01:00
Julien Fontanet
cf8613886a 4.8.0 2015-10-29 10:45:37 +01:00
Olivier Lambert
39c25c2001 moving json5 as a real dep and not a dev dep anymore. Fix #109 2015-10-28 19:21:32 +01:00
Julien Fontanet
9c9721ade5 Fix permissions checking for API -_-" 2015-10-28 17:22:09 +01:00
Julien Fontanet
4b8abe4ce8 Fix test.hasPermission(). 2015-10-28 17:09:33 +01:00
Julien Fontanet
33dfaba276 Remove useless console.log. 2015-10-28 16:56:50 +01:00
Julien Fontanet
dd8bbcf358 VM snapshots require operate permission on all SRs. (fix vatesfr/xo-web#429). 2015-10-28 16:56:41 +01:00
Julien Fontanet
cc3e4369ed Fix some VM-snapshot & VDI ACLs resolution. 2015-10-28 16:51:09 +01:00
Julien Fontanet
548355fce6 Use Xo#getUserByName() where possible. 2015-10-28 16:17:33 +01:00
Julien Fontanet
a4e0e6544b Merge pull request #108 from vatesfr/julien-f-acl-inheritance
ACLs inheritance (fix vatesfr/xo-web#279).
2015-10-28 15:29:31 +01:00
Julien Fontanet
62067e0801 ACLs inheritance (fix vatesfr/xo-web#279). 2015-10-28 15:11:28 +01:00
Olivier Lambert
5eb40d2299 Merge pull request #107 from vatesfr/pierre-remember-me-label
Clicking on 'remember me' label checks the box
2015-10-28 14:49:59 +01:00
Pierre
53990a531b Clicking on 'remember me' label checks the box 2015-10-28 14:46:14 +01:00
Olivier Lambert
d799aea3c4 Merge pull request #105 from vatesfr/abhamonr-intelligent-stats
New parser for host and vms stats.
2015-10-28 14:44:56 +01:00
Julien Fontanet
9af86cbba2 Adds granularity param spec to {host,vm}.stats(). 2015-10-28 14:35:00 +01:00
wescoeur
6fbfece4ff New parser for host and vms stats.
The data are cached for other http requests.
2015-10-28 14:20:48 +01:00
Julien Fontanet
d56cca7873 Use undefined provider for local providers. 2015-10-28 12:38:55 +01:00
Julien Fontanet
fa1096a6ba Remove unused variable. 2015-10-28 12:38:27 +01:00
Julien Fontanet
16ff721331 Throttle authentications tries by user (fix #339). 2015-10-28 12:11:50 +01:00
Julien Fontanet
798ee9dc46 Remove commented code. 2015-10-28 11:45:18 +01:00
Julien Fontanet
bc17c60305 Refactor Xo#authenticateUser(). 2015-10-28 11:44:17 +01:00
Julien Fontanet
432688d577 Remove unused code. 2015-10-28 11:44:17 +01:00
Julien Fontanet
da8d4b47f1 Remove some console logs. 2015-10-28 11:44:17 +01:00
Olivier Lambert
ed1e2e2449 Merge pull request #102 from vatesfr/julien-f-refactor-vm-import
Refactor `vm.import()`
2015-10-27 18:26:29 +01:00
Julien Fontanet
b9744b4688 Refactor vm.import()
- Move logic code to `Xapi#importVm()`
- `vm.import()` following request now returns the id of the imported VM
2015-10-27 18:00:51 +01:00
Julien Fontanet
2f328f8f37 Merge pull request #106 from vatesfr/pierre-patch-name-in-upload-task-description
'Pending tasks' panel: upload task displays patch name
2015-10-27 12:23:59 +01:00
Pierre
ffefd7e50b Added default patch name for uploadPoolPatch to handle handlePatchUpload in pool.js 2015-10-27 11:07:45 +01:00
Pierre
c2445f8a7c 'Pending tasks' panel: upload task displays patch name 2015-10-27 10:05:14 +01:00
Julien Fontanet
54d44079cc Remove unused dep. 2015-10-27 09:16:59 +01:00
Julien Fontanet
87f089a12c Do not proxy data when the connection is closed. 2015-10-26 18:30:45 +01:00
Julien Fontanet
aa2172e4db Use source-map-support-2 from npm (fix old npm). 2015-10-26 18:30:45 +01:00
Julien Fontanet
0a33e94e79 Remove unused variable. 2015-10-26 18:30:44 +01:00
Julien Fontanet
fada54abae Enable XO API HTTP requests without HTTP auth. 2015-10-26 18:30:44 +01:00
Olivier Lambert
802641b719 Merge pull request #103 from vatesfr/pierre-install-all-patches-on-host
Algorithm to install all patches in correct order
2015-10-26 18:24:07 +01:00
Pierre
1da93829d4 Algorithm to install patches in correct order 2015-10-26 17:56:50 +01:00
Julien Fontanet
9e7acbc49a Avoid special chars in date formatting (fix #448). 2015-10-26 16:49:41 +01:00
Julien Fontanet
318765d40b Remove unused dep. 2015-10-26 10:47:07 +01:00
Julien Fontanet
94ba20dfa1 Register objects with the correct key. 2015-10-23 16:26:06 +02:00
Julien Fontanet
2ad3dc4a32 Uniformize pool patches between collection and host.listMissingPatches(). 2015-10-23 15:09:13 +02:00
Julien Fontanet
eef940dd7c Pool patches ids are opaque refs instead of UUIDs. 2015-10-23 15:08:29 +02:00
Julien Fontanet
1b5fc12ac1 Use createRawObject() instead of Object.create(null). 2015-10-21 17:17:15 +02:00
Julien Fontanet
c1c7b8dfcd Minor updates in utils.js 2015-10-21 17:15:49 +02:00
Julien Fontanet
d4510c2afe Put schemas in a dedicated directory. 2015-10-20 18:02:57 +02:00
Julien Fontanet
f241f073a3 Merge pull request #101 from vatesfr/julien-f-hvm-network-install
Set correct boot order when installing HVM from network.
2015-10-19 15:08:50 +02:00
Julien Fontanet
26a6c72611 Set correct boot order when installing HVM from network. 2015-10-19 15:06:08 +02:00
Julien Fontanet
51cee7804b Merge pull request #100 from vatesfr/julien-f-expose-virtualization-mode
Expose virtualization mode in VM object.
2015-10-19 15:02:40 +02:00
Julien Fontanet
52228430f1 Expose virtualization mode in VM object. 2015-10-19 14:30:08 +02:00
Julien Fontanet
4fcd45d8a4 Do not filter out node_modules in stack traces. 2015-10-16 09:53:13 +02:00
Julien Fontanet
ea5736947d No need to parse source maps for ignored call sites. 2015-10-16 09:42:16 +02:00
Julien Fontanet
6b5f36fb7e Move source mapping after async support. 2015-10-15 15:05:42 +02:00
Julien Fontanet
b328d6d95f Augment stack traces limit to 100. 2015-10-15 15:05:42 +02:00
Julien Fontanet
2e06921bf8 Merge pull request #99 from vatesfr/abhamonr-stats-optimization-host
Cache Host stats for 5 secs to avoid unnecessary requests.
2015-10-15 11:30:07 +02:00
Julien Fontanet
fd95e2d711 Use source-map-support-2.
It is based on stack-chain and should give better results with
`trace`.
2015-10-15 10:42:51 +02:00
wescoeur
490e253b79 Cache Host stats for 5 secs to avoid unnecessary requests. 2015-10-14 17:03:53 +02:00
Julien Fontanet
8a10f5cd52 Merge pull request #98 from vatesfr/abhamonr-stats-optimization
Cache VM stats for 5 secs to avoid unnecessary requests.
2015-10-14 16:43:20 +02:00
wescoeur
5cebcc2424 Cache VM stats for 5 secs to avoid unnecessary requests. 2015-10-14 16:34:57 +02:00
Julien Fontanet
7663b89289 Allowed favicon before sign in. 2015-10-13 11:49:38 +02:00
Julien Fontanet
d0d1f9e3c0 4.7.0 2015-10-12 16:34:55 +02:00
Julien Fontanet
4433760e37 Add better-stacks.js to package.json 2015-10-12 13:46:50 +02:00
Julien Fontanet
b63fcd2254 Merge pull request #89 from vatesfr/plugins-api
Plugins API.
2015-10-09 18:41:26 +02:00
Julien Fontanet
eb2aa352ef API really manages plugins. 2015-10-09 18:36:24 +02:00
Julien Fontanet
ec95f198ec Initial plugins API (with mockup data). 2015-10-08 14:00:33 +02:00
Olivier Lambert
f166e480f1 Merge pull request #96 from vatesfr/abhamonr-auth-non-persistent-cookies
Checkbox added on login page for create persistent session (1 year in…
2015-10-08 13:57:04 +02:00
wescoeur
2051f0486c Checkbox added on login page for create persistent session (1 year in practice) only for internal provider.
If checkbox is not checked or if an external provider is used (as Github, Twitter...) the session is not-persistent.
2015-10-08 12:28:11 +02:00
Julien Fontanet
f33fc5d730 Minor fixes. 2015-10-07 15:01:19 +02:00
Julien Fontanet
1603df3503 Avoid listing node_modules in stacks. 2015-10-07 14:42:36 +02:00
Julien Fontanet
6055ac182b Minor fix on pool merge. 2015-10-07 14:42:36 +02:00
Olivier Lambert
4678f60adf fix the pool merge issue #402 2015-10-06 15:15:54 +02:00
Julien Fontanet
b48521950e Always use got instead of request. 2015-10-05 18:41:54 +02:00
Julien Fontanet
45da6fb39f Upgrade must and got. 2015-10-05 18:41:50 +02:00
Julien Fontanet
1604d327da Use redis 2 directly. 2015-10-05 15:32:34 +02:00
Julien Fontanet
98b2b325a1 Reorder some imports. 2015-10-05 13:07:17 +02:00
Julien Fontanet
55b3def630 Avoid direct dependency on Blubird AMAP. 2015-10-05 13:06:53 +02:00
Julien Fontanet
1b5f6bd3eb Only unregister the Xen Server on success. 2015-10-01 16:13:18 +02:00
Julien Fontanet
3472b85345 Minor fix. 2015-10-01 15:46:31 +02:00
Julien Fontanet
1c6ae53656 Remove a xen pool only after successful pool.mergeInto() (fix #403). 2015-10-01 15:45:03 +02:00
Julien Fontanet
a84a56f611 Merge pull request #95 from vatesfr/julien-f-pool-merge
pool.mergeInto(source, target)
2015-09-30 19:06:29 +02:00
Julien Fontanet
69751aa415 Expose XAPI error messages in pool.mergeInto(). 2015-09-30 17:36:25 +02:00
Julien Fontanet
9ef0337807 Correctly export pool.mergeInto(). 2015-09-30 16:39:30 +02:00
Julien Fontanet
a3fdd274c3 pool.mergeInto(source, target) 2015-09-30 16:26:44 +02:00
Julien Fontanet
f069c02153 Only test on Node 0.10, 0.12 and latest stable. 2015-09-25 10:22:09 +02:00
Olivier Lambert
ad0d14c517 Merge pull request #93 from vatesfr/next-release
4.6 release
2015-09-25 00:28:48 +02:00
Olivier Lambert
a72da79743 4.6.0 2015-09-25 00:12:03 +02:00
Julien Fontanet
6bc35217d9 vm.set() supports PV args. 2015-09-24 10:05:20 +02:00
Julien Fontanet
c526e9ac8f Temporary disable incorrect standard reports. 2015-09-23 15:10:53 +02:00
Julien Fontanet
3dfebcadc1 Fix permissions check for networks and SRs (fix #91). 2015-09-23 15:10:53 +02:00
Olivier Lambert
693af532a2 Merge pull request #90 from vatesfr/better-vm-migration
Better VM migration.
2015-09-22 15:42:11 +02:00
Julien Fontanet
4bac57fcd1 Better VM migration. 2015-09-22 15:22:01 +02:00
Julien Fontanet
59291fcac2 VM export is named after the VM name label (fix #370). 2015-09-17 16:57:30 +02:00
Julien Fontanet
1f21b202a5 Merge pull request #87 from vatesfr/pvargs
PV args can be specified at VM creation.
2015-09-17 16:40:30 +02:00
Olivier Lambert
b3ca02a166 add PV args for VM 2015-09-17 16:17:11 +02:00
Julien Fontanet
2462f8f87e Fix Xapi#_setObjectProperties() for uppercase properties. 2015-09-17 16:16:35 +02:00
Olivier Lambert
18268acc1f Merge pull request #83 from vatesfr/tags
Tags
2015-09-16 20:39:11 +02:00
Julien Fontanet
44f4423a9d Fix tag.{add,remove}(). 2015-09-15 16:25:45 +02:00
Olivier Lambert
37250a6f48 Support tags on Xen objects. 2015-09-15 11:59:25 +02:00
Olivier Lambert
fd97541417 Merge pull request #85 from vatesfr/changePassword
Password change API for any user. Related to xo-web issue#362
2015-09-14 16:34:45 +02:00
Fabrice Marsaud
dba3e30d02 Fixes after PR feedback 2015-09-14 16:28:29 +02:00
Julien Fontanet
5962283ad3 Directly use posix path functions. 2015-09-14 14:14:40 +02:00
Fabrice Marsaud
cdd705831b reworked password change 2015-09-14 13:33:44 +02:00
Fabrice Marsaud
a1a7c5e4bb Password change API for any user. Related to xo-web issue#362 2015-09-14 11:28:33 +02:00
Fabrice Marsaud
c1e9061568 Minor code style fix 2015-09-14 11:28:10 +02:00
Julien Fontanet
90ee04de57 Fix bad sign in redirections (fix vatesfr/xo-web#373). 2015-09-14 11:19:38 +02:00
Julien Fontanet
cd24cfbe5c Minor fix in vm.stop(). 2015-09-11 18:03:47 +02:00
Julien Fontanet
5b05668a30 4.5.0 2015-09-11 13:00:24 +02:00
Julien Fontanet
a2eca9589f Avoid crashes on failed VM backups. 2015-09-11 12:48:42 +02:00
Julien Fontanet
a2adbb19bd Avoid crashes on failed VM exports. 2015-09-11 12:48:22 +02:00
Julien Fontanet
012e5c09ed Minor fixes. 2015-09-11 12:31:53 +02:00
Fabrice Marsaud
5f33aa7fd4 Fixed host stats 2015-09-10 17:16:21 +02:00
Fabrice Marsaud
7ea2204dfd Merge pull request #82 from vatesfr/vmMetadata
Only VM metadata handle in various backup/export methods
2015-09-10 17:14:19 +02:00
Julien Fontanet
be8cadf5ac Pass context to ACL checkers. 2015-09-10 17:01:12 +02:00
Fabrice Marsaud
fc7192c748 Only VM metadata handle in various backup/export methods 2015-09-10 16:20:49 +02:00
Julien Fontanet
5c6b6b3919 Implements ACL inheritance for hosts, networks, SRs and VMs. 2015-09-10 14:57:10 +02:00
Julien Fontanet
87553ac685 Use relative paths for sign in (fix vatesfr/xo-web#361). 2015-09-10 14:45:35 +02:00
Julien Fontanet
384f396bbb Revert redis to 0.12.1 for compatibility with then-redis. 2015-09-09 17:33:34 +02:00
Julien Fontanet
d40560bd49 Allow a query string in external auth providers callback. 2015-09-07 17:27:42 +02:00
Julien Fontanet
67952ca246 Update deps. 2015-09-07 16:07:23 +02:00
Julien Fontanet
4ddbefb147 Update standard to 5.2 and fix coding style. 2015-09-04 11:00:36 +02:00
Julien Fontanet
edabc17ac9 onlyMetadata param for vm.export() is optional. 2015-09-04 10:38:45 +02:00
Olivier Lambert
c7e8211fae replace passport placehold by password 2015-09-02 22:00:51 +02:00
Olivier Lambert
dc3f07dd52 add the parameter in the VM method 2015-09-02 17:01:06 +02:00
Olivier Lambert
fae6a5cfb4 add the onlyMetadata parameter 2015-09-02 16:34:31 +02:00
Julien Fontanet
cafd225797 Better logs for the consoles proxy. 2015-09-02 16:34:20 +02:00
Julien Fontanet
bf77d2973e Error handling should be in place before the connection. 2015-09-02 16:22:47 +02:00
Julien Fontanet
dfd8133431 Handle errors in consoles proxy. 2015-09-02 16:15:28 +02:00
Olivier Lambert
e9d78b8990 fix xo-web/#304 2015-09-02 15:43:27 +02:00
Olivier Lambert
13532cdffb Merge pull request #81 from vatesfr/julien-f-direct-consoles
Access directly to consoles without using wsproxy.
2015-09-01 17:58:06 +02:00
Julien Fontanet
c17620efb7 Access directly to consoles without using wsproxy. 2015-09-01 17:51:25 +02:00
Julien Fontanet
d3b5b1080f Correctly handle VM_LACKS_FEATURE_SHUTDOWN. 2015-09-01 17:45:03 +02:00
Julien Fontanet
e4b0c23bb9 Add comment regarding chained certificates. 2015-09-01 15:22:47 +02:00
Julien Fontanet
6c24fb6d79 Minor cleanup. 2015-08-28 18:06:49 +02:00
Julien Fontanet
bd93551c13 Minor fixes for external auth providers. 2015-08-28 18:06:49 +02:00
Fabrice Marsaud
dc0799a56b 4.4.0 2015-08-28 17:43:02 +02:00
Julien Fontanet
e1fca1520b Merge pull request #79 from vatesfr/passport
Passport integration.
2015-08-28 16:12:00 +02:00
Julien Fontanet
c72f3b8efb Fix providers list on sign in page. 2015-08-28 16:03:24 +02:00
Julien Fontanet
afcd172a94 Put signin page in its own file. 2015-08-28 15:52:46 +02:00
Julien Fontanet
5957700699 Better error feedback. 2015-08-28 15:14:41 +02:00
Julien Fontanet
451d023e81 Authentication is now handled by passport. 2015-08-28 15:04:01 +02:00
Julien Fontanet
64d166cebf Enable Travis for iojs v3. 2015-08-28 09:06:01 +02:00
Fabrice Marsaud
51b067def7 host.stats fixed 2 2015-08-27 17:51:29 +02:00
Fabrice Marsaud
de25e8dd6f host.stats fixed 2015-08-27 16:48:42 +02:00
Fabrice Marsaud
39ac291ba2 vm.stats fix 2015-08-27 09:57:53 +02:00
Julien Fontanet
722d26c5b9 Only super admins can interact with a network (should fix vatesfr/xo-web#322). 2015-08-24 17:34:15 +02:00
Julien Fontanet
0346760a75 Hide non managed VDIs (should fix #324). 2015-08-24 16:12:27 +02:00
Julien Fontanet
a2015143f8 Fix coding style. 2015-08-24 13:27:00 +02:00
Julien Fontanet
071d99a7b4 Update deps. 2015-08-24 13:26:24 +02:00
Fabrice Marsaud
e6d8e063c9 stats api funcs now have 4 possible time granularities 2015-08-10 15:41:16 +02:00
Fabrice Marsaud
29526144c9 4.3.2 2015-07-29 15:59:54 +02:00
Fabrice Marsaud
b88bcafddd Merge branch 'next-release' 2015-07-29 15:52:55 +02:00
Fabrice Marsaud
78d844d693 Fixed backup depth 2015-07-29 15:36:18 +02:00
Fabrice Marsaud
49310b53e9 4.3.1 2015-07-29 15:32:57 +02:00
Fabrice Marsaud
4684487ff8 Fixed backup path failure for nfs remotes 2015-07-29 15:32:57 +02:00
Fabrice Marsaud
89250205dc 4.3.1 2015-07-29 15:25:04 +02:00
Fabrice Marsaud
9039919b03 Fixed backup path failure for nfs remotes 2015-07-29 15:15:14 +02:00
Julien Fontanet
df16803f11 Expose host.powerOnMode (fixes #77). 2015-07-27 16:24:38 +02:00
Julien Fontanet
48327cf5f8 A pool’s name defaults to its master’s name. 2015-07-24 13:42:08 +02:00
Varchar38
2ead125b9d Check if the server already exist 2015-07-23 14:24:28 +02:00
Fabrice Marsaud
23807f11f9 4.3.0 2015-07-22 15:46:07 +02:00
Fabrice Marsaud
cad666d07f Merge branch 'next-release' 2015-07-22 15:44:12 +02:00
Varchar38
a0b11051e1 Position can be a string or a number 2015-07-22 09:40:00 +02:00
Julien Fontanet
b6e6fb9de2 Closes WebSockets connections on SIGINT/SIGTERM. 2015-07-21 16:03:20 +02:00
Olivier Lambert
4172fd8aff Merge pull request #75 from vatesfr/marsaud-backup
Scheduled VM Backup feature
2015-07-21 14:35:15 +02:00
Fabrice Marsaud
d60df6ca69 Backup, rolling backup, and remote backup location features 2015-07-21 14:22:31 +02:00
Julien Fontanet
f9ba7377eb Do not create the promise if unnecessary. 2015-07-21 13:58:43 +02:00
Julien Fontanet
5d3c47b8ae Prefer pathname over path with got. 2015-07-21 13:58:25 +02:00
Fabrice Marsaud
ef9cc860a9 removed console output 2015-07-17 14:57:21 +02:00
Julien Fontanet
5a1ec8aa74 Merge pull request #76 from vatesfr/xo-web-issue#301
Deleting a VM also deletes its snapshots.
2015-07-16 17:11:13 +02:00
Fabrice Marsaud
ac435f3699 Deleting a VM also deletes its snapshots. 2015-07-16 17:03:15 +02:00
Julien Fontanet
0374dec79c Use standard Promise instead of Bluebird where possible. 2015-07-15 15:15:54 +02:00
Julien Fontanet
41b6bf38c4 Fix disks deletion in deleteVm(). 2015-07-15 13:44:16 +02:00
Julien Fontanet
ddba251449 Coding style fixes. 2015-07-15 09:42:50 +02:00
Julien Fontanet
bf76e47648 Coding style fixes. 2015-07-15 09:41:54 +02:00
Julien Fontanet
5a3ad35bdd Update standard to 4.5.4. 2015-07-15 09:41:54 +02:00
Julien Fontanet
7da18274ad Use standard Promise instead of Bluebird where possible. 2015-07-15 09:41:54 +02:00
Varchar38
9b66ae05eb Delete set_enable 2015-07-13 15:49:25 +02:00
Fabrice Marsaud
d407964625 Avoid deleting Isos in drive when deleting a VM 2015-07-09 21:59:09 +02:00
Fabrice Marsaud
bc254d5a8d Issue #303, delete unpluggable disks with VMs 2015-07-09 19:09:36 +02:00
Fabrice Marsaud
1d9128a650 Removed unused import 2015-07-02 17:29:20 +02:00
Fabrice Marsaud
a1f2e9e4e2 Fixed a xapi call 2015-07-02 16:50:37 +02:00
Julien Fontanet
8c8188c24f Update deps. 2015-07-01 16:54:24 +02:00
Julien Fontanet
e42eaf73b8 Update xen-api to 0.6.1. 2015-06-30 17:23:20 +02:00
Julien Fontanet
fbd8552c0b Fix error symbol in API traces. 2015-06-30 17:15:38 +02:00
Julien Fontanet
daa26b2e1e Created VBDs should be unpluggable. 2015-06-30 16:23:51 +02:00
Julien Fontanet
18473e6819 Fix inter pool migration. 2015-06-30 13:05:30 +02:00
Julien Fontanet
a51d6b9a74 Better API traces. 2015-06-30 11:06:31 +02:00
Olivier Lambert
706871c12a 4.2.0 2015-06-29 09:17:00 +02:00
Julien Fontanet
16c49e965c Update json-rpc-peer to 0.10 (fixes #71, fixes #72 and maybe vatesfr/xo-web#297) 2015-06-26 20:24:04 +02:00
Fabrice Marsaud
f29e867441 Merge pull request #66 from vatesfr/marsaud-issue176
Marsaud issue176 schedules/jobs
2015-06-26 14:23:16 +02:00
Fabrice Marsaud
4a5f6d8393 Job scheduler feature 2015-06-26 14:13:38 +02:00
Julien Fontanet
39e3025077 Work around babel/babel#1850. 2015-06-26 14:02:11 +02:00
Julien Fontanet
9ee293816d Properly cast booleans from xen-api. 2015-06-26 10:51:09 +02:00
Julien Fontanet
b3c1397753 Fix invalid exception in vdi.set(). 2015-06-25 17:02:25 +02:00
Julien Fontanet
93d63538bb vdi.set() supports size as string 2015-06-25 16:34:10 +02:00
Julien Fontanet
09c28d2311 Update source-map-support to 0.3.2. 2015-06-25 14:10:42 +02:00
Julien Fontanet
5b8ed496db Fix disk.create(). 2015-06-25 13:53:42 +02:00
Julien Fontanet
27b4cf743e Work around for dates from XAPI JSON. 2015-06-25 10:32:30 +02:00
Julien Fontanet
95938a65b6 Minor fix. 2015-06-24 17:47:47 +02:00
Julien Fontanet
70780fc4ef New Xapi#ejectCdFromVm(). 2015-06-24 17:46:34 +02:00
Julien Fontanet
21d265d12f Only set the CD drive bootable on VM creation. 2015-06-24 17:30:02 +02:00
Julien Fontanet
788526d6eb disk.create() requires a sr. 2015-06-24 17:02:25 +02:00
Julien Fontanet
a7203e9a17 Xapi#createVdi() use default_SR if necessary. 2015-06-24 16:27:16 +02:00
Julien Fontanet
eff50daae4 Fix CD insertion for HVM VM creation. 2015-06-23 15:34:04 +02:00
Julien Fontanet
7612db15e0 Do not use babel-plugin-closure-elimination. 2015-06-23 14:59:29 +02:00
Julien Fontanet
0731ee473d Minor fix. 2015-06-23 14:43:51 +02:00
Julien Fontanet
3a6a76fe19 Prefers position (device) 3 for CD drive. 2015-06-23 14:38:16 +02:00
Julien Fontanet
edb0509194 Minor package.json change. 2015-06-23 14:07:58 +02:00
Julien Fontanet
1806be1fd7 Xapi#_createTask() now returns a ref. 2015-06-23 14:04:54 +02:00
Varchar38
7769f25869 Add delete VM-template 2015-06-23 13:57:59 +02:00
Julien Fontanet
f6e5743f20 Update xen-api to v0.6. 2015-06-23 10:47:34 +02:00
Julien Fontanet
1ef6196de6 TODOs. 2015-06-23 10:14:16 +02:00
Julien Fontanet
75ceee23ec Fix attachVdiToVm. 2015-06-22 10:52:56 +02:00
Julien Fontanet
38f2372ee8 Do not use require-tree. 2015-06-22 10:41:36 +02:00
Julien Fontanet
b58826da6e Merge pull request #70 from vatesfr/vm-create-refactoring
vm.create() refactoring
2015-06-19 16:59:36 +02:00
Varchar38
2c05e606c7 Merge branch 'next-release' of https://github.com/vatesfr/xo-server into next-release 2015-06-18 16:55:08 +02:00
Varchar38
92f1c080c4 Add missing await for async unregisterXenServer 2015-06-18 16:54:00 +02:00
Julien Fontanet
8f79699e84 Xapi#_createVbd() correctly finds a default position. 2015-06-18 16:11:37 +02:00
Julien Fontanet
e7b3e28f76 vm.delete() must not remove unpluggable VDIs. 2015-06-18 16:11:08 +02:00
Julien Fontanet
123677b6c6 Fix isVmHvm(). 2015-06-18 16:10:45 +02:00
Julien Fontanet
f393c7173c vm.create() only one VBD is bootable. 2015-06-18 16:10:32 +02:00
Julien Fontanet
0abfb9f1e4 vm.create() can set the description. 2015-06-18 16:09:59 +02:00
Julien Fontanet
379771a5c1 Remove unused import. 2015-06-18 15:26:31 +02:00
Julien Fontanet
2f4a76b3fa Fix handling when vm.create(installation) is undefined. 2015-06-18 15:18:42 +02:00
Julien Fontanet
7d82e199b7 Fix Xapi#_deleteVdi(). 2015-06-18 15:09:28 +02:00
Julien Fontanet
de693a08ad vm.create() seems to work ok. 2015-06-18 15:09:28 +02:00
Julien Fontanet
923091ca62 Various updates. 2015-06-18 15:09:28 +02:00
Julien Fontanet
cb65ddedb6 Remove problematic _waitObject(). 2015-06-18 15:09:27 +02:00
Julien Fontanet
7aa75539c9 Fix VDIs creation. 2015-06-18 15:09:27 +02:00
Julien Fontanet
a1a7cf59b3 vm.create() returns the new VM id. 2015-06-18 15:09:27 +02:00
Julien Fontanet
f572cb5f3e Test utils.formatXml(). 2015-06-18 15:09:27 +02:00
Julien Fontanet
8f1a31ad13 Fix XML generation. 2015-06-18 15:09:26 +02:00
Julien Fontanet
dcf63e3da2 Typo. 2015-06-18 15:09:26 +02:00
Julien Fontanet
153dca8137 More tolerant parsing of VM-template.disks. 2015-06-18 15:09:26 +02:00
Julien Fontanet
db97787b15 Fix other_config.disks XML generation. 2015-06-18 15:09:26 +02:00
Julien Fontanet
7148fec6e1 Object watchers are never rejected. 2015-06-18 15:09:25 +02:00
Julien Fontanet
db6d48f8ca vm.create() refactoring. 2015-06-18 15:09:25 +02:00
Julien Fontanet
6d87a1a604 Update xen-api to 0.5.6. 2015-06-18 13:42:03 +02:00
Julien Fontanet
5c414fc7b4 Test on both io.js v1 & v2. 2015-06-18 11:05:44 +02:00
Julien Fontanet
127f4446ae Log SIGINT & SIGTERM. 2015-06-18 10:48:40 +02:00
Julien Fontanet
49a49e2a2c Use must instead of chai. 2015-06-15 16:41:11 +02:00
Julien Fontanet
8b9389b468 Fix tests execution on Windows. 2015-06-15 16:27:02 +02:00
Julien Fontanet
ee17336d64 Remove unused import. 2015-06-15 16:24:50 +02:00
Julien Fontanet
2b768d2fb5 TODO: an user should be able to delete its tokens. 2015-06-15 13:15:38 +02:00
Julien Fontanet
4fc63010d4 Remove incorrect (and unused) code. 2015-06-15 13:15:24 +02:00
Julien Fontanet
3311ded843 Fix tokens deletion. 2015-06-15 13:15:12 +02:00
Julien Fontanet
135c2e7a71 Better npm test. 2015-06-12 10:59:36 +02:00
Julien Fontanet
a3a8f600b6 Add Travis CI badge on README. 2015-06-12 10:56:23 +02:00
Olivier Lambert
23643b99e2 remove old permissions for snapshot, convert, clone and set 2015-06-11 14:42:15 +02:00
Julien Fontanet
764a334952 Various updates. 2015-06-11 14:21:47 +02:00
Julien Fontanet
6f163f2d01 Use Xapi#createVirtualInterface in vm.create(). 2015-06-11 13:59:39 +02:00
Julien Fontanet
aae65f8235 Fix CD drive creation in vm.create(). 2015-06-11 13:59:20 +02:00
Julien Fontanet
764ea571eb Fix VIFs creation in vm.create(). 2015-06-11 13:42:33 +02:00
Julien Fontanet
aef719b574 Fix stack traces on Node 0.10. 2015-06-11 13:02:16 +02:00
Julien Fontanet
73e52e625b Build on install to fix tests on Travis CI. 2015-06-11 09:16:50 +02:00
Julien Fontanet
a967588fe1 Travis CI integration. 2015-06-10 17:00:46 +02:00
Julien Fontanet
72e530f062 Do not distribute examples & tests. 2015-06-10 17:00:06 +02:00
Julien Fontanet
a0b422f99e Also ignore npm-debug.log.* 2015-06-10 16:59:03 +02:00
Julien Fontanet
6b92f30324 Better stack traces in tests and production. 2015-06-10 16:59:03 +02:00
Julien Fontanet
464cfe701c Add Babel plugin for closure elimination (disabled for now). 2015-06-10 16:59:03 +02:00
Olivier Lambert
070fa03108 4.1.0 2015-06-10 16:32:24 +02:00
Olivier Lambert
51abeabb33 fix issue xo-web/#287 2015-06-10 16:22:13 +02:00
Olivier Lambert
74b0697da1 4.0.3 2015-06-07 16:11:41 +02:00
Julien Fontanet
0ca409bb22 4.0.3-alpha.2 2015-06-05 18:52:35 +02:00
Julien Fontanet
527cf25d1b Explicitly depends on redis. 2015-06-05 18:50:29 +02:00
Julien Fontanet
a49594e6a5 4.0.3-alpha.1 2015-06-05 18:38:11 +02:00
Julien Fontanet
5cd22b41d6 No longer use fibers. 2015-06-05 18:34:04 +02:00
Julien Fontanet
934949c514 Remove unused dependencies. 2015-06-05 17:42:54 +02:00
Julien Fontanet
cc61e8d334 Require package.json instead of package.
Not using the extension confuses dependency-check.
2015-06-05 17:21:34 +02:00
Julien Fontanet
81be499c49 4.0.3-alpha.0 2015-06-05 16:02:35 +02:00
Julien Fontanet
082aa55566 Disable Babel experiemental transformers. 2015-06-05 15:45:57 +02:00
Julien Fontanet
c783039557 Use julien-f-unzip instead of @julien-f/unzip. 2015-06-05 15:45:49 +02:00
Julien Fontanet
206dfeb879 Use json-rpc-peer & json-rpc-protocol instead of deprecated @julien-f/json-rpc. 2015-06-05 15:00:08 +02:00
Julien Fontanet
f839e76f4b Show app-conf debug messages. 2015-06-05 15:00:08 +02:00
Julien Fontanet
c67151f922 Disable Babel minification.deadCodeElimination which has issues with Node 0.12. 2015-06-05 12:53:34 +02:00
Julien Fontanet
aedec5de18 Update source-map-support to 0.3. 2015-06-05 12:04:44 +02:00
Julien Fontanet
3df973a1ea External Babel configuration. 2015-06-03 17:34:50 +02:00
Julien Fontanet
0253031d7f Use standard with babel-eslint. 2015-06-03 17:34:49 +02:00
Olivier Lambert
f4445d4681 4.0.2 2015-06-02 20:33:49 +02:00
Olivier Lambert
e399dfa7e6 fix permissions issues 2015-06-02 18:13:54 +02:00
Olivier Lambert
787f95ac3a 4.0.1 2015-06-01 10:45:29 +02:00
Fabrice Marsaud
d2f35d46d2 Fix for xo-web Issue #264 password not saving 2015-06-01 09:34:56 +02:00
Julien Fontanet
b21d078c5d 4.0.0 2015-05-29 16:14:39 +02:00
Julien Fontanet
032c3fb856 Merge branch 'next-release' 2015-05-29 16:14:22 +02:00
Julien Fontanet
bbd79379ce Remove unused import. 2015-05-29 16:11:43 +02:00
Julien Fontanet
d01d544a0a Remove a fixed FIXME. 2015-05-29 15:23:53 +02:00
Julien Fontanet
01ecd76976 vm.ejectCd() succeed even if the VBD cannot be destroyed. 2015-05-29 15:23:36 +02:00
Julien Fontanet
26e8ae4bf3 position is now optional for vm.attachDisk(). 2015-05-29 11:55:59 +02:00
Julien Fontanet
3befdbc93d Fix group.setUsers(). 2015-05-29 10:21:49 +02:00
Olivier Lambert
c91a890d42 add ACLs in objects 2015-05-29 09:35:20 +02:00
Julien Fontanet
3369ab601a Stupide error -_-". 2015-05-28 23:26:07 +02:00
Julien Fontanet
bfe5b71f19 Various updates. 2015-05-28 23:12:32 +02:00
Julien Fontanet
eb25cf65dd acl.getCurrent() handles groups. 2015-05-28 22:42:57 +02:00
Julien Fontanet
aa1ca3be64 Various updates. 2015-05-28 22:32:30 +02:00
Julien Fontanet
a4e03daeee Various updates. 2015-05-28 22:14:20 +02:00
Julien Fontanet
cbd0b9db1d Users must also linked to their groups. 2015-05-28 20:47:42 +02:00
Julien Fontanet
621e8e89a5 Implements groups. 2015-05-28 19:26:16 +02:00
Julien Fontanet
c9eca5ec7e ACLs have a role and existing ACLs are automatically upadted. 2015-05-28 18:08:36 +02:00
Julien Fontanet
05063b76eb Initial role API. 2015-05-28 16:57:11 +02:00
Julien Fontanet
7d1d34d1eb Remove unused code. 2015-05-28 16:56:45 +02:00
Julien Fontanet
40423a0547 Set debug to xo:main only in production. 2015-05-28 14:57:04 +02:00
Julien Fontanet
682804b1ad Fix consoles proxy. 2015-05-28 12:45:37 +02:00
Julien Fontanet
790e67866c Fix VM-template.template_info.disks. 2015-05-28 12:25:59 +02:00
Julien Fontanet
8399edb4dc Fix vm.docker.version. 2015-05-28 11:42:30 +02:00
Julien Fontanet
55a1c27d6d Fix VIF creation. 2015-05-28 11:42:13 +02:00
Julien Fontanet
35bf7dc484 Better message when a object param is not found. 2015-05-28 11:41:51 +02:00
Julien Fontanet
4d3dfa1dca Typo. 2015-05-27 19:27:37 +02:00
Olivier Lambert
ac4686125f fix RRD fetching on VM view 2015-05-27 18:49:07 +02:00
Olivier Lambert
fb2ca3bb19 fix CPU parsing error in RRD 2015-05-27 18:43:26 +02:00
Julien Fontanet
c0122aace7 Various fixes. 2015-05-27 18:25:24 +02:00
Fabrice Marsaud
c141e92cc4 Group managment for ACLs (Mock. No implementation) 2015-05-27 17:22:07 +02:00
Julien Fontanet
5236441be0 New collection! 2015-05-27 17:00:35 +02:00
Olivier Lambert
94620748ab filter IOPS 2015-05-27 10:56:14 +02:00
Julien Fontanet
da70c03845 Use correct HTTP status code
See https://tools.ietf.org/html/rfc7231#section-6.5.10
2015-05-27 10:33:57 +02:00
Olivier Lambert
337eb0f27b remove useless debug 2015-05-26 19:57:10 +02:00
Olivier Lambert
26a63c4baf optimize the stats code 2015-05-26 19:43:51 +02:00
Julien Fontanet
8b03890f2a New util extractProperty() and some tests. 2015-05-26 17:59:52 +02:00
Julien Fontanet
61731e2c2e Detect blocked event loop. 2015-05-26 11:57:49 +02:00
Julien Fontanet
5c1611c484 @autobind decorator. 2015-05-25 16:50:27 +02:00
Julien Fontanet
a502965d19 Fix syntax. 2015-05-25 15:29:42 +02:00
Julien Fontanet
b55764db56 More code in Xapi. 2015-05-25 15:20:59 +02:00
Julien Fontanet
510897f672 Display error stack if available in Xo#_handleHttpRequest(). 2015-05-25 14:56:40 +02:00
Julien Fontanet
2689fd17d0 Correctly forward req & res in Xo#_handleHttpRequest(). 2015-05-25 14:56:06 +02:00
Julien Fontanet
75e3949cec Expose patch UUID. 2015-05-25 14:49:19 +02:00
Julien Fontanet
a7bb4b7104 Check for patch existence in Xapi#_getOrUploadPoolPatch(). 2015-05-25 14:44:15 +02:00
Julien Fontanet
9bcb2ac094 Fix snapshot deletion after VM export. 2015-05-25 12:51:42 +02:00
Julien Fontanet
9ab110277a Do not include conflicting patches in Xapi#listMissingPoolPatchesOnHost(). 2015-05-25 12:03:29 +02:00
Olivier Lambert
d1506bcdae start to work on patches conflicts and dependencies 2015-05-25 11:24:49 +02:00
Julien Fontanet
00c38c96cd Remove now unneeded code. 2015-05-25 10:51:58 +02:00
Julien Fontanet
9798d4ff6a Update deps. 2015-05-24 18:55:30 +02:00
Julien Fontanet
5801b29ede Do not crash when the console URL cannot be found. 2015-05-24 16:51:51 +02:00
Julien Fontanet
22ed022787 Updates @julien-f/json-rpc to 0.4.4. 2015-05-24 16:22:38 +02:00
Julien Fontanet
f7e7ecf5ae Minor coding style fix. 2015-05-24 15:24:27 +02:00
Julien Fontanet
c116d3f453 Use babel-standard instead of standard. 2015-05-24 15:24:18 +02:00
Julien Fontanet
d9b3d263ae Remove no longer used xo.$running_VMs. 2015-05-24 15:23:01 +02:00
Julien Fontanet
9a265a0437 New API method: test.wait(). 2015-05-22 16:37:26 +02:00
Julien Fontanet
16450e2133 Remove useless statement. 2015-05-22 11:58:31 +02:00
Julien Fontanet
5678742810 Fix SR editing. 2015-05-22 11:58:19 +02:00
Julien Fontanet
76d551a238 Move consoles in /api/consoles/ 2015-05-20 10:28:22 +02:00
Julien Fontanet
5467c4b1b8 Fix proxy URLs generation (fix #58). 2015-05-19 18:40:49 +02:00
Julien Fontanet
e48d277440 SPDX valid license. 2015-05-19 17:45:02 +02:00
Julien Fontanet
9d1da81557 Remove unnecessary traces. 2015-05-19 13:03:12 +02:00
Julien Fontanet
91f557ac9e TODO: sort proxies by descending prefix length. 2015-05-19 12:59:02 +02:00
Julien Fontanet
452826bd61 Missing token is not a auth provider bug. 2015-05-19 12:58:46 +02:00
Julien Fontanet
84564bb7fb WS proxy forwards the subprotocol. 2015-05-19 12:56:06 +02:00
Julien Fontanet
bf7647c737 WS proxy correctly handle subpaths. 2015-05-19 12:55:46 +02:00
Julien Fontanet
1f98d7e5ec HTTP proxy correctly handle subpaths. 2015-05-19 12:55:35 +02:00
Julien Fontanet
e4486f4c17 Fix send error messages in wsProxy. 2015-05-19 12:31:14 +02:00
Julien Fontanet
65daa23a74 Do not set rejectUnauthorized by default in wsProxy. 2015-05-19 12:27:02 +02:00
Julien Fontanet
523a30afb4 Fix initial user creation (fix #57). 2015-05-19 09:54:57 +02:00
Julien Fontanet
1d0de4584e Fix session.getUser(). 2015-05-18 11:56:37 +02:00
Julien Fontanet
7aac124407 Forward the upgrade event to connect. 2015-05-18 11:15:29 +02:00
Olivier Lambert
03e8b664ac add host stats 2015-05-17 23:08:16 +02:00
Julien Fontanet
66883ae37c Remove discouraged path for the config file from the doc. 2015-05-15 11:47:18 +02:00
Julien Fontanet
2a075d929a Xapi#_setObjectProperties() gets the object type itself. 2015-05-14 15:53:54 +02:00
Olivier Lambert
41147483d8 remove old docker method in VM and add the bootOrder method 2015-05-13 15:25:36 +02:00
Julien Fontanet
ca517784ed Fix many errors and styles. 2015-05-13 14:27:14 +02:00
Julien Fontanet
4dd3be1568 ACLs functions moved to Xo. 2015-05-13 12:00:01 +02:00
Julien Fontanet
7412d97bf3 Do not attempt to set up proxies if there are none. 2015-05-13 10:33:00 +02:00
Fabrice Marsaud
ab7b2da83b Mixed missing error import 2015-05-13 10:05:05 +02:00
Julien Fontanet
19e26729a8 Correctly initialize Xo#_httpRequestWatchers. 2015-05-12 18:49:40 +02:00
Julien Fontanet
0101365ebc Configurable proxies. 2015-05-12 18:45:21 +02:00
Julien Fontanet
1f56e63f9c Comments. 2015-05-12 18:24:52 +02:00
Julien Fontanet
883a30c7ad Patch upload reworked. 2015-05-12 17:34:13 +02:00
Julien Fontanet
6e151a9f8b Properties settings moved into xapi.js 2015-05-12 17:08:38 +02:00
Julien Fontanet
321bb299b1 Fix grammar in error message. 2015-05-12 17:03:58 +02:00
Julien Fontanet
2ca18340c7 Remove 2 unused imports. 2015-05-12 14:07:16 +02:00
Julien Fontanet
74d4237913 Fix docker methods. 2015-05-12 12:52:29 +02:00
Olivier Lambert
a4f9b9208d fix registration 2015-05-09 11:43:21 +02:00
Olivier Lambert
8fd65b7365 replace unregister by deregister 2015-05-09 00:29:16 +02:00
Olivier Lambert
4f4d0bf6aa work in progress. Find where (un)register raise UNKNOWN_XENAPI_PLUGIN_FUNCTION. Because it shouldn't. 2015-05-09 00:26:14 +02:00
Olivier Lambert
873e2aed94 enable/disable docker and more robust spec with XML parsing for docker stuff 2015-05-08 19:03:25 +02:00
Olivier Lambert
89d485e188 remove typo in id 2015-05-08 16:12:15 +02:00
Julien Fontanet
2e9870014f Fix docker.*() functions export. 2015-05-08 16:02:46 +02:00
Julien Fontanet
528529c0d1 docker.*() methods. 2015-05-08 15:51:53 +02:00
Olivier Lambert
9bddec2dfd first Docker attempt 2015-05-08 15:37:30 +02:00
Olivier Lambert
f986487df9 Update README.md 2015-05-07 19:42:34 +02:00
Julien Fontanet
99461a70e6 Remove useless $coroutine. 2015-05-06 17:53:36 +02:00
Julien Fontanet
adbbb15a92 Fix possibly long standing bug in Api#call(). 2015-05-06 17:53:20 +02:00
Julien Fontanet
d85a4c9ad4 Fix patch upload! 2015-05-06 17:37:31 +02:00
Julien Fontanet
41baea780a Xapi#_watchTask() unpack the ref if necessary. 2015-05-06 17:23:38 +02:00
Julien Fontanet
a165884bcb Fix debug message. 2015-05-06 17:23:17 +02:00
Julien Fontanet
456adc5d0b Add missing Error class. 2015-05-06 17:22:46 +02:00
Julien Fontanet
cfc42906b9 Add debug traces for patch install. 2015-05-06 16:49:26 +02:00
Julien Fontanet
738d657c8e Fix copy pasta -_-". 2015-05-06 16:19:17 +02:00
Julien Fontanet
a51452ee7c Remove unused var. 2015-05-06 16:13:58 +02:00
Julien Fontanet
5d2a41082a Fix server management due to f*** merge. 2015-05-06 16:06:04 +02:00
Julien Fontanet
f9dd00b79b Do not XO & XAPI objects. 2015-05-06 15:36:27 +02:00
Olivier Lambert
898244d04d link pool_patches to a pool 2015-05-06 15:34:57 +02:00
Julien Fontanet
33334830cc Various fixes. 2015-05-06 15:33:09 +02:00
Julien Fontanet
8503350bfd Missing dep (xo-collection). 2015-05-06 15:01:59 +02:00
Julien Fontanet
a4bb2aaf12 Missing file. 2015-05-06 15:01:26 +02:00
Julien Fontanet
da443045bf Merge branch 'patch' into next-release 2015-05-06 14:50:40 +02:00
Julien Fontanet
b9927cd48d pool.installPatch() & host.installPatch(). 2015-05-06 14:33:49 +02:00
Julien Fontanet
7af3f7e881 Xapi#_getXenUpdates() should be static. 2015-05-06 10:54:28 +02:00
Julien Fontanet
ee81febc89 Fix @debounce to work correctly with multiple instances. 2015-05-06 10:54:10 +02:00
Julien Fontanet
8146bee846 Upload to pool master. 2015-05-05 19:00:22 +02:00
Julien Fontanet
53e94378ae Correctly handle patch upload error. 2015-05-05 19:00:22 +02:00
Julien Fontanet
8592ead0e3 Missing import. 2015-05-05 19:00:22 +02:00
Olivier Lambert
67699372f2 add url parameter 2015-05-05 18:44:29 +02:00
Julien Fontanet
95a8ced558 Modularize. 2015-05-05 18:42:02 +02:00
Julien Fontanet
ae437be6e7 Memoize Xapi#listMissingHostPatches() 2015-05-05 18:41:47 +02:00
Julien Fontanet
1441d9f4ee host.listMissingPatches() & host.installPatchFromUrl(). 2015-05-05 17:06:52 +02:00
Julien Fontanet
adeb5c2344 Put high level Xen Server features in dedicated class. 2015-05-05 11:40:25 +02:00
Julien Fontanet
f0b0277b9d Fix Xen error handling (#56). 2015-05-05 10:24:13 +02:00
Olivier Lambert
6fb5fb63e7 allow to patch one host only and not the whole pool 2015-05-02 18:14:50 +02:00
Olivier Lambert
5330cc5ae9 fix a typo 2015-05-02 14:04:14 +02:00
Julien Fontanet
bcc2244fdb Various updates. 2015-04-30 18:31:42 +02:00
Julien Fontanet
ad2de95f32 Various updates. 2015-04-30 17:45:53 +02:00
Olivier Lambert
453dee33ba initial Docker control 2015-04-29 17:27:53 +02:00
Julien Fontanet
13f36b3f79 Various code simplifications and fixes. 2015-04-28 15:47:26 +02:00
Julien Fontanet
719b63ee02 Typo. 2015-04-28 14:44:44 +02:00
Julien Fontanet
38a5698f90 Use async functions instead of Bluebird.coroutine(). 2015-04-28 14:36:16 +02:00
Julien Fontanet
a05b60f48e Remove no-lone-blocks directive which is no longer needed. 2015-04-28 13:06:57 +02:00
Julien Fontanet
8694ecd417 xo: CoffeeScript to ES6 and split in multiple files. 2015-04-28 13:06:26 +02:00
Julien Fontanet
100d007271 3.9.2 2015-04-26 11:29:09 +02:00
Julien Fontanet
a1a764d807 Fix json-rpc dep. 2015-04-26 11:28:53 +02:00
Julien Fontanet
6cb30adf5d helpers.spec: CoffeeScript to ES6. 2015-04-24 17:52:05 +02:00
Julien Fontanet
9eb939e38f helpers: CoffeeScript to ES6. 2015-04-24 17:16:43 +02:00
Julien Fontanet
3e26060979 fibers-urils: CoffeeScript to ES6 and tests fixed. 2015-04-24 14:01:12 +02:00
Julien Fontanet
cc60aa7b84 Remove Coffeelint as it is not really used. 2015-04-24 11:23:04 +02:00
Julien Fontanet
bdfdafaec0 Install json-rpc from the npm repository. 2015-04-24 10:58:49 +02:00
Julien Fontanet
7737dc6b6c Convert last ES5 files to ES6. 2015-04-22 14:28:30 +02:00
Julien Fontanet
1a89465201 Replace AMAP var by const. 2015-04-22 14:10:04 +02:00
Julien Fontanet
fe3ce45b8e Remove unused dep. 2015-04-21 14:40:12 +02:00
Julien Fontanet
7af0883f08 gulp-sourcemaps is a dev dep. 2015-04-21 14:39:20 +02:00
Julien Fontanet
f48c21b124 Remove unused code. 2015-04-21 14:38:21 +02:00
Julien Fontanet
abc2e74f2c 3.9.1 2015-04-21 11:10:11 +02:00
Julien Fontanet
6130c49b83 Merge branch 'next-release' 2015-04-21 11:10:05 +02:00
Julien Fontanet
433b58511c Fix VM_guest_metrics. 2015-04-20 19:47:58 +02:00
Olivier Lambert
b04111c79b add snapshot type for certain VM actions 2015-04-20 18:30:26 +02:00
Olivier Lambert
06ca0079b3 better error message if host unreach 2015-04-20 18:30:02 +02:00
Julien Fontanet
ff53c6b49d 3.9.0 2015-04-20 17:40:09 +02:00
Julien Fontanet
da58458fb7 Merge branch 'next-release' 2015-04-20 17:40:01 +02:00
Julien Fontanet
1a21989ad1 Use lodash.includes instead of lodash.contains. 2015-04-20 16:26:14 +02:00
Julien Fontanet
76d54b8914 Update to make-error v1. 2015-04-20 12:58:46 +02:00
Julien Fontanet
d22d64f68c Minor fixes. 2015-04-18 19:35:27 +02:00
Julien Fontanet
580ae005f4 Fix some compilation errors. 2015-04-18 19:35:18 +02:00
Julien Fontanet
75ab9d2e8c Use Babel 5. 2015-04-18 19:34:58 +02:00
Fabrice Marsaud
6c246768e9 Fixed broken graphs after reboot #228 2015-04-15 18:45:16 +02:00
Olivier Lambert
bc75bc199b remove admin permission for stats 2015-04-15 14:19:08 +02:00
Julien Fontanet
f234b6a540 Better error message when authentication fails in server.connect(). 2015-04-14 18:15:21 +02:00
Julien Fontanet
bff8bfea7b server.add() does not wait for the connection. 2015-04-14 17:01:08 +02:00
Julien Fontanet
48bf0d1942 Do not compact the dev build. 2015-04-14 15:24:52 +02:00
Julien Fontanet
04bbb84845 Typos. 2015-04-14 15:24:28 +02:00
Julien Fontanet
311f8cd00f pool.$id not pool.id!! 2015-04-14 11:45:06 +02:00
Julien Fontanet
ed0ab78048 Better error messages in XO#getXAPI(). 2015-04-14 11:40:46 +02:00
Julien Fontanet
0eec1c1f61 Use standard style. 2015-04-13 18:33:15 +02:00
Julien Fontanet
b4a3b832dc Update to latest xen-api. 2015-04-13 17:47:16 +02:00
Julien Fontanet
8e7830dd7d Minor fixes. 2015-04-13 16:50:00 +02:00
Julien Fontanet
d32a18d965 Increment VIF # when creating a VM (fix #229). 2015-04-13 16:27:53 +02:00
Julien Fontanet
7d00d47cb6 Port XAPI code to xen-api. 2015-04-13 16:21:44 +02:00
Julien Fontanet
b0853eb119 ES6 style. 2015-04-13 16:21:44 +02:00
Julien Fontanet
25d29fb389 server: CoffeeScript → ES6. 2015-04-13 16:21:44 +02:00
Olivier Lambert
ed241ede9d fix force reboot method 2015-04-13 13:12:13 +02:00
Julien Fontanet
04a27d5778 Authentication providers can throw null. 2015-04-10 11:20:35 +02:00
Fabrice Marsaud
70a2067a06 Fixed date in vm stat data 2015-04-08 12:54:26 +02:00
Fabrice Marsaud
4a13c01817 First stat view delivery for #228 2015-04-08 12:54:26 +02:00
Fabrice Marsaud
151c2b573c vm stats code enhancment 2015-04-08 12:53:34 +02:00
Olivier Lambert
4cdb3f4c6a allow variable CPUs number 2015-04-08 12:53:34 +02:00
Olivier Lambert
3cf0384bc5 use a promise 2015-04-08 12:53:34 +02:00
Olivier Lambert
ad2f6ebe93 add npm dependencies 2015-04-08 12:53:34 +02:00
Olivier Lambert
178a429f26 start to work on RRD 2015-04-08 12:52:56 +02:00
Olivier Lambert
71194d5b4e use get dedicated call to avoid confusions between UUIDs and Refs 2015-04-01 21:54:34 +02:00
Olivier Lambert
771c530b85 add createNetwork method for issue https://github.com/vatesfr/xo-web/issues/225 2015-04-01 21:29:26 +02:00
Olivier Lambert
78a6b622fb refactoring of VM auto power 2015-04-01 15:40:08 +02:00
Olivier Lambert
0177bbebe0 autopower VM feature, see https://github.com/vatesfr/xo-web/issues/224 2015-04-01 15:22:25 +02:00
Olivier Lambert
8deed4a9cd better handling of other_config value 2015-04-01 14:56:33 +02:00
Julien Fontanet
60b2576ce8 Fix #53. 2015-03-30 23:24:50 +02:00
Julien Fontanet
90cc58a8fe Fix authentication providers iteration. 2015-03-30 18:37:41 +02:00
Julien Fontanet
d79f750e30 Add missing files to distribution. 2015-03-30 18:09:36 +02:00
Julien Fontanet
9f9ab01508 Proper compilation phase (fix #50). 2015-03-30 17:58:13 +02:00
Olivier Lambert
4dc89c9082 add local LVM SR creation 2015-03-30 12:02:09 +02:00
Olivier Lambert
500349a8bd start to implement vgpus and pgpus 2015-03-29 14:25:08 +02:00
Olivier Lambert
e299f3e510 initial work on PCI attach devices 2015-03-29 01:48:48 +01:00
Julien Fontanet
6114f4644f 3.8.0 2015-03-27 15:13:15 +01:00
Julien Fontanet
eb664404e1 Update proxy-http-request. 2015-03-27 12:51:11 +01:00
Olivier Lambert
370f645cf0 add createInterface in VM object 2015-03-26 00:14:56 +01:00
Julien Fontanet
bd5b18a163 Minor changes. 2015-03-25 17:20:25 +01:00
Olivier Lambert
c51b0c6a41 add destroy task 2015-03-25 17:07:07 +01:00
Julien Fontanet
d56f6e75f9 Fix host.*(). 2015-03-25 15:22:24 +01:00
Olivier Lambert
c743348872 add setter for VBD position 2015-03-25 11:26:37 +01:00
Olivier Lambert
578049bfb6 fix wrong case VDI call 2015-03-23 15:56:24 +01:00
Julien Fontanet
564cd37628 Only send objects notifs to authenticated clients (2/2). 2015-03-20 13:37:35 +01:00
Julien Fontanet
60ecf91935 Only send objects notifs to authenticated clients. 2015-03-20 13:22:28 +01:00
Julien Fontanet
7b452e93b2 xo.getAllObjects() requires authentication. 2015-03-20 10:36:00 +01:00
Julien Fontanet
0bc1f7bf8c New disk.create(). 2015-03-19 17:17:03 +01:00
Olivier Lambert
62c2421d85 already implemented in vm with attach disk 2015-03-19 16:41:07 +01:00
Olivier Lambert
f2edf56d02 add method description 2015-03-19 16:27:52 +01:00
Olivier Lambert
376e5aeb45 add VBD create method 2015-03-19 16:23:04 +01:00
Julien Fontanet
3d1c7e0bc1 Fix sr.set(). 2015-03-19 15:18:10 +01:00
Julien Fontanet
a2603f882d Remove unused code in fiber-utils. 2015-03-19 14:31:47 +01:00
Julien Fontanet
0c1dcafc35 Cast model ids to string. 2015-03-19 13:24:05 +01:00
Julien Fontanet
d5108f8007 Remove dead code. 2015-03-19 13:23:42 +01:00
Julien Fontanet
ebeca9aa04 Fix token.create(). 2015-03-19 12:07:38 +01:00
Julien Fontanet
7307d9f7f1 Collection returns either an array of properties or an instance of Model. 2015-03-19 11:32:33 +01:00
Julien Fontanet
eac7cdae1c Fix handling of no password in PasswordAuthenticationProvider. 2015-03-19 11:24:21 +01:00
Julien Fontanet
7e548cb133 Coding style. 2015-03-19 11:23:51 +01:00
Julien Fontanet
0a61512fc7 Clean fiber-utils. 2015-03-19 11:05:30 +01:00
Julien Fontanet
479f2010a9 Restore session.signOut(). 2015-03-18 18:02:43 +01:00
Julien Fontanet
55796932c4 Better handling of plugin short names + Debug traces. 2015-03-18 17:38:59 +01:00
Julien Fontanet
9267adf79a Create an authenticated user if necessary. 2015-03-18 17:09:00 +01:00
Julien Fontanet
cc2f86cb06 A user can be created without a password. 2015-03-18 17:08:34 +01:00
Julien Fontanet
14c6895135 User permission default to none. 2015-03-18 17:08:19 +01:00
Julien Fontanet
83f6647352 Extend Babel ignore regexp. 2015-03-18 17:07:45 +01:00
Julien Fontanet
792ecee399 FIXME: VM restarting is not properly handled in console. 2015-03-18 14:17:45 +01:00
Julien Fontanet
93a1ef6bdb session.getUser() description. 2015-03-18 14:16:59 +01:00
Julien Fontanet
62607b16f8 session.signIn() 2015-03-18 14:16:44 +01:00
Julien Fontanet
ca60376447 Password & Token auth providers. 2015-03-18 14:16:28 +01:00
Julien Fontanet
3cc4b5db79 Initial plugin system (#37). 2015-03-18 14:14:08 +01:00
Julien Fontanet
f8179c83e7 Fix signInWithPassword(). 2015-03-17 19:05:10 +01:00
Julien Fontanet
b2233f61e4 Use proxy-http-request. 2015-03-17 19:05:10 +01:00
Julien Fontanet
a7e2f776e4 Update deps. 2015-03-17 19:05:09 +01:00
Olivier Lambert
50d672892c Enable Babel for XO-Server files 2015-03-17 16:07:26 +01:00
Julien Fontanet
e6154db6e5 API session: CoffeeScript → ES6. 2015-03-09 15:28:20 +01:00
Julien Fontanet
34e8f57f7d 3.7.0 2015-03-06 17:04:46 +01:00
Julien Fontanet
4a8c089fa9 Merge branch 'next-release' 2015-03-06 17:02:38 +01:00
Julien Fontanet
b3aa5ee247 Fix various vm.*() methods. 2015-03-06 16:52:50 +01:00
Julien Fontanet
64bf98a7d3 Fix VM creation. 2015-03-06 16:45:30 +01:00
Julien Fontanet
e8e38beeb8 Fix task.cancel(). 2015-03-06 16:31:49 +01:00
Julien Fontanet
de96a96ac6 Use babel instead of legacy 6to5 for the test runner. 2015-03-06 15:32:38 +01:00
Julien Fontanet
ee3ad17163 Minor fix. 2015-03-06 15:31:25 +01:00
Julien Fontanet
fafd8a5d51 Fix sr.reattachIso(). 2015-03-06 15:30:33 +01:00
Julien Fontanet
c5879f17f8 ACLs for task.cancel(). 2015-03-06 15:30:23 +01:00
Julien Fontanet
999cbd314c Fix vif.connect(). 2015-03-06 15:21:15 +01:00
Julien Fontanet
a9d34a223a Fix VM-snapshot authorization. 2015-03-06 15:18:50 +01:00
Julien Fontanet
3381030ed5 Add VIF authorization. 2015-03-06 15:09:35 +01:00
Julien Fontanet
2bacc6cfe8 vm.clone() is only authorized for admins. 2015-03-06 15:09:22 +01:00
Julien Fontanet
973c936514 Fix VBD authorization. 2015-03-06 14:59:39 +01:00
Julien Fontanet
c5121a7fc5 More ACLs. 2015-03-06 14:55:25 +01:00
Julien Fontanet
37bf0f6b53 ACLs for message.*(). 2015-03-06 14:27:42 +01:00
Julien Fontanet
203d51cdbf ACLs for host.*(). 2015-03-06 14:15:17 +01:00
Julien Fontanet
9669d8eb8b ACLs for vm.*(). 2015-03-06 14:10:03 +01:00
Julien Fontanet
1b7571be5b Improve authorizations checking. 2015-03-06 14:10:03 +01:00
Julien Fontanet
614ff2a30e Update to latest http-server-plus. 2015-03-06 14:10:03 +01:00
Julien Fontanet
5b11671997 Snapshots inherit ACLs of their VM. 2015-03-06 14:10:03 +01:00
Julien Fontanet
5158e08901 Properly handle optional params in resolve. 2015-03-06 14:10:03 +01:00
Julien Fontanet
2cb9c7211e Some types do not require explicit authorization. 2015-03-06 14:10:03 +01:00
Olivier Lambert
24e26c95ff add reattach iso and fix reattach 2015-03-05 16:30:50 +01:00
Julien Fontanet
b8286af8fa Gracefully shutdown on SIGINT & SIGTERM. 2015-03-05 16:15:58 +01:00
Olivier Lambert
735279c27c ACLization of SR object 2015-03-04 17:36:53 +01:00
Olivier Lambert
d75be22d1f add reattach for iscsi and nfs 2015-03-04 17:09:57 +01:00
Olivier Lambert
40f1b1c665 add probeNfsExists and fix array 2015-03-04 16:53:56 +01:00
Olivier Lambert
d076c875ed fix bad parameter name 2015-03-04 15:28:34 +01:00
Olivier Lambert
771c7fe863 fix serverPath parameter 2015-03-04 15:08:21 +01:00
Olivier Lambert
369454c12a return UUID of createIscsi and createNfs created 2015-03-04 14:57:23 +01:00
Olivier Lambert
1784eacf58 ACLization of PIF object 2015-03-04 14:54:12 +01:00
Olivier Lambert
e86f5b3b7c return UUID of createISO created 2015-03-04 14:53:35 +01:00
Olivier Lambert
80ff6cda04 ACLization of PBD object 2015-03-04 14:24:58 +01:00
Julien Fontanet
dff96cfd95 Remove a proxy request after one use. 2015-03-04 14:04:16 +01:00
Julien Fontanet
31d244ef78 Remove an unnecessary import. 2015-03-04 14:04:16 +01:00
Olivier Lambert
8325a84ab2 fix typo in PBD class 2015-03-04 13:48:46 +01:00
Olivier Lambert
793839c7d5 new acl model for import 2015-03-03 19:28:46 +01:00
Olivier Lambert
23cf87dbc0 add requiered parameters 2015-03-03 11:53:04 +01:00
Julien Fontanet
7171de336d Remove an unnecessary import. 2015-03-02 13:31:45 +01:00
Julien Fontanet
e206cfe6d6 Fix acl.get(). 2015-03-02 13:31:17 +01:00
Julien Fontanet
1a71cc9223 Implement method.resolve
API methods can now have some of their objects automatically fetched:

```
method.resolve = {
	vm: ['vm', 'VM'],
};
```

The key is the name of the property with which the object will be
attached in the parameters dictionary, the first entry of the array is
the name of the parameter to use to fetch the object and the second
the expected type/types of the object.

Note that permissions are automatically checked via the ACLs.
2015-03-02 13:27:37 +01:00
Julien Fontanet
ed6fcf5ae7 Move ensureArray() in utils. 2015-02-27 17:31:11 +01:00
Olivier Lambert
bb31693a4d fix array check 2015-02-27 15:00:02 +01:00
Olivier Lambert
d15c8b16f3 add NFS SR 2015-02-26 23:15:58 +01:00
Olivier Lambert
8b9c932b80 add optionnal port 2015-02-26 22:34:52 +01:00
Olivier Lambert
c10e8f5f9a handle correctly iSCSI exists 2015-02-26 15:55:35 +01:00
Olivier Lambert
cd27e43994 iscsi target probe 2015-02-26 14:17:17 +01:00
Olivier Lambert
20614cf64b start to work on iscsi SR 2015-02-26 13:16:44 +01:00
Julien Fontanet
c69c02bcb3 formatXml() & parseXml(). 2015-02-26 12:58:27 +01:00
Julien Fontanet
21b177cbb4 Cannot use arrow function here. (fix #44) 2015-02-26 10:23:23 +01:00
Olivier Lambert
31a7e48768 add methods for SR: createIso, destroy and forget 2015-02-25 18:10:10 +01:00
Julien Fontanet
fd3d60ed7d Fix vdi.migrate() & vdi.delete() parameters. 2015-02-25 17:10:08 +01:00
Julien Fontanet
e2e369a463 Cannot use arrow functions. 2015-02-25 16:08:55 +01:00
Julien Fontanet
0c3304f041 API sr.*() converted to ES6. 2015-02-25 16:07:10 +01:00
Julien Fontanet
0d4b9b4bce Update Api code. 2015-02-24 18:28:56 +01:00
Julien Fontanet
1192bf6a87 The identifier of an object is its UUID not its ref. 2015-02-23 18:37:01 +01:00
Julien Fontanet
2366a91e8d Shameful typo (fix consoles). 2015-02-23 17:44:46 +01:00
Julien Fontanet
2c4e46c630 Rename acl.* methods and always accept identifiers. 2015-02-19 16:28:16 +01:00
Julien Fontanet
a989e296b0 Missing file. 2015-02-19 12:54:53 +01:00
Julien Fontanet
26648dbcd2 Remove debug trace. 2015-02-19 12:46:44 +01:00
Julien Fontanet
147d759d35 Minor fixes. 2015-02-19 12:45:49 +01:00
Julien Fontanet
f6b07c5609 Remove no longer relevant comment. 2015-02-19 12:40:42 +01:00
Julien Fontanet
29fa7a053f Minor fixes. 2015-02-19 12:40:31 +01:00
Julien Fontanet
f380f245c6 Minor fix. 2015-02-18 16:06:40 +01:00
Julien Fontanet
1824a30cde 6to5 has been renamed Babel. 2015-02-18 14:52:56 +01:00
Julien Fontanet
8ab86fd6bb Remove unused deps. 2015-02-18 14:48:11 +01:00
Julien Fontanet
2c7bdc54c1 Minor fixes. 2015-02-18 13:35:28 +01:00
Julien Fontanet
39b57da42b Remove a debugging trace. 2015-02-18 11:58:59 +01:00
Julien Fontanet
a98a9fd97a Remove unused memory collection implementation. 2015-02-18 11:58:36 +01:00
Julien Fontanet
093a5c1019 Minor fixes. 2015-02-18 11:56:11 +01:00
Julien Fontanet
ba25acaab9 Redis implementation converted to ES6. 2015-02-18 11:53:51 +01:00
Julien Fontanet
9783802370 ACL model and collection. 2015-02-17 18:15:00 +01:00
Julien Fontanet
47bb02ac08 Minor fixes. 2015-02-17 18:14:32 +01:00
Julien Fontanet
1f952d81aa API methods never return undefined. 2015-02-17 18:13:26 +01:00
Julien Fontanet
0632019e44 Collection & Model rewritten in ES6. 2015-02-17 17:01:12 +01:00
Julien Fontanet
bc14d0f580 Revert problematic changes. 2015-02-12 18:06:59 +01:00
Julien Fontanet
4bc3998010 Update EditorConfig. 2015-02-12 18:03:50 +01:00
Julien Fontanet
cd9c2d1988 Remove unused $waitEvent(). 2015-02-12 16:54:50 +01:00
Julien Fontanet
5d597c22bf Remove $fiberize in favor of $coroutine. 2015-02-12 16:52:09 +01:00
Julien Fontanet
574144f9b1 Minor fix in tests. 2015-02-12 16:01:40 +01:00
Julien Fontanet
b26bee3524 Fix tests using ES6. 2015-02-12 15:58:44 +01:00
Julien Fontanet
c835cf7829 utils: CoffeeScript → ES6. 2015-02-12 15:58:29 +01:00
Julien Fontanet
a1d819dcb6 Remove unused code. 2015-02-12 14:47:36 +01:00
Julien Fontanet
2234cc9334 Always use let instead of var in ES6. 2015-02-12 14:18:40 +01:00
Julien Fontanet
cabd1506b7 Remove unused import. 2015-02-12 13:45:29 +01:00
Julien Fontanet
a7c2e321bf Remove incorrectly saved dep. 2015-02-12 13:45:16 +01:00
Julien Fontanet
31b75179bd Remove unused dep. 2015-02-12 13:32:19 +01:00
Julien Fontanet
06152f3131 Use graceful-fs. 2015-02-12 12:28:06 +01:00
Julien Fontanet
c82f8c997f Use fs-promise. 2015-02-12 12:27:48 +01:00
Julien Fontanet
f06840f4b8 Main startup file: CoffeeScript → ES6. 2015-02-12 11:54:36 +01:00
Julien Fontanet
11c3d6d056 Async methods must return promises. 2015-02-12 11:40:45 +01:00
Julien Fontanet
814a566845 Update to http-server-plus 0.5. 2015-02-12 11:32:09 +01:00
Julien Fontanet
f3bcaf2710 Typo. 2015-02-11 11:05:30 +01:00
Julien Fontanet
f9dba9266f Fix: NoSuchMethod → MethodNotFound. 2015-02-11 11:05:30 +01:00
Olivier Lambert
00f7df3982 add bios strings 2015-02-10 23:32:54 +01:00
Olivier Lambert
b873a77409 add task cancel 2015-02-05 13:40:49 +01:00
Julien Fontanet
cd5a26398a Fix host.tasks. 2015-02-05 11:18:20 +01:00
Julien Fontanet
5e8a614d82 Unregister task watchers when finished. 2015-02-04 16:34:17 +01:00
Julien Fontanet
bad601edb1 Main file is now much cleaner. 2015-02-04 16:30:37 +01:00
Julien Fontanet
58297219a8 Update deps. 2015-02-04 15:06:03 +01:00
Julien Fontanet
087b191e5b More traces during startup. 2015-02-04 15:05:56 +01:00
Julien Fontanet
de4468a15a Enable console for hosts. 2015-02-04 13:54:43 +01:00
Julien Fontanet
b73de087d2 Console proxy (fix vatesfr/xo#14). 2015-02-03 17:39:12 +01:00
Julien Fontanet
39fd092055 Update .jshintrc. 2015-02-03 15:38:07 +01:00
Julien Fontanet
dec88bd601 Correctly handle WebSocket send errors. 2015-02-03 14:34:15 +01:00
Julien Fontanet
bc9975baa1 Fix connection double closing. 2015-02-03 14:33:39 +01:00
Julien Fontanet
d2d401883e Do not display “starting...” log when --help. 2015-01-30 10:59:50 +01:00
Julien Fontanet
3b3ac1688a Update deps. 2015-01-27 18:28:44 +01:00
Julien Fontanet
6bb0ca22d0 Enable ES6. 2015-01-27 18:26:32 +01:00
Julien Fontanet
e157bc7b97 Fix JSON-RPC. 2015-01-24 15:27:33 +01:00
Julien Fontanet
578da0f1a7 Fix JSON-RPC. 2015-01-24 15:27:11 +01:00
Olivier Lambert
8f0dd0b0c6 manage suspend/resume 2015-01-12 14:04:52 +01:00
Julien Fontanet
9e05bc4fad Compatibility with Node 0.11.14. 2015-01-09 18:12:55 +01:00
Olivier Lambert
4cee341ce5 solve the issue https://github.com/vatesfr/xo-web/issues/126 2015-01-02 16:52:22 +01:00
Olivier Lambert
c40192aa46 Update README.md 2014-12-29 20:43:51 +01:00
Olivier Lambert
651748cd4e add VDI migration on another SR 2014-12-27 20:30:35 +01:00
Olivier Lambert
9e8f8357b1 Authorize storage motion to a host with different CPU config 2014-12-19 16:37:56 +01:00
Julien Fontanet
3cc4c07fa1 3.6.0 2014-11-28 17:23:41 +01:00
Julien Fontanet
8ed52af203 Merge branch 'next-release' 2014-11-28 17:23:17 +01:00
Julien Fontanet
8e9a941b5d Minor comments & coding style. 2014-11-28 15:50:12 +01:00
Olivier Lambert
4538a4d33a add pif object 2014-11-24 21:01:51 +01:00
Olivier Lambert
a8469456ce add VIF management 2014-11-24 20:42:57 +01:00
Julien Fontanet
6ca25f913a Do not log API/XAPI parameters (might be sensitive). 2014-11-24 18:53:03 +01:00
Julien Fontanet
da74c7df8a Improve API logging. 2014-11-24 18:52:25 +01:00
Julien Fontanet
278aa87753 Various API cleanup. 2014-11-24 18:39:14 +01:00
Olivier Lambert
0f77294718 add pbd plug and unplug 2014-11-24 18:28:11 +01:00
Olivier Lambert
38df160a5e add patches in the data model 2014-11-24 13:55:03 +01:00
Olivier Lambert
dc61a3307c resolve a snapshot rename bug 2014-11-20 15:21:38 +01:00
Olivier Lambert
2724f8d3c5 add position to VBD 2014-11-19 20:14:47 +01:00
Olivier Lambert
36e1c1eff0 add vbd connect method 2014-11-19 20:14:29 +01:00
Olivier Lambert
81f830fe23 remove bootable because xo-cli can't send boolean 2014-11-19 15:10:41 +01:00
Olivier Lambert
6a42482b92 try to add diskattach feature 2014-11-16 15:35:53 +01:00
Olivier Lambert
8be83c278b first work 2014-11-14 18:28:58 +01:00
Olivier Lambert
eb82980cbc fix small bug 2014-11-11 13:37:48 +01:00
Olivier Lambert
08a6d28868 modify variable ha name 2014-11-10 17:29:48 +01:00
Olivier Lambert
37afbc8e9d expose higher level call for HA on a VM: enable or disable it 2014-11-10 17:01:47 +01:00
Olivier Lambert
12546b3f17 add the possibility to get and set HA for a VM 2014-11-10 16:12:13 +01:00
Julien Fontanet
70821c5d26 Fix XAPI double logins. 2014-11-08 16:23:26 +01:00
Julien Fontanet
2f7725c5a9 Debug traces in XAPI. 2014-11-08 15:03:57 +01:00
Julien Fontanet
a96d26c3bd Handle ETIMEDOUT error. 2014-11-08 14:50:28 +01:00
Julien Fontanet
a9f37c9238 Use the make-error package. 2014-10-11 18:11:35 +02:00
Olivier Lambert
239ebcdcb8 pool.patch() also applies the patch. 2014-10-01 15:12:34 +02:00
Olivier Lambert
9e6e62c5e8 Use task watching in vm.export(). 2014-10-01 15:12:04 +02:00
Olivier Lambert
3a0e9f422e Use task ref instead of UUIDs and minor fixes. 2014-10-01 15:11:44 +02:00
Julien Fontanet
ef8beb9310 xo.watchTask(uuid) 2014-10-01 14:27:15 +02:00
Julien Fontanet
260094a666 Add separators in spec. 2014-10-01 14:04:28 +02:00
Julien Fontanet
659f9a8f18 Add generic id field. 2014-10-01 14:04:28 +02:00
Olivier Lambert
cf2e3c8018 add basic patch upload 2014-10-01 14:01:03 +02:00
Olivier Lambert
a05901e792 add a small todo 2014-09-26 22:33:16 +02:00
Olivier Lambert
0928ec5c4c vm.export() works for running VM 2014-09-26 13:26:03 +02:00
Julien Fontanet
ef843d02c0 vm.snapshot() returns the ref of the new snapshot. 2014-09-26 11:03:46 +02:00
Julien Fontanet
07cdc6bf2f Merge branch 'file-transfer' into next-release 2014-09-25 15:36:04 +02:00
Julien Fontanet
832c1ef83c Better handling of proxy requests errors. 2014-09-24 20:30:26 +02:00
Julien Fontanet
f5d0fc8672 Put API debug in the correct file. 2014-09-24 19:40:43 +02:00
Julien Fontanet
4c0c917fb5 Minor coding style update. 2014-09-24 17:26:18 +02:00
Julien Fontanet
9e5ac261e2 Can proxy a request using a different method. 2014-09-24 17:25:45 +02:00
Olivier Lambert
06abfc4337 add PUT method 2014-09-24 17:10:16 +02:00
Olivier Lambert
c9c54200aa minor fix 2014-09-24 14:55:30 +02:00
Julien Fontanet
c5f948099d Parameter names should be more semantic. 2014-09-24 14:14:31 +02:00
Julien Fontanet
a78cb59bc3 Fix operations on VM snapshots (fixes vatesfr/xo-web#147 and fixes vatesfr/xo-cli#5). 2014-09-24 10:43:32 +02:00
Julien Fontanet
fb5ff24747 Minor improvements in proxy request. 2014-09-24 09:36:45 +02:00
Julien Fontanet
acb2ede658 Proxy requests. 2014-09-23 17:30:19 +02:00
Julien Fontanet
05b1bffeef Small fix in token generation. 2014-09-22 13:55:08 +02:00
Julien Fontanet
b330b55054 Various updates. 2014-09-22 12:51:56 +02:00
Julien Fontanet
9a67e63e9b Proper constructor for XO. 2014-09-15 22:48:35 +02:00
Julien Fontanet
0d629a5385 Minor fix. 2014-09-15 22:47:51 +02:00
Julien Fontanet
4e6a214581 Comments. 2014-09-15 19:17:05 +02:00
Julien Fontanet
333c591771 Parallelization of first connection, logs & fixes. 2014-09-15 19:03:15 +02:00
Julien Fontanet
e6645101ad Minor debug update. 2014-09-15 17:30:37 +02:00
Julien Fontanet
48788986cb Missing file api-errors.js 2014-09-15 16:43:40 +02:00
Julien Fontanet
d400beffb6 Various fixes. 2014-09-15 16:42:43 +02:00
Julien Fontanet
7762135cb1 More debugging logs. 2014-09-15 16:42:30 +02:00
Julien Fontanet
d0d594df69 http-server-plus v0.3.0 2014-09-15 16:01:03 +02:00
Julien Fontanet
ed97f2d786 Code not used due to event-to-promise. 2014-09-15 15:21:57 +02:00
Julien Fontanet
f3a724237f Minor bug fix. 2014-09-15 01:40:27 +02:00
Julien Fontanet
aeb3a308a8 Coding style updates in fiber utils. 2014-09-15 01:26:33 +02:00
Julien Fontanet
62cc97bc44 Rename $promisify() to $coroutine() to better align with Bluebird. 2014-09-14 22:43:59 +02:00
Julien Fontanet
20928c7a7f Typo. 2014-09-14 22:40:51 +02:00
Julien Fontanet
6f4a865604 Proper error classes for API. 2014-09-14 22:40:30 +02:00
Julien Fontanet
e7919416d5 WiP. 2014-09-12 20:56:17 +02:00
Julien Fontanet
cf8a512af4 Add coffeelint config. 2014-09-12 20:55:40 +02:00
Julien Fontanet
3efef7bbbb Use lodash.forEach() instead of own code. 2014-09-12 15:58:27 +02:00
Julien Fontanet
65d8e01529 Fix error when deleting users without tokens (fix #34). 2014-09-12 15:40:10 +02:00
Julien Fontanet
e0dd7a9b4b Minor fixes. 2014-09-12 11:31:53 +02:00
Julien Fontanet
3a32d220dd Missing dep. 2014-09-12 11:29:43 +02:00
Julien Fontanet
5efaf7b23e Underscore.js is no more. 2014-09-12 11:29:36 +02:00
Julien Fontanet
91375a5447 More coding style & lodash. 2014-09-11 18:56:03 +02:00
Julien Fontanet
f6574d346c Coding style updates & use lodash. 2014-09-11 13:48:40 +02:00
Olivier Lambert
b9b29b11d4 add XenStorage motion with automatic parameters 2014-09-03 16:18:55 +02:00
Julien Fontanet
54d062156d Check object type before using them. 2014-09-02 17:53:34 +02:00
Olivier Lambert
4dc24e48d8 Interpool migration 2014-09-02 17:38:40 +02:00
Julien Fontanet
3a24464c90 Better detection of host.power_state. 2014-08-28 11:42:12 +02:00
Olivier Lambert
f2ad9395fc add start method for h host 2014-08-27 19:17:44 +02:00
Julien Fontanet
61539416e5 Fix invalid session in XAPI connection (should fix #20). 2014-08-27 19:10:45 +02:00
Julien Fontanet
ecf7c1f3f3 Update deps. 2014-08-27 12:01:03 +02:00
Julien Fontanet
d18886ed7c Hung XAPI calls timeout after 10 seconds. 2014-08-27 11:58:07 +02:00
Julien Fontanet
07cc529f6e Ignore config files of unknown formats. 2014-08-27 11:57:15 +02:00
Julien Fontanet
01b87bfbfd 3.5.0 2014-08-14 16:30:30 +02:00
Julien Fontanet
b126f0cb79 systemd configuration 2014-08-14 16:26:56 +02:00
Julien Fontanet
10c6901a04 No longer relevant 2014-08-14 16:10:08 +02:00
Julien Fontanet
c26efb111e 3.5.0-alpha2 2014-08-14 16:06:35 +02:00
Julien Fontanet
f07cbe0087 Config file can now be in /etc/xo-server & basic help message. 2014-08-14 16:05:23 +02:00
Julien Fontanet
7d72e196e0 Remove unused deps. 2014-08-12 16:13:28 +02:00
Julien Fontanet
9bc935da96 Update JSHint config. 2014-08-12 16:13:28 +02:00
147 changed files with 18453 additions and 6104 deletions

View File

@@ -1,30 +1,65 @@
# EditorConfig is awesome: http://EditorConfig.org
# http://EditorConfig.org
#
# Julien Fontanet's configuration
# https://gist.github.com/julien-f/8096213
# top-most EditorConfig file
# Top-most EditorConfig file.
root = true
# Unix-style newlines with a newline ending every file
#
# Tab indentation (size of 4 spaces)
# Common config.
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = tab
insert_final_newline = true
trim_trailing_whitespaces = true
# YAML only allows spaces.
[*.yaml]
# CoffeeScript
#
# https://github.com/polarmobile/coffeescript-style-guide/blob/master/README.md
[*.{,lit}coffee]
indent_size = 2
indent_style = space
# Special settings for NPM file.
# Markdown
[*.{md,mdwn,mdown,markdown}]
indent_size = 4
indent_style = space
# Package.json
#
# This indentation style is the one used by npm.
[/package.json]
indent_size = 2
indent_style = space
# For CoffeeScript files, we follow this Polarmobile style guide (https://github.com/polarmobile/coffeescript-style-guide/blob/master/README.md).
[*{,.spec}.{,lit}coffee]
# Jade
[*.jade]
indent_size = 2
indent_style = space
# JavaScript
#
# Two spaces seems to be the standard most common style, at least in
# Node.js (http://nodeguide.com/style.html#tabs-vs-spaces).
[*.js]
indent_size = 2
indent_style = space
# Less
[*.less]
indent_size = 2
indent_style = space
# Sass
#
# Style used for http://libsass.com
[*.s[ac]ss]
indent_size = 2
indent_style = space
# YAML
#
# Only spaces are allowed.
[*.yaml]
indent_size = 2
indent_style = space

9
.gitignore vendored
View File

@@ -1,2 +1,11 @@
/.nyc_output/
/dist/
/node_modules/
/src/api/index.js
/src/xapi/mixins/index.js
/src/xo-mixins/index.js
npm-debug.log
npm-debug.log.*
.xo-server.*

126
.jshintrc
View File

@@ -1,126 +0,0 @@
{
// --------------------------------------------------------------------
// JSHint Configuration, Node.js Edition
// --------------------------------------------------------------------
//
// This is an options template for [JSHint][1], forked from
// haschek's [JSHint template][2]:
//
// * the environment has been changed to `node`;
// * recent options were added;
// * coding style has been adapted to node (e.g. 2 spaces
// indenting, global use strict).
//
// [1]: http://www.jshint.com/
// [2]: https://gist.github.com/haschek/2595796
//
// @author Julien Fontanet <julien.fontanet@isonoe.net>
// @license http://unlicense.org/
// == Enforcing Options ===============================================
//
// These options tell JSHint to be more strict towards your code. Use
// them if you want to allow only a safe subset of JavaScript, very
// useful when your codebase is shared with a big number of developers
// with different skill levels.
"bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.).
"camelcase" : true, // Require variable names to use either camelCase or UPPER_CASE styles.
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : true, // Require triple equals i.e. `===`.
"forin" : true, // Tolerate `for in` loops without `hasOwnPrototype`.
"freeze" : true, // Prohibit modification of native objects' prototypes.
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"indent" : 2, // Specify indentation spacing
"latedef" : true, // Prohibit variable use before definition.
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects.
"plusplus" : false, // Prohibit use of `++` & `--`.
"quotmark" : "'", // Require single quotes.
"undef" : true, // Require all non-global variables be declared before they are used.
"unused" : true, // Prohibit unused variables.
"strict" : true, // Require `use strict` pragma in every function.
"trailing" : true, // Prohibit trailing whitespaces.
"maxparams" : 4, // Prohibit more than 4 parameters per function definition.
"maxdepth" : 3, // Prohibit nesting more than 3 control blocks.
"maxstatements" : 20, // Prohibit more than 20 statements per function.
"maxcomplexity" : 7, // Prohibit having to much branches in your code.
"maxlen" : 80, // Prohibit line with more than 80 characters.
// == Relaxing Options ================================================
//
// These options allow you to suppress certain types of warnings. Use
// them only if you are absolutely positive that you know what you are
// doing.
"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // Tolerate use of `== null`.
"es5" : false, // Allow EcmaScript 5 syntax.
"esnext" : true, // Allow ES.next specific features such as `const` and `let`.
"evil" : false, // Tolerate use of `eval`.
"expr" : true, // Tolerate `ExpressionStatement` as Programs. (Allowed for Mocha.)
"funcscope" : false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside.
"gcl" : false, // Makes JSHint compatible with Google Closure Compiler.
"globalstrict" : true, // Allow global "use strict" (also enables 'strict').
"iterator" : false, // Allow usage of __iterator__ property.
"lastsemic" : false, // Tolerat missing semicolons when the it is omitted for the last statement in a one-line block.
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"laxcomma" : false, // Suppress warnings about comma-first coding style.
"loopfunc" : false, // Allow functions to be defined within loops.
"maxerr" : 50, // Maximum errors before stopping.
"moz" : false, // Tolerate Mozilla JavaScript extensions.
"notypeof" : false, // Tolerate invalid typeof values.
"multistr" : false, // Tolerate multi-line strings.
"proto" : false, // Tolerate __proto__ property. This property is deprecated.
"scripturl" : false, // Tolerate script-targeted URLs.
"smarttabs" : false, // Tolerate mixed tabs and spaces when the latter are used for alignmnent only.
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"validthis" : false, // Tolerate strict violations when the code is running in strict mode and you use this in a non-constructor function.
// == Environments ====================================================
//
// These options pre-define global variables that are exposed by
// popular JavaScript libraries and runtime environments—such as
// browser or node.js.
"browser" : false, // Standard browser globals e.g. `window`, `document`.
"couch" : false, // Enable globals exposed by CouchDB.
"devel" : false, // Allow development statements e.g. `console.log();`.
"dojo" : false, // Enable globals exposed by Dojo Toolkit.
"jquery" : false, // Enable globals exposed by jQuery JavaScript library.
"mootools" : false, // Enable globals exposed by MooTools JavaScript framework.
"node" : true, // Enable globals available when code is running inside of the NodeJS runtime environment.
"nonstandard" : false, // Define non-standard but widely adopted globals such as escape and unescape.
"phantom" : false, // Enable globals exposed by PhantomJS.
"prototypejs" : false, // Enable globals exposed by Prototype JavaScript framework.
"rhino" : false, // Enable globals available when your code is running inside of the Rhino runtime environment.
"worker" : false, // Enable globals exposed when running inside a Web Worker.
"wsh" : false, // Enable globals available when your code is running as a script for the Windows Script Host.
"yui" : false, // Enable globals exposed by YUI.
// == JSLint Legacy ===================================================
//
// These options are legacy from JSLint. Aside from bug fixes they will
// not be improved in any way and might be removed at any point.
"nomen" : false, // Prohibit use of initial or trailing underbars in names.
"onevar" : false, // Allow only one `var` statement per function.
"passfail" : false, // Stop on first error.
"white" : false, // Check against strict whitespace and indentation rules.
"globals": {
// Mocha.
"after" : false,
"afterEach" : false,
"before" : false,
"beforeEach" : false,
"describe" : false,
"it" : false
}
}

1
.mocha.opts Normal file
View File

@@ -0,0 +1 @@
--require ./better-stacks.js

10
.npmignore Normal file
View File

@@ -0,0 +1,10 @@
/examples/
example.js
example.js.map
*.example.js
*.example.js.map
/test/
/tests/
*.spec.js
*.spec.js.map

8
.travis.yml Normal file
View File

@@ -0,0 +1,8 @@
language: node_js
node_js:
- '6'
- '4'
# Use containers.
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

3
ISSUE_TEMPLATE.md Normal file
View File

@@ -0,0 +1,3 @@
# ALL ISSUES SHOULD BE CREATED IN XO-WEB'S TRACKER!
https://github.com/vatesfr/xo-web/issues

View File

@@ -1,5 +1,7 @@
# Xen Orchestra Server
![](http://i.imgur.com/HVFMrTk.png)
XO-Server is part of [Xen Orchestra](https://github.com/vatesfr/xo), a web interface for XenServer or XAPI enabled hosts.
It contains all the logic of XO and handles:
@@ -9,6 +11,7 @@ It contains all the logic of XO and handles:
- users authentication and authorizations (work in progress);
- a JSON-RPC based interface for XO clients (i.e. [XO-Web](https://github.com/vatesfr/xo-web)).
[![Build Status](https://travis-ci.org/vatesfr/xo-server.svg?branch=next-release)](https://travis-ci.org/vatesfr/xo-server)
[![Dependency Status](https://david-dm.org/vatesfr/xo-server.svg?theme=shields.io)](https://david-dm.org/vatesfr/xo-server)
[![devDependency Status](https://david-dm.org/vatesfr/xo-server/dev-status.svg?theme=shields.io)](https://david-dm.org/vatesfr/xo-server#info=devDependencies)
@@ -16,10 +19,22 @@ ___
## Installation
Manual install procedure is [available here](https://github.com/vatesfr/xo/blob/master/installation.md)
Manual install procedure is [available here](https://xen-orchestra.com/docs/from_the_sources.html).
## Compilation
Production build:
```
$ npm run build
```
Development build:
```
$ npm run dev
```
## How to report a bug?
If you are certain the bug is exclusively related to XO-Server, you may use the [bugtracker of this repository](https://github.com/vatesfr/xo-server/issues).
Otherwise, please consider using the [bugtracker of the general repository](https://github.com/vatesfr/xo/issues).
All bug reports should go into the [bugtracker of xo-web](https://github.com/vatesfr/xo-web/issues).

37
better-stacks.js Normal file
View File

@@ -0,0 +1,37 @@
Error.stackTraceLimit = 100
// Async stacks.
//
// Disabled for now as it cause a huge memory usage with
// fs.createReadStream().
// TODO: find a way to reenable.
//
// try { require('trace') } catch (_) {}
// Removes internal modules.
try {
var sep = require('path').sep
require('stack-chain').filter.attach(function (_, frames) {
var filtered = frames.filter(function (frame) {
var name = frame && frame.getFileName()
return (
// has a filename
name &&
// contains a separator (no internal modules)
name.indexOf(sep) !== -1
)
})
// depd (used amongst other by express requires at least 3 frames
// in the stack.
return filtered.length > 2
? filtered
: frames
})
} catch (_) {}
// Source maps.
try { require('julien-f-source-map-support/register') } catch (_) {}

View File

@@ -1,7 +1,31 @@
#!/usr/bin/env node
'use strict';
'use strict'
//====================================================================
// ===================================================================
require('exec-promise')(require('../'));
// Better stack traces if possible.
require('../better-stacks')
// Use Bluebird for all promises as it provides better performance and
// less memory usage.
global.Promise = require('bluebird')
// Make unhandled rejected promises visible.
process.on('unhandledRejection', function (reason) {
console.warn('[Warn] Possibly unhandled rejection:', reason && reason.stack || reason)
})
;(function (EE) {
var proto = EE.prototype
var emit = proto.emit
proto.emit = function patchedError (event, error) {
if (event === 'error' && !this.listenerCount(event)) {
return console.warn('[Warn] Unhandled error event:', error && error.stack || error)
}
return emit.apply(this, arguments)
}
})(require('events').EventEmitter)
require('exec-promise')(require('../'))

10
bin/xo-server-logs Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env node
'use strict'
// ===================================================================
// Better stack traces if possible.
require('../better-stacks')
require('exec-promise')(require('../dist/logs-cli').default)

40
config.json Normal file
View File

@@ -0,0 +1,40 @@
// Vendor config: DO NOT TOUCH!
//
// See sample.config.yaml to override.
{
"http": {
"listen": [
{
"port": 80
}
],
"mounts": {},
// Ciphers to use.
//
// These are the default ciphers in Node 4.2.6, we are setting
// them explicitly for older Node versions.
"ciphers": "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA",
// Tell Node to respect the cipher order.
"honorCipherOrder": true,
// Specify to use at least TLSv1.1.
// See: https://github.com/certsimple/minimum-tls-version
"secureOptions": 117440512
},
"datadir": "/var/lib/xo-server/data",
// Should users be created on first sign in?
//
// Necessary for external authentication providers.
"createUserOnFirstSignin": true,
// Whether API logs should contains the full request/response on
// errors.
//
// This is disabled by default for performance (lots of data) and
// security concerns (avoiding sensitive data in the logs) but can
// be turned for investigation by the administrator.
"verboseApiLogsOnErrors": false
}

1
config/.gitignore vendored
View File

@@ -1 +0,0 @@
/local.yaml

70
gulpfile.js Normal file
View File

@@ -0,0 +1,70 @@
'use strict'
// ===================================================================
var gulp = require('gulp')
var babel = require('gulp-babel')
var coffee = require('gulp-coffee')
var plumber = require('gulp-plumber')
var rimraf = require('rimraf')
var sourceMaps = require('gulp-sourcemaps')
var watch = require('gulp-watch')
var join = require('path').join
// ===================================================================
var SRC_DIR = join(__dirname, 'src')
var DIST_DIR = join(__dirname, 'dist')
var PRODUCTION = process.argv.indexOf('--production') !== -1
// ===================================================================
function src (patterns) {
return PRODUCTION
? gulp.src(patterns, {
base: SRC_DIR,
cwd: SRC_DIR
})
: watch(patterns, {
base: SRC_DIR,
cwd: SRC_DIR,
ignoreInitial: false,
verbose: true
})
.pipe(plumber())
}
// ===================================================================
gulp.task(function clean (cb) {
rimraf(DIST_DIR, cb)
})
gulp.task(function buildCoffee () {
return src('**/*.coffee')
.pipe(sourceMaps.init())
.pipe(coffee({
bare: true
}))
// Necessary to correctly compile generators.
.pipe(babel())
.pipe(sourceMaps.write('.'))
.pipe(gulp.dest(DIST_DIR))
})
gulp.task(function buildEs6 () {
return src('**/*.js')
.pipe(sourceMaps.init())
.pipe(babel())
.pipe(sourceMaps.write('.'))
.pipe(gulp.dest(DIST_DIR))
})
// ===================================================================
gulp.task('build', gulp.series('clean', gulp.parallel('buildCoffee', 'buildEs6')))

View File

@@ -1,6 +1,11 @@
'use strict';
'use strict'
//====================================================================
// ===================================================================
require('coffee-script/register');
module.exports = require('./src/main');
// Enable xo logs by default.
if (process.env.DEBUG === undefined) {
process.env.DEBUG = 'app-conf,xen-api,xo:*'
}
// Import the real main module.
module.exports = require('./dist').default

View File

@@ -1,7 +1,7 @@
{
"name": "xo-server",
"version": "3.5.0-alpha1",
"license": "AGPL3",
"version": "5.3.2",
"license": "AGPL-3.0",
"description": "Server part of Xen-Orchestra",
"keywords": [
"xen",
@@ -11,50 +11,162 @@
],
"homepage": "http://github.com/vatesfr/xo-server/",
"bugs": {
"url": "https://github.com/vatesfr/xo-server/issues"
},
"author": "Julien Fontanet <julien.fontanet@vates.fr>",
"preferGlobal": true,
"directories": {
"bin": "bin"
"url": "https://github.com/vatesfr/xo-web/issues"
},
"repository": {
"type": "git",
"url": "git://github.com/vatesfr/xo-server.git"
},
"author": "Julien Fontanet <julien.fontanet@vates.fr>",
"preferGlobal": true,
"files": [
"better-stacks.js",
"bin/",
"dist/",
"config.json",
"index.js",
"signin.pug"
],
"directories": {
"bin": "bin"
},
"engines": {
"node": ">=0.12"
},
"dependencies": {
"backoff": "~2.4.0",
"bluebird": "^2.2.2",
"coffee-script": "~1.7.1",
"connect": "^3.1.0",
"event-to-promise": "^0.3.0",
"exec-promise": "^0.3.0",
"extendable": "~0.0.6",
"fibers": "~1.0.1",
"hashy": "~0.3.6",
"hiredis": "~0.1.17",
"http-server-plus": "^0.2.3",
"js-yaml": "~3.1.0",
"nconf": "~0.6.9",
"redis": "~0.11.0",
"require-tree": "~0.3.3",
"schema-inspector": "^1.4.5",
"serve-static": "^1.4.0",
"then-redis": "~0.3.12",
"underscore": "~1.6.0",
"ws": "~0.4.31",
"xml2js": "~0.4.4",
"xmlrpc": "~1.2.0"
"@marsaud/smb2-promise": "^0.2.1",
"@nraynaud/struct-fu": "^1.0.1",
"app-conf": "^0.4.0",
"babel-runtime": "^6.5.0",
"base64url": "^2.0.0",
"blocked": "^1.1.0",
"bluebird": "^3.1.1",
"body-parser": "^1.13.3",
"connect-flash": "^0.1.1",
"cookie": "^0.3.0",
"cookie-parser": "^1.3.5",
"cron": "^1.0.9",
"d3-time-format": "^2.0.0",
"debug": "^2.1.3",
"escape-string-regexp": "^1.0.3",
"event-to-promise": "^0.7.0",
"exec-promise": "^0.6.1",
"execa": "^0.5.0",
"express": "^4.13.3",
"express-session": "^1.11.3",
"fatfs": "^0.10.3",
"fs-extra": "^0.30.0",
"fs-promise": "^0.5.0",
"get-stream": "^2.1.0",
"hashy": "~0.4.2",
"helmet": "^2.0.0",
"highland": "^2.5.1",
"http-proxy": "^1.13.2",
"http-server-plus": "^0.7.0",
"human-format": "^0.7.0",
"is-my-json-valid": "^2.13.1",
"is-redirect": "^1.0.0",
"js-yaml": "^3.2.7",
"json-rpc-peer": "^0.12.0",
"json5": "^0.5.0",
"julien-f-source-map-support": "0.0.0",
"julien-f-unzip": "^0.2.1",
"kindof": "^2.0.0",
"level": "^1.3.0",
"level-party": "^3.0.4",
"level-sublevel": "^6.5.2",
"leveldown": "^1.4.2",
"lodash": "^4.13.1",
"make-error": "^1",
"micromatch": "^2.3.2",
"minimist": "^1.2.0",
"moment-timezone": "^0.5.4",
"ms": "^0.7.1",
"multikey-hash": "^1.0.1",
"ndjson": "^1.4.3",
"partial-stream": "0.0.0",
"passport": "^0.3.0",
"passport-local": "^1.0.0",
"promise-toolbox": "^0.7.0",
"proxy-agent": "^2.0.0",
"pug": "^2.0.0-alpha6",
"redis": "^2.0.1",
"schema-inspector": "^1.5.1",
"semver": "^5.1.0",
"serve-static": "^1.9.2",
"stack-chain": "^1.3.3",
"tar-stream": "^1.5.2",
"through2": "^2.0.0",
"trace": "^2.0.1",
"uuid": "^2.0.3",
"ws": "^1.1.1",
"xen-api": "^0.9.4",
"xml2js": "~0.4.6",
"xo-acl-resolver": "^0.2.2",
"xo-collection": "^0.4.0",
"xo-remote-parser": "^0.3",
"xo-vmdk-to-vhd": "0.0.12"
},
"devDependencies": {
"chai": "~1.9.1",
"glob": "~4.0.4",
"mocha": "^1.21.0",
"node-inspector": "^0.7.4",
"sinon": "^1.10.3"
"babel-eslint": "^7.0.0",
"babel-plugin-lodash": "^3.2.9",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.5.2",
"babel-preset-es2015": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"chai": "^3.0.0",
"dependency-check": "^2.4.0",
"ghooks": "^1.0.3",
"gulp": "git://github.com/gulpjs/gulp#4.0",
"gulp-babel": "^6",
"gulp-coffee": "^2.3.1",
"gulp-plumber": "^1.0.0",
"gulp-sourcemaps": "^2.1.1",
"gulp-watch": "^4.2.2",
"index-modules": "0.0.0",
"leche": "^2.1.1",
"mocha": "^3.0.2",
"must": "^0.13.1",
"nyc": "^8.1.0",
"rimraf": "^2.5.2",
"sinon": "^1.14.1",
"standard": "^8.1.0"
},
"scripts": {
"build": "npm run build-indexes && gulp build --production",
"depcheck": "dependency-check ./package.json",
"build-indexes": "index-modules src/api src/xapi/mixins src/xo-mixins",
"dev": "npm run build-indexes && gulp build",
"dev-test": "mocha --opts .mocha.opts --watch --reporter=min \"dist/**/*.spec.js\"",
"lint": "standard",
"postrelease": "git checkout master && git merge --ff-only stable && git checkout next-release && git merge --ff-only stable",
"posttest": "npm run lint && npm run depcheck",
"prepublish": "npm run build",
"prerelease": "git checkout next-release && git pull --ff-only && git checkout stable && git pull --ff-only && git merge next-release",
"release": "npm version",
"start": "node bin/xo-server",
"test": "coffee run-tests"
"test": "nyc mocha --opts .mocha.opts \"dist/**/*.spec.js\""
},
"babel": {
"plugins": [
"lodash",
"transform-decorators-legacy",
"transform-runtime"
],
"presets": [
"stage-0",
"es2015"
]
},
"config": {
"ghooks": {
"commit-msg": "npm test"
}
},
"standard": {
"ignore": [
"dist"
],
"parser": "babel-eslint"
}
}

View File

@@ -1,29 +0,0 @@
#!/usr/bin/env coffee
# Tests runner.
$mocha = require 'mocha'
# Used to find the specification files.
$glob = require 'glob'
#=====================================================================
do ->
# Instantiates the tests runner.
mocha = new $mocha {
reporter: 'spec'
}
# Processes arguments.
do ->
{argv} = process
i = 2
n = argv.length
mocha.grep argv[i++] while i < n
$glob 'src/**/*.spec.{coffee,js}', (error, files) ->
console.error(error) if error
mocha.addFile file for file in files
mocha.run()

View File

@@ -1,4 +1,18 @@
# Note: Relative paths will be resolved from XO-Server's directory.
# BE *VERY* CAREFUL WHEN EDITING!
# YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
# visit http://www.yamllint.com/ to validate this file as needed
#=====================================================================
# Example XO-Server configuration.
#
# This file is automatically looking for at the following places:
# - `$HOME/.config/xo-server/config.yaml`
# - `/etc/xo-server/config.yaml`
#
# The first entries have priority.
#
# Note: paths are relative to the configuration file.
#=====================================================================
@@ -44,7 +58,7 @@ http:
# Sets it to '127.0.0.1' to listen only on the local host.
#
# Default: '0.0.0.0' (all addresses)
#host: '127.0.0.1'
#hostname: '127.0.0.1'
# Port on which the server is listening on.
#
@@ -58,17 +72,26 @@ http:
#socket: './http.sock'
# Basic HTTPS.
#
# You can find the list of possible options there https://nodejs.org/docs/latest/api/tls.html#tls.createServer
# -
# # The only difference is the presence of the certificate and the
# # key.
# #host: '127.0.0.1'
# #
# #hostname: '127.0.0.1'
# port: 443
# # File containing the certificate (PEM format).
#
# # If a chain of certificates authorities is needed, you may bundle
# # them directly in the certificate.
# #
# # Note: the order of certificates does matter, your certificate
# # should come first followed by the certificate of the above
# # certificate authority up to the root.
# #
# # Default: undefined
# certificate: './certificate.pem'
# cert: './certificate.pem'
# # File containing the private key (PEM format).
# #
@@ -78,15 +101,35 @@ http:
# # Default: undefined
# key: './key.pem'
# If set to true, all HTTP traffic will be redirected to the first
# HTTPs configuration.
#redirectToHttps: true
# List of files/directories which will be served.
mounts:
#'/': '/path/to/xo-web/dist/'
# List of proxied URLs (HTTP & WebSockets).
proxies:
# '/any/url': 'http://localhost:54722'
# HTTP proxy configuration used by xo-server to fetch resources on the
# Internet.
#
# See: https://github.com/TooTallNate/node-proxy-agent#maps-proxy-protocols-to-httpagent-implementations
#httpProxy: 'http://jsmith:qwerty@proxy.lan:3128'
#=====================================================================
# Connection to the Redis server.
redis:
# Syntax: tcp://[db[:password]@]hostname[:port]
# Syntax: redis://[db[:password]@]hostname[:port]
#
# Default: tcp://localhost:6379
# Default: redis://localhost:6379
#uri: ''
# Directory containing the database of XO.
# Currently used for logs.
#
# Default: '/var/lib/xo-server/data'
#datadir: '/var/lib/xo-server/data'

50
signin.pug Normal file
View File

@@ -0,0 +1,50 @@
doctype html
html
head
meta(charset = 'utf-8')
meta(http-equiv = 'X-UA-Compatible' content = 'IE=edge,chrome=1')
meta(name = 'viewport' content = 'width=device-width, initial-scale=1.0')
title Xen Orchestra
meta(name = 'author' content = 'Vates SAS')
link(rel = 'stylesheet' href = 'index.css')
body(style = 'display: flex; height: 100vh;')
div(style = 'margin: auto; width: 20em;')
div.m-b-2(style = 'display: flex;')
img(src = 'assets/logo.png' style = 'margin: auto;')
h2.text-xs-center.m-b-2 Xen Orchestra
form(action = 'signin/local' method = 'post')
fieldset
if error
p.text-danger #{error}
.input-group.m-b-1
span.input-group-addon
i.xo-icon-user.fa-fw
input.form-control(
name = 'username'
type = 'text'
placeholder = 'Username'
required
)
.input-group.m-b-1
span.input-group-addon
i.fa.fa-key.fa-fw
input.form-control(
name = 'password'
type = 'password'
placeholder = 'Password'
required
)
.checkbox
label
input(
name = 'remember-me'
type = 'checkbox'
)
| &nbsp;
| Remember me
div
button.btn.btn-block.btn-info
i.fa.fa-sign-in
| Sign in
each label, id in strategies
div: a(href = 'signin/' + id) Sign in with #{label}

View File

@@ -1,439 +0,0 @@
{EventEmitter: $EventEmitter} = require 'events'
#----------------------------------------------------------------------
$_ = require 'underscore'
#=====================================================================
{$each, $makeFunction, $mapInPlace} = require './utils'
#=====================================================================
class $MappedCollection extends $EventEmitter
# The dispatch function is called whenever a new item has to be
# processed and returns the name of the rule to use.
#
# To change the way it is dispatched, just override this it.
dispatch: ->
(@genval and (@genval.rule ? @genval.type)) ? 'unknown'
# This function is called when an item has been dispatched to a
# missing rule.
#
# The default behavior is to throw an error but you may instead
# choose to create a rule:
#
# collection.missingRule = collection.rule
missingRule: (name) ->
throw new Error "undefined rule “#{name}"
# This function is called when the new generator of an existing item has been
# matched to a different rule.
#
# The default behavior is to throw an error as it usually indicates a bug but
# you can ignore it.
ruleConflict: (rule, item) ->
throw new Error "the item “#{item.key}” was of rule “#{item.rule}"+
"but matches to “#{rule}"
constructor: ->
# Items are stored here indexed by key.
#
# The prototype of this object is set to `null` to avoid pollution
# from enumerable properties of `Object.prototype` and the
# performance hit of `hasOwnProperty o`.
@_byKey = Object.create null
# Hooks are stored here indexed by moment.
@_hooks = {
beforeDispatch: []
beforeUpdate: []
beforeSave: []
afterRule: []
}
# Rules are stored here indexed by name.
#
# The prototype of this object is set to `null` to avoid pollution
# from enumerable properties of `Object.prototype` and to be able
# to use the `name of @_rules` syntax.
@_rules = Object.create null
# Register a hook to run at a given point.
#
# A hook receives as parameter an event object with the following
# properties:
# - `preventDefault()`: prevents the next default action from
# happening;
# - `stopPropagation()`: prevents other hooks from being run.
#
# Note: if a hook throws an exception, `event.stopPropagation()`
# then `event.preventDefault()` will be called and the exception
# will be forwarded.
#
# # Item hook
#
# Valid items related moments are:
# - beforeDispatch: even before the item has been dispatched;
# - beforeUpdate: after the item has been dispatched but before
# updating its value.
# - beforeSave: after the item has been updated.
#
# An item hook is run in the context of the current item.
#
# # Rule hook
#
# Valid rules related moments are:
# - afterRule: just after a new rule has been defined (even
# singleton).
#
# An item hook is run in the context of the current rule.
hook: (name, hook) ->
# Allows a nicer syntax for CoffeeScript.
if $_.isObject name
# Extracts the name and the value from the first property of the
# object.
do ->
object = name
return for own name, hook of object
hooks = @_hooks[name]
@_assert(
hooks?
"invalid hook moment “#{name}"
)
hooks.push hook
# Register a new singleton rule.
#
# See the `rule()` method for more information.
item: (name, definition) ->
# Creates the corresponding rule.
rule = @rule name, definition, true
# Creates the singleton.
item = {
rule: rule.name
key: rule.key() # No context because there is not generator.
val: undefined
}
@_updateItems [item], true
# Register a new rule.
#
# If the definition is a function, it will be run in the context of
# an item-like object with the following properties:
# - `key`: the definition for the key of this item;
# - `val`: the definition for the value of this item.
#
# Warning: The definition function is run only once!
rule: (name, definition, singleton = false) ->
# Allows a nicer syntax for CoffeeScript.
if $_.isObject name
# Extracts the name and the definition from the first property
# of the object.
do ->
object = name
return for own name, definition of object
@_assert(
name not of @_rules
"the rule “#{name}” is already defined"
)
# Extracts the rule definition.
if $_.isFunction definition
ctx = {
name
key: undefined
data: undefined
val: undefined
singleton
}
definition.call ctx
else
ctx = {
name
key: definition?.key
data: definition?.data
val: definition?.val
singleton
}
# Runs the `afterRule` hook and returns if the registration has
# been prevented.
return unless @_runHook 'afterRule', ctx
{key, data, val} = ctx
# The default key.
key ?= if singleton then -> name else -> @genkey
# The default value.
val ?= -> @genval
# Makes sure `key` is a function for uniformity.
key = $makeFunction key unless $_.isFunction key
# Register the new rule.
@_rules[name] = {
name
key
data
val
singleton
}
#--------------------------------
get: (keys, ignoreMissingItems = false) ->
if keys is undefined
items = $_.map @_byKey, (item) -> item.val
else
items = @_fetchItems keys, ignoreMissingItems
$mapInPlace items, (item) -> item.val
if $_.isString keys then items[0] else items
getRaw: (keys, ignoreMissingItems = false) ->
if keys is undefined
item for _, item of @_byKey
else
items = @_fetchItems keys, ignoreMissingItems
if $_.isString keys then items[0] else items
remove: (keys, ignoreMissingItems = false) ->
@_removeItems (@_fetchItems keys, ignoreMissingItems)
set: (items, {add, update, remove} = {}) ->
add = true unless add?
update = true unless update?
remove = false unless remove?
itemsToAdd = {}
itemsToUpdate = {}
itemsToRemove = {}
$_.extend itemsToRemove, @_byKey if remove
$each items, (genval, genkey) =>
item = {
rule: undefined
key: undefined
data: undefined
val: undefined
genkey
genval
}
return unless @_runHook 'beforeDispatch', item
# Searches for a rule to handle it.
ruleName = @dispatch.call item
rule = @_rules[ruleName]
unless rule?
@missingRule ruleName
# If `missingRule()` has not created the rule, just keep this
# item.
rule = @_rules[ruleName]
return unless rule?
# Checks if this is a singleton.
@_assert(
not rule.singleton
"cannot add items to singleton rule “#{rule.name}"
)
# Computes its key.
key = rule.key.call item
@_assert(
$_.isString key
"the key “#{key}” is not a string"
)
# Updates known values.
item.rule = rule.name
item.key = key
if key of @_byKey
# Marks this item as not to be removed.
delete itemsToRemove[key]
if update
# Fetches the existing entry.
prev = @_byKey[key]
# Checks if there is a conflict in rules.
unless item.rule is prev.rule
@ruleConflict item.rule, prev
item.prevRule = prev.rule
else
delete item.prevRule
# Gets its previous data/value.
item.data = prev.data
item.val = prev.val
# Registers the item to be updated.
itemsToUpdate[key] = item
# Note: an item will be updated only once per `set()` and
# only the last generator will be used.
else
if add
# Registers the item to be added.
itemsToAdd[key] = item
# Adds items.
@_updateItems itemsToAdd, true
# Updates items.
@_updateItems itemsToUpdate
# Removes any items not seen (iff `remove` is true).
@_removeItems itemsToRemove
# Forces items to update their value.
touch: (keys) ->
@_updateItems (@_fetchItems keys, true)
#--------------------------------
_assert: (cond, message) ->
throw new Error message unless cond
# Emits item related event.
_emitEvent: (event, items) ->
getRule = if event is 'exit'
(item) -> item.prevRule or item.rule
else
(item) -> item.rule
byRule = Object.create null
# One per item.
$each items, (item) =>
@emit "key=#{item.key}", event, item
(byRule[getRule item] ?= []).push item
# One per rule.
@emit "rule=#{rule}", event, byRule[rule] for rule of byRule
# One for everything.
@emit 'any', event, items
_fetchItems: (keys, ignoreMissingItems = false) ->
unless $_.isArray keys
keys = if $_.isObject keys then $_.keys keys else [keys]
items = []
for key in keys
item = @_byKey[key]
if item?
items.push item
else
@_assert(
ignoreMissingItems
"no item with key “#{key}"
)
items
_removeItems: (items) ->
return if $_.isEmpty items
$each items, (item) => delete @_byKey[item.key]
@_emitEvent 'exit', items
# Runs hooks for the moment `name` with the given context and
# returns false if the default action has been prevented.
_runHook: (name, ctx) ->
hooks = @_hooks[name]
# If no hooks, nothing to do.
return true unless hooks? and (n = hooks.length) isnt 0
# Flags controlling the run.
notStopped = true
actionNotPrevented = true
# Creates the event object.
event = {
stopPropagation: -> notStopped = false
# TODO: Should `preventDefault()` imply `stopPropagation()`?
preventDefault: -> actionNotPrevented = false
}
i = 0
while notStopped and i < n
hooks[i++].call ctx, event
# TODO: Is exception handling necessary to have the wanted
# behavior?
return actionNotPrevented
_updateItems: (items, areNew) ->
return if $_.isEmpty items
# An update is similar to an exit followed by an enter.
@_removeItems items unless areNew
$each items, (item) =>
return unless @_runHook 'beforeUpdate', item
{rule: ruleName} = item
# Computes its value.
do =>
# Item is not passed directly to function to avoid direct
# modification.
#
# This is not a true security but better than nothing.
proxy = Object.create item
updateValue = (parent, prop, def) ->
if not $_.isObject def
parent[prop] = def
else if $_.isFunction def
parent[prop] = def.call proxy, parent[prop]
else if $_.isArray def
i = 0
n = def.length
current = parent[prop] ?= new Array n
while i < n
updateValue current, i, def[i]
++i
else
# It's a plain object.
current = parent[prop] ?= {}
for i of def
updateValue current, i, def[i]
updateValue item, 'data', @_rules[ruleName].data
updateValue item, 'val', @_rules[ruleName].val
unless @_runHook 'beforeSave', item
# FIXME: should not be removed, only not saved.
delete @_byKey[item.key]
# Really inserts the items and trigger events.
$each items, (item) => @_byKey[item.key] = item
@_emitEvent 'enter', items
#=====================================================================
module.exports = {$MappedCollection}

View File

@@ -1,121 +0,0 @@
{expect: $expect} = require 'chai'
$sinon = require 'sinon'
#---------------------------------------------------------------------
{$MappedCollection} = require './MappedCollection.coffee'
#=====================================================================
describe '$MappedCollection', ->
# Shared variables.
collection = null
beforeEach ->
collection = new $MappedCollection()
#-------------------------------------------------------------------
describe '#dispatch()', ->
# Test data.
beforeEach ->
collection.rule test: {}
#------------------------------
it 'should have genkey and genval', ->
collection.dispatch = ->
$expect(@genkey).to.equal 'a key'
$expect(@genval).to.equal 'a value'
'test'
collection.set {
'a key': 'a value'
}
#------------------------------
it 'should be used to dispatch an item', ->
collection.dispatch = -> 'test'
collection.set [
'any value'
]
$expect(collection.getRaw('0').rule).to.equal 'test'
#-------------------------------------------------------------------
describe 'item hooks', ->
# Test data.
beforeEach ->
collection.rule test: {}
#------------------------------
it 'should be called in the correct order', ->
beforeDispatch = $sinon.spy()
collection.hook {beforeDispatch}
dispatcher = $sinon.spy ->
$expect(beforeDispatch.called).to.true
# It still is a dispatcher.
'test'
collection.dispatch = dispatcher
beforeUpdate = $sinon.spy ->
$expect(dispatcher.called).to.true
collection.hook {beforeUpdate}
beforeSave = $sinon.spy ->
$expect(beforeUpdate.called).to.true
collection.hook {beforeSave}
collection.set [
'any value'
]
$expect(beforeSave.called).to.be.true
#-------------------------------------------------------------------
describe 'adding new items', ->
beforeEach ->
collection.rule test: {}
collection.dispatch = -> 'test'
#------------------------------
it 'should trigger three `enter` events', ->
keySpy = $sinon.spy()
ruleSpy = $sinon.spy()
anySpy = $sinon.spy()
collection.on 'key=a key', keySpy
collection.on 'rule=test', ruleSpy
collection.on 'any', anySpy
collection.set {
'a key': 'a value'
}
item = collection.getRaw 'a key'
# TODO: items can be an array or a object (it is not defined).
$expect(keySpy.args).to.deep.equal [
['enter', item]
]
$expect(ruleSpy.args).to.deep.equal [
['enter', [item]]
]
$expect(anySpy.args).to.deep.equal [
['enter', {'a key': item}]
]

70
src/api-errors.js Normal file
View File

@@ -0,0 +1,70 @@
import {JsonRpcError} from 'json-rpc-peer'
// ===================================================================
// Export standard JSON-RPC errors.
export { // eslint-disable-line no-duplicate-imports
InvalidJson,
InvalidParameters,
InvalidRequest,
JsonRpcError,
MethodNotFound
} from 'json-rpc-peer'
// -------------------------------------------------------------------
export class NotImplemented extends JsonRpcError {
constructor () {
super('not implemented', 0)
}
}
// -------------------------------------------------------------------
export class NoSuchObject extends JsonRpcError {
constructor (id, type) {
super('no such object', 1, {id, type})
}
}
// -------------------------------------------------------------------
export class Unauthorized extends JsonRpcError {
constructor () {
super('not authenticated or not enough permissions', 2)
}
}
// -------------------------------------------------------------------
export class InvalidCredential extends JsonRpcError {
constructor () {
super('invalid credential', 3)
}
}
// -------------------------------------------------------------------
export class AlreadyAuthenticated extends JsonRpcError {
constructor () {
super('already authenticated', 4)
}
}
// -------------------------------------------------------------------
export class ForbiddenOperation extends JsonRpcError {
constructor (operation, reason) {
super(`forbidden operation: ${operation}`, 5, reason)
}
}
// -------------------------------------------------------------------
// To be used with a user-readable message.
// The message can be destined to be displayed to the front-end user.
export class GenericError extends JsonRpcError {
constructor (message) {
super(message, 6)
}
}

View File

@@ -1,337 +0,0 @@
'use strict';
//////////////////////////////////////////////////////////////////////
var $_ = require('underscore');
var $requireTree = require('require-tree');
var $schemaInspector = require('schema-inspector');
//--------------------------------------------------------------------
var $wait = require('./fibers-utils').$wait;
//////////////////////////////////////////////////////////////////////
function $deprecated(fn)
{
return function (session, req) {
console.warn(req.method +' is deprecated!');
return fn.apply(this, arguments);
};
}
var wrap = function (val) {
return function () {
return val;
};
};
//////////////////////////////////////////////////////////////////////
// TODO: Helper functions that could be written:
// - checkParams(req.params, param1, ..., paramN)
var helpers = {};
helpers.checkPermission = function (permission)
{
// TODO: Handle token permission.
var userId = this.session.get('user_id', undefined);
if (undefined === userId)
{
throw Api.err.UNAUTHORIZED;
}
if (!permission)
{
return;
}
var user = $wait(this.users.first(userId));
// The user MUST exist at this time.
if (!user.hasPermission(permission))
{
throw Api.err.UNAUTHORIZED;
}
};
// Checks and returns parameters.
helpers.getParams = function (schema) {
var params = this.request.params;
schema = {
type: 'object',
properties: schema,
};
var result = $schemaInspector.validate(schema, params);
if (!result.valid)
{
this.throw('INVALID_PARAMS', result.error);
}
return params;
};
helpers.getUserPublicProperties = function (user) {
// Handles both properties and wrapped models.
var properties = user.properties || user;
return $_.pick(properties, 'id', 'email', 'permission');
};
helpers.getServerPublicProperties = function (server) {
// Handles both properties and wrapped models.
var properties = server.properties || server;
return $_.pick(properties, 'id', 'host', 'username');
};
helpers.throw = function (errorId, data) {
var error = Api.err[errorId];
if (!error)
{
console.error('Invalid error:', errorId);
throw Api.err.SERVER_ERROR;
}
if (data)
{
error = $_.extend({}, error, {data: data});
}
throw error;
};
//////////////////////////////////////////////////////////////////////
function Api(xo)
{
if ( !(this instanceof Api) )
{
return new Api(xo);
}
this.xo = xo;
}
Api.prototype.exec = function (session, request) {
var ctx = Object.create(this.xo);
$_.extend(ctx, helpers, {
session: session,
request: request,
});
var method = this.getMethod(request.method);
if (!method)
{
console.warn('Invalid method: '+ request.method);
throw Api.err.INVALID_METHOD;
}
if ('permission' in method)
{
helpers.checkPermission.call(ctx, method.permission)
}
if (method.params)
{
helpers.getParams.call(ctx, method.params);
}
return method.call(ctx, request.params);
};
Api.prototype.getMethod = function (name) {
var parts = name.split('.');
var current = Api.fn;
for (
var i = 0, n = parts.length;
(i < n) && (current = current[parts[i]]);
++i
)
{
/* jshint noempty:false */
}
// Method found.
if ($_.isFunction(current))
{
return current;
}
// It's a (deprecated) alias.
if ($_.isString(current))
{
return $deprecated(this.getMethod(current));
}
// No entry found, looking for a catch-all method.
current = Api.fn;
var catchAll;
for (i = 0; (i < n) && (current = current[parts[i]]); ++i)
{
catchAll = current.__catchAll || catchAll;
}
return catchAll;
};
module.exports = Api;
//////////////////////////////////////////////////////////////////////
function err(code, message)
{
return {
'code': code,
'message': message
};
}
Api.err = {
//////////////////////////////////////////////////////////////////
// JSON-RPC errors.
//////////////////////////////////////////////////////////////////
'INVALID_JSON': err(-32700, 'invalid JSON'),
'INVALID_REQUEST': err(-32600, 'invalid JSON-RPC request'),
'INVALID_METHOD': err(-32601, 'method not found'),
'INVALID_PARAMS': err(-32602, 'invalid parameter(s)'),
'SERVER_ERROR': err(-32603, 'unknown error from the server'),
//////////////////////////////////////////////////////////////////
// XO errors.
//////////////////////////////////////////////////////////////////
'NOT_IMPLEMENTED': err(0, 'not implemented'),
'NO_SUCH_OBJECT': err(1, 'no such object'),
// Not authenticated or not enough permissions.
'UNAUTHORIZED': err(2, 'not authenticated or not enough permissions'),
// Invalid email & passwords or token.
'INVALID_CREDENTIAL': err(3, 'invalid credential'),
'ALREADY_AUTHENTICATED': err(4, 'already authenticated'),
};
//////////////////////////////////////////////////////////////////////
var $register = function (path, fn, params) {
var component, current;
if (params)
{
fn.params = params;
}
if (!$_.isArray(path))
{
path = path.split('.');
}
current = Api.fn;
for (var i = 0, n = path.length - 1; i < n; ++i)
{
component = path[i];
current = (current[component] || (current[component] = {}));
}
if ($_.isFunction(fn))
{
current[path[n]] = fn;
}
else if ($_.isObject(fn) && !$_.isArray(fn))
{
// If it is not an function but an object, copies its
// properties.
component = path[n];
current = (current[component] || (current[component] = {}));
for (var prop in fn)
{
current[prop] = fn[prop];
}
}
else
{
current[path[n]] = wrap(fn);
}
};
Api.fn = $requireTree('./api');
//--------------------------------------------------------------------
$register('system.getVersion', wrap('0.1'));
$register('xo.getAllObjects', function () {
return this.getObjects();
});
// Returns the list of available methods similar to XML-RPC
// introspection (http://xmlrpc-c.sourceforge.net/introspection.html).
(function () {
var methods = {};
(function browse(container, path) {
var n = path.length;
$_.each(container, function (content, key) {
path[n] = key;
if ($_.isFunction(content))
{
methods[path.join('.')] = {
description: content.description,
params: content.params || {},
permission: content.permission,
};
}
else
{
browse(content, path);
}
});
path.pop();
})(Api.fn, []);
$register('system.listMethods', wrap($_.keys(methods)));
$register('system.methodSignature', function (params) {
var method = methods[params.name];
if (!method)
{
this.throw('NO_SUCH_OBJECT');
}
// XML-RPC can have multiple signatures per method.
return [
// XML-RPC requires the method name.
$_.extend({name: name}, method)
];
}, {
name: {
description: 'method to describe',
type: 'string',
},
});
$register('system.getMethodsInfo', wrap(methods));
})();

0
src/api/.index-modules Normal file
View File

49
src/api/acl.js Normal file
View File

@@ -0,0 +1,49 @@
export async function get () {
return /* await */ this.getAllAcls()
}
get.permission = 'admin'
get.description = 'get existing ACLs'
// -------------------------------------------------------------------
export async function getCurrentPermissions () {
return /* await */ this.getPermissionsForUser(this.session.get('user_id'))
}
getCurrentPermissions.permission = ''
getCurrentPermissions.description = 'get (explicit) permissions by object for the current user'
// -------------------------------------------------------------------
export async function add ({subject, object, action}) {
await this.addAcl(subject, object, action)
}
add.permission = 'admin'
add.params = {
subject: { type: 'string' },
object: { type: 'string' },
action: { type: 'string' }
}
add.description = 'add a new ACL entry'
// -------------------------------------------------------------------
export async function remove ({subject, object, action}) {
await this.removeAcl(subject, object, action)
}
remove.permission = 'admin'
remove.params = {
subject: { type: 'string' },
object: { type: 'string' },
action: { type: 'string' }
}
remove.description = 'remove an existing ACL entry'

40
src/api/disk.js Normal file
View File

@@ -0,0 +1,40 @@
import {parseSize} from '../utils'
// ===================================================================
export async function create ({name, size, sr}) {
const vdi = await this.getXapi(sr).createVdi(parseSize(size), {
name_label: name,
sr: sr._xapiId
})
return vdi.$id
}
create.description = 'create a new disk on a SR'
create.params = {
name: { type: 'string' },
size: { type: ['integer', 'string'] },
sr: { type: 'string' }
}
create.resolve = {
sr: ['sr', 'SR', 'administrate']
}
// -------------------------------------------------------------------
export async function resize ({ vdi, size }) {
await this.getXapi(vdi).resizeVdi(vdi._xapiId, parseSize(size))
}
resize.description = 'resize an existing VDI'
resize.params = {
id: { type: 'string' },
size: { type: ['integer', 'string'] }
}
resize.resolve = {
vdi: ['id', ['VDI', 'VDI-snapshot'], 'administrate']
}

60
src/api/docker.js Normal file
View File

@@ -0,0 +1,60 @@
export async function register ({vm}) {
await this.getXapi(vm).registerDockerContainer(vm._xapiId)
}
register.description = 'Register the VM for Docker management'
register.params = {
vm: { type: 'string' }
}
register.resolve = {
vm: ['vm', 'VM', 'administrate']
}
// -----------------------------------------------------------------------------
export async function deregister ({vm}) {
await this.getXapi(vm).unregisterDockerContainer(vm._xapiId)
}
deregister.description = 'Deregister the VM for Docker management'
deregister.params = {
vm: { type: 'string' }
}
deregister.resolve = {
vm: ['vm', 'VM', 'administrate']
}
// -----------------------------------------------------------------------------
export async function start ({vm, container}) {
await this.getXapi(vm).startDockerContainer(vm._xapiId, container)
}
export async function stop ({vm, container}) {
await this.getXapi(vm).stopDockerContainer(vm._xapiId, container)
}
export async function restart ({vm, container}) {
await this.getXapi(vm).restartDockerContainer(vm._xapiId, container)
}
export async function pause ({vm, container}) {
await this.getXapi(vm).pauseDockerContainer(vm._xapiId, container)
}
export async function unpause ({vm, container}) {
await this.getXapi(vm).unpauseDockerContainer(vm._xapiId, container)
}
for (let fn of [start, stop, restart, pause, unpause]) {
fn.params = {
vm: { type: 'string' },
container: { type: 'string' }
}
fn.resolve = {
vm: ['vm', 'VM', 'operate']
}
}

91
src/api/group.js Normal file
View File

@@ -0,0 +1,91 @@
export async function create ({name}) {
return (await this.createGroup({name})).id
}
create.description = 'creates a new group'
create.permission = 'admin'
create.params = {
name: {type: 'string'}
}
// -------------------------------------------------------------------
// Deletes an existing group.
async function delete_ ({id}) {
await this.deleteGroup(id)
}
// delete is not a valid identifier.
export {delete_ as delete}
delete_.description = 'deletes an existing group'
delete_.permission = 'admin'
delete_.params = {
id: {type: 'string'}
}
// -------------------------------------------------------------------
export async function getAll () {
return /* await */ this.getAllGroups()
}
getAll.description = 'returns all the existing group'
getAll.permission = 'admin'
// -------------------------------------------------------------------
// sets group.users with an array of user ids
export async function setUsers ({id, userIds}) {
await this.setGroupUsers(id, userIds)
}
setUsers.description = 'sets the users belonging to a group'
setUsers.permission = 'admin'
setUsers.params = {
id: {type: 'string'},
userIds: {}
}
// -------------------------------------------------------------------
// adds the user id to group.users
export async function addUser ({id, userId}) {
await this.addUserToGroup(userId, id)
}
addUser.description = 'adds a user to a group'
addUser.permission = 'admin'
addUser.params = {
id: {type: 'string'},
userId: {type: 'string'}
}
// -------------------------------------------------------------------
// remove the user id from group.users
export async function removeUser ({id, userId}) {
await this.removeUserFromGroup(userId, id)
}
// -------------------------------------------------------------------
removeUser.description = 'removes a user from a group'
removeUser.permission = 'admin'
removeUser.params = {
id: {type: 'string'},
userId: {type: 'string'}
}
// -------------------------------------------------------------------
export async function set ({id, name}) {
await this.updateGroup(id, {name})
}
set.description = 'changes the properties of an existing group'
set.permission = 'admin'
set.params = {
id: { type: 'string' },
name: { type: 'string', optional: true }
}

View File

@@ -1,27 +1,32 @@
{$wait} = require '../fibers-utils'
$debug = (require 'debug') 'xo:api:vm'
$find = require 'lodash/find'
$findIndex = require 'lodash/findIndex'
$forEach = require 'lodash/forEach'
endsWith = require 'lodash/endsWith'
startsWith = require 'lodash/startsWith'
{coroutine: $coroutine} = require 'bluebird'
{
extractProperty,
parseXml
} = require '../utils'
#=====================================================================
exports.set = (params) ->
try
host = @getObject params.id
catch
@throw 'NO_SUCH_OBJECT'
set = ({
host,
xapi = @getXAPI host
# TODO: use camel case.
name_label: nameLabel,
name_description: nameDescription
}) ->
return @getXapi(host).setHostProperties(host._xapiId, {
nameLabel,
nameDescription
})
for param, field of {
'name_label'
'name_description'
'enabled'
}
continue unless param of params
set.description = 'changes the properties of an host'
$wait xapi.call "host.set_#{field}", host.ref, params[param]
return true
exports.set.permission = 'admin'
exports.set.params =
set.params =
id: type: 'string'
name_label:
type: 'string'
@@ -29,106 +34,234 @@ exports.set.params =
name_description:
type: 'string'
optional: true
enabled:
type: 'boolean'
set.resolve = {
host: ['id', 'host', 'administrate'],
}
exports.set = set
#---------------------------------------------------------------------
# FIXME: set force to false per default when correctly implemented in
# UI.
restart = ({host, force = true}) ->
return @getXapi(host).rebootHost(host._xapiId, force)
restart.description = 'restart the host'
restart.params = {
id: { type: 'string' },
force: {
type: 'boolean',
optional: true
}
}
exports.restart = ({id}) ->
@checkPermission 'admin'
restart.resolve = {
host: ['id', 'host', 'operate'],
}
try
host = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
exports.restart = restart
xapi = @getXAPI host
#---------------------------------------------------------------------
$wait xapi.call 'host.disable', host.ref
$wait xapi.call 'host.reboot', host.ref
restartAgent = ({host}) ->
return @getXapi(host).restartHostAgent(host._xapiId)
return true
exports.restart.permission = 'admin'
exports.restart.params = {
restartAgent.description = 'restart the Xen agent on the host'
restartAgent.params = {
id: { type: 'string' }
}
exports.restart_agent = ({id}) ->
try
host = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
restartAgent.resolve = {
host: ['id', 'host', 'administrate'],
}
xapi = @getXAPI host
# TODO camel case
exports.restart_agent = restartAgent
$wait xapi.call 'host.restart_agent', host.ref
#---------------------------------------------------------------------
return true
exports.restart_agent.permission = 'admin'
exports.restart_agent.params = {
start = ({host}) ->
return @getXapi(host).powerOnHost(host._xapiId)
start.description = 'start the host'
start.params = {
id: { type: 'string' }
}
exports.stop = ({id}) ->
try
host = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
start.resolve = {
host: ['id', 'host', 'operate'],
}
xapi = @getXAPI host
exports.start = start
$wait xapi.call 'host.disable', host.ref
$wait xapi.call 'host.shutdown', host.ref
#---------------------------------------------------------------------
return true
exports.stop.permission = 'admin'
exports.stop.params = {
stop = ({host}) ->
return @getXapi(host).shutdownHost(host._xapiId)
stop.description = 'stop the host'
stop.params = {
id: { type: 'string' }
}
exports.detach = ({id}) ->
try
host = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
stop.resolve = {
host: ['id', 'host', 'operate'],
}
xapi = @getXAPI host
exports.stop = stop
$wait xapi.call 'pool.eject', host.ref
#---------------------------------------------------------------------
return true
exports.detach.permission = 'admin'
exports.detach.params = {
detach = ({host}) ->
return @getXapi(host).ejectHostFromPool(host._xapiId)
detach.description = 'eject the host of a pool'
detach.params = {
id: { type: 'string' }
}
exports.enable = ({id}) ->
try
host = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
detach.resolve = {
host: ['id', 'host', 'administrate'],
}
xapi = @getXAPI host
exports.detach = detach
$wait xapi.call 'host.enable', host.ref
#---------------------------------------------------------------------
return true
exports.stop.permission = 'admin'
exports.stop.params = {
enable = ({host}) ->
return @getXapi(host).enableHost(host._xapiId)
enable.description = 'enable to create VM on the host'
enable.params = {
id: { type: 'string' }
}
exports.disable = ({id}) ->
try
host = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
enable.resolve = {
host: ['id', 'host', 'administrate'],
}
xapi = @getXAPI host
exports.enable = enable
$wait xapi.call 'host.disable', host.ref
#---------------------------------------------------------------------
return true
exports.stop.permission = 'admin'
exports.stop.params = {
disable = ({host}) ->
return @getXapi(host).disableHost(host._xapiId)
disable.description = 'disable to create VM on the hsot'
disable.params = {
id: { type: 'string' }
}
}
disable.resolve = {
host: ['id', 'host', 'administrate'],
}
exports.disable = disable
#---------------------------------------------------------------------
# Returns an array of missing new patches in the host
# Returns an empty array if up-to-date
# Throws an error if the host is not running the latest XS version
listMissingPatches = ({host}) ->
return @getXapi(host).listMissingPoolPatchesOnHost(host._xapiId)
listMissingPatches.params = {
host: { type: 'string' }
}
listMissingPatches.resolve = {
host: ['host', 'host', 'view'],
}
exports.listMissingPatches = listMissingPatches
listMissingPatches.description = 'return an array of missing new patches in the host'
#---------------------------------------------------------------------
installPatch = ({host, patch: patchUuid}) ->
return @getXapi(host).installPoolPatchOnHost(patchUuid, host._xapiId)
installPatch.description = 'install a patch on an host'
installPatch.params = {
host: { type: 'string' }
patch: { type: 'string' }
}
installPatch.resolve = {
host: ['host', 'host', 'administrate']
}
exports.installPatch = installPatch
#---------------------------------------------------------------------
installAllPatches = ({host}) ->
return @getXapi(host).installAllPoolPatchesOnHost(host._xapiId)
installAllPatches.description = 'install all the missing patches on a host'
installAllPatches.params = {
host: { type: 'string' }
}
installAllPatches.resolve = {
host: ['host', 'host', 'administrate']
}
exports.installAllPatches = installAllPatches
#---------------------------------------------------------------------
emergencyShutdownHost = ({host}) ->
return @getXapi(host).emergencyShutdownHost(host._xapiId)
emergencyShutdownHost.description = 'suspend all VMs and shutdown host'
emergencyShutdownHost.params = {
host: { type: 'string' }
}
emergencyShutdownHost.resolve = {
host: ['host', 'host', 'administrate']
}
exports.emergencyShutdownHost = emergencyShutdownHost
#---------------------------------------------------------------------
stats = ({host, granularity}) ->
return @getXapiHostStats(host, granularity)
stats.description = 'returns statistic of the host'
stats.params = {
host: { type: 'string' },
granularity: {
type: 'string',
optional: true
}
}
stats.resolve = {
host: ['host', 'host', 'view']
}
exports.stats = stats;
#=====================================================================
Object.defineProperty(exports, '__esModule', {
value: true
})

39
src/api/ip-pool.js Normal file
View File

@@ -0,0 +1,39 @@
import { Unauthorized } from '../api-errors'
export function create (props) {
return this.createIpPool(props)
}
create.permission = 'admin'
// -------------------------------------------------------------------
function delete_ ({ id }) {
return this.deleteIpPool(id)
}
export { delete_ as delete }
delete_.permission = 'admin'
// -------------------------------------------------------------------
export function getAll (params) {
const { user } = this
if (!user) {
throw new Unauthorized()
}
return this.getAllIpPools(user.permission === 'admin'
? params && params.userId
: user.id
)
}
// -------------------------------------------------------------------
export function set ({ id, ...props }) {
return this.updateIpPool(id, props)
}
set.permission = 'admin'

105
src/api/job.js Normal file
View File

@@ -0,0 +1,105 @@
// FIXME so far, no acls for jobs
export async function getAll () {
return /* await */ this.getAllJobs()
}
getAll.permission = 'admin'
getAll.description = 'Gets all available jobs'
export async function get (id) {
return /* await */ this.getJob(id)
}
get.permission = 'admin'
get.description = 'Gets an existing job'
get.params = {
id: {type: 'string'}
}
export async function create ({job}) {
job.userId = this.session.get('user_id')
return (await this.createJob(job)).id
}
create.permission = 'admin'
create.description = 'Creates a new job from description object'
create.params = {
job: {
type: 'object',
properties: {
name: {type: 'string', optional: true},
type: {type: 'string'},
key: {type: 'string'},
method: {type: 'string'},
paramsVector: {
type: 'object',
properties: {
type: {type: 'string'},
items: {
type: 'array',
items: {
type: 'object'
}
}
},
optional: true
}
}
}
}
export async function set ({job}) {
await this.updateJob(job)
}
set.permission = 'admin'
set.description = 'Modifies an existing job from a description object'
set.params = {
job: {
type: 'object',
properties: {
id: {type: 'string'},
name: {type: 'string', optional: true},
type: {type: 'string'},
key: {type: 'string'},
method: {type: 'string'},
paramsVector: {
type: 'object',
properties: {
type: {type: 'string'},
items: {
type: 'array',
items: {
type: 'object'
}
}
},
optional: true
}
}
}
}
async function delete_ ({id}) {
await this.removeJob(id)
}
delete_.permission = 'admin'
delete_.description = 'Deletes an existing job'
delete_.params = {
id: {type: 'string'}
}
export {delete_ as delete}
export async function runSequence ({idSequence}) {
await this.runJobSequence(idSequence)
}
runSequence.permission = 'admin'
runSequence.description = 'Runs jobs sequentially, in the provided order'
runSequence.params = {
idSequence: {type: 'array', items: {type: 'string'}}
}

38
src/api/log.js Normal file
View File

@@ -0,0 +1,38 @@
export async function get ({namespace}) {
const logger = await this.getLogger(namespace)
return new Promise((resolve, reject) => {
const logs = {}
logger.createReadStream()
.on('data', (data) => {
logs[data.key] = data.value
})
.on('end', () => {
resolve(logs)
})
.on('error', reject)
})
}
get.description = 'returns logs list for one namespace'
get.params = {
namespace: { type: 'string' }
}
get.permission = 'admin'
// -------------------------------------------------------------------
async function delete_ ({namespace, id}) {
const logger = await this.getLogger(namespace)
logger.del(id)
}
delete_.description = 'deletes one or several logs from a namespace'
delete_.params = {
id: { type: [ 'array', 'string' ] },
namespace: { type: 'string' }
}
delete_.permission = 'admin'
export {delete_ as delete}

View File

@@ -1,19 +0,0 @@
{$wait} = require '../fibers-utils'
#=====================================================================
exports.delete = ({id}) ->
try
message = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI message
$wait xapi.call 'message.destroy', message.ref
return true
exports.delete.permission = 'admin'
exports.delete.params =
id:
type: 'string'

12
src/api/message.js Normal file
View File

@@ -0,0 +1,12 @@
async function delete_ ({ message }) {
await this.getXapi(message).call('message.destroy', message._xapiRef)
}
export {delete_ as delete}
delete_.params = {
id: { type: 'string' }
}
delete_.resolve = {
message: ['id', 'message', 'administrate']
}

118
src/api/network.js Normal file
View File

@@ -0,0 +1,118 @@
import { mapToArray } from '../utils'
export function getBondModes () {
return ['balance-slb', 'active-backup', 'lacp']
}
export async function create ({ pool, name, description, pif, mtu = 1500, vlan = 0 }) {
return this.getXapi(pool).createNetwork({
name,
description,
pifId: pif && this.getObject(pif, 'PIF')._xapiId,
mtu: +mtu,
vlan: +vlan
})
}
create.params = {
pool: { type: 'string' },
name: { type: 'string' },
description: { type: 'string', optional: true },
pif: { type: 'string', optional: true },
mtu: { type: ['integer', 'string'], optional: true },
vlan: { type: ['integer', 'string'], optional: true }
}
create.resolve = {
pool: ['pool', 'pool', 'administrate']
}
create.permission = 'admin'
// =================================================================
export async function createBonded ({ pool, name, description, pifs, mtu = 1500, mac, bondMode }) {
return this.getXapi(pool).createBondedNetwork({
name,
description,
pifIds: mapToArray(pifs, pif =>
this.getObject(pif, 'PIF')._xapiId
),
mtu: +mtu,
mac,
bondMode
})
}
createBonded.params = {
pool: { type: 'string' },
name: { type: 'string' },
description: { type: 'string', optional: true },
pifs: {
type: 'array',
items: {
type: 'string'
}
},
mtu: { type: ['integer', 'string'], optional: true },
// RegExp since schema-inspector does not provide a param check based on an enumeration
bondMode: { type: 'string', pattern: new RegExp(`^(${getBondModes().join('|')})$`) }
}
createBonded.resolve = {
pool: ['pool', 'pool', 'administrate']
}
createBonded.permission = 'admin'
// ===================================================================
export async function set ({
network,
name_description: nameDescription,
name_label: nameLabel,
defaultIsLocked,
id
}) {
await this.getXapi(network).setNetworkProperties(network._xapiId, {
nameDescription,
nameLabel,
defaultIsLocked
})
}
set.params = {
id: {
type: 'string'
},
name_label: {
type: 'string',
optional: true
},
name_description: {
type: 'string',
optional: true
},
defaultIsLocked: {
type: 'boolean',
optional: true
}
}
set.resolve = {
network: ['id', 'network', 'administrate']
}
// =================================================================
export async function delete_ ({ network }) {
return this.getXapi(network).deleteNetwork(network._xapiId)
}
export {delete_ as delete}
delete_.params = {
id: { type: 'string' }
}
delete_.resolve = {
network: ['id', 'network', 'administrate']
}

49
src/api/pbd.js Normal file
View File

@@ -0,0 +1,49 @@
// FIXME: too low level, should be removed.
// ===================================================================
// Delete
async function delete_ ({PBD}) {
// TODO: check if PBD is attached before
await this.getXapi(PBD).call('PBD.destroy', PBD._xapiRef)
}
export {delete_ as delete}
delete_.params = {
id: { type: 'string' }
}
delete_.resolve = {
PBD: ['id', 'PBD', 'administrate']
}
// ===================================================================
// Disconnect
export async function disconnect ({ pbd }) {
return this.getXapi(pbd).unplugPbd(pbd._xapiId)
}
disconnect.params = {
id: { type: 'string' }
}
disconnect.resolve = {
pbd: ['id', 'PBD', 'administrate']
}
// ===================================================================
// Connect
export async function connect ({PBD}) {
// TODO: check if PBD is attached before
await this.getXapi(PBD).call('PBD.plug', PBD._xapiRef)
}
connect.params = {
id: { type: 'string' }
}
connect.resolve = {
PBD: ['id', 'PBD', 'administrate']
}

93
src/api/pif.js Normal file
View File

@@ -0,0 +1,93 @@
// TODO: too low level, move into host.
import { IPV4_CONFIG_MODES, IPV6_CONFIG_MODES } from '../xapi'
export function getIpv4ConfigurationModes () {
return IPV4_CONFIG_MODES
}
export function getIpv6ConfigurationModes () {
return IPV6_CONFIG_MODES
}
// ===================================================================
// Delete
async function delete_ ({pif}) {
// TODO: check if PIF is attached before
await this.getXapi(pif).call('PIF.destroy', pif._xapiRef)
}
export {delete_ as delete}
delete_.params = {
id: { type: 'string' }
}
delete_.resolve = {
pif: ['id', 'PIF', 'administrate']
}
// ===================================================================
// Disconnect
export async function disconnect ({pif}) {
// TODO: check if PIF is attached before
await this.getXapi(pif).call('PIF.unplug', pif._xapiRef)
}
disconnect.params = {
id: { type: 'string' }
}
disconnect.resolve = {
pif: ['id', 'PIF', 'administrate']
}
// ===================================================================
// Connect
export async function connect ({pif}) {
// TODO: check if PIF is attached before
await this.getXapi(pif).call('PIF.plug', pif._xapiRef)
}
connect.params = {
id: { type: 'string' }
}
connect.resolve = {
pif: ['id', 'PIF', 'administrate']
}
// ===================================================================
// Reconfigure IP
export async function reconfigureIp ({ pif, mode = 'DHCP', ip, netmask, gateway, dns }) {
await this.getXapi(pif).call('PIF.reconfigure_ip', pif._xapiRef, mode, ip, netmask, gateway, dns)
}
reconfigureIp.params = {
id: { type: 'string', optional: true },
mode: { type: 'string', optional: true },
ip: { type: 'string', optional: true },
netmask: { type: 'string', optional: true },
gateway: { type: 'string', optional: true },
dns: { type: 'string', optional: true }
}
reconfigureIp.resolve = {
pif: ['id', 'PIF', 'administrate']
}
// ===================================================================
export async function editPif ({ pif, vlan }) {
await this.getXapi(pif).editPif(pif._xapiId, { vlan })
}
editPif.params = {
id: { type: 'string' },
vlan: { type: ['integer', 'string'] }
}
editPif.resolve = {
pif: ['id', 'PIF', 'administrate']
}

104
src/api/plugin.js Normal file
View File

@@ -0,0 +1,104 @@
export async function get () {
return /* await */ this.getPlugins()
}
get.description = 'returns a list of all installed plugins'
get.permission = 'admin'
// -------------------------------------------------------------------
export async function configure ({ id, configuration }) {
await this.configurePlugin(id, configuration)
}
configure.description = 'sets the configuration of a plugin'
configure.params = {
id: {
type: 'string'
},
configuration: {}
}
configure.permission = 'admin'
// -------------------------------------------------------------------
export async function disableAutoload ({ id }) {
await this.disablePluginAutoload(id)
}
disableAutoload.description = ''
disableAutoload.params = {
id: {
type: 'string'
}
}
disableAutoload.permission = 'admin'
// -------------------------------------------------------------------
export async function enableAutoload ({ id }) {
await this.enablePluginAutoload(id)
}
enableAutoload.description = 'enables a plugin, allowing it to be loaded'
enableAutoload.params = {
id: {
type: 'string'
}
}
enableAutoload.permission = 'admin'
// -------------------------------------------------------------------
export async function load ({ id }) {
await this.loadPlugin(id)
}
load.description = 'loads a plugin'
load.params = {
id: {
type: 'string'
}
}
load.permission = 'admin'
// -------------------------------------------------------------------
export async function unload ({ id }) {
await this.unloadPlugin(id)
}
unload.description = 'unloads a plugin'
unload.params = {
id: {
type: 'string'
}
}
unload.permission = 'admin'
// -------------------------------------------------------------------
export async function purgeConfiguration ({ id }) {
await this.purgePluginConfiguration(id)
}
purgeConfiguration.description = 'removes a plugin configuration'
purgeConfiguration.params = {
id: {
type: 'string'
}
}
purgeConfiguration.permission = 'admin'

View File

@@ -1,31 +0,0 @@
{$wait} = require '../fibers-utils'
#=====================================================================
exports.set = ->
try
pool = @getObject params.id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI pool
for param, field of {
'name_label'
'name_description'
}
continue unless param of params
$wait xapi.call "pool.set_#{field}", pool.ref, params[param]
return true
exports.set.permission = 'admin'
exports.set.params =
id:
type: 'string'
name_label:
type: 'string'
optional: true
name_description:
type: 'string'
optional: true

160
src/api/pool.js Normal file
View File

@@ -0,0 +1,160 @@
import {GenericError} from '../api-errors'
// ===================================================================
export async function set ({
pool,
// TODO: use camel case.
name_description: nameDescription,
name_label: nameLabel
}) {
await this.getXapi(pool).setPoolProperties({
nameDescription,
nameLabel
})
}
set.params = {
id: {
type: 'string'
},
name_label: {
type: 'string',
optional: true
},
name_description: {
type: 'string',
optional: true
}
}
set.resolve = {
pool: ['id', 'pool', 'administrate']
}
// -------------------------------------------------------------------
export async function setDefaultSr ({ sr }) {
await this.hasPermissions(this.user.id, [ [ sr.$pool, 'administrate' ] ])
await this.getXapi(sr).setDefaultSr(sr._xapiId)
}
setDefaultSr.permission = '' // signed in
setDefaultSr.params = {
sr: {
type: 'string'
}
}
setDefaultSr.resolve = {
sr: ['sr', 'SR']
}
// -------------------------------------------------------------------
export async function installPatch ({pool, patch: patchUuid}) {
await this.getXapi(pool).installPoolPatchOnAllHosts(patchUuid)
}
installPatch.params = {
pool: {
type: 'string'
},
patch: {
type: 'string'
}
}
installPatch.resolve = {
pool: ['pool', 'pool', 'administrate']
}
// -------------------------------------------------------------------
export async function installAllPatches ({ pool }) {
await this.getXapi(pool).installAllPoolPatchesOnAllHosts()
}
installPatch.params = {
pool: {
type: 'string'
}
}
installPatch.resolve = {
pool: ['pool', 'pool', 'administrate']
}
// -------------------------------------------------------------------
async function handlePatchUpload (req, res, {pool}) {
const contentLength = req.headers['content-length']
if (!contentLength) {
res.writeHead(411)
res.end('Content length is mandatory')
return
}
await this.getXapi(pool).uploadPoolPatch(req, contentLength)
}
export async function uploadPatch ({pool}) {
return {
$sendTo: await this.registerHttpRequest(handlePatchUpload, {pool})
}
}
uploadPatch.params = {
pool: { type: 'string' }
}
uploadPatch.resolve = {
pool: ['pool', 'pool', 'administrate']
}
// Compatibility
//
// TODO: remove when no longer used in xo-web
export {uploadPatch as patch}
// -------------------------------------------------------------------
export async function mergeInto ({ source, target, force }) {
try {
await this.mergeXenPools(source._xapiId, target._xapiId, force)
} catch (e) {
// FIXME: should we expose plain XAPI error messages?
throw new GenericError(e.message)
}
}
mergeInto.params = {
force: { type: 'boolean', optional: true },
source: { type: 'string' },
target: { type: 'string' }
}
mergeInto.resolve = {
source: ['source', 'pool', 'administrate'],
target: ['target', 'pool', 'administrate']
}
// -------------------------------------------------------------------
export async function getLicenseState ({pool}) {
return this.getXapi(pool).call(
'pool.get_license_state',
pool._xapiId.$ref,
)
}
getLicenseState.params = {
pool: {
type: 'string'
}
}
getLicenseState.resolve = {
pool: ['pool', 'pool', 'administrate']
}

72
src/api/remote.js Normal file
View File

@@ -0,0 +1,72 @@
export async function getAll () {
return this.getAllRemotes()
}
getAll.permission = 'admin'
getAll.description = 'Gets all existing fs remote points'
export async function get ({id}) {
return this.getRemote(id)
}
get.permission = 'admin'
get.description = 'Gets an existing fs remote point'
get.params = {
id: {type: 'string'}
}
export async function test ({id}) {
return this.testRemote(id)
}
test.permission = 'admin'
test.description = 'Performs a read/write matching test on a remote point'
test.params = {
id: {type: 'string'}
}
export async function list ({id}) {
return this.listRemoteBackups(id)
}
list.permission = 'admin'
list.description = 'Lists the files found in a remote point'
list.params = {
id: {type: 'string'}
}
export async function create ({name, url}) {
return this.createRemote({name, url})
}
create.permission = 'admin'
create.description = 'Creates a new fs remote point'
create.params = {
name: {type: 'string'},
url: {type: 'string'}
}
export async function set ({id, name, url, enabled}) {
await this.updateRemote(id, {name, url, enabled})
}
set.permission = 'admin'
set.description = 'Modifies an existing fs remote point'
set.params = {
id: {type: 'string'},
name: {type: 'string', optional: true},
url: {type: 'string', optional: true},
enabled: {type: 'boolean', optional: true}
}
async function delete_ ({id}) {
await this.removeRemote(id)
}
delete_.permission = 'admin'
delete_.description = 'Deletes an existing fs remote point'
delete_.params = {
id: {type: 'string'}
}
export {delete_ as delete}

237
src/api/resource-set.js Normal file
View File

@@ -0,0 +1,237 @@
import {
Unauthorized
} from '../api-errors'
// ===================================================================
export function create ({ name, subjects, objects, limits }) {
return this.createResourceSet(name, subjects, objects, limits)
}
create.permission = 'admin'
create.params = {
name: {
type: 'string'
},
subjects: {
type: 'array',
items: {
type: 'string'
},
optional: true
},
objects: {
type: 'array',
items: {
type: 'string'
},
optional: true
},
limits: {
type: 'object',
optional: true
}
}
// -------------------------------------------------------------------
function delete_ ({ id }) {
return this.deleteResourceSet(id)
}
export { delete_ as delete }
delete_.permission = 'admin'
delete_.params = {
id: {
type: 'string'
}
}
// -------------------------------------------------------------------
export function set ({ id, name, subjects, objects, ipPools, limits }) {
return this.updateResourceSet(id, {
limits,
name,
objects,
ipPools,
subjects
})
}
set.permission = 'admin'
set.params = {
id: {
type: 'string'
},
name: {
type: 'string',
optional: true
},
subjects: {
type: 'array',
items: {
type: 'string'
},
optional: true
},
objects: {
type: 'array',
items: {
type: 'string'
},
optional: true
},
ipPools: {
type: 'array',
items: {
type: 'string'
},
optional: true
},
limits: {
type: 'object',
optional: true
}
}
// -------------------------------------------------------------------
export function get ({ id }) {
return this.getResourceSet(id)
}
get.permission = 'admin'
get.params = {
id: {
type: 'string'
}
}
// -------------------------------------------------------------------
export async function getAll () {
const { user } = this
if (!user) {
throw new Unauthorized()
}
return this.getAllResourceSets(user.id)
}
// -------------------------------------------------------------------
export function addObject ({ id, object }) {
return this.addObjectToResourceSet(object, id)
}
addObject.permission = 'admin'
addObject.params = {
id: {
type: 'string'
},
object: {
type: 'string'
}
}
// -------------------------------------------------------------------
export function removeObject ({ id, object }) {
return this.removeObjectFromResourceSet(object, id)
}
removeObject.permission = 'admin'
removeObject.params = {
id: {
type: 'string'
},
object: {
type: 'string'
}
}
// -------------------------------------------------------------------
export function addSubject ({ id, subject }) {
return this.addSubjectToResourceSet(subject, id)
}
addSubject.permission = 'admin'
addSubject.params = {
id: {
type: 'string'
},
subject: {
type: 'string'
}
}
// -------------------------------------------------------------------
export function removeSubject ({ id, subject }) {
return this.removeSubjectFromResourceSet(subject, id)
}
removeSubject.permission = 'admin'
removeSubject.params = {
id: {
type: 'string'
},
subject: {
type: 'string'
}
}
// -------------------------------------------------------------------
export function addLimit ({ id, limitId, quantity }) {
return this.addLimitToResourceSet(limitId, quantity, id)
}
addLimit.permission = 'admin'
addLimit.params = {
id: {
type: 'string'
},
limitId: {
type: 'string'
},
quantity: {
type: 'integer'
}
}
// -------------------------------------------------------------------
export function removeLimit ({ id, limitId }) {
return this.removeLimitFromResourceSet(limitId, id)
}
removeLimit.permission = 'admin'
removeLimit.params = {
id: {
type: 'string'
},
limitId: {
type: 'string'
}
}
// -------------------------------------------------------------------
export function recomputeAllLimits () {
return this.recomputeResourceSetsLimits()
}
recomputeAllLimits.permission = 'admin'

3
src/api/role.js Normal file
View File

@@ -0,0 +1,3 @@
export async function getAll () {
return /* await */ this.getRoles()
}

57
src/api/schedule.js Normal file
View File

@@ -0,0 +1,57 @@
// FIXME so far, no acls for schedules
export async function getAll () {
return /* await */ this.getAllSchedules()
}
getAll.permission = 'admin'
getAll.description = 'Gets all existing schedules'
export async function get (id) {
return /* await */ this.getSchedule(id)
}
get.permission = 'admin'
get.description = 'Gets an existing schedule'
get.params = {
id: {type: 'string'}
}
export async function create ({ jobId, cron, enabled, name, timezone }) {
return /* await */ this.createSchedule(this.session.get('user_id'), { job: jobId, cron, enabled, name, timezone })
}
create.permission = 'admin'
create.description = 'Creates a new schedule'
create.params = {
jobId: {type: 'string'},
cron: {type: 'string'},
enabled: {type: 'boolean', optional: true},
name: {type: 'string', optional: true}
}
export async function set ({ id, jobId, cron, enabled, name, timezone }) {
await this.updateSchedule(id, { job: jobId, cron, enabled, name, timezone })
}
set.permission = 'admin'
set.description = 'Modifies an existing schedule'
set.params = {
id: {type: 'string'},
jobId: {type: 'string', optional: true},
cron: {type: 'string', optional: true},
enabled: {type: 'boolean', optional: true},
name: {type: 'string', optional: true}
}
async function delete_ ({id}) {
await this.removeSchedule(id)
}
delete_.permission = 'admin'
delete_.description = 'Deletes an existing schedule'
delete_.params = {
id: {type: 'string'}
}
export {delete_ as delete}

30
src/api/scheduler.js Normal file
View File

@@ -0,0 +1,30 @@
export async function enable ({id}) {
const schedule = await this.getSchedule(id)
schedule.enabled = true
await this.updateSchedule(id, schedule)
}
enable.permission = 'admin'
enable.description = 'Enables a schedule to run it\'s job as scheduled'
enable.params = {
id: {type: 'string'}
}
export async function disable ({id}) {
const schedule = await this.getSchedule(id)
schedule.enabled = false
await this.updateSchedule(id, schedule)
}
disable.permission = 'admin'
disable.description = 'Disables a schedule'
disable.params = {
id: {type: 'string'}
}
export function getScheduleTable () {
return this.scheduleTable
}
disable.permission = 'admin'
disable.description = 'Get a map of existing schedules enabled/disabled state'

View File

@@ -1,88 +0,0 @@
{$wait} = require '../fibers-utils'
#=====================================================================
# FIXME: We are storing passwords which is bad!
# Could we use tokens instead?
# Adds a new server.
exports.add = ({host, username, password}) ->
server = $wait @servers.add {
host
username
password
}
return server.id
exports.add.description = 'Add a new Xen server to XO'
exports.add.permission = 'admin'
exports.add.params =
host:
type: 'string'
username:
type: 'string'
password:
type: 'string'
# Removes an existing server.
exports.remove = ({id}) ->
# Throws an error if the server did not exist.
@throw 'NO_SUCH_OBJECT' unless $wait @servers.remove id
return true
exports.remove.permission = 'admin'
exports.remove.params =
id:
type: 'string'
# Returns all servers.
exports.getAll = ->
# Retrieves the servers.
servers = $wait @servers.get()
# Filters out private properties.
for server, i in servers
servers[i] = @getServerPublicProperties server
return servers
exports.getAll.permission = 'admin'
# Changes the properties of an existing server.
exports.set = ({id, host, username, password}) ->
# Retrieves the server.
server = $wait @servers.first id
# Throws an error if it did not exist.
@throw 'NO_SUCH_OBJECT' unless server
# Updates the provided properties.
server.set {host} if host?
server.set {username} if username?
server.set {password} if password?
# Updates the server.
$wait @servers.update server
return true
exports.set.permission = 'admin'
exports.set.params =
id:
type: 'string'
host:
type: 'string'
optional: true
username:
type: 'string'
optional: true
password:
type: 'string'
optional: true
# Connects to an existing server.
exports.connect = ->
@throw 'NOT_IMPLEMENTED'
# Disconnects from an existing server.
exports.disconnect = ->
@throw 'NOT_IMPLEMENTED'

131
src/api/server.js Normal file
View File

@@ -0,0 +1,131 @@
import {
noop,
pCatch
} from '../utils'
export async function add ({
host,
username,
password,
readOnly,
autoConnect = true
}) {
const server = await this.registerXenServer({host, username, password, readOnly})
if (autoConnect) {
// Connect asynchronously, ignore any errors.
this.connectXenServer(server.id)::pCatch(noop)
}
return server.id
}
add.description = 'register a new Xen server'
add.permission = 'admin'
add.params = {
host: {
type: 'string'
},
username: {
type: 'string'
},
password: {
type: 'string'
},
autoConnect: {
optional: true,
type: 'boolean'
}
}
// -------------------------------------------------------------------
export async function remove ({id}) {
await this.unregisterXenServer(id)
}
remove.description = 'unregister a Xen server'
remove.permission = 'admin'
remove.params = {
id: {
type: 'string'
}
}
// -------------------------------------------------------------------
// TODO: remove this function when users are integrated to the main
// collection.
export function getAll () {
return this.getAllXenServers()
}
getAll.description = 'returns all the registered Xen server'
getAll.permission = 'admin'
// -------------------------------------------------------------------
export async function set ({id, host, username, password, readOnly}) {
await this.updateXenServer(id, {host, username, password, readOnly})
}
set.description = 'changes the properties of a Xen server'
set.permission = 'admin'
set.params = {
id: {
type: 'string'
},
host: {
type: 'string',
optional: true
},
username: {
type: 'string',
optional: true
},
password: {
type: 'string',
optional: true
}
}
// -------------------------------------------------------------------
export async function connect ({id}) {
this.updateXenServer(id, {enabled: true})::pCatch(noop)
await this.connectXenServer(id)
}
connect.description = 'connect a Xen server'
connect.permission = 'admin'
connect.params = {
id: {
type: 'string'
}
}
// -------------------------------------------------------------------
export async function disconnect ({id}) {
this.updateXenServer(id, {enabled: false})::pCatch(noop)
await this.disconnectXenServer(id)
}
disconnect.description = 'disconnect a Xen server'
disconnect.permission = 'admin'
disconnect.params = {
id: {
type: 'string'
}
}

View File

@@ -1,61 +0,0 @@
{$wait} = require '../fibers-utils'
#=====================================================================
# Signs a user in with its email/password.
exports.signInWithPassword = ({email, password}) ->
@throw 'ALREADY_AUTHENTICATED' if @session.has 'user_id'
# Gets the user.
user = $wait @users.first {email}
# Invalid credentials if the user does not exists or if the password
# does not check.
@throw 'INVALID_CREDENTIAL' unless user and user.checkPassword password
# Stores the user identifier in the session.
@session.set 'user_id', user.get 'id'
# Returns the user.
return @getUserPublicProperties user
exports.signInWithPassword.params = {
email: { type: 'string' }
password: { type: 'string' }
}
# Signs a user in with a token.
exports.signInWithToken = ({token}) ->
@throw 'ALREADY_AUTHENTICATED' if @session.has 'user_id'
# Gets the token.
token = $wait @tokens.first token
@throw 'INVALID_CREDENTIAL' unless token?
# Stores the user and the token identifiers in the session.
user_id = token.get('user_id')
@session.set 'token_id', token.get 'id'
@session.set 'user_id', user_id
# Returns the user.
user = $wait @users.first user_id
return @getUserPublicProperties user
exports.signInWithToken.params = {
token: { type: 'string' }
}
exports.signOut = ->
@session.unset 'token_id'
@session.unset 'user_id'
return true
# Gets the the currently signed in user.
exports.getUser = ->
id = @session.get 'user_id', null
# If the user is not signed in, returns null.
return null unless id?
# Returns the user.
user = $wait @users.first id
return @getUserPublicProperties user

62
src/api/session.js Normal file
View File

@@ -0,0 +1,62 @@
import {deprecate} from 'util'
import { getUserPublicProperties } from '../utils'
import {InvalidCredential, AlreadyAuthenticated} from '../api-errors'
// ===================================================================
export async function signIn (credentials) {
if (this.session.has('user_id')) {
throw new AlreadyAuthenticated()
}
const user = await this.authenticateUser(credentials)
if (!user) {
throw new InvalidCredential()
}
this.session.set('user_id', user.id)
return getUserPublicProperties(user)
}
signIn.description = 'sign in'
// -------------------------------------------------------------------
export const signInWithPassword = deprecate(signIn, 'use session.signIn() instead')
signInWithPassword.params = {
email: { type: 'string' },
password: { type: 'string' }
}
// -------------------------------------------------------------------
export const signInWithToken = deprecate(signIn, 'use session.signIn() instead')
signInWithToken.params = {
token: { type: 'string' }
}
// -------------------------------------------------------------------
export function signOut () {
this.session.unset('user_id')
}
signOut.description = 'sign out the user from the current session'
// This method requires the user to be signed in.
signOut.permission = ''
// -------------------------------------------------------------------
export async function getUser () {
const userId = this.session.get('user_id')
return userId === undefined
? null
: getUserPublicProperties(await this.getUser(userId))
}
getUser.description = 'return the currently connected user'

View File

@@ -1,46 +0,0 @@
{$wait} = require '../fibers-utils'
#=====================================================================
exports.set = (params) ->
try
SR = @getObject params.id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI SR
for param, field of {
'name_label'
'name_description'
}
continue unless param of params
$wait xapi.call "SR.set_#{field}", SR.ref, params[param]
return true
exports.set.permission = 'admin'
exports.set.params = {
id: { type: 'string' }
name_label: { type: 'string', optional: true }
name_description: { type: 'string', optional: true }
}
exports.scan = ({id}) ->
try
SR = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI SR
$wait xapi.call 'SR.scan', SR.ref
return true
exports.scan.permission = 'admin'
exports.scan.params = {
id: { type: 'string' }
}

716
src/api/sr.js Normal file
View File

@@ -0,0 +1,716 @@
import { asInteger } from '../xapi/utils'
import {
ensureArray,
forEach,
parseXml
} from '../utils'
// ===================================================================
export async function set ({
sr,
// TODO: use camel case.
name_description: nameDescription,
name_label: nameLabel
}) {
await this.getXapi(sr).setSrProperties(sr._xapiId, {
nameDescription,
nameLabel
})
}
set.params = {
id: { type: 'string' },
name_label: { type: 'string', optional: true },
name_description: { type: 'string', optional: true }
}
set.resolve = {
sr: ['id', 'SR', 'operate']
}
// -------------------------------------------------------------------
export async function scan ({SR}) {
await this.getXapi(SR).call('SR.scan', SR._xapiRef)
}
scan.params = {
id: { type: 'string' }
}
scan.resolve = {
SR: ['id', 'SR', 'operate']
}
// -------------------------------------------------------------------
// TODO: find a way to call this "delete" and not destroy
export async function destroy ({ sr }) {
await this.getXapi(sr).destroySr(sr._xapiId)
}
destroy.params = {
id: { type: 'string' }
}
destroy.resolve = {
sr: ['id', 'SR', 'administrate']
}
// -------------------------------------------------------------------
export async function forget ({SR}) {
await this.getXapi(SR).forgetSr(SR._xapiId)
}
forget.params = {
id: { type: 'string' }
}
forget.resolve = {
SR: ['id', 'SR', 'administrate']
}
// -------------------------------------------------------------------
export async function connectAllPbds ({SR}) {
await this.getXapi(SR).connectAllSrPbds(SR._xapiId)
}
connectAllPbds.params = {
id: { type: 'string' }
}
connectAllPbds.resolve = {
SR: ['id', 'SR', 'administrate']
}
// -------------------------------------------------------------------
export async function disconnectAllPbds ({SR}) {
await this.getXapi(SR).disconnectAllSrPbds(SR._xapiId)
}
disconnectAllPbds.params = {
id: { type: 'string' }
}
disconnectAllPbds.resolve = {
SR: ['id', 'SR', 'administrate']
}
// -------------------------------------------------------------------
export async function createIso ({
host,
nameLabel,
nameDescription,
path,
type,
user,
password
}) {
const xapi = this.getXapi(host)
const deviceConfig = {}
if (type === 'local') {
deviceConfig.legacy_mode = 'true'
} else if (type === 'smb') {
path = path.replace(/\\/g, '/')
deviceConfig.username = user
deviceConfig.cifspassword = password
}
deviceConfig.location = path
const srRef = await xapi.call(
'SR.create',
host._xapiRef,
deviceConfig,
'0', // SR size 0 because ISO
nameLabel,
nameDescription,
'iso', // SR type ISO
'iso', // SR content type ISO
type !== 'local',
{}
)
const sr = await xapi.call('SR.get_record', srRef)
return sr.uuid
}
createIso.params = {
host: { type: 'string' },
nameLabel: { type: 'string' },
nameDescription: { type: 'string' },
path: { type: 'string' },
type: { type: 'string' },
user: { type: 'string', optional: true },
password: { type: 'string', optional: true }
}
createIso.resolve = {
host: ['host', 'host', 'administrate']
}
// -------------------------------------------------------------------
// NFS SR
// This functions creates a NFS SR
export async function createNfs ({
host,
nameLabel,
nameDescription,
server,
serverPath,
nfsVersion
}) {
const xapi = this.getXapi(host)
const deviceConfig = {
server,
serverpath: serverPath
}
// if NFS version given
if (nfsVersion) {
deviceConfig.nfsversion = nfsVersion
}
const srRef = await xapi.call(
'SR.create',
host._xapiRef,
deviceConfig,
'0',
nameLabel,
nameDescription,
'nfs', // SR LVM over iSCSI
'user', // recommended by Citrix
true,
{}
)
const sr = await xapi.call('SR.get_record', srRef)
return sr.uuid
}
createNfs.params = {
host: { type: 'string' },
nameLabel: { type: 'string' },
nameDescription: { type: 'string' },
server: { type: 'string' },
serverPath: { type: 'string' },
nfsVersion: { type: 'string', optional: true }
}
createNfs.resolve = {
host: ['host', 'host', 'administrate']
}
// -------------------------------------------------------------------
// Local LVM SR
// This functions creates a local LVM SR
export async function createLvm ({
host,
nameLabel,
nameDescription,
device
}) {
const xapi = this.getXapi(host)
const deviceConfig = {
device
}
const srRef = await xapi.call(
'SR.create',
host._xapiRef,
deviceConfig,
'0',
nameLabel,
nameDescription,
'lvm', // SR LVM
'user', // recommended by Citrix
false,
{}
)
const sr = await xapi.call('SR.get_record', srRef)
return sr.uuid
}
createLvm.params = {
host: { type: 'string' },
nameLabel: { type: 'string' },
nameDescription: { type: 'string' },
device: { type: 'string' }
}
createLvm.resolve = {
host: ['host', 'host', 'administrate']
}
// -------------------------------------------------------------------
// This function helps to detect all NFS shares (exports) on a NFS server
// Return a table of exports with their paths and ACLs
export async function probeNfs ({
host,
server
}) {
const xapi = this.getXapi(host)
const deviceConfig = {
server
}
let xml
try {
await xapi.call(
'SR.probe',
host._xapiRef,
deviceConfig,
'nfs',
{}
)
throw new Error('the call above should have thrown an error')
} catch (error) {
if (error.code !== 'SR_BACKEND_FAILURE_101') {
throw error
}
xml = parseXml(error.params[2])
}
const nfsExports = []
forEach(ensureArray(xml['nfs-exports'].Export), nfsExport => {
nfsExports.push({
path: nfsExport.Path.trim(),
acl: nfsExport.Accesslist.trim()
})
})
return nfsExports
}
probeNfs.params = {
host: { type: 'string' },
server: { type: 'string' }
}
probeNfs.resolve = {
host: ['host', 'host', 'administrate']
}
// -------------------------------------------------------------------
// ISCSI SR
// This functions creates a iSCSI SR
export async function createIscsi ({
host,
nameLabel,
nameDescription,
size,
target,
port,
targetIqn,
scsiId,
chapUser,
chapPassword
}) {
const xapi = this.getXapi(host)
const deviceConfig = {
target,
targetIQN: targetIqn,
SCSIid: scsiId
}
// if we give user and password
if (chapUser && chapPassword) {
deviceConfig.chapUser = chapUser
deviceConfig.chapPassword = chapPassword
}
// if we give another port than default iSCSI
if (port) {
deviceConfig.port = asInteger(port)
}
const srRef = await xapi.call(
'SR.create',
host._xapiRef,
deviceConfig,
'0',
nameLabel,
nameDescription,
'lvmoiscsi', // SR LVM over iSCSI
'user', // recommended by Citrix
true,
{}
)
const sr = await xapi.call('SR.get_record', srRef)
return sr.uuid
}
createIscsi.params = {
host: { type: 'string' },
nameLabel: { type: 'string' },
nameDescription: { type: 'string' },
target: { type: 'string' },
port: { type: 'integer', optional: true },
targetIqn: { type: 'string' },
scsiId: { type: 'string' },
chapUser: { type: 'string', optional: true },
chapPassword: { type: 'string', optional: true }
}
createIscsi.resolve = {
host: ['host', 'host', 'administrate']
}
// -------------------------------------------------------------------
// This function helps to detect all iSCSI IQN on a Target (iSCSI "server")
// Return a table of IQN or empty table if no iSCSI connection to the target
export async function probeIscsiIqns ({
host,
target: targetIp,
port,
chapUser,
chapPassword
}) {
const xapi = this.getXapi(host)
const deviceConfig = {
target: targetIp
}
// if we give user and password
if (chapUser && chapPassword) {
deviceConfig.chapUser = chapUser
deviceConfig.chapPassword = chapPassword
}
// if we give another port than default iSCSI
if (port) {
deviceConfig.port = asInteger(port)
}
let xml
try {
await xapi.call(
'SR.probe',
host._xapiRef,
deviceConfig,
'lvmoiscsi',
{}
)
throw new Error('the call above should have thrown an error')
} catch (error) {
if (error.code === 'SR_BACKEND_FAILURE_141') {
return []
}
if (error.code !== 'SR_BACKEND_FAILURE_96') {
throw error
}
xml = parseXml(error.params[2])
}
const targets = []
forEach(ensureArray(xml['iscsi-target-iqns'].TGT), target => {
// if the target is on another IP adress, do not display it
if (target.IPAddress.trim() === targetIp) {
targets.push({
iqn: target.TargetIQN.trim(),
ip: target.IPAddress.trim()
})
}
})
return targets
}
probeIscsiIqns.params = {
host: { type: 'string' },
target: { type: 'string' },
port: { type: 'integer', optional: true },
chapUser: { type: 'string', optional: true },
chapPassword: { type: 'string', optional: true }
}
probeIscsiIqns.resolve = {
host: ['host', 'host', 'administrate']
}
// -------------------------------------------------------------------
// This function helps to detect all iSCSI ID and LUNs on a Target
// It will return a LUN table
export async function probeIscsiLuns ({
host,
target: targetIp,
port,
targetIqn,
chapUser,
chapPassword
}) {
const xapi = this.getXapi(host)
const deviceConfig = {
target: targetIp,
targetIQN: targetIqn
}
// if we give user and password
if (chapUser && chapPassword) {
deviceConfig.chapUser = chapUser
deviceConfig.chapPassword = chapPassword
}
// if we give another port than default iSCSI
if (port) {
deviceConfig.port = asInteger(port)
}
let xml
try {
await xapi.call(
'SR.probe',
host._xapiRef,
deviceConfig,
'lvmoiscsi',
{}
)
throw new Error('the call above should have thrown an error')
} catch (error) {
if (error.code !== 'SR_BACKEND_FAILURE_107') {
throw error
}
xml = parseXml(error.params[2])
}
const luns = []
forEach(ensureArray(xml['iscsi-target'].LUN), lun => {
luns.push({
id: lun.LUNid.trim(),
vendor: lun.vendor.trim(),
serial: lun.serial.trim(),
size: lun.size.trim(),
scsiId: lun.SCSIid.trim()
})
})
return luns
}
probeIscsiLuns.params = {
host: { type: 'string' },
target: { type: 'string' },
port: { type: 'integer', optional: true },
targetIqn: { type: 'string' },
chapUser: { type: 'string', optional: true },
chapPassword: { type: 'string', optional: true }
}
probeIscsiLuns.resolve = {
host: ['host', 'host', 'administrate']
}
// -------------------------------------------------------------------
// This function helps to detect if this target already exists in XAPI
// It returns a table of SR UUID, empty if no existing connections
export async function probeIscsiExists ({
host,
target: targetIp,
port,
targetIqn,
scsiId,
chapUser,
chapPassword
}) {
const xapi = this.getXapi(host)
const deviceConfig = {
target: targetIp,
targetIQN: targetIqn,
SCSIid: scsiId
}
// if we give user and password
if (chapUser && chapPassword) {
deviceConfig.chapUser = chapUser
deviceConfig.chapPassword = chapPassword
}
// if we give another port than default iSCSI
if (port) {
deviceConfig.port = asInteger(port)
}
const xml = parseXml(await xapi.call('SR.probe', host._xapiRef, deviceConfig, 'lvmoiscsi', {}))
const srs = []
forEach(ensureArray(xml['SRlist'].SR), sr => {
// get the UUID of SR connected to this LUN
srs.push({uuid: sr.UUID.trim()})
})
return srs
}
probeIscsiExists.params = {
host: { type: 'string' },
target: { type: 'string' },
port: { type: 'integer', optional: true },
targetIqn: { type: 'string' },
scsiId: { type: 'string' },
chapUser: { type: 'string', optional: true },
chapPassword: { type: 'string', optional: true }
}
probeIscsiExists.resolve = {
host: ['host', 'host', 'administrate']
}
// -------------------------------------------------------------------
// This function helps to detect if this NFS SR already exists in XAPI
// It returns a table of SR UUID, empty if no existing connections
export async function probeNfsExists ({
host,
server,
serverPath
}) {
const xapi = this.getXapi(host)
const deviceConfig = {
server,
serverpath: serverPath
}
const xml = parseXml(await xapi.call('SR.probe', host._xapiRef, deviceConfig, 'nfs', {}))
const srs = []
forEach(ensureArray(xml['SRlist'].SR), sr => {
// get the UUID of SR connected to this LUN
srs.push({uuid: sr.UUID.trim()})
})
return srs
}
probeNfsExists.params = {
host: { type: 'string' },
server: { type: 'string' },
serverPath: { type: 'string' }
}
probeNfsExists.resolve = {
host: ['host', 'host', 'administrate']
}
// -------------------------------------------------------------------
// This function helps to reattach a forgotten NFS/iSCSI SR
export async function reattach ({
host,
uuid,
nameLabel,
nameDescription,
type
}) {
const xapi = this.getXapi(host)
if (type === 'iscsi') {
type = 'lvmoiscsi' // the internal XAPI name
}
const srRef = await xapi.call(
'SR.introduce',
uuid,
nameLabel,
nameDescription,
type,
'user',
true,
{}
)
const sr = await xapi.call('SR.get_record', srRef)
return sr.uuid
}
reattach.params = {
host: { type: 'string' },
uuid: { type: 'string' },
nameLabel: { type: 'string' },
nameDescription: { type: 'string' },
type: { type: 'string' }
}
reattach.resolve = {
host: ['host', 'host', 'administrate']
}
// -------------------------------------------------------------------
// This function helps to reattach a forgotten ISO SR
export async function reattachIso ({
host,
uuid,
nameLabel,
nameDescription,
type
}) {
const xapi = this.getXapi(host)
if (type === 'iscsi') {
type = 'lvmoiscsi' // the internal XAPI name
}
const srRef = await xapi.call(
'SR.introduce',
uuid,
nameLabel,
nameDescription,
type,
'iso',
true,
{}
)
const sr = await xapi.call('SR.get_record', srRef)
return sr.uuid
}
reattachIso.params = {
host: { type: 'string' },
uuid: { type: 'string' },
nameLabel: { type: 'string' },
nameDescription: { type: 'string' },
type: { type: 'string' }
}
reattachIso.resolve = {
host: ['host', 'host', 'administrate']
}

67
src/api/system.js Normal file
View File

@@ -0,0 +1,67 @@
import forEach from 'lodash/forEach'
import getKeys from 'lodash/keys'
import moment from 'moment-timezone'
import { NoSuchObject } from '../api-errors'
import { version as xoServerVersion } from '../../package.json'
// ===================================================================
export function getMethodsInfo () {
const methods = {}
forEach(this.apiMethods, (method, name) => {
methods[name] = {
description: method.description,
params: method.params || {},
permission: method.permission
}
})
return methods
}
getMethodsInfo.description = 'returns the signatures of all available API methods'
// -------------------------------------------------------------------
export const getServerTimezone = (tz => () => tz)(moment.tz.guess())
getServerTimezone.description = 'return the timezone server'
// -------------------------------------------------------------------
export const getServerVersion = () => xoServerVersion
getServerVersion.description = 'return the version of xo-server'
// -------------------------------------------------------------------
export const getVersion = () => '0.1'
getVersion.description = 'API version (unstable)'
// -------------------------------------------------------------------
export function listMethods () {
return getKeys(this.apiMethods)
}
listMethods.description = 'returns the name of all available API methods'
// -------------------------------------------------------------------
export function methodSignature ({method: name}) {
const method = this.apiMethods[name]
if (!method) {
throw new NoSuchObject()
}
// Return an array for compatibility with XML-RPC.
return [
// XML-RPC require the name of the method.
{
name,
description: method.description,
params: method.params || {},
permission: method.permission
}
]
}
methodSignature.description = 'returns the signature of an API method'

31
src/api/tag.js Normal file
View File

@@ -0,0 +1,31 @@
export async function add ({tag, object}) {
await this.getXapi(object).addTag(object._xapiId, tag)
}
add.description = 'add a new tag to an object'
add.resolve = {
object: ['id', null, 'administrate']
}
add.params = {
tag: { type: 'string' },
id: { type: 'string' }
}
// -------------------------------------------------------------------
export async function remove ({tag, object}) {
await this.getXapi(object).removeTag(object._xapiId, tag)
}
remove.description = 'remove an existing tag from an object'
remove.resolve = {
object: ['id', null, 'administrate']
}
remove.params = {
tag: { type: 'string' },
id: { type: 'string' }
}

25
src/api/task.js Normal file
View File

@@ -0,0 +1,25 @@
export async function cancel ({task}) {
await this.getXapi(task).call('task.cancel', task._xapiRef)
}
cancel.params = {
id: { type: 'string' }
}
cancel.resolve = {
task: ['id', 'task', 'administrate']
}
// -------------------------------------------------------------------
export async function destroy ({task}) {
await this.getXapi(task).call('task.destroy', task._xapiRef)
}
destroy.params = {
id: { type: 'string' }
}
destroy.resolve = {
task: ['id', 'task', 'administrate']
}

49
src/api/test.js Normal file
View File

@@ -0,0 +1,49 @@
export function getPermissionsForUser ({ userId }) {
return this.getPermissionsForUser(userId)
}
getPermissionsForUser.permission = 'admin'
getPermissionsForUser.params = {
userId: {
type: 'string'
}
}
// -------------------------------------------------------------------
export function hasPermission ({ userId, objectId, permission }) {
return this.hasPermissions(userId, [
[ objectId, permission ]
])
}
hasPermission.permission = 'admin'
hasPermission.params = {
userId: {
type: 'string'
},
objectId: {
type: 'string'
},
permission: {
type: 'string'
}
}
// -------------------------------------------------------------------
export function wait ({duration, returnValue}) {
return new Promise(resolve => {
setTimeout(() => {
resolve(returnValue)
}, +duration)
})
}
wait.params = {
duration: {
type: 'string'
}
}

View File

@@ -1,31 +0,0 @@
{$wait} = require '../fibers-utils'
#=====================================================================
# Creates a new token.
#
# TODO: Token permission.
exports.create = ->
userId = @session.get 'user_id'
# The user MUST be signed in and not with a token
@throw 'UNAUTHORIZED' if not userId? or @session.has 'token_id'
# Creates the token.
token = $wait @tokens.generate userId
return token.id
# Deletes a token.
exports.delete = ({token: tokenId}) ->
# Gets the token.
token = $wait @tokens.first tokenId
@throw 'NO_SUCH_OBJECT' unless token?
# Deletes the token.
$wait @tokens.remove tokenId
return true
exports.delete.params = {
token: { type: 'string' }
}

27
src/api/token.js Normal file
View File

@@ -0,0 +1,27 @@
// TODO: Prevent token connections from creating tokens.
// TODO: Token permission.
export async function create () {
const userId = this.session.get('user_id')
return (await this.createAuthenticationToken({userId})).id
}
create.description = 'create a new authentication token'
create.permission = '' // sign in
// -------------------------------------------------------------------
// TODO: an user should be able to delete its own tokens.
async function delete_ ({token: id}) {
await this.deleteAuthenticationToken(id)
}
export {delete_ as delete}
delete_.description = 'delete an existing authentication token'
delete_.permission = 'admin'
delete_.params = {
token: { type: 'string' }
}

View File

@@ -1,106 +0,0 @@
{$wait} = require '../fibers-utils'
#=====================================================================
# Creates a new user.
exports.create = ({email, password, permission}) ->
# Creates the user.
user = $wait @users.create email, password, permission
return user.id
exports.create.permission = 'admin'
exports.create.params = {
email: { type: 'string' }
password: { type: 'string' }
permission: { type: 'string', optional: true}
}
# Deletes an existing user.
#
# FIXME: a user should not be able to delete itself.
exports.delete = ({id}) ->
# The user cannot delete himself.
@throw 'INVALID_PARAMS' if id is @session.get 'user_id'
# Throws an error if the user did not exist.
@throw 'NO_SUCH_OBJECT' unless $wait @users.remove id
return true
exports.delete.permission = 'admin'
exports.delete.params = {
id: { type: 'string' }
}
# Changes the password of the current user.
exports.changePassword = ({old, new: newP}) ->
# Gets the current user (which MUST exist).
user = $wait @users.first @session.get 'user_id'
# Checks its old password.
@throw 'INVALID_CREDENTIAL' unless user.checkPassword old
# Sets the new password.
user.setPassword newP
# Updates the user.
$wait @users.update user
return true
exports.changePassword.permission = '' # Signed in.
exports.changePassword.params = {
old: { type: 'string' }
new: { type: 'string' }
}
# Returns the user with a given identifier.
exports.get = ({id}) ->
# Only an administrator can see another user.
@checkPermission 'admin' unless @session.get 'user_id' is id
# Retrieves the user.
user = $wait @users.first id
# Throws an error if it did not exist.
@throw 'NO_SUCH_OBJECT' unless user
return @getUserPublicProperties user
exports.get.params = {
id: { type: 'string' }
}
# Returns all users.
exports.getAll = ->
# Retrieves the users.
users = $wait @users.get()
# Filters out private properties.
for user, i in users
users[i] = @getUserPublicProperties user
return users
exports.getAll.permission = 'admin'
# Changes the properties of an existing user.
exports.set = ({id, email, password, permission}) ->
# Retrieves the user.
user = $wait @users.first id
# Throws an error if it did not exist.
@throw 'NO_SUCH_OBJECT' unless user
# Updates the provided properties.
user.set {email} if email?
user.set {permission} if permission?
user.setPassword password if password?
# Updates the user.
$wait @users.update user
return true
exports.set.permission = 'admin'
exports.set.params = {
id: { type: 'string' }
email: { type: 'string', optional: true }
password: { type: 'string', optional: true }
permission: { type: 'string', optional: true }
}

99
src/api/user.js Normal file
View File

@@ -0,0 +1,99 @@
import {InvalidParameters} from '../api-errors'
import { getUserPublicProperties, mapToArray } from '../utils'
// ===================================================================
export async function create ({email, password, permission}) {
return (await this.createUser({email, password, permission})).id
}
create.description = 'creates a new user'
create.permission = 'admin'
create.params = {
email: { type: 'string' },
password: { type: 'string' },
permission: { type: 'string', optional: true }
}
// -------------------------------------------------------------------
// Deletes an existing user.
async function delete_ ({id}) {
if (id === this.session.get('user_id')) {
throw new InvalidParameters('a user cannot delete itself')
}
await this.deleteUser(id)
}
// delete is not a valid identifier.
export {delete_ as delete}
delete_.description = 'deletes an existing user'
delete_.permission = 'admin'
delete_.params = {
id: { type: 'string' }
}
// -------------------------------------------------------------------
// TODO: remove this function when users are integrated to the main
// collection.
export async function getAll () {
// Retrieves the users.
const users = await this.getAllUsers()
// Filters out private properties.
return mapToArray(users, getUserPublicProperties)
}
getAll.description = 'returns all the existing users'
getAll.permission = 'admin'
// -------------------------------------------------------------------
export async function set ({id, email, password, permission, preferences}) {
const isAdmin = this.user && this.user.permission === 'admin'
if (isAdmin) {
if (permission && id === this.session.get('user_id')) {
throw new InvalidParameters('a user cannot change its own permission')
}
} else if (email || password || permission) {
throw new InvalidParameters('this properties can only changed by an administrator')
}
await this.updateUser(id, {email, password, permission, preferences})
}
set.description = 'changes the properties of an existing user'
set.permission = ''
set.params = {
id: { type: 'string' },
email: { type: 'string', optional: true },
password: { type: 'string', optional: true },
permission: { type: 'string', optional: true },
preferences: { type: 'object', optional: true }
}
// -------------------------------------------------------------------
export async function changePassword ({oldPassword, newPassword}) {
const id = this.session.get('user_id')
await this.changeUserPassword(id, oldPassword, newPassword)
}
changePassword.description = 'change password after checking old password (user function)'
changePassword.permission = ''
changePassword.params = {
oldPassword: {type: 'string'},
newPassword: {type: 'string'}
}

View File

@@ -1,37 +1,109 @@
{$wait} = require '../fibers-utils'
# FIXME: too low level, should be removed.
{coroutine: $coroutine} = require 'bluebird'
#=====================================================================
exports.delete = ({id}) ->
try
VBD = @getObject params.id
catch
@throw 'NO_SUCH_OBJECT'
xapi = @getXAPI VBD
delete_ = $coroutine ({vbd}) ->
xapi = @getXapi vbd
# TODO: check if VBD is attached before
$wait xapi.call 'VBD.destroy', VBD.ref
yield xapi.call 'VBD.destroy', vbd._xapiRef
return true
exports.delete.permission = 'admin'
exports.delete.params = {
delete_.params = {
id: { type: 'string' }
}
exports.disconnect = ({id}) ->
try
VBD = @getObject params.id
catch
@throw 'NO_SUCH_OBJECT'
delete_.resolve = {
vbd: ['id', 'VBD', 'administrate'],
}
xapi = @getXAPI VBD
exports.delete = delete_
# TODO: check if VBD is attached before
$wait xapi.call 'VBD.unplug_force', VBD.ref
#---------------------------------------------------------------------
return true
exports.disconnect.permission = 'admin'
exports.disconnect.params = {
disconnect = $coroutine ({vbd}) ->
xapi = @getXapi vbd
yield xapi.disconnectVbd(vbd._xapiRef)
return
disconnect.params = {
id: { type: 'string' }
}
disconnect.resolve = {
vbd: ['id', 'VBD', 'administrate'],
}
exports.disconnect = disconnect
#---------------------------------------------------------------------
connect = $coroutine ({vbd}) ->
xapi = @getXapi vbd
yield xapi.connectVbd(vbd._xapiRef)
return
connect.params = {
id: { type: 'string' }
}
connect.resolve = {
vbd: ['id', 'VBD', 'administrate'],
}
exports.connect = connect
#---------------------------------------------------------------------
set = $coroutine (params) ->
{vbd} = params
xapi = @getXapi vbd
{ _xapiRef: ref } = vbd
# VBD position
if 'position' of params
yield xapi.call 'VBD.set_userdevice', ref, String(params.position)
set.params = {
# Identifier of the VBD to update.
id: { type: 'string' }
position: { type: ['string', 'number'], optional: true }
}
set.resolve = {
vbd: ['id', 'VBD', 'administrate'],
}
exports.set = set
#---------------------------------------------------------------------
setBootable = $coroutine ({vbd, bootable}) ->
xapi = @getXapi vbd
{ _xapiRef: ref } = vbd
yield xapi.call 'VBD.set_bootable', ref, bootable
return
setBootable.params = {
vbd: { type: 'string' }
bootable: { type: 'boolean' }
}
setBootable.resolve = {
vbd: ['vbd', 'VBD', 'administrate'],
}
exports.setBootable = setBootable
#=====================================================================
Object.defineProperty(exports, '__esModule', {
value: true
})

View File

@@ -1,49 +1,47 @@
{isArray: $isArray} = require 'underscore'
# FIXME: rename to disk.*
#---------------------------------------------------------------------
{coroutine: $coroutine} = require 'bluebird'
{$wait} = require '../fibers-utils'
{format} = require 'json-rpc-peer'
{InvalidParameters} = require '../api-errors'
{isArray: $isArray, parseSize} = require '../utils'
{JsonRpcError} = require '../api-errors'
#=====================================================================
exports.delete = ({id}) ->
try
VDI = @getObject id
catch
@throw 'NO_SUCH_OBJECT'
delete_ = $coroutine ({vdi}) ->
yield @getXapi(vdi).deleteVdi(vdi._xapiId)
xapi = @getXAPI VDI
return
# TODO: check if VDI is attached before
$wait xapi.call 'VDI.destroy', VDI.ref
delete_.params = {
id: { type: 'string' },
}
return true
exports.delete.permission = 'admin'
exports.delete.params =
id:
type: 'string'
delete_.resolve = {
vdi: ['id', ['VDI', 'VDI-snapshot'], 'administrate'],
}
exports.set = (params) ->
try
VDI = @getObject params.id
catch
@throw 'NO_SUCH_OBJECT'
exports.delete = delete_
xapi = @getXAPI VDI
#---------------------------------------------------------------------
{ref} = VDI
# FIXME: human readable strings should be handled.
set = $coroutine (params) ->
{vdi} = params
xapi = @getXapi vdi
{_xapiRef: ref} = vdi
# Size.
if 'size' of params
{size} = params
size = parseSize(params.size)
if size < VDI.size
@throw(
'INVALID_SIZE'
"cannot set new size below the current size (#{VDI.size})"
if size < vdi.size
throw new InvalidParameters(
"cannot set new size (#{size}) below the current size (#{vdi.size})"
)
$wait xapi.call 'VDI.resize_online', ref, "#{size}"
yield xapi.resizeVdi(ref, size)
# Other fields.
for param, fields of {
@@ -53,11 +51,11 @@ exports.set = (params) ->
continue unless param of params
for field in (if $isArray fields then fields else [fields])
$wait xapi.call "VDI.set_#{field}", ref, "#{params[param]}"
yield xapi.call "VDI.set_#{field}", ref, "#{params[param]}"
return true
exports.set.permission = 'admin'
exports.set.params = {
set.params = {
# Identifier of the VDI to update.
id: { type: 'string' }
@@ -66,5 +64,38 @@ exports.set.params = {
name_description: { type: 'string', optional: true }
# size of VDI
size: { type: 'integer', optional: true }
size: { type: ['integer', 'string'], optional: true }
}
set.resolve = {
vdi: ['id', ['VDI', 'VDI-snapshot'], 'administrate'],
}
exports.set = set
#---------------------------------------------------------------------
migrate = $coroutine ({vdi, sr}) ->
xapi = @getXapi vdi
yield xapi.moveVdi(vdi._xapiRef, sr._xapiRef)
return true
migrate.params = {
id: { type: 'string' }
sr_id: { type: 'string' }
}
migrate.resolve = {
vdi: ['id', ['VDI', 'VDI-snapshot'], 'administrate'],
sr: ['sr_id', 'SR', 'administrate'],
}
exports.migrate = migrate
#=====================================================================
Object.defineProperty(exports, '__esModule', {
value: true
})

142
src/api/vif.js Normal file
View File

@@ -0,0 +1,142 @@
import {
diffItems,
noop,
pCatch
} from '../utils'
// ===================================================================
// TODO: move into vm and rename to removeInterface
async function delete_ ({vif}) {
this.allocIpAddresses(
vif.id,
vif.$network,
null,
vif.allowedIpv4Addresses.concat(vif.allowedIpv6Addresses)
)::pCatch(noop)
await this.getXapi(vif).deleteVif(vif._xapiId)
}
export {delete_ as delete}
delete_.params = {
id: { type: 'string' }
}
delete_.resolve = {
vif: ['id', 'VIF', 'administrate']
}
// -------------------------------------------------------------------
// TODO: move into vm and rename to disconnectInterface
export async function disconnect ({vif}) {
// TODO: check if VIF is attached before
await this.getXapi(vif).disconnectVif(vif._xapiId)
}
disconnect.params = {
id: { type: 'string' }
}
disconnect.resolve = {
vif: ['id', 'VIF', 'operate']
}
// -------------------------------------------------------------------
// TODO: move into vm and rename to connectInterface
export async function connect ({vif}) {
// TODO: check if VIF is attached before
await this.getXapi(vif).connectVif(vif._xapiId)
}
connect.params = {
id: { type: 'string' }
}
connect.resolve = {
vif: ['id', 'VIF', 'operate']
}
// -------------------------------------------------------------------
export async function set ({
vif,
network,
mac,
allowedIpv4Addresses,
allowedIpv6Addresses,
attached
}) {
const oldIpAddresses = vif.allowedIpv4Addresses.concat(vif.allowedIpv6Addresses)
const newIpAddresses = []
{
const { push } = newIpAddresses
push.apply(newIpAddresses, allowedIpv4Addresses || vif.allowedIpv4Addresses)
push.apply(newIpAddresses, allowedIpv6Addresses || vif.allowedIpv6Addresses)
}
if (network || mac) {
const xapi = this.getXapi(vif)
const vm = xapi.getObject(vif.$VM)
mac == null && (mac = vif.MAC)
network = xapi.getObject(network && network.id || vif.$network)
attached == null && (attached = vif.attached)
await this.allocIpAddresses(vif.id, null, oldIpAddresses)
// create new VIF with new parameters
await xapi.createVif(vm.$id, network.$id, {
mac,
currently_attached: attached,
ipv4Allowed: allowedIpv4Addresses,
ipv6Allowed: allowedIpv6Addresses
})
await this.allocIpAddresses(vif.id, newIpAddresses)
return
}
const [ addAddresses, removeAddresses ] = diffItems(
newIpAddresses,
oldIpAddresses
)
await this.allocIpAddresses(
vif.id,
addAddresses,
removeAddresses
)
return this.getXapi(vif).editVif(vif._xapiId, {
ipv4Allowed: allowedIpv4Addresses,
ipv6Allowed: allowedIpv6Addresses
})
}
set.params = {
id: { type: 'string' },
network: { type: 'string', optional: true },
mac: { type: 'string', optional: true },
allowedIpv4Addresses: {
type: 'array',
items: {
type: 'string'
},
optional: true
},
allowedIpv6Addresses: {
type: 'array',
items: {
type: 'string'
},
optional: true
},
attached: { type: 'boolean', optional: true }
}
set.resolve = {
vif: ['id', 'VIF', 'operate'],
network: ['network', 'network', 'operate']
}

File diff suppressed because it is too large Load Diff

49
src/api/xo.js Normal file
View File

@@ -0,0 +1,49 @@
import { streamToBuffer } from '../utils'
// ===================================================================
export function clean () {
return this.clean()
}
clean.permission = 'admin'
// -------------------------------------------------------------------
export async function exportConfig () {
return {
$getFrom: await this.registerHttpRequest((req, res) => {
res.writeHead(200, 'OK', {
'content-disposition': 'attachment'
})
return this.exportConfig()
},
undefined,
{ suffix: '/config.json' })
}
}
exportConfig.permission = 'admin'
// -------------------------------------------------------------------
export function getAllObjects () {
return this.getObjects()
}
getAllObjects.permission = ''
// -------------------------------------------------------------------
export async function importConfig () {
return {
$sendTo: await this.registerHttpRequest(async (req, res) => {
await this.importConfig(JSON.parse(await streamToBuffer(req)))
res.end('config successfully imported')
})
}
}
importConfig.permission = 'admin'

View File

@@ -1,255 +1,172 @@
'use strict';
import Model from './model'
import {BaseError} from 'make-error'
import {EventEmitter} from 'events'
import {
isArray,
isObject,
map
} from './utils'
//====================================================================
// ===================================================================
var _ = require('underscore');
var Promise = require('bluebird');
//====================================================================
function Collection()
{
// Parent constructor.
Collection.super_.call(this);
export class ModelAlreadyExists extends BaseError {
constructor (id) {
super('this model already exists: ' + id)
}
}
require('util').inherits(Collection, require('events').EventEmitter);
Collection.prototype.model = require('./model');
// ===================================================================
/**
* Adds new models to this collection.
*/
Collection.prototype.add = function (models, options) {
var array = true;
if (!_.isArray(models))
{
models = [models];
array = false;
}
export default class Collection extends EventEmitter {
// Default value for Model.
get Model () {
return Model
}
for (var i = 0, n = models.length; i < n; ++i)
{
var model = models[i];
// Make this property writable.
set Model (Model) {
Object.defineProperty(this, 'Model', {
configurable: true,
enumerale: true,
value: Model,
writable: true
})
}
if ( !(model instanceof this.model) )
{
model = new this.model(model);
}
async add (models, opts) {
const array = isArray(models)
if (!array) {
models = [models]
}
var error = model.validate();
if (undefined !== error)
{
// TODO: Better system inspired by Backbone.js.
throw error;
}
const {Model} = this
map(models, model => {
if (!(model instanceof Model)) {
model = new Model(model)
}
models[i] = model.properties;
}
const error = model.validate()
if (error) {
// TODO: Better system inspired by Backbone.js
throw error
}
var self = this;
return Promise.cast(this._add(models, options)).then(function (models) {
self.emit('add', models);
return model.properties
}, models)
if (!array)
{
return models[0];
}
return models;
});
};
models = await this._add(models, opts)
this.emit('add', models)
/**
*
*/
Collection.prototype.first = function (properties) {
if (!_.isObject(properties))
{
properties = (undefined !== properties)
? { 'id': properties }
: {}
;
}
return array
? models
: new this.Model(models[0])
}
var self = this;
return Promise.cast(this._first(properties)).then(function (model) {
if (!model)
{
return null;
}
async first (properties) {
if (!isObject(properties)) {
properties = (properties !== undefined)
? { id: properties }
: {}
}
return new self.model(model);
});
};
const model = await this._first(properties)
return model && new this.Model(model)
}
/**
* Find all models which have a given set of properties.
*
* /!\: Does not return instances of this.model.
*/
Collection.prototype.get = function (properties) {
// For coherence with other methods.
if (!_.isObject(properties))
{
properties = (undefined !== properties)
? { 'id': properties }
: {}
;
}
async get (properties) {
if (!isObject(properties)) {
properties = (properties !== undefined)
? { id: properties }
: {}
}
/* jshint newcap: false */
return Promise.cast(this._get(properties));
};
return /* await */ this._get(properties)
}
async remove (ids) {
if (!isArray(ids)) {
ids = [ids]
}
/**
* Removes models from this collection.
*/
Collection.prototype.remove = function (ids) {
if (!_.isArray(ids))
{
ids = [ids];
}
await this._remove(ids)
var self = this;
return Promise.cast(this._remove(ids)).then(function () {
self.emit('remove', ids);
return true;
});
};
this.emit('remove', ids)
return true
}
/**
* Smartly updates the collection.
*
* - Adds new models.
* - Updates existing models.
* - Removes missing models.
*/
// Collection.prototype.set = function (/*models*/) {
// // TODO:
// };
async update (models) {
const array = isArray(models)
if (!isArray(models)) {
models = [models]
}
/**
* Updates existing models.
*/
Collection.prototype.update = function (models) {
var array = true;
if (!_.isArray(models))
{
models = [models];
array = false;
}
const {Model} = this
map(models, model => {
if (!(model instanceof Model)) {
// TODO: Problems, we may be mixing in some default
// properties which will overwrite existing ones.
model = new Model(model)
}
for (var i = 0, n = models.length; i < n; i++)
{
var model = models[i];
const id = model.get('id')
if ( !(model instanceof this.model) )
{
// TODO: Problems, we may be mixing in some default
// properties which will overwrite existing ones.
model = new this.model(model);
}
// Missing models should be added not updated.
if (id === undefined) {
// FIXME: should not throw an exception but return a rejected promise.
throw new Error('a model without an id cannot be updated')
}
var id = model.get('id');
const error = model.validate()
if (error !== undefined) {
// TODO: Better system inspired by Backbone.js.
throw error
}
// Missing models should be added not updated.
if (!id)
{
return Promise.reject('a model without an id cannot be updated');
}
return model.properties
}, models)
var error = model.validate();
if (undefined !== error)
{
// TODO: Better system inspired by Backbone.js.
throw error;
}
models = await this._update(models)
this.emit('update', models)
models[i] = model.properties;
}
return array
? models
: new this.Model(models[0])
}
var self = this;
return Promise.cast(this._update(models)).then(function (models) {
self.emit('update', models);
// Methods to override in implementations.
if (!array)
{
return models[0];
}
return models;
});
};
_add () {
throw new Error('not implemented')
}
//Collection.extend = require('extendable');
_get () {
throw new Error('not implemented')
}
//////////////////////////////////////////////////////////////////////
// Methods to override in implementations.
//////////////////////////////////////////////////////////////////////
_remove () {
throw new Error('not implemented')
}
/**
*
*/
Collection.prototype._add = function (models, options) {
throw 'not implemented';
};
_update () {
throw new Error('not implemented')
}
/**
*
*/
Collection.prototype._get = function (properties) {
throw 'not implemented';
};
// Methods which may be overridden in implementations.
/**
*
*/
Collection.prototype._remove = function (ids) {
throw 'not implemented';
};
count (properties) {
return this.get(properties).get('count')
}
/**
*
*/
Collection.prototype._update = function (models) {
throw 'not implemented';
};
exists (properties) {
/* jshint eqnull: true */
return this.first(properties).then(model => model != null)
}
//////////////////////////////////////////////////////////////////////
// Methods which may be overriden in implementations.
//////////////////////////////////////////////////////////////////////
async _first (properties) {
const models = await this.get(properties)
/**
*
*/
Collection.prototype.count = function (properties) {
return this.get(properties).then(function (models) {
return models.length;
});
};
/**
*
*/
Collection.prototype.exists = function (properties) {
return this.first(properties).then(function (model) {
return (null !== model);
});
};
/**
*
*/
Collection.prototype._first = function (properties) {
return Promise.cast(this.get(properties)).then(function (models) {
if (0 === models.length)
{
return null;
}
return models[0];
});
};
//////////////////////////////////////////////////////////////////////
module.exports = Collection;
return models.length
? models[0]
: null
}
}

View File

@@ -1,103 +0,0 @@
'use strict';
//====================================================================
var _ = require('underscore');
var Promise = require('bluebird');
//====================================================================
function Memory(models)
{
Memory.super_.call(this);
this.models = {};
this.next_id = 0;
if (models)
{
this.add(models);
}
}
require('util').inherits(Memory, require('../collection'));
Memory.prototype._add = function (models, options) {
// TODO: Temporary mesure, implement “set()” instead.
var replace = !!(options && options.replace);
for (var i = 0, n = models.length; i < n; ++i)
{
var model = models[i];
var id = model.id;
if (undefined === id)
{
model.id = id = ''+ this.next_id++;
}
else if (!replace && this.models[id])
{
// Existing models are ignored.
return Promise.reject('cannot add existing models!');
}
this.models[id] = model;
}
return models;
};
Memory.prototype._first = function (properties) {
if (_.isEmpty(properties))
{
// Return the first model if any.
for (var id in this.models)
{
return this.models[id];
}
return null;
}
return _.findWhere(this.models, properties);
};
Memory.prototype._get = function (properties) {
if (_.isEmpty(properties))
{
return _.values(this.models);
}
return _.where(this.models, properties);
};
Memory.prototype._remove = function (ids) {
for (var i = 0, n = ids.length; i < n; ++i)
{
delete this.models[ids[i]];
}
};
Memory.prototype._update = function (models) {
for (var i = 0, n = models.length; i < n; i++)
{
var model = models[i];
var id = model.id;
// Missing models should be added not updated.
if (!this.models[id])
{
return Promise.reject('missing model');
}
_.extend(this.models[id], model);
}
return models;
};
//////////////////////////////////////////////////////////////////////
Memory.extend = require('extendable');
module.exports = Memory;

View File

@@ -1,22 +1,27 @@
'use strict';
import Collection, {ModelAlreadyExists} from '../collection'
import difference from 'lodash/difference'
import filter from 'lodash/filter'
import getKey from 'lodash/keys'
import {createClient as createRedisClient} from 'redis'
import {v4 as generateUuid} from 'uuid'
//====================================================================
import {
forEach,
isEmpty,
mapToArray,
promisifyAll
} from '../utils'
var _ = require('underscore');
var Promise = require('bluebird');
// ===================================================================
var thenRedis = require('then-redis');
//====================================================================
//////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////
// Data model:
// - prefix +'_id': value of the last generated identifier;
// - prefix +'_ids': set containing identifier of all models;
// - prefix +'_'+ index +':' + value: set of identifiers which have
// value for the given index.
// - prefix +':'+ id: hash containing the properties of a model;
//////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////
// TODO: then-redis sends commands in order, we should use this
// semantic to simplify the code.
@@ -26,208 +31,139 @@ var thenRedis = require('then-redis');
// TODO: Remote events.
function Redis(options, models)
{
if (!options)
{
options = {};
}
export default class Redis extends Collection {
constructor ({
connection,
indexes = [],
prefix,
uri = 'tcp://localhost:6379'
}) {
super()
_.defaults(options, {
'uri': 'tcp://localhost:6379',
'indexes': [],
});
this.indexes = indexes
this.prefix = prefix
this.redis = promisifyAll(connection || createRedisClient(uri))
}
if (!options.prefix)
{
throw 'missing option: prefix';
}
_extract (ids) {
const prefix = this.prefix + ':'
const {redis} = this
Redis.super_.call(this, models);
const models = []
return Promise.all(mapToArray(ids, id => {
return redis.hgetall(prefix + id).then(model => {
// If empty, consider it a no match.
if (isEmpty(model)) {
return
}
this.redis = options.connection || thenRedis.createClient(options.uri);
this.prefix = options.prefix;
this.indexes = options.indexes;
// Mix the identifier in.
model.id = id
models.push(model)
})
})).then(() => models)
}
_add (models, {replace = false} = {}) {
// TODO: remove “replace” which is a temporary measure, implement
// “set()” instead.
const {indexes, prefix, redis} = this
return Promise.all(mapToArray(models, async model => {
// Generate a new identifier if necessary.
if (model.id === undefined) {
model.id = generateUuid()
}
const success = await redis.sadd(prefix + '_ids', model.id)
// The entry already exists an we are not in replace mode.
if (!success && !replace) {
throw new ModelAlreadyExists(model.id)
}
// TODO: Remove existing fields.
const params = []
forEach(model, (value, name) => {
// No need to store the identifier (already in the key).
if (name === 'id') {
return
}
params.push(name, value)
})
const key = `${prefix}:${model.id}`
const promises = [
redis.del(key),
redis.hmset(key, ...params)
]
// Update indexes.
forEach(indexes, (index) => {
const value = model[index]
if (value === undefined) {
return
}
const key = prefix + '_' + index + ':' + value
promises.push(redis.sadd(key, model.id))
})
await Promise.all(promises)
return model
}))
}
_get (properties) {
const {prefix, redis} = this
if (isEmpty(properties)) {
return redis.smembers(prefix + '_ids').then(ids => this._extract(ids))
}
// Special treatment for the identifier.
const id = properties.id
if (id !== undefined) {
delete properties.id
return this._extract([id]).then(models => {
return (models.length && !isEmpty(properties))
? filter(models)
: models
})
}
const {indexes} = this
// Check for non indexed fields.
const unfit = difference(getKey(properties), indexes)
if (unfit.length) {
throw new Error('fields not indexed: ' + unfit.join())
}
const keys = mapToArray(properties, (value, index) => `${prefix}_${index}:${value}`)
return redis.sinter(...keys).then(ids => this._extract(ids))
}
_remove (ids) {
const {prefix, redis} = this
// TODO: handle indexes.
return Promise.all([
// Remove the identifiers from the main index.
redis.srem(prefix + '_ids', ...ids),
// Remove the models.
redis.del(mapToArray(ids, id => `${prefix}:${id}`))
])
}
_update (models) {
return this._add(models, { replace: true })
}
}
require('util').inherits(Redis, require('../collection'));
// Private method.
Redis.prototype._extract = function (ids) {
var redis = this.redis;
var prefix = this.prefix +':';
var promises = [];
_.each(ids, function (id) {
promises.push(redis.hgetall(prefix + id).then(function (model) {
// If empty, considers it a no match and returns null.
if (_.isEmpty(model))
{
return null;
}
// Mix the identifier in.
model.id = id;
return model;
}));
});
return Promise.all(promises).then(function (models) {
return _.filter(models, function (model) {
return (null !== model);
});
});
};
Redis.prototype._add = function (models, options) {
// TODO: Temporary mesure, implement “set()” instead.
var replace = !!(options && options.replace);
var redis = this.redis;
var prefix = this.prefix;
var indexes = this.indexes;
var promises = [];
_.each(models, function (model) {
var promise;
// Generates a new identifier if necessary.
if (undefined === model.id)
{
promise = redis.incr(prefix +'_id').then(function (id) {
model.id = id;
});
}
else
{
// Ensures the promise chain is correctly initialized.
promise = Promise.cast();
}
promise = promise.then(function () {
// Adds the identifier to the models' ids set.
return redis.sadd(prefix +'_ids', model.id);
}).then(function (success) {
// The entry already existed an we are not in replace mode.
if (!success && !replace)
{
throw 'cannot add existing model: '+ model.id;
}
// TODO: Remove existing fields.
var params = [prefix +':'+ model.id];
_.each(model, function (value, prop) {
// No need to store the id (already in the key.)
if ('id' === prop)
{
return;
}
params.push(prop, value);
});
var promises = [
redis.send('hmset', params),
];
// Adds indexes.
_.each(indexes, function (index) {
var value = model[index];
if (undefined === value)
{
return;
}
var key = prefix +'_'+ index +':'+ value;
promises.push(redis.sadd(key, model.id));
});
return Promise.all(promises);
}).then(function () { return model; });
promises.push(promise);
});
return Promise.all(promises);
};
Redis.prototype._get = function (properties) {
var prefix = this.prefix;
var redis = this.redis;
var self = this;
if (_.isEmpty(properties))
{
return redis.smembers(prefix +'_ids').then(function (ids) {
return self._extract(ids);
});
}
// Special treatment for 'id'.
var id = properties.id;
delete properties.id;
// Special case where we only match against id.
if (_.isEmpty(properties))
{
return this._extract([id]);
}
var indexes = this.indexes;
var unfit = _.difference(_.keys(properties), indexes);
if (0 !== unfit.length)
{
throw 'not indexed fields: '+ unfit.join();
}
var keys = _.map(properties, function (value, index) {
return (prefix +'_'+ index +':'+ value);
});
return redis.send('sinter', keys).then(function (ids) {
if (undefined !== id)
{
if (!_.contains(ids, id))
{
return [];
}
ids = [id];
}
return self._extract(ids);
});
};
Redis.prototype._remove = function (ids) {
var redis = this.redis;
var prefix = this.prefix;
var promises = [];
var keys = [];
for (var i = 0, n = ids.length; i < n; ++i)
{
keys.push(prefix +':'+ ids[i]);
}
// TODO: Handle indexes.
promises.push(
redis.send('srem', [prefix +'_ids'].concat(ids)),
redis.send('del', keys)
);
return Promise.all(promises);
};
Redis.prototype._update = function (models) {
// TODO:
return this._add(models, { 'replace': true });
};
//////////////////////////////////////////////////////////////////////
Redis.extend = require('extendable');
module.exports = Redis;

View File

@@ -1,81 +1,50 @@
'use strict';
import {EventEmitter} from 'events'
//====================================================================
import {createRawObject, noop} from './utils'
var EventEmitter = require('events').EventEmitter;
var inherits = require('util').inherits;
// ===================================================================
//--------------------------------------------------------------------
export default class Connection extends EventEmitter {
constructor () {
super()
var extend = require('underscore').extend;
this._data = createRawObject()
}
//====================================================================
// Close the connection.
close () {
// Prevent errors when the connection is closed more than once.
this.close = noop
var has = Object.prototype.hasOwnProperty;
has = has.call.bind(has);
this.emit('close')
}
//====================================================================
// Gets the value for this key.
get (key, defaultValue) {
const {_data: data} = this
var Connection = function Connection(adapter) {
this.data = Object.create(null);
if (key in data) {
return data[key]
}
this._adapter = adapter;
};
inherits(Connection, EventEmitter);
if (arguments.length >= 2) {
return defaultValue
}
extend(Connection.prototype, {
// Close the connection.
close: function () {
this._adapter.close();
this.emit('close');
throw new Error('no value for `' + key + '`')
}
// Releases values AMAP to ease the garbage collecting.
for (var key in this)
{
if (has(this, key))
{
delete this[key];
}
}
},
// Checks whether there is a value for this key.
has (key) {
return key in this._data
}
// Gets the value for this key.
get: function (key, defaultValue) {
var data = this.data;
// Sets the value for this key.
set (key, value) {
this._data[key] = value
}
if (key in data)
{
return data[key];
}
if (arguments.length >= 2)
{
return defaultValue;
}
throw new Error('no value for `'+ key +'`');
},
// Checks whether there is a value for this key.
has: function (key) {
return key in this.data;
},
// Sets the value for this key.
set: function (key, value) {
this.data[key] = value;
},
// Sends a message.
send: function (name, data) {
this._adapter.send(name, data);
},
unset: function (key) {
delete this.data[key];
},
});
//====================================================================
module.exports = Connection;
unset (key) {
delete this._data[key]
}
}

347
src/decorators.js Normal file
View File

@@ -0,0 +1,347 @@
import bind from 'lodash/bind'
import {
isArray,
isPromise,
isFunction,
noop,
pFinally
} from './utils'
// ===================================================================
const {
defineProperties,
defineProperty,
getOwnPropertyDescriptor
} = Object
// ===================================================================
// See: https://github.com/jayphelps/core-decorators.js#autobind
//
// TODO: make it work for all class methods.
export const autobind = (target, key, {
configurable,
enumerable,
value: fn,
writable
}) => ({
configurable,
enumerable,
get () {
if (this === target) {
return fn
}
const bound = bind(fn, this)
defineProperty(this, key, {
configurable: true,
enumerable: false,
value: bound,
writable: true
})
return bound
},
set (newValue) {
// Cannot use assignment because it will call the setter on
// the prototype.
defineProperty(this, key, {
configurable: true,
enumerable: true,
value: newValue,
writable: true
})
}
})
// -------------------------------------------------------------------
// Debounce decorator for methods.
//
// See: https://github.com/wycats/javascript-decorators
//
// TODO: make it work for single functions.
export const debounce = duration => (target, name, descriptor) => {
const fn = descriptor.value
// This symbol is used to store the related data directly on the
// current object.
const s = Symbol()
function debounced () {
const data = this[s] || (this[s] = {
lastCall: 0,
wrapper: null
})
const now = Date.now()
if (now > data.lastCall + duration) {
data.lastCall = now
try {
const result = fn.apply(this, arguments)
data.wrapper = () => result
} catch (error) {
data.wrapper = () => { throw error }
}
}
return data.wrapper()
}
debounced.reset = obj => { delete obj[s] }
descriptor.value = debounced
return descriptor
}
// -------------------------------------------------------------------
const _push = Array.prototype.push
export const deferrable = (target, name, descriptor) => {
let fn
function newFn () {
const deferreds = []
const defer = fn => {
deferreds.push(fn)
}
defer.clear = () => {
deferreds.length = 0
}
const args = [ defer ]
_push.apply(args, arguments)
let executeDeferreds = () => {
let i = deferreds.length
while (i) {
deferreds[--i]()
}
}
try {
const result = fn.apply(this, args)
if (isPromise(result)) {
result::pFinally(executeDeferreds)
// Do not execute the deferreds in the finally block.
executeDeferreds = noop
}
return result
} finally {
executeDeferreds()
}
}
if (descriptor) {
fn = descriptor.value
descriptor.value = newFn
return descriptor
}
fn = target
return newFn
}
// Deferred functions are only executed on failures.
//
// i.e.: defer.clear() is automatically called in case of success.
deferrable.onFailure = (target, name, descriptor) => {
let fn
function newFn (defer) {
const result = fn.apply(this, arguments)
return isPromise(result)
? result.then(result => {
defer.clear()
return result
})
: (defer.clear(), result)
}
if (descriptor) {
fn = descriptor.value
descriptor.value = newFn
} else {
fn = target
target = newFn
}
return deferrable(target, name, descriptor)
}
// Deferred functions are only executed on success.
//
// i.e.: defer.clear() is automatically called in case of failure.
deferrable.onSuccess = (target, name, descriptor) => {
let fn
function newFn (defer) {
try {
const result = fn.apply(this, arguments)
return isPromise(result)
? result.then(null, error => {
defer.clear()
throw error
})
: result
} catch (error) {
defer.clear()
throw error
}
}
if (descriptor) {
fn = descriptor.value
descriptor.value = newFn
} else {
fn = target
target = newFn
}
return deferrable(target, name, descriptor)
}
// -------------------------------------------------------------------
const _ownKeys = (
typeof Reflect !== 'undefined' && Reflect.ownKeys ||
(({
getOwnPropertyNames: names,
getOwnPropertySymbols: symbols
}) => symbols
? obj => names(obj).concat(symbols(obj))
: names
)(Object)
)
const _bindPropertyDescriptor = (descriptor, thisArg) => {
const { get, set, value } = descriptor
if (get) {
descriptor.get = bind(get, thisArg)
}
if (set) {
descriptor.set = bind(set, thisArg)
}
if (isFunction(value)) {
descriptor.value = bind(value, thisArg)
}
return descriptor
}
const _isIgnoredProperty = name => (
name[0] === '_' ||
name === 'constructor'
)
const _IGNORED_STATIC_PROPERTIES = {
__proto__: null,
arguments: true,
caller: true,
length: true,
name: true,
prototype: true
}
const _isIgnoredStaticProperty = name => _IGNORED_STATIC_PROPERTIES[name]
export const mixin = MixIns => Class => {
if (!isArray(MixIns)) {
MixIns = [ MixIns ]
}
const { name } = Class
// Copy properties of plain object mix-ins to the prototype.
{
const allMixIns = MixIns
MixIns = []
const { prototype } = Class
const descriptors = { __proto__: null }
for (const MixIn of allMixIns) {
if (isFunction(MixIn)) {
MixIns.push(MixIn)
continue
}
for (const prop of _ownKeys(MixIn)) {
if (prop in prototype) {
throw new Error(`${name}#${prop} is already defined`)
}
(
descriptors[prop] = getOwnPropertyDescriptor(MixIn, prop)
).enumerable = false // Object methods are enumerable but class methods are not.
}
}
defineProperties(prototype, descriptors)
}
const Decorator = (...args) => {
const instance = new Class(...args)
for (const MixIn of MixIns) {
const { prototype } = MixIn
const mixinInstance = new MixIn(instance)
const descriptors = { __proto__: null }
for (const prop of _ownKeys(prototype)) {
if (_isIgnoredProperty(prop)) {
continue
}
if (prop in instance) {
throw new Error(`${name}#${prop} is already defined`)
}
descriptors[prop] = _bindPropertyDescriptor(
getOwnPropertyDescriptor(prototype, prop),
mixinInstance
)
}
defineProperties(instance, descriptors)
}
return instance
}
// Copy original and mixed-in static properties on Decorator class.
const descriptors = { __proto__: null }
for (const prop of _ownKeys(Class)) {
let descriptor
if (!(
// Special properties are not defined...
_isIgnoredStaticProperty(prop) &&
// if they already exist...
(descriptor = getOwnPropertyDescriptor(Decorator, prop)) &&
// and are not configurable.
!descriptor.configurable
)) {
descriptors[prop] = getOwnPropertyDescriptor(Class, prop)
}
}
for (const MixIn of MixIns) {
for (const prop of _ownKeys(MixIn)) {
if (_isIgnoredStaticProperty(prop)) {
continue
}
if (prop in descriptors) {
throw new Error(`${name}.${prop} is already defined`)
}
descriptors[prop] = getOwnPropertyDescriptor(MixIn, prop)
}
}
defineProperties(Decorator, descriptors)
return Decorator
}

173
src/decorators.spec.js Normal file
View File

@@ -0,0 +1,173 @@
/* eslint-env mocha */
import expect from 'must'
// ===================================================================
import {autobind, debounce, deferrable} from './decorators'
// ===================================================================
describe('autobind()', () => {
class Foo {
@autobind
getFoo () {
return this
}
}
it('returns a bound instance for a method', () => {
const foo = new Foo()
const { getFoo } = foo
expect(getFoo()).to.equal(foo)
})
it('returns the same bound instance each time', () => {
const foo = new Foo()
expect(foo.getFoo).to.equal(foo.getFoo)
})
it('works with multiple instances of the same class', () => {
const foo1 = new Foo()
const foo2 = new Foo()
const getFoo1 = foo1.getFoo
const getFoo2 = foo2.getFoo
expect(getFoo1()).to.equal(foo1)
expect(getFoo2()).to.equal(foo2)
})
})
// -------------------------------------------------------------------
describe('debounce()', () => {
let i
class Foo {
@debounce(1e1)
foo () {
++i
}
}
beforeEach(() => {
i = 0
})
it('works', done => {
const foo = new Foo()
expect(i).to.equal(0)
foo.foo()
expect(i).to.equal(1)
foo.foo()
expect(i).to.equal(1)
setTimeout(() => {
foo.foo()
expect(i).to.equal(2)
done()
}, 2e1)
})
})
// -------------------------------------------------------------------
describe('deferrable()', () => {
it('works with normal termination', () => {
let i = 0
const fn = deferrable(defer => {
i += 2
defer(() => { i -= 2 })
i *= 2
defer(() => { i /= 2 })
return i
})
expect(fn()).to.equal(4)
expect(i).to.equal(0)
})
it('defer.clear() removes previous deferreds', () => {
let i = 0
const fn = deferrable(defer => {
i += 2
defer(() => { i -= 2 })
defer.clear()
i *= 2
defer(() => { i /= 2 })
return i
})
expect(fn()).to.equal(4)
expect(i).to.equal(2)
})
it('works with exception', () => {
let i = 0
const fn = deferrable(defer => {
i += 2
defer(() => { i -= 2 })
i *= 2
defer(() => { i /= 2 })
throw i
})
expect(() => fn()).to.throw(4)
expect(i).to.equal(0)
})
it('works with promise resolution', async () => {
let i = 0
const fn = deferrable(async defer => {
i += 2
defer(() => { i -= 2 })
i *= 2
defer(() => { i /= 2 })
// Wait a turn of the events loop.
await Promise.resolve()
return i
})
await expect(fn()).to.eventually.equal(4)
expect(i).to.equal(0)
})
it('works with promise rejection', async () => {
let i = 0
const fn = deferrable(async defer => {
// Wait a turn of the events loop.
await Promise.resolve()
i += 2
defer(() => { i -= 2 })
i *= 2
defer(() => { i /= 2 })
// Wait a turn of the events loop.
await Promise.resolve()
throw i
})
await expect(fn()).to.reject.to.equal(4)
expect(i).to.equal(0)
})
})

84
src/fatfs-buffer.js Normal file
View File

@@ -0,0 +1,84 @@
// Buffer driver for [fatfs](https://github.com/natevw/fatfs).
//
// Usage:
//
// ```js
// import fatfs from 'fatfs'
// import fatfsBuffer, { init as fatfsBufferInit } from './fatfs-buffer'
//
// const buffer = fatfsBufferinit()
//
// const fs = fatfs.createFileSystem(fatfsBuffer(buffer))
//
// fs.writeFile('/foo', 'content of foo', function (err, content) {
// if (err) {
// console.error(err)
// }
// })
import { boot16 as fat16 } from 'fatfs/structs'
const SECTOR_SIZE = 512
// Creates a 10MB buffer and initializes it as a FAT 16 volume.
export function init () {
const buf = new Buffer(10 * 1024 * 1024) // 10MB
buf.fill(0)
// https://github.com/natevw/fatfs/blob/master/structs.js
fat16.pack({
jmpBoot: new Buffer('eb3c90', 'hex'),
OEMName: 'mkfs.fat',
BytsPerSec: SECTOR_SIZE,
SecPerClus: 4,
ResvdSecCnt: 1,
NumFATs: 2,
RootEntCnt: 512,
TotSec16: 20480,
Media: 248,
FATSz16: 20,
SecPerTrk: 32,
NumHeads: 64,
HiddSec: 0,
TotSec32: 0,
DrvNum: 128,
Reserved1: 0,
BootSig: 41,
VolID: 895111106,
VolLab: 'NO NAME ',
FilSysType: 'FAT16 '
}, buf)
// End of sector.
buf[0x1fe] = 0x55
buf[0x1ff] = 0xaa
// Mark sector as reserved.
buf[0x200] = 0xf8
buf[0x201] = 0xff
buf[0x202] = 0xff
buf[0x203] = 0xff
// Mark sector as reserved.
buf[0x2a00] = 0xf8
buf[0x2a01] = 0xff
buf[0x2a02] = 0xff
buf[0x2a03] = 0xff
return buf
}
export default buffer => {
return {
sectorSize: SECTOR_SIZE,
numSectors: Math.floor(buffer.length / SECTOR_SIZE),
readSectors: (i, target, cb) => {
buffer.copy(target, 0, i * SECTOR_SIZE)
cb()
},
writeSectors: (i, source, cb) => {
source.copy(buffer, i * SECTOR_SIZE, 0)
cb()
}
}
}

View File

@@ -1,141 +0,0 @@
# Low level tools.
$_ = require 'underscore'
# Async code is easier with fibers (light threads)!
$fiber = require 'fibers'
$Promise = require 'bluebird'
#=====================================================================
$isPromise = (obj) -> obj? and $_.isFunction obj.then
# The value is guarantee to resolve asynchronously.
$runAsync = (value, resolve, reject) ->
if $isPromise value
return value.then resolve, reject
if $_.isFunction value # Continuable
async = false
handler = (error, result) ->
unless async
return process.nextTick handler.bind null, error, result
if error?
return reject error
resolve result
value handler
async = true
return
unless $_.isObject value
return process.nextTick -> resolve value
left = 0
results = if $_.isArray value
new Array value.length
else
Object.create null
$_.each value, (value, index) ->
++left
$runAsync(
value
(result) ->
# Returns if already rejected.
return unless results
results[index] = result
resolve results unless --left
(error) ->
# Returns if already rejected.
return unless results
# Frees the reference ASAP.
results = null
reject error
)
if left is 0
process.nextTick -> resolve value
#=====================================================================
# Makes a function running in its own fiber.
$fiberize = (fn) ->
(args...) ->
$fiber(=>
try
fn.apply this, args
catch error
process.nextTick ->
throw error
).run()
# Makes a function run in its own fiber and returns a promise.
$promisify = (fn) ->
(args...) ->
new $Promise (resolve, reject) ->
$fiber(=>
try
resolve fn.apply this, args
catch error
reject error
).run()
# Waits for an event.
#
# Note: if the *error* event is emitted, this function will throw.
$waitEvent = (emitter, event) ->
fiber = $fiber.current
throw new Error 'not running in a fiber' unless fiber?
errorHandler = null
handler = (args...) ->
emitter.removeListener 'error', errorHandler
fiber.run args
errorHandler = (error) ->
emitter.removeListener event, handler
fiber.throwInto error
emitter.once event, handler
emitter.once 'error', errorHandler
$fiber.yield()
# Waits for a promise or a continuable to end.
#
# If value is composed (array or map), every asynchronous value is
# resolved before returning (parallelization).
$wait = (value) ->
fiber = $fiber.current
throw new Error 'not running in a fiber' unless fiber?
if $wait._stash
value = $wait._stash
delete $wait._stash
$runAsync(
value
fiber.run.bind fiber
fiber.throwInto.bind fiber
)
$fiber.yield()
$wait.register = ->
throw new Error 'something has already been registered' if $wait._stash
deferred = $Promise.defer()
$wait._stash = deferred.promise
deferred.callback
#=====================================================================
module.exports = {
$fiberize
$promisify
$waitEvent
$wait
}

View File

@@ -1,247 +0,0 @@
'use strict';
//====================================================================
var expect = require('chai').expect;
//--------------------------------------------------------------------
var Promise = require('bluebird');
//--------------------------------------------------------------------
var utils = require('./fibers-utils');
var $fiberize = utils.$fiberize;
//====================================================================
describe('$fiberize', function () {
it('creates a function which runs in a new fiber', function () {
var previous = require('fibers').current;
var fn = $fiberize(function () {
var current = require('fibers').current;
expect(current).to.exists;
expect(current).to.not.equal(previous);
});
fn();
});
it('forwards all arguments (even this)', function () {
var self = {};
var arg1 = {};
var arg2 = {};
$fiberize(function (arg1, arg2) {
expect(this).to.equal(self);
expect(arg1).to.equal(arg1);
expect(arg2).to.equal(arg2);
}).call(self, arg1, arg2);
});
});
//--------------------------------------------------------------------
describe('$wait', function () {
var $wait = utils.$wait;
it('waits for a promise', function (done) {
$fiberize(function () {
var value = {};
var promise = Promise.cast(value);
expect($wait(promise)).to.equal(value);
done();
})();
});
it('handles promise rejection', function (done) {
$fiberize(function () {
var promise = Promise.reject('an exception');
expect(function () {
$wait(promise);
}).to.throw('an exception');
done();
})();
});
it('waits for a continuable', function (done) {
$fiberize(function () {
var value = {};
var continuable = function (callback) {
callback(null, value);
};
expect($wait(continuable)).to.equal(value);
done();
})();
});
it('handles continuable error', function (done) {
$fiberize(function () {
var continuable = function (callback) {
callback('an exception');
};
expect(function () {
$wait(continuable);
}).to.throw('an exception');
done();
})();
});
it('forwards scalar values', function (done) {
$fiberize(function () {
var value = 'a scalar value';
expect($wait(value)).to.equal(value);
value = [
'foo',
'bar',
'baz',
];
expect($wait(value)).to.deep.equal(value);
value = [];
expect($wait(value)).to.deep.equal(value);
value = {
foo: 'foo',
bar: 'bar',
baz: 'baz',
};
expect($wait(value)).to.deep.equal(value);
value = {};
expect($wait(value)).to.deep.equal(value);
done();
})();
});
it('handles arrays of promises/continuables', function (done) {
$fiberize(function () {
var value1 = {};
var value2 = {};
var promise = Promise.cast(value1);
var continuable = function (callback) {
callback(null, value2);
};
var results = $wait([promise, continuable]);
expect(results[0]).to.equal(value1);
expect(results[1]).to.equal(value2);
done();
})();
});
it('handles maps of promises/continuable', function (done) {
$fiberize(function () {
var value1 = {};
var value2 = {};
var promise = Promise.cast(value1);
var continuable = function (callback) {
callback(null, value2);
};
var results = $wait({
foo: promise,
bar: continuable
});
expect(results.foo).to.equal(value1);
expect(results.bar).to.equal(value2);
done();
})();
});
it('handles nested arrays/maps', function (done) {
var promise = Promise.cast('a promise');
var continuable = function (callback) {
callback(null, 'a continuable');
};
$fiberize(function () {
expect($wait({
foo: promise,
bar: [
continuable,
'a scalar'
]
})).to.deep.equal({
foo: 'a promise',
bar: [
'a continuable',
'a scalar'
]
});
done();
})();
});
describe('#register()', function () {
it('registers a callback-based function to be waited', function (done) {
$fiberize(function () {
var fn = function (value, callback) {
callback(null, value);
};
var value = {};
expect($wait(fn(value, $wait.register()))).to.equal(value);
value = {};
expect($wait(fn(value, $wait.register()))).to.equal(value);
done();
})();
});
});
});
//--------------------------------------------------------------------
describe('$waitEvent', function () {
var $waitEvent = utils.$waitEvent;
it('waits for an event', function (done) {
$fiberize(function () {
var emitter = new (require('events').EventEmitter)();
var value = {};
process.nextTick(function () {
emitter.emit('foo', value);
});
expect($waitEvent(emitter, 'foo')[0]).to.equal(value);
done();
})();
});
it('handles the error event', function (done) {
$fiberize(function () {
var emitter = new (require('events').EventEmitter)();
process.nextTick(function () {
emitter.emit('error', 'an error');
});
expect(function () {
$waitEvent(emitter, 'foo');
}).to.throw('an error');
done();
})();
});
});

54
src/glob-matcher.js Normal file
View File

@@ -0,0 +1,54 @@
// See: https://gist.github.com/julien-f/5b9a3537eb82a34b04e2
var matcher = require('micromatch').matcher
module.exports = function globMatcher (patterns, opts) {
if (!Array.isArray(patterns)) {
if (patterns[0] === '!') {
var m = matcher(patterns.slice(1), opts)
return function (string) {
return !m(string)
}
} else {
return matcher(patterns, opts)
}
}
var noneMustMatch = []
var anyMustMatch = []
// TODO: could probably be optimized by combining all positive patterns (and all negative patterns) as a single matcher.
for (var i = 0, n = patterns.length; i < n; ++i) {
var pattern = patterns[i]
if (pattern[0] === '!') {
noneMustMatch.push(matcher(pattern.slice(1), opts))
} else {
anyMustMatch.push(matcher(pattern, opts))
}
}
var nNone = noneMustMatch.length
var nAny = anyMustMatch.length
return function (string) {
var i
for (i = 0; i < nNone; ++i) {
if (noneMustMatch[i](string)) {
return false
}
}
if (nAny === 0) {
return true
}
for (i = 0; i < nAny; ++i) {
if (anyMustMatch[i](string)) {
return true
}
}
return false
}
}

View File

@@ -1,330 +0,0 @@
$_ = require 'underscore'
# FIXME: This file name should reflect what's inside!
#=====================================================================
$asArray = (val) -> if $_.isArray val then val else [val]
$asFunction = (val) -> if $_.isFunction val then val else -> val
$each = $_.each
$first = (collection, def) ->
if (n = collection.length)?
return collection[0] unless n is 0
else
return value for own _, value of collection
# Nothing was found, returns the `def` value.
def
$removeValue = (array, value) ->
index = array.indexOf value
return false if index is -1
array.splice index, 1
true
#---------------------------------------------------------------------
# TODO: currently the watch can be updated multiple times per
# “$MappedCollection.set()” which is inefficient: it should be
# possible to address that.
$watch = (collection, {
# Key(s) of the “remote” objects watched.
#
# If it is a function, it is evaluated in the scope of the “current”
# object. (TODO)
#
# Default: undefined
keys
# Alias for `keys`.
key
# Rule(s) of the “remote” objects watched.
#
# If it is a function, it is evaluated in the scope of the “current”
# object. (TODO)
#
# Note: `key`/`keys` and `rule`/`rules` cannot be used both.
#
# Default: undefined
rules
# Alias for `rules`.
rule
# Value to add to the set.
#
# If it is a function, it is evaluated in the scope of the “remote”
# object.
#
# Default: -> @val
val
# Predicates the “remote” object must fulfill to be used.
#
# Default: -> true
if: cond
# Function evaluated in the scope of the “remote” object which
# returns the key of the object to update (usually the current one).
#
# TODO: Does it make sense to return an array?
#
# Default: undefined
bind
# Initial value.
init
# Function called when a loop is detected.
#
# Usually it is used to either throw an exception or do nothing to
# stop the loop.
#
# Note: The function may also returns `true` to force the processing
# to continue.
#
# Default: (number_of_loops) -> throw new Error 'loop detected'
loopDetected
}, fn) ->
val = if val is undefined
# The default value is simply the value of the item.
-> @val
else
$asFunction val
loopDetected ?= -> throw new Error 'loop detected'
# Method allowing the cleanup when the helper is no longer used.
#cleanUp = -> # TODO: noop for now.
# Keys of items using the current helper.
consumers = Object.create null
# Current values.
values = Object.create null
values.common = init
# The number of nested processing for this watcher is counted to
# avoid an infinite loop.
loops = 0
updating = false
process = (event, items) ->
return if updating
# Values are grouped by namespace.
valuesByNamespace = Object.create null
$each items, (item, key) -> # `key` is a local variable.
return unless not cond? or cond.call item
if bind?
key = bind.call item
# If bind did not return a key, ignores this value.
return unless key?
namespace = "$#{key}"
else
namespace = 'common'
# Computes the current value.
value = val.call item
(valuesByNamespace[namespace] ?= []).push value
# Stops here if no values were computed.
return if do ->
return false for _ of valuesByNamespace
true
if loops
return unless (loopDetected loops) is true
previousLoops = loops++
# For each namespace.
for namespace, values_ of valuesByNamespace
# Updates the value.
value = values[namespace]
ctx = {
# TODO: test the $_.clone
value: if value is undefined then $_.clone init else value
}
changed = if event is 'enter'
fn.call ctx, values_, {}
else
fn.call ctx, {}, values_
# Notifies watchers unless it is known the value has not
# changed.
unless changed is false
values[namespace] = ctx.value
updating = true
if namespace is 'common'
collection.touch consumers
else
collection.touch (namespace.substr 1)
updating = false
loops = previousLoops
processOne = (event, item) ->
process event, [item]
# Sets up the watch based on the provided criteria.
#
# TODO: provides a way to clean this when no longer used.
keys = $asArray (keys ? key ? [])
rules = $asArray (rules ? rule ? [])
if not $_.isEmpty keys
# Matching is done on the keys.
throw new Error 'cannot use keys and rules' unless $_.isEmpty rules
$each keys, (key) -> collection.on "key=#{key}", processOne
# Handles existing items.
process 'enter', (collection.getRaw keys, true)
else if not $_.isEmpty rules
# Matching is done the rules.
$each rules, (rule) -> collection.on "rule=#{rule}", process
# TODO: Inefficient, is there another way?
rules = do -> # Minor optimization.
tmp = Object.create null
tmp[rule] = true for rule in rules
tmp
$each collection.getRaw(), (item) ->
processOne 'enter', item if item.rule of rules
else
# No matching done.
collection.on 'any', process
# Handles existing items.
process 'enter', collection.getRaw()
# Creates the generator: the function which items will used to
# register to this watcher and to get the current value.
generator = do (key) -> # Declare a local variable.
->
{key} = this
# Register this item has a consumer.
consumers[key] = true
# Returns the value for this item if any or the common value.
namespace = "$#{key}"
if namespace of values
values[namespace]
else
values.common
# Creates a helper to unregister an item from this watcher.
generator.unregister = do (key) -> # Declare a local variable.
->
{key} = this
delete consumers[key]
delete values["$#{key}"]
# Creates a helper to get the value without using an item.
generator.raw = (key) ->
values[if key? then "$#{key}" else 'common']
# Returns the generator.
generator
#=====================================================================
$map = (options) ->
options.init = Object.create null
$watch this, options, (entered, exited) ->
changed = false
$each entered, ([key, value]) =>
unless @value[key] is value
@value[key] = value
changed = true
$each exited, ([key, value]) =>
if key of @value
delete @value[key]
changed = true
changed
#---------------------------------------------------------------------
# Creates a set of value from various items.
$set = (options) ->
# Contrary to other helpers, the default value is the key.
options.val ?= -> @key
options.init = []
$watch this, options, (entered, exited) ->
changed = false
$each entered, (value) =>
if (@value.indexOf value) is -1
@value.push value
changed = true
$each exited, (value) =>
changed = true if $removeValue @value, value
changed
#---------------------------------------------------------------------
$sum = (options) ->
options.init ?= 0
$watch this, options, (entered, exited) ->
prev = @value
$each entered, (value) => @value += value
$each exited, (value) => @value -= value
@value isnt prev
#---------------------------------------------------------------------
# Uses a value from another item.
#
# Important note: Behavior is not specified when binding to multiple
# items.
$val = (options) ->
# The default value.
def = options.default
delete options.default
options.init ?= def
# Should the last value be kept instead of returning to the default
# value when no items are available!
keepLast = !!options.keepLast
delete options.keepLast
$watch this, options, (entered, exited) ->
prev = @value
@value = $first entered, (if keepLast then @value else def)
@value isnt prev
#=====================================================================
module.exports = {
$map
$set
$sum
$val
}

View File

@@ -1,244 +0,0 @@
{expect: $expect} = require 'chai'
$sinon = require 'sinon'
#---------------------------------------------------------------------
{$MappedCollection} = require './MappedCollection.coffee'
$nonBindedHelpers = require './helpers'
#=====================================================================
describe 'Helper', ->
# Shared variables.
collection = $set = $sum = $val = null
beforeEach ->
# Creates the collection.
collection = new $MappedCollection()
# Dispatcher used for tests.
collection.dispatch = -> (@genkey.split '.')[0]
# Missing rules should be automatically created.
collection.missingRule = collection.rule
# # Monkey patch the collection to see all emitted events.
# emit = collection.emit
# collection.emit = (args...) ->
# console.log args...
# emit.call collection, args...
# Binds helpers to this collection.
{$set, $sum, $val} = do ->
helpers = {}
helpers[name] = fn.bind collection for name, fn of $nonBindedHelpers
helpers
#-------------------------------------------------------------------
# All helpers share the same logical code, we need only to test one
# extensively and test the others basically.
#
# $sum was chosen because it is the simplest helper to test.
describe '$sum', ->
it 'with single key', ->
collection.set foo: 1
collection.item sum: ->
@val = $sum {
key: 'foo'
}
$expect(collection.get 'sum').to.equal 1
collection.set foo:2
$expect(collection.get 'sum').to.equal 2
collection.remove 'foo'
$expect(collection.get 'sum').to.equal 0
it 'with multiple keys', ->
collection.set {
foo: 1
bar: 2
}
collection.item sum: ->
@val = $sum {
keys: ['foo', 'bar']
}
$expect(collection.get 'sum').to.equal 3
collection.set bar:3
$expect(collection.get 'sum').to.equal 4
collection.remove 'foo'
$expect(collection.get 'sum').to.equal 3
# FIXME: This test fails but this feature is not used.
it.skip 'with dynamic keys', ->
collection.set {
foo: 1
bar: 2
}
collection.rule sum: ->
@val = $sum {
key: -> (@key.split '.')[1]
}
collection.set {
'sum.foo': null
'sum.bar': null
}
$expect(collection.get 'sum.foo').to.equal 1
$expect(collection.get 'sum.bar').to.equal 2
collection.remove 'bar'
$expect(collection.get 'sum.foo').to.equal 1
$expect(collection.get 'sum.bar').to.equal 0
it 'with single rule', ->
collection.set {
'foo.1': 1
'foo.2': 2
}
collection.item sum: ->
@val = $sum {
rule: 'foo'
}
$expect(collection.get 'sum').to.equal 3
collection.set 'foo.2':3
$expect(collection.get 'sum').to.equal 4
collection.remove 'foo.1'
$expect(collection.get 'sum').to.equal 3
it 'with multiple rules', ->
collection.set {
'foo': 1
'bar.1': 2
'bar.2': 3
}
collection.item sum: ->
@val = $sum {
rules: ['foo', 'bar']
}
$expect(collection.get 'sum').to.equal 6
collection.set 'bar.1':3
$expect(collection.get 'sum').to.equal 7
collection.remove 'bar.2'
$expect(collection.get 'sum').to.equal 4
it 'with bind', ->
collection.set {
'foo': {
sum: 2 # This item will participate to `sum.2`.
val: 1
}
'bar': {
sum: 1 # This item will participate to `sum.1`.
val: 2
}
}
collection.rule sum: ->
@val = $sum {
bind: ->
id = @val.sum
return unless id?
"sum.#{id}"
val: -> @val.val
}
collection.set {
'sum.1': null
'sum.2': null
}
$expect(collection.get 'sum.1').equal 2
$expect(collection.get 'sum.2').equal 1
collection.set {
'foo': {
sum: 1
val: 3
}
}
$expect(collection.get 'sum.1').equal 5
$expect(collection.get 'sum.2').equal 0
collection.remove 'bar'
$expect(collection.get 'sum.1').equal 3
$expect(collection.get 'sum.2').equal 0
it 'with predicate', ->
collection.set {
foo: 1
bar: 2
baz: 3
}
collection.item sum: ->
@val = $sum {
if: -> /^b/.test @rule
}
$expect(collection.get 'sum').equal 5
collection.set foo:4
$expect(collection.get 'sum').equal 5
collection.set bar:5
$expect(collection.get 'sum').equal 8
collection.remove 'baz'
$expect(collection.get 'sum').equal 5
it 'with initial value', ->
collection.set foo: 1
collection.item sum: ->
@val = $sum {
key: 'foo'
init: 2
}
$expect(collection.get 'sum').to.equal 3
collection.set foo:2
$expect(collection.get 'sum').to.equal 4
collection.remove 'foo'
$expect(collection.get 'sum').to.equal 2
# TODO:
# - dynamic keys
# - dynamic rules

13
src/http-proxy.js Normal file
View File

@@ -0,0 +1,13 @@
import ProxyAgent from 'proxy-agent'
let agent
export { agent as default }
export function setup (uri) {
agent = uri != null
? new ProxyAgent(uri)
: undefined
}
const { env } = process
setup(env.http_proxy || env.HTTP_PROXY)

143
src/http-request.js Normal file
View File

@@ -0,0 +1,143 @@
import isRedirect from 'is-redirect'
import { assign, isString, startsWith } from 'lodash'
import { request as httpRequest } from 'http'
import { request as httpsRequest } from 'https'
import { stringify as formatQueryString } from 'querystring'
import {
format as formatUrl,
parse as parseUrl,
resolve as resolveUrl
} from 'url'
import { streamToBuffer } from './utils'
// -------------------------------------------------------------------
const raw = opts => {
let req
const pResponse = new Promise((resolve, reject) => {
const {
body,
headers: { ...headers } = {},
protocol,
query,
...rest
} = opts
if (headers['content-length'] == null && body != null) {
let tmp
if (isString(body)) {
headers['content-length'] = Buffer.byteLength(body)
} else if (
(
(tmp = body.headers) &&
(tmp = tmp['content-length']) != null
) ||
(tmp = body.length) != null
) {
headers['content-length'] = tmp
}
}
if (query) {
rest.path = `${rest.pathname || rest.path || '/'}?${
isString(query)
? query
: formatQueryString(query)
}`
}
// Some headers can be explicitly removed by setting them to null.
const headersToRemove = []
for (const header in headers) {
if (headers[header] === null) {
delete headers[header]
headersToRemove.push(header)
}
}
const secure = protocol && startsWith(protocol.toLowerCase(), 'https')
let requestFn
if (secure) {
requestFn = httpsRequest
} else {
requestFn = httpRequest
delete rest.rejectUnauthorized
}
req = requestFn({
...rest,
headers
})
for (let i = 0, length = headersToRemove.length; i < length; ++i) {
req.removeHeader(headersToRemove[i])
}
if (body) {
if (typeof body.pipe === 'function') {
body.pipe(req)
} else {
req.end(body)
}
} else {
req.end()
}
req.on('error', reject)
req.once('response', resolve)
}).then(response => {
response.cancel = () => {
req.abort()
}
response.readAll = () => streamToBuffer(response)
const length = response.headers['content-length']
if (length) {
response.length = length
}
const code = response.statusCode
const { location } = response.headers
if (isRedirect(code) && location) {
assign(opts, parseUrl(resolveUrl(formatUrl(opts), location)))
return raw(opts)
}
if (code < 200 || code >= 300) {
const error = new Error(response.statusMessage)
error.code = code
Object.defineProperty(error, 'response', {
configurable: true,
value: response,
writable: true
})
throw error
}
return response
})
pResponse.request = req
return pResponse
}
const httpRequestPlus = (...args) => {
const opts = {}
for (let i = 0, length = args.length; i < length; ++i) {
const arg = args[i]
assign(opts, isString(arg) ? parseUrl(arg) : arg)
}
const pResponse = raw(opts)
pResponse.cancel = () => {
const { request } = pResponse
request.emit('error', new Error('HTTP request canceled!'))
request.abort()
}
pResponse.readAll = () => pResponse.then(response => response.readAll())
return pResponse
}
export { httpRequestPlus as default }

633
src/index.js Normal file
View File

@@ -0,0 +1,633 @@
import createLogger from 'debug'
const debug = createLogger('xo:main')
import appConf from 'app-conf'
import bind from 'lodash/bind'
import blocked from 'blocked'
import createExpress from 'express'
import eventToPromise from 'event-to-promise'
import has from 'lodash/has'
import helmet from 'helmet'
import includes from 'lodash/includes'
import proxyConsole from './proxy-console'
import serveStatic from 'serve-static'
import startsWith from 'lodash/startsWith'
import WebSocket from 'ws'
import { compile as compilePug } from 'pug'
import { createServer as createProxyServer } from 'http-proxy'
import { join as joinPath } from 'path'
import JsonRpcPeer from 'json-rpc-peer'
import { InvalidCredential } from './api-errors'
import {
readFile,
readdir
} from 'fs-promise'
import WebServer from 'http-server-plus'
import Xo from './xo'
import {
setup as setupHttpProxy
} from './http-proxy'
import {
createRawObject,
forEach,
isArray,
isFunction,
mapToArray,
pFromCallback
} from './utils'
import bodyParser from 'body-parser'
import connectFlash from 'connect-flash'
import cookieParser from 'cookie-parser'
import expressSession from 'express-session'
import passport from 'passport'
import { parse as parseCookies } from 'cookie'
import { Strategy as LocalStrategy } from 'passport-local'
// ===================================================================
const warn = (...args) => {
console.warn('[Warn]', ...args)
}
// ===================================================================
const DEPRECATED_ENTRIES = [
'users',
'servers'
]
async function loadConfiguration () {
const config = await appConf.load('xo-server', {
ignoreUnknownFormats: true
})
debug('Configuration loaded.')
// Print a message if deprecated entries are specified.
forEach(DEPRECATED_ENTRIES, entry => {
if (has(config, entry)) {
warn(`${entry} configuration is deprecated.`)
}
})
return config
}
// ===================================================================
function createExpressApp () {
const app = createExpress()
app.use(helmet())
// Registers the cookie-parser and express-session middlewares,
// necessary for connect-flash.
app.use(cookieParser())
app.use(expressSession({
resave: false,
saveUninitialized: false,
// TODO: should be in the config file.
secret: 'CLWguhRZAZIXZcbrMzHCYmefxgweItKnS'
}))
// Registers the connect-flash middleware, necessary for Passport to
// display error messages.
app.use(connectFlash())
// Registers the body-parser middleware, necessary for Passport to
// access the username and password from the sign in form.
app.use(bodyParser.urlencoded({ extended: false }))
// Registers Passport's middlewares.
app.use(passport.initialize())
return app
}
async function setUpPassport (express, xo) {
const strategies = createRawObject()
xo.registerPassportStrategy = strategy => {
passport.use(strategy)
const {name} = strategy
if (name !== 'local') {
strategies[name] = strategy.label || name
}
}
// Registers the sign in form.
const signInPage = compilePug(
await readFile(joinPath(__dirname, '..', 'signin.pug'))
)
express.get('/signin', (req, res, next) => {
res.send(signInPage({
error: req.flash('error')[0],
strategies
}))
})
const SIGNIN_STRATEGY_RE = /^\/signin\/([^/]+)(\/callback)?(:?\?.*)?$/
express.use(async (req, res, next) => {
const { url } = req
const matches = url.match(SIGNIN_STRATEGY_RE)
if (matches) {
return passport.authenticate(matches[1], async (err, user, info) => {
if (err) {
return next(err)
}
if (!user) {
req.flash('error', info ? info.message : 'Invalid credentials')
return res.redirect('/signin')
}
// The cookie will be set in via the next request because some
// browsers do not save cookies on redirect.
req.flash(
'token',
(await xo.createAuthenticationToken({userId: user.id})).id
)
// The session is only persistent for internal provider and if 'Remember me' box is checked
req.flash(
'session-is-persistent',
matches[1] === 'local' && req.body['remember-me'] === 'on'
)
res.redirect(req.flash('return-url')[0] || '/')
})(req, res, next)
}
const token = req.flash('token')[0]
if (token) {
const isPersistent = req.flash('session-is-persistent')[0]
if (isPersistent) {
// Persistent cookie ? => 1 year
res.cookie('token', token, { maxAge: 1000 * 60 * 60 * 24 * 365 })
} else {
// Non-persistent : external provider as Github, Twitter...
res.cookie('token', token)
}
next()
} else if (req.cookies.token) {
next()
} else if (/favicon|fontawesome|images|styles|\.(?:css|jpg|png)$/.test(url)) {
next()
} else {
req.flash('return-url', url)
return res.redirect('/signin')
}
})
// Install the local strategy.
xo.registerPassportStrategy(new LocalStrategy(
async (username, password, done) => {
try {
const user = await xo.authenticateUser({username, password})
done(null, user)
} catch (error) {
done(null, false, { message: error.message })
}
}
))
}
// ===================================================================
async function registerPlugin (pluginPath, pluginName) {
const plugin = require(pluginPath)
const { version = 'unknown' } = (() => {
try {
return require(pluginPath + '/package.json')
} catch (_) {
return {}
}
})()
// Supports both “normal” CommonJS and Babel's ES2015 modules.
const {
default: factory = plugin,
configurationSchema,
configurationPresets
} = plugin
// The default export can be either a factory or directly a plugin
// instance.
const instance = isFunction(factory)
? factory({ xo: this })
: factory
await this.registerPlugin(
pluginName,
instance,
configurationSchema,
configurationPresets,
version
)
}
const debugPlugin = createLogger('xo:plugin')
function registerPluginWrapper (pluginPath, pluginName) {
debugPlugin('register %s', pluginName)
return registerPlugin.call(this, pluginPath, pluginName).then(
() => {
debugPlugin(`successfully register ${pluginName}`)
},
error => {
debugPlugin(`failed register ${pluginName}`)
debugPlugin(error)
}
)
}
const PLUGIN_PREFIX = 'xo-server-'
const PLUGIN_PREFIX_LENGTH = PLUGIN_PREFIX.length
async function registerPluginsInPath (path) {
const files = await readdir(path).catch(error => {
if (error.code === 'ENOENT') {
return []
}
throw error
})
await Promise.all(mapToArray(files, name => {
if (startsWith(name, PLUGIN_PREFIX)) {
return registerPluginWrapper.call(
this,
`${path}/${name}`,
name.slice(PLUGIN_PREFIX_LENGTH)
)
}
}))
}
async function registerPlugins (xo) {
await Promise.all(mapToArray([
`${__dirname}/../node_modules/`,
'/usr/local/lib/node_modules/'
], xo::registerPluginsInPath))
}
// ===================================================================
async function makeWebServerListen ({
certificate,
// The properties was called `certificate` before.
cert = certificate,
key,
...opts
}) {
if (cert && key) {
[opts.cert, opts.key] = await Promise.all([
readFile(cert),
readFile(key)
])
}
try {
const niceAddress = await this.listen(opts)
debug(`Web server listening on ${niceAddress}`)
} catch (error) {
if (error.niceAddress) {
warn(`Web server could not listen on ${error.niceAddress}`)
const {code} = error
if (code === 'EACCES') {
warn(' Access denied.')
warn(' Ports < 1024 are often reserved to privileges users.')
} else if (code === 'EADDRINUSE') {
warn(' Address already in use.')
}
} else {
warn('Web server could not listen:', error.message)
}
}
}
async function createWebServer (opts) {
const webServer = new WebServer()
await Promise.all(mapToArray(opts, webServer::makeWebServerListen))
return webServer
}
// ===================================================================
const setUpProxies = (express, opts, xo) => {
if (!opts) {
return
}
const proxy = createProxyServer({
ignorePath: true
}).on('error', (error) => console.error(error))
// TODO: sort proxies by descending prefix length.
// HTTP request proxy.
express.use((req, res, next) => {
const { url } = req
for (const prefix in opts) {
if (startsWith(url, prefix)) {
const target = opts[prefix]
proxy.web(req, res, {
target: target + url.slice(prefix.length)
})
return
}
}
next()
})
// WebSocket proxy.
const webSocketServer = new WebSocket.Server({
noServer: true
})
xo.on('stop', () => pFromCallback(cb => webSocketServer.close(cb)))
express.on('upgrade', (req, socket, head) => {
const { url } = req
for (const prefix in opts) {
if (startsWith(url, prefix)) {
const target = opts[prefix]
proxy.ws(req, socket, head, {
target: target + url.slice(prefix.length)
})
return
}
}
})
}
// ===================================================================
const setUpStaticFiles = (express, opts) => {
forEach(opts, (paths, url) => {
if (!isArray(paths)) {
paths = [paths]
}
forEach(paths, path => {
debug('Setting up %s → %s', url, path)
express.use(url, serveStatic(path))
})
})
}
// ===================================================================
const setUpApi = (webServer, xo, verboseLogsOnErrors) => {
const webSocketServer = new WebSocket.Server({
server: webServer,
path: '/api/'
})
xo.on('stop', () => pFromCallback(cb => webSocketServer.close(cb)))
webSocketServer.on('connection', socket => {
const { remoteAddress } = socket.upgradeReq.socket
debug('+ WebSocket connection (%s)', remoteAddress)
// Create the abstract XO object for this connection.
const connection = xo.createUserConnection()
connection.once('close', () => {
socket.close()
})
// Create the JSON-RPC server for this connection.
const jsonRpc = new JsonRpcPeer(message => {
if (message.type === 'request') {
return xo.callApiMethod(connection, message.method, message.params)
}
})
connection.notify = bind(jsonRpc.notify, jsonRpc)
// Close the XO connection with this WebSocket.
socket.once('close', () => {
debug('- WebSocket connection (%s)', remoteAddress)
connection.close()
})
// Connect the WebSocket to the JSON-RPC server.
socket.on('message', message => {
jsonRpc.write(message)
})
const onSend = error => {
if (error) {
warn('WebSocket send:', error.stack)
}
}
jsonRpc.on('data', data => {
// The socket may have been closed during the API method
// execution.
if (socket.readyState === WebSocket.OPEN) {
socket.send(data, onSend)
}
})
})
}
// ===================================================================
const CONSOLE_PROXY_PATH_RE = /^\/api\/consoles\/(.*)$/
const setUpConsoleProxy = (webServer, xo) => {
const webSocketServer = new WebSocket.Server({
noServer: true
})
xo.on('stop', () => pFromCallback(cb => webSocketServer.close(cb)))
webServer.on('upgrade', async (req, socket, head) => {
const matches = CONSOLE_PROXY_PATH_RE.exec(req.url)
if (!matches) {
return
}
const [, id] = matches
try {
// TODO: factorize permissions checking in an Express middleware.
{
const { token } = parseCookies(req.headers.cookie)
const user = await xo.authenticateUser({ token })
if (!await xo.hasPermissions(user.id, [ [ id, 'operate' ] ])) {
throw new InvalidCredential()
}
const { remoteAddress } = socket
debug('+ Console proxy (%s - %s)', user.name, remoteAddress)
socket.on('close', () => {
debug('- Console proxy (%s - %s)', user.name, remoteAddress)
})
}
const xapi = xo.getXapi(id, ['VM', 'VM-controller'])
const vmConsole = xapi.getVmConsole(id)
// FIXME: lost connection due to VM restart is not detected.
webSocketServer.handleUpgrade(req, socket, head, connection => {
proxyConsole(connection, vmConsole, xapi.sessionId)
})
} catch (error) {
console.error(error && error.stack || error)
}
})
}
// ===================================================================
const USAGE = (({
name,
version
}) => `Usage: ${name} [--safe-mode]
${name} v${version}`)(require('../package.json'))
// ===================================================================
export default async function main (args) {
if (includes(args, '--help') || includes(args, '-h')) {
return USAGE
}
{
const debug = createLogger('xo:perf')
blocked(ms => {
debug('blocked for %sms', ms | 0)
})
}
const config = await loadConfiguration()
const webServer = await createWebServer(config.http.listen)
// Now the web server is listening, drop privileges.
try {
const {user, group} = config
if (group) {
process.setgid(group)
debug('Group changed to', group)
}
if (user) {
process.setuid(user)
debug('User changed to', user)
}
} catch (error) {
warn('Failed to change user/group:', error)
}
if (config.httpProxy) {
setupHttpProxy(config.httpProxy)
}
// Creates main object.
const xo = new Xo(config)
// Register web server close on XO stop.
xo.on('stop', () => pFromCallback(cb => webServer.close(cb)))
// Connects to all registered servers.
await xo.start()
// Express is used to manage non WebSocket connections.
const express = createExpressApp()
if (config.http.redirectToHttps) {
let port
forEach(config.http.listen, listen => {
if (
listen.port &&
(listen.cert || listen.certificate)
) {
port = listen.port
return false
}
})
if (port === undefined) {
warn('Could not setup HTTPs redirection: no HTTPs port found')
} else {
express.use((req, res, next) => {
if (req.secure) {
return next()
}
res.redirect(`https://${req.hostname}:${port}${req.originalUrl}`)
})
}
}
// Must be set up before the API.
setUpConsoleProxy(webServer, xo)
// Must be set up before the API.
express.use(bind(xo._handleHttpRequest, xo))
// Everything above is not protected by the sign in, allowing xo-cli
// to work properly.
await setUpPassport(express, xo)
// Attaches express to the web server.
webServer.on('request', express)
webServer.on('upgrade', (req, socket, head) => {
express.emit('upgrade', req, socket, head)
})
// Must be set up before the static files.
setUpApi(webServer, xo, config.verboseApiLogsOnErrors)
setUpProxies(express, config.http.proxies, xo)
setUpStaticFiles(express, config.http.mounts)
if (!includes(args, '--safe-mode')) {
await registerPlugins(xo)
}
// Gracefully shutdown on signals.
//
// TODO: implements a timeout? (or maybe it is the services launcher
// responsibility?)
forEach([ 'SIGINT', 'SIGTERM' ], signal => {
let alreadyCalled = false
process.on(signal, () => {
if (alreadyCalled) {
warn('forced exit')
process.exit(1)
}
alreadyCalled = true
debug('%s caught, closing…', signal)
xo.stop()
})
})
await eventToPromise(xo, 'stopped')
debug('bye :-)')
}

195
src/job-executor.js Normal file
View File

@@ -0,0 +1,195 @@
import assign from 'lodash/assign'
import Bluebird from 'bluebird'
import every from 'lodash/every'
import filter from 'lodash/filter'
import isArray from 'lodash/isArray'
import isPlainObject from 'lodash/isPlainObject'
import map from 'lodash/map'
import mapValues from 'lodash/mapValues'
import size from 'lodash/size'
import some from 'lodash/some'
import { BaseError } from 'make-error'
import { crossProduct } from './math'
import {
serializeError,
thunkToArray
} from './utils'
export class JobExecutorError extends BaseError {}
export class UnsupportedJobType extends JobExecutorError {
constructor (job) {
super('Unknown job type: ' + job.type)
}
}
export class UnsupportedVectorType extends JobExecutorError {
constructor (vector) {
super('Unknown vector type: ' + vector.type)
}
}
// ===================================================================
const match = (pattern, value) => {
if (isPlainObject(pattern)) {
if (pattern.__or && size(pattern) === 1) {
return some(pattern.__or, subpattern => match(subpattern, value))
}
return isPlainObject(value) && every(pattern, (subpattern, key) => (
value[key] !== undefined && match(subpattern, value[key])
))
}
if (isArray(pattern)) {
return isArray(value) && every(pattern, subpattern =>
some(value, subvalue => match(subpattern, subvalue))
)
}
return pattern === value
}
const paramsVectorActionsMap = {
extractProperties ({ mapping, value }) {
return mapValues(mapping, key => value[key])
},
crossProduct ({ items }) {
return thunkToArray(crossProduct(
map(items, value => resolveParamsVector.call(this, value))
))
},
fetchObjects ({ pattern }) {
return filter(this.xo.getObjects(), object => match(pattern, object))
},
map ({ collection, iteratee, paramName = 'value' }) {
return map(resolveParamsVector.call(this, collection), value => {
return resolveParamsVector.call(this, {
...iteratee,
[paramName]: value
})
})
},
set: ({ values }) => values
}
export function resolveParamsVector (paramsVector) {
const visitor = paramsVectorActionsMap[paramsVector.type]
if (!visitor) {
throw new Error(`Unsupported function '${paramsVector.type}'.`)
}
return visitor.call(this, paramsVector)
}
// ===================================================================
export default class JobExecutor {
constructor (xo) {
this.xo = xo
this._extractValueCb = {
'set': items => items.values
}
// The logger is not available until Xo has started.
xo.on('start', () => xo.getLogger('jobs').then(logger => {
this._logger = logger
}))
}
async exec (job) {
const runJobId = this._logger.notice(`Starting execution of ${job.id}.`, {
event: 'job.start',
userId: job.userId,
jobId: job.id,
key: job.key
})
try {
if (job.type === 'call') {
const execStatus = await this._execCall(job, runJobId)
this.xo.emit('job:terminated', execStatus)
} else {
throw new UnsupportedJobType(job)
}
this._logger.notice(`Execution terminated for ${job.id}.`, {
event: 'job.end',
runJobId
})
} catch (error) {
this._logger.error(`The execution of ${job.id} has failed.`, {
event: 'job.end',
runJobId,
error: serializeError(error)
})
throw error
}
}
async _execCall (job, runJobId) {
const { paramsVector } = job
const paramsFlatVector = paramsVector
? resolveParamsVector.call(this, paramsVector)
: [{}] // One call with no parameters
const connection = this.xo.createUserConnection()
connection.set('user_id', job.userId)
const execStatus = {
runJobId,
start: Date.now(),
calls: {}
}
await Bluebird.map(paramsFlatVector, params => {
const runCallId = this._logger.notice(`Starting ${job.method} call. (${job.id})`, {
event: 'jobCall.start',
runJobId,
method: job.method,
params
})
const call = execStatus.calls[runCallId] = {
method: job.method,
params,
start: Date.now()
}
return this.xo.callApiMethod(connection, job.method, assign({}, params)).then(
value => {
this._logger.notice(`Call ${job.method} (${runCallId}) is a success. (${job.id})`, {
event: 'jobCall.end',
runJobId,
runCallId,
returnedValue: value
})
call.returnedValue = value
call.end = Date.now()
},
reason => {
this._logger.notice(`Call ${job.method} (${runCallId}) has failed. (${job.id})`, {
event: 'jobCall.end',
runJobId,
runCallId,
error: serializeError(reason)
})
call.error = reason
call.end = Date.now()
}
)
}, {
concurrency: 2
})
connection.close()
execStatus.end = Date.now()
return execStatus
}
}

100
src/job-executor.spec.js Normal file
View File

@@ -0,0 +1,100 @@
/* eslint-env mocha */
import leche from 'leche'
import { expect } from 'chai'
import { resolveParamsVector } from './job-executor'
describe('resolveParamsVector', function () {
leche.withData({
'cross product with three sets': [
// Expected result.
[ { id: 3, value: 'foo', remote: 'local' },
{ id: 7, value: 'foo', remote: 'local' },
{ id: 10, value: 'foo', remote: 'local' },
{ id: 3, value: 'bar', remote: 'local' },
{ id: 7, value: 'bar', remote: 'local' },
{ id: 10, value: 'bar', remote: 'local' } ],
// Entry.
{
type: 'crossProduct',
items: [{
type: 'set',
values: [ { id: 3 }, { id: 7 }, { id: 10 } ]
}, {
type: 'set',
values: [ { value: 'foo' }, { value: 'bar' } ]
}, {
type: 'set',
values: [ { remote: 'local' } ]
}]
}
],
'cross product with `set` and `map`': [
// Expected result.
[
{ remote: 'local', id: 'vm:2' },
{ remote: 'smb', id: 'vm:2' }
],
// Entry.
{
type: 'crossProduct',
items: [{
type: 'set',
values: [ { remote: 'local' }, { remote: 'smb' } ]
}, {
type: 'map',
collection: {
type: 'fetchObjects',
pattern: {
$pool: { __or: [ 'pool:1', 'pool:8', 'pool:12' ] },
power_state: 'Running',
tags: [ 'foo' ],
type: 'VM'
}
},
iteratee: {
type: 'extractProperties',
mapping: { id: 'id' }
}
}]
},
// Context.
{
xo: {
getObjects: function () {
return [{
id: 'vm:1',
$pool: 'pool:1',
tags: [],
type: 'VM',
power_state: 'Halted'
}, {
id: 'vm:2',
$pool: 'pool:1',
tags: [ 'foo' ],
type: 'VM',
power_state: 'Running'
}, {
id: 'host:1',
type: 'host',
power_state: 'Running'
}, {
id: 'vm:3',
$pool: 'pool:8',
tags: [ 'foo' ],
type: 'VM',
power_state: 'Halted'
}]
}
}
}
]
}, function (expectedResult, entry, context) {
it('Resolves params vector', function () {
expect(resolveParamsVector.call(context, entry)).to.deep.have.members(expectedResult)
})
})
})

22
src/loggers/abstract.js Normal file
View File

@@ -0,0 +1,22 @@
export default class AbstractLogger {}
// See: https://en.wikipedia.org/wiki/Syslog#Severity_level
const LEVELS = [
'emergency',
'alert',
'critical',
'error',
'warning',
'notice',
'informational',
'debug'
]
// Create high level log methods.
for (const level of LEVELS) {
Object.defineProperty(AbstractLogger.prototype, level, {
value (message, data) {
return this._add(level, message, data)
}
})
}

59
src/loggers/leveldb.js Normal file
View File

@@ -0,0 +1,59 @@
import highland from 'highland'
import AbstractLogger from './abstract'
import { forEach, noop } from '../utils'
let lastDate = 0
let increment = 0
function generateUniqueKey (date) {
if (date === lastDate) {
return `${date}:${increment++}`
}
increment = 0
return String(lastDate = date)
}
export default class LevelDbLogger extends AbstractLogger {
constructor (db, namespace) {
super()
this._db = db
this._namespace = namespace
}
_add (level, message, data) {
const time = Date.now()
const log = {
level,
message,
data,
namespace: this._namespace,
time
}
const key = generateUniqueKey(time)
this._db.putSync(key, log)
return key
}
createReadStream () {
return highland(this._db.createReadStream())
.filter(({value}) => value.namespace === this._namespace)
}
del (id) {
if (!Array.isArray(id)) {
id = [id]
}
forEach(id, id => {
this._db.get(id).then(value => {
if (value.namespace === this._namespace) {
this._db.delSync(id, noop)
}
})
})
}
}

202
src/logs-cli.js Normal file
View File

@@ -0,0 +1,202 @@
import appConf from 'app-conf'
import get from 'lodash/get'
import highland from 'highland'
import levelup from 'level-party'
import ndjson from 'ndjson'
import parseArgs from 'minimist'
import sublevel from 'level-sublevel'
import util from 'util'
import { repair as repairDb } from 'leveldown'
import {forEach} from './utils'
import globMatcher from './glob-matcher'
// ===================================================================
async function printLogs (db, args) {
let stream = highland(db.createReadStream({reverse: true}))
if (args.since) {
stream = stream.filter(({value}) => (value.time >= args.since))
}
if (args.until) {
stream = stream.filter(({value}) => (value.time <= args.until))
}
const fields = Object.keys(args.matchers)
if (fields.length > 0) {
stream = stream.filter(({value}) => {
for (const field of fields) {
const fieldValue = get(value, field)
if (fieldValue === undefined || !args.matchers[field](fieldValue)) {
return false
}
}
return true
})
}
stream = stream.take(args.limit)
if (args.json) {
stream = highland(stream.pipe(ndjson.serialize()))
.each(value => {
process.stdout.write(value)
})
} else {
stream = stream.each(value => {
console.log(util.inspect(value, { depth: null }))
})
}
return new Promise(resolve => {
stream.done(resolve)
})
}
// ===================================================================
function helper () {
console.error(`
xo-server-logs --help, -h
Display this help message.
xo-server-logs [--json] [--limit=<limit>] [--since=<date>] [--until=<date>] [<pattern>...]
Prints the logs.
--json
Display the results as new line delimited JSON for consumption
by another program.
--limit=<limit>, -n <limit>
Limit the number of results to be displayed (default 100)
--since=<date>, --until=<date>
Start showing entries on or newer than the specified date, or on
or older than the specified date.
<date> should use the format \`YYYY-MM-DD\`.
<pattern>
Patterns can be used to filter the entries.
Patterns have the following format \`<field>=<value>\`/\`<field>\`.
xo-server-logs --repair
Repair/compact the database.
This is an advanced operation and should be used only when necessary and offline (xo-server should be stopped).
`)
}
// ===================================================================
function getArgs () {
const stringArgs = ['since', 'until', 'limit']
const args = parseArgs(process.argv.slice(2), {
string: stringArgs,
boolean: ['help', 'json', 'repair'],
default: {
limit: 100,
json: false,
help: false
},
alias: {
limit: 'n',
help: 'h'
}
})
const patterns = {}
for (let value of args._) {
value = String(value)
const i = value.indexOf('=')
if (i !== -1) {
const field = value.slice(0, i)
const pattern = value.slice(i + 1)
patterns[pattern]
? patterns[field].push(pattern)
: patterns[field] = [ pattern ]
} else if (!patterns[value]) {
patterns[value] = null
}
}
const trueFunction = () => true
args.matchers = {}
for (const field in patterns) {
const values = patterns[field]
args.matchers[field] = (values === null) ? trueFunction : globMatcher(values)
}
// Warning: minimist makes one array of values if the same option is used many times.
// (But only for strings args, not boolean)
forEach(stringArgs, arg => {
if (args[arg] instanceof Array) {
throw new Error(`error: too many values for ${arg} argument`)
}
})
;['since', 'until'].forEach(arg => {
if (args[arg] !== undefined) {
args[arg] = Date.parse(args[arg])
if (isNaN(args[arg])) {
throw new Error(`error: bad ${arg} timestamp format`)
}
}
})
if (isNaN(args.limit = +args.limit)) {
throw new Error('error: limit is not a valid number')
}
return args
}
// ===================================================================
export default async function main () {
const args = getArgs()
if (args.help) {
helper()
return
}
const config = await appConf.load('xo-server', {
ignoreUnknownFormats: true
})
if (args.repair) {
await new Promise((resolve, reject) => {
repairDb(`${config.datadir}/leveldb`, error => {
if (error) {
reject(error)
} else {
resolve()
}
})
})
return
}
const db = sublevel(levelup(
`${config.datadir}/leveldb`,
{ valueEncoding: 'json' }
)).sublevel('logs')
return printLogs(db, args)
}

View File

@@ -1,230 +0,0 @@
# File system handling.
$fs = require 'fs'
#---------------------------------------------------------------------
# Low level tools.
$_ = require 'underscore'
# HTTP(s) middleware framework.
$connect = require 'connect'
$serveStatic = require 'serve-static'
$eventToPromise = require 'event-to-promise'
# Configuration handling.
$nconf = require 'nconf'
$Promise = require 'bluebird'
$Promise.longStackTraces()
# WebSocket server.
{Server: $WSServer} = require 'ws'
# YAML formatting and parsing.
$YAML = require 'js-yaml'
#---------------------------------------------------------------------
$API = require './api'
$Connection = require './connection'
$XO = require './xo'
# Helpers for dealing with fibers.
{$fiberize, $promisify, $waitEvent, $wait} = require './fibers-utils'
# HTTP/HTTPS server which can listen on multiple ports.
$WebServer = require 'http-server-plus'
#=====================================================================
$readFile = $Promise.promisify $fs.readFile
$handleJsonRpcCall = (api, session, encodedRequest) ->
request = {
id: null
}
formatError = (error) -> JSON.stringify {
jsonrpc: '2.0'
error: error
id: request.id
}
# Parses the JSON.
try
request = JSON.parse encodedRequest.toString()
catch error
return formatError (
if error instanceof SyntaxError
$API.err.INVALID_JSON
else
$API.err.SERVER_ERROR
)
# Checks it is a compliant JSON-RPC 2.0 request.
if (
not request.method? or
not request.params? or
not request.id? or
request.jsonrpc isnt '2.0'
)
return formatError $API.err.INVALID_REQUEST
# Executes the requested method on the API.
try
JSON.stringify {
jsonrpc: '2.0'
result: $wait api.exec session, request
id: request.id
}
catch error
# If it is not a valid API error, hides it with a generic server error.
unless (error not instanceof Error) and error.code? and error.message?
console.error error.stack ? error
error = $API.err.SERVER_ERROR
formatError error
#=====================================================================
# Main.
module.exports = $promisify (args) ->
# Relative paths in the configuration are relative to this
# directory's parent.
process.chdir "#{__dirname}/.."
# Loads the environment.
$nconf.env()
# Parses process' arguments.
$nconf.argv()
# Loads the configuration files.
format =
stringify: $YAML.safeDump
parse: $YAML.safeLoad
$nconf.use 'file', {
file: "#{__dirname}/../config/local.yaml"
format
}
# Defines defaults configuration.
$nconf.defaults {
http: {
listen: [
port: 80
]
mounts: []
}
redis: {
# Default values are handled by `redis`.
}
}
# Prints a message if deprecated entries are specified.
for entry in ['users', 'servers']
if $nconf.get entry
console.warn "[Warn] `#{entry}` configuration is deprecated."
# Creates the web server according to the configuration.
webServer = new $WebServer()
$wait $Promise.map ($nconf.get 'http:listen'), (options) ->
# Reads certificate and key if necessary.
if options.certificate? and options.key?
options.certificate = $wait $readFile options.certificate
options.key = $wait $readFile options.key
# Starts listening
webServer.listen options
.then ->
console.log "WebServer listening on #{@niceAddress()}"
.catch (error) ->
console.warn "[WARN] WebServer could not listen on #{@niceAddress()}"
switch error.code
when 'EACCES'
console.warn ' Access denied.'
console.warn ' Ports < 1024 are often reserved to privileges users.'
when 'EADDRINUSE'
console.warn ' Address already in use.'
# Now the web server is listening, drop privileges.
try
if (group = $nconf.get 'group')?
process.setgid group
if (user = $nconf.get 'user')?
process.setuid user
catch error
console.warn "[WARN] Failed to change the user or group: #{error.message}"
# Handles error as gracefully as possible.
webServer.on 'error', (error) ->
console.error '[ERR] Web server', error
webServer.close()
# Creates the main object which will connects to Xen servers and
# manages all the models.
xo = new $XO()
# Starts it.
xo.start {
redis: {
uri: $nconf.get 'redis:uri'
}
}
# Static file serving (e.g. for XO-Web).
connect = $connect()
for urlPath, filePaths of $nconf.get 'http:mounts'
filePaths = [filePaths] unless $_.isArray filePaths
for filePath in filePaths
connect.use urlPath, $serveStatic filePath
webServer.on 'request', connect
# Creates the API.
api = new $API xo
conId = 0
unregisterConnection = ->
delete xo.connections[@id]
# JSON-RPC over WebSocket.
wsServer = new $WSServer {
server: webServer
path: '/api/'
}
wsServer.on 'connection', (socket) ->
connection = new $Connection {
close: socket.close.bind socket
send: socket.send.bind socket
}
connection.id = conId++
xo.connections[connection.id] = connection
connection.on 'close', unregisterConnection
socket.on 'close', connection.close.bind connection
# Handles each request in a separate fiber.
socket.on 'message', $fiberize (request) ->
response = $handleJsonRpcCall api, connection, request
# The socket may have closed between the request and the
# response.
socket.send response if socket.readyState is socket.OPEN
socket.on 'error', $fiberize (error) ->
console.error '[WARN] WebSocket connection', error
socket.close()
wsServer.on 'error', $fiberize (error) ->
console.error '[WARN] WebSocket server', error
wsServer.close()
# Creates a default user if there is none.
unless $wait xo.users.exists()
email = 'admin@admin.net'
password = 'admin' # TODO: Should be generated.
xo.users.create email, password, 'admin'
console.log "[INFO] Default user: “#{email}” with password “#{password}"
return $eventToPromise webServer, 'close'

48
src/math.js Normal file
View File

@@ -0,0 +1,48 @@
import assign from 'lodash/assign'
const _combine = (vectors, n, cb) => {
if (!n) {
return
}
const nLast = n - 1
const vector = vectors[nLast]
const m = vector.length
if (n === 1) {
for (let i = 0; i < m; ++i) {
cb([ vector[i] ])
}
return
}
for (let i = 0; i < m; ++i) {
const value = vector[i]
_combine(vectors, nLast, (vector) => {
vector.push(value)
cb(vector)
})
}
}
// Compute all combinations from vectors.
//
// Ex: combine([[2, 3], [5, 7]])
// => [ [ 2, 5 ], [ 3, 5 ], [ 2, 7 ], [ 3, 7 ] ]
export const combine = vectors => cb => _combine(vectors, vectors.length, cb)
// Merge the properties of an objects set in one object.
//
// Ex: mergeObjects([ { a: 1 }, { b: 2 } ]) => { a: 1, b: 2 }
export const mergeObjects = objects => assign({}, ...objects)
// Compute a cross product between vectors.
//
// Ex: crossProduct([ [ { a: 2 }, { b: 3 } ], [ { c: 5 }, { d: 7 } ] ] )
// => [ { a: 2, c: 5 }, { b: 3, c: 5 }, { a: 2, d: 7 }, { b: 3, d: 7 } ]
export const crossProduct = (vectors, mergeFn = mergeObjects) => cb => (
combine(vectors)(vector => {
cb(mergeFn(vector))
})
)

72
src/math.spec.js Normal file
View File

@@ -0,0 +1,72 @@
/* eslint-env mocha */
import { expect } from 'chai'
import leche from 'leche'
import { thunkToArray } from './utils'
import {
crossProduct,
mergeObjects
} from './math'
describe('mergeObjects', function () {
leche.withData({
'Two sets of one': [
{a: 1, b: 2}, {a: 1}, {b: 2}
],
'Two sets of two': [
{a: 1, b: 2, c: 3, d: 4}, {a: 1, b: 2}, {c: 3, d: 4}
],
'Three sets': [
{a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}, {a: 1}, {b: 2, c: 3}, {d: 4, e: 5, f: 6}
],
'One set': [
{a: 1, b: 2}, {a: 1, b: 2}
],
'Empty set': [
{a: 1}, {a: 1}, {}
],
'All empty': [
{}, {}, {}
],
'No set': [
{}
]
}, function (resultSet, ...sets) {
it('Assembles all given param sets in on set', function () {
expect(mergeObjects(sets)).to.eql(resultSet)
})
})
})
describe('crossProduct', function () {
// Gives the sum of all args
const addTest = args => args.reduce((prev, curr) => prev + curr, 0)
// Gives the product of all args
const multiplyTest = args => args.reduce((prev, curr) => prev * curr, 1)
leche.withData({
'2 sets of 2 items to multiply': [
[10, 14, 15, 21], [[2, 3], [5, 7]], multiplyTest
],
'3 sets of 2 items to multiply': [
[110, 130, 154, 182, 165, 195, 231, 273], [[2, 3], [5, 7], [11, 13]], multiplyTest
],
'2 sets of 3 items to multiply': [
[14, 22, 26, 21, 33, 39, 35, 55, 65], [[2, 3, 5], [7, 11, 13]], multiplyTest
],
'2 sets of 2 items to add': [
[7, 9, 8, 10], [[2, 3], [5, 7]], addTest
],
'3 sets of 2 items to add': [
[18, 20, 20, 22, 19, 21, 21, 23], [[2, 3], [5, 7], [11, 13]], addTest
],
'2 sets of 3 items to add': [
[9, 13, 15, 10, 14, 16, 12, 16, 18], [[2, 3, 5], [7, 11, 13]], addTest
]
}, function (product, items, cb) {
it('Crosses sets of values with a crossProduct callback', function () {
expect(thunkToArray(crossProduct(items, cb))).to.have.members(product)
})
})
})

View File

@@ -1,113 +1,73 @@
'use strict';
import {EventEmitter} from 'events'
var _ = require('underscore');
import {
forEach,
isEmpty,
isString
} from './utils'
//////////////////////////////////////////////////////////////////////
// ===================================================================
function Model(properties)
{
// Parent constructor.
Model.super_.call(this);
export default class Model extends EventEmitter {
constructor (properties) {
super()
this.properties = _.extend({}, this['default']);
this.properties = { ...this.default }
if (properties)
{
this.set(properties);
}
if (properties) {
this.set(properties)
}
}
// Initialize the model after construction.
initialize () {}
// Validate the defined properties.
//
// Returns the error if any.
validate (properties) {}
// Get a property.
get (name, def) {
const value = this.properties[name]
return value !== undefined ? value : def
}
// Check whether a property exists.
has (name) {
return (this.properties[name] !== undefined)
}
// Set properties.
set (properties, value) {
// This method can also be used with two arguments to set a single
// property.
if (isString(properties)) {
properties = { [properties]: value }
}
const previous = {}
forEach(properties, (value, name) => {
const prev = this.properties[name]
if (value !== prev) {
previous[name] = prev
if (value === undefined) {
delete this.properties[name]
} else {
this.properties[name] = value
}
}
})
if (!isEmpty(previous)) {
this.emit('change', previous)
forEach(previous, (value, name) => {
this.emit('change:' + name, value)
})
}
}
}
require('util').inherits(Model, require('events').EventEmitter);
/**
* Initializes the model after construction.
*/
Model.prototype.initialize = function () {};
/**
* Validates the defined properties.
*
* @returns {undefined|mixed} Returns something else than undefined if
* there was an error.
*/
Model.prototype.validate = function (/*properties*/) {};
/**
* Gets property.
*/
Model.prototype.get = function (property, def) {
var prop = this.properties[property];
if (undefined !== prop)
{
return prop;
}
return def;
};
/**
* Checks if a property exists.
*/
Model.prototype.has = function (property) {
return (undefined !== this.properties[property]);
};
/**
* Sets properties.
*/
Model.prototype.set = function (properties, value) {
if (undefined !== value)
{
var property = properties;
properties = {};
properties[property] = value;
}
var previous = {};
var model = this;
_.each(properties, function (value, key) {
if (undefined === value)
{
return;
}
var prev = model.get(key);
// New value.
if (value !== prev)
{
previous[key] = prev;
model.properties[key] = value;
}
});
if (!_.isEmpty(previous))
{
this.emit('change', previous);
_.each(previous, function (previous, property) {
this.emit('change:'+ property, previous);
}, this);
}
};
/**
* Unsets properties.
*/
Model.prototype.unset = function (properties) {
// TODO: Events.
this.properties = _.omit(this.properties, properties);
};
/**
* Default properties.
*
* @type {Object}
*/
Model.prototype['default'] = {};
Model.extend = require('extendable');
//////////////////////////////////////////////////////////////////////
module.exports = Model;

79
src/models/acl.js Normal file
View File

@@ -0,0 +1,79 @@
import Collection from '../collection/redis'
import Model from '../model'
import {
forEach,
mapToArray,
multiKeyHash
} from '../utils'
// ===================================================================
// Up until now, there were no actions, therefore the default
// action is used to update existing entries.
const DEFAULT_ACTION = 'admin'
// ===================================================================
export default class Acl extends Model {}
Acl.create = (subject, object, action) => {
return Acl.hash(subject, object, action).then(hash => new Acl({
id: hash,
subject,
object,
action
}))
}
Acl.hash = (subject, object, action) => multiKeyHash(subject, object, action)
// -------------------------------------------------------------------
export class Acls extends Collection {
get Model () {
return Acl
}
create (subject, object, action) {
return Acl.create(subject, object, action).then(acl => this.add(acl))
}
delete (subject, object, action) {
return Acl.hash(subject, object, action).then(hash => this.remove(hash))
}
aclExists (subject, object, action) {
return Acl.hash(subject, object, action).then(hash => this.exists(hash))
}
async get (properties) {
const acls = await super.get(properties)
// Finds all records that are missing a action and need to be updated.
const toUpdate = []
forEach(acls, acl => {
if (!acl.action) {
acl.action = DEFAULT_ACTION
toUpdate.push(acl)
}
})
if (toUpdate.length) {
// Removes all existing entries.
await this.remove(mapToArray(toUpdate, 'id'))
// Compute the new ids (new hashes).
const {hash} = Acl
await Promise.all(mapToArray(
toUpdate,
(acl) => hash(acl.subject, acl.object, acl.action).then(id => {
acl.id = id
})
))
// Inserts the new (updated) entries.
await this.add(toUpdate)
}
return acls
}
}

47
src/models/group.js Normal file
View File

@@ -0,0 +1,47 @@
import Collection from '../collection/redis'
import Model from '../model'
import { forEach } from '../utils'
// ===================================================================
export default class Group extends Model {}
// ===================================================================
export class Groups extends Collection {
get Model () {
return Group
}
create (name) {
return this.add(new Group({
name,
users: '[]'
}))
}
async save (group) {
// Serializes.
group.users = JSON.stringify(group.users)
return /* await */ this.update(group)
}
async get (properties) {
const groups = await super.get(properties)
// Deserializes.
forEach(groups, group => {
const {users} = group
try {
group.users = JSON.parse(users)
} catch (error) {
console.warn('cannot parse group.users:', users)
group.users = []
}
})
return groups
}
}

42
src/models/job.js Normal file
View File

@@ -0,0 +1,42 @@
import Collection from '../collection/redis'
import Model from '../model'
import { forEach } from '../utils'
// ===================================================================
export default class Job extends Model {}
export class Jobs extends Collection {
get Model () {
return Job
}
async create (job) {
// Serializes.
job.paramsVector = JSON.stringify(job.paramsVector)
return /* await */ this.add(new Job(job))
}
async save (job) {
// Serializes.
job.paramsVector = JSON.stringify(job.paramsVector)
return /* await */ this.update(job)
}
async get (properties) {
const jobs = await super.get(properties)
// Deserializes.
forEach(jobs, job => {
const {paramsVector} = job
try {
job.paramsVector = JSON.parse(paramsVector)
} catch (error) {
console.warn('cannot parse job.paramsVector:', paramsVector) // FIXME this is a warning as I copy/paste acl.js, but...
job.paramsVector = {}
}
})
return jobs
}
}

View File

@@ -0,0 +1,53 @@
import Collection from '../collection/redis'
import Model from '../model'
import { forEach } from '../utils'
// ===================================================================
export default class PluginMetadata extends Model {}
// ===================================================================
export class PluginsMetadata extends Collection {
get Model () {
return PluginMetadata
}
async save ({ id, autoload, configuration }) {
return /* await */ this.update({
id,
autoload: autoload ? 'true' : 'false',
configuration: configuration && JSON.stringify(configuration)
})
}
async merge (id, data) {
const pluginMetadata = await this.first(id)
if (!pluginMetadata) {
throw new Error('no such plugin metadata')
}
return /* await */ this.save({
...pluginMetadata.properties,
...data
})
}
async get (properties) {
const pluginsMetadata = await super.get(properties)
// Deserializes.
forEach(pluginsMetadata, pluginMetadata => {
const { autoload, configuration } = pluginMetadata
pluginMetadata.autoload = autoload === 'true'
try {
pluginMetadata.configuration = configuration && JSON.parse(configuration)
} catch (error) {
console.warn('cannot parse pluginMetadata.configuration:', configuration)
pluginMetadata.configuration = []
}
})
return pluginsMetadata
}
}

36
src/models/remote.js Normal file
View File

@@ -0,0 +1,36 @@
import Collection from '../collection/redis'
import Model from '../model'
import {
forEach
} from '../utils'
// ===================================================================
export default class Remote extends Model {}
export class Remotes extends Collection {
get Model () {
return Remote
}
create (name, url) {
return this.add(new Remote({
name,
url,
enabled: false,
error: ''
}))
}
async save (remote) {
return /* await */ this.update(remote)
}
async get (properties) {
const remotes = await super.get(properties)
forEach(remotes, remote => {
remote.enabled = (remote.enabled === 'true')
})
return remotes
}
}

36
src/models/schedule.js Normal file
View File

@@ -0,0 +1,36 @@
import Collection from '../collection/redis'
import Model from '../model'
import { forEach } from '../utils'
// ===================================================================
export default class Schedule extends Model {}
export class Schedules extends Collection {
get Model () {
return Schedule
}
create (userId, job, cron, enabled, name = undefined, timezone = undefined) {
return this.add(new Schedule({
userId,
job,
cron,
enabled,
name,
timezone
}))
}
async save (schedule) {
return /* await */ this.update(schedule)
}
async get (properties) {
const schedules = await super.get(properties)
forEach(schedules, schedule => {
schedule.enabled = (schedule.enabled === 'true')
})
return schedules
}
}

22
src/models/server.js Normal file
View File

@@ -0,0 +1,22 @@
import Collection from '../collection/redis'
import Model from '../model'
// ===================================================================
export default class Server extends Model {}
// -------------------------------------------------------------------
export class Servers extends Collection {
get Model () {
return Server
}
async create ({host, username, password, readOnly}) {
if (await this.exists({host})) {
throw new Error('server already exists')
}
return /* await */ this.add({host, username, password, readOnly})
}
}

10
src/models/token.js Normal file
View File

@@ -0,0 +1,10 @@
import Collection from '../collection/redis'
import Model from '../model'
// ===================================================================
export default class Token extends Model {}
// -------------------------------------------------------------------
export class Tokens extends Collection {}

76
src/models/user.js Normal file
View File

@@ -0,0 +1,76 @@
import isEmpty from 'lodash/isEmpty'
import Collection from '../collection/redis'
import Model from '../model'
import { forEach } from '../utils'
// ===================================================================
export default class User extends Model {}
User.prototype.default = {
permission: 'none'
}
// -------------------------------------------------------------------
const parseProp = (obj, name) => {
const value = obj[name]
if (value == null) {
return
}
try {
return JSON.parse(value)
} catch (error) {
console.warn('cannot parse user[%s] (%s):', name, value, error)
}
}
export class Users extends Collection {
get Model () {
return User
}
async create (properties) {
const { email } = properties
// Avoid duplicates.
if (await this.exists({email})) {
throw new Error(`the user ${email} already exists`)
}
// Create the user object.
const user = new User(properties)
// Adds the user to the collection.
return /* await */ this.add(user)
}
async save (user) {
// Serializes.
let tmp
if (!isEmpty(tmp = user.groups)) {
user.groups = JSON.stringify(tmp)
}
if (!isEmpty(tmp = user.preferences)) {
user.preferences = JSON.stringify(tmp)
}
return /* await */ this.update(user)
}
async get (properties) {
const users = await super.get(properties)
// Deserializes
forEach(users, user => {
let tmp
user.groups = ((tmp = parseProp(user, 'groups')) && tmp.length)
? tmp
: undefined
user.preferences = parseProp(user, 'preferences')
})
return users
}
}

76
src/proxy-console.js Normal file
View File

@@ -0,0 +1,76 @@
import createDebug from 'debug'
import partialStream from 'partial-stream'
import {connect} from 'tls'
import {parse} from 'url'
const debug = createDebug('xo:proxy-console')
export default function proxyConsole (ws, vmConsole, sessionId) {
const url = parse(vmConsole.location)
let closed = false
const socket = connect({
host: url.host,
port: url.port || 443,
rejectUnauthorized: false
}, () => {
// Write headers.
socket.write([
`CONNECT ${url.path} HTTP/1.0`,
`Host: ${url.hostname}`,
`Cookie: session_id=${sessionId}`,
'', ''
].join('\r\n'))
const onSend = (error) => {
if (error) {
debug('error sending to the XO client: %s', error.stack || error.message || error)
}
}
socket.pipe(partialStream('\r\n\r\n', headers => {
// TODO: check status code 200.
debug('connected')
})).on('data', data => {
if (!closed) {
// Encode to base 64.
ws.send(data.toString('base64'), onSend)
}
}).on('end', () => {
if (!closed) {
closed = true
debug('disconnected from the console')
}
ws.close()
})
ws
.on('error', error => {
closed = true
debug('error from the XO client: %s', error.stack || error.message || error)
socket.close()
})
.on('message', data => {
if (!closed) {
// Decode from base 64.
socket.write(new Buffer(data, 'base64'))
}
})
.on('close', () => {
if (!closed) {
closed = true
debug('disconnected from the XO client')
}
socket.end()
})
}).on('error', error => {
closed = true
debug('error from the console: %s', error.stack || error.message || error)
ws.close()
})
}

View File

@@ -0,0 +1,217 @@
import eventToPromise from 'event-to-promise'
import through2 from 'through2'
import {
parse
} from 'xo-remote-parser'
import {
addChecksumToReadStream,
getPseudoRandomBytes,
noop,
pCatch,
streamToBuffer,
validChecksumOfReadStream
} from '../utils'
export default class RemoteHandlerAbstract {
constructor (remote) {
this._remote = {...remote, ...parse(remote.url)}
if (this._remote.type !== this.type) {
throw new Error('Incorrect remote type')
}
}
get type () {
throw new Error('Not implemented')
}
/**
* Asks the handler to sync the state of the effective remote with its' metadata
*/
async sync () {
return this._sync()
}
async _sync () {
throw new Error('Not implemented')
}
/**
* Free the resources possibly dedicated to put the remote at work, when it is no more needed
*/
async forget () {
return this._forget()
}
async _forget () {
throw new Error('Not implemented')
}
async test () {
const testFileName = `${Date.now()}.test`
const data = getPseudoRandomBytes(1024 * 1024)
let step = 'write'
try {
await this.outputFile(testFileName, data)
step = 'read'
const read = await this.readFile(testFileName)
if (data.compare(read) !== 0) {
throw new Error('output and input did not match')
}
return {
success: true
}
} catch (error) {
return {
success: false,
step,
file: testFileName,
error: error.message || String(error)
}
} finally {
this.unlink(testFileName).catch(noop)
}
}
async outputFile (file, data, options) {
return this._outputFile(file, data, {
flags: 'wx',
...options
})
}
async _outputFile (file, data, options) {
const stream = await this.createOutputStream(file, options)
const promise = eventToPromise(stream, 'finish')
stream.end(data)
return promise
}
async readFile (file, options) {
return this._readFile(file, options)
}
_readFile (file, options) {
return this.createReadStream(file, options).then(streamToBuffer)
}
async rename (oldPath, newPath) {
return this._rename(oldPath, newPath)
}
async _rename (oldPath, newPath) {
throw new Error('Not implemented')
}
async list (dir = '.') {
return this._list(dir)
}
async _list (dir) {
throw new Error('Not implemented')
}
async createReadStream (file, {
checksum = false,
ignoreMissingChecksum = false,
...options
} = {}) {
const streamP = this._createReadStream(file, options).then(async stream => {
await eventToPromise(stream, 'readable')
if (stream.length === undefined) {
stream.length = await this.getSize(file)::pCatch(noop)
}
return stream
})
if (!checksum) {
return streamP
}
try {
checksum = await this.readFile(`${file}.checksum`)
} catch (error) {
if (error.code === 'ENOENT' && ignoreMissingChecksum) {
return streamP
}
throw error
}
let stream = await streamP
const { length } = stream
stream = validChecksumOfReadStream(stream, checksum.toString())
stream.length = length
return stream
}
async _createReadStream (file, options) {
throw new Error('Not implemented')
}
async refreshChecksum (path) {
const stream = addChecksumToReadStream(await this.createReadStream(path))
stream.resume() // start reading the whole file
const checksum = await stream.checksum
await this.outputFile(`${path}.checksum`, checksum)
}
async createOutputStream (file, {
checksum = false,
...options
} = {}) {
const streamP = this._createOutputStream(file, {
flags: 'wx',
...options
})
if (!checksum) {
return streamP
}
const connectorStream = through2()
const forwardError = error => {
connectorStream.emit('error', error)
}
const streamWithChecksum = addChecksumToReadStream(connectorStream)
streamWithChecksum.pipe(await streamP)
streamWithChecksum.checksum
.then(value => this.outputFile(`${file}.checksum`, value))
.catch(forwardError)
return connectorStream
}
async _createOutputStream (file, options) {
throw new Error('Not implemented')
}
async unlink (file, {
checksum = false
} = {}) {
if (checksum) {
this._unlink(`${file}.checksum`)::pCatch(noop)
}
return this._unlink(file)
}
async _unlink (file) {
throw new Error('Not implemented')
}
async getSize (file) {
return this._getSize(file)
}
async _getSize (file) {
throw new Error('Not implemented')
}
}

View File

@@ -0,0 +1,90 @@
import fs from 'fs-promise'
import startsWith from 'lodash/startsWith'
import {
dirname,
resolve
} from 'path'
import RemoteHandlerAbstract from './abstract'
import {
noop
} from '../utils'
export default class LocalHandler extends RemoteHandlerAbstract {
get type () {
return 'file'
}
_getRealPath () {
return this._remote.path
}
_getFilePath (file) {
const realPath = this._getRealPath()
const parts = [realPath]
if (file) {
parts.push(file)
}
const path = resolve.apply(null, parts)
if (!startsWith(path, realPath)) {
throw new Error('Remote path is unavailable')
}
return path
}
async _sync () {
if (this._remote.enabled) {
try {
const path = this._getRealPath()
await fs.ensureDir(path)
await fs.access(path, fs.R_OK | fs.W_OK)
} catch (exc) {
this._remote.enabled = false
this._remote.error = exc.message
}
}
return this._remote
}
async _forget () {
return noop()
}
async _outputFile (file, data, options) {
const path = this._getFilePath(file)
await fs.ensureDir(dirname(path))
await fs.writeFile(path, data, options)
}
async _readFile (file, options) {
return fs.readFile(this._getFilePath(file), options)
}
async _rename (oldPath, newPath) {
return fs.rename(this._getFilePath(oldPath), this._getFilePath(newPath))
}
async _list (dir = '.') {
return fs.readdir(this._getFilePath(dir))
}
async _createReadStream (file, options) {
return fs.createReadStream(this._getFilePath(file), options)
}
async _createOutputStream (file, options) {
const path = this._getFilePath(file)
await fs.ensureDir(dirname(path))
return fs.createWriteStream(path, options)
}
async _unlink (file) {
return fs.unlink(this._getFilePath(file))
}
async _getSize (file) {
const stats = await fs.stat(this._getFilePath(file))
return stats.size
}
}

Some files were not shown because too many files have changed in this diff Show More