Compare commits

..

431 Commits

Author SHA1 Message Date
Julien Fontanet
8e9946b645 feat(complex-matcher): support datetime comparison
```
<-2w
```
2020-10-23 12:19:24 +02:00
Julien Fontanet
4911bbe3a2 chore: normalize packages 2020-10-23 10:21:52 +02:00
Julien Fontanet
e0b6ab3f8a feat(value-matcher/README): document patterns 2020-10-23 10:21:52 +02:00
Rajaa.BARHTAOUI
8736c2cf9a feat(xo-server,xo-web/VIF): require network ACLs to change VIF locking mode (#5283)
See xoa-support#2929
2020-10-23 10:18:29 +02:00
Rajaa.BARHTAOUI
d825c33b55 feat(xo-server,xo-web/networks): ability to change a VIF's network for self users (#5203)
Fixes #5020
2020-10-23 10:05:03 +02:00
badrAZ
171ecaaf62 feat(xo-server, xo-web/host): display installed certificates (#5319)
See #5134
2020-10-21 14:36:55 +02:00
Julien Fontanet
5e6d5d4eb0 docs(xo-server): file restoration (#5336) 2020-10-20 15:35:16 +02:00
Rajaa.BARHTAOUI
3733a3c335 fix(xo-web): component names must be in PascalCase (#5322) 2020-10-20 15:19:59 +02:00
badrAZ
7fca6defd6 fix(xo-web, xo-server): fix host power state (#5288)
Fixes #4919
2020-10-20 10:01:48 +02:00
Julien Fontanet
2a270b399e fix(xo-server/getRemoteHandler): synchronize to avoid race conds during sync 2020-10-19 22:35:13 +02:00
Julien Fontanet
64109aee05 chore(vhd-lib/Vhd#_createBlock): assert block not already allocated 2020-10-19 22:33:58 +02:00
Julien Fontanet
e1d9395128 feat(vhd-lib/Vhd#_createBlock): dont initialize block
It's unnecessary, the block is written right after creation.
2020-10-19 22:30:57 +02:00
Julien Fontanet
32eec95c26 feat(@xen-orchestra/backups-cli): 0.2.1 2020-10-19 17:15:00 +02:00
badrAZ
f41cca45aa feat(audit-core, xo-server-audit): ability to delete a range of records (#5277) 2020-10-19 13:09:08 +02:00
Rajaa.BARHTAOUI
48eeab974c feat(xo-web/backup/restore): load backups in parallel (#5278)
See #5176
2020-10-19 11:47:33 +02:00
Pierre Donias
eed44156ae feat: release 5.51.1 (#5328) 2020-10-14 16:12:37 +02:00
Pierre Donias
1177d9bdd8 feat: technical release (#5327) 2020-10-14 15:23:00 +02:00
badrAZ
d151a94285 feat(xo-server, xo-web/proxy): ability to update http proxy cfg (#5148) 2020-10-14 14:43:33 +02:00
badrAZ
a7fe6453ee feat(xo-server#_migrateVmWithStorageMotion): improve migration error (#5306)
Fixes #5282
2020-10-14 13:17:55 +02:00
Rajaa.BARHTAOUI
313eb136f4 fix(xo-web): some methods call throw 'not enough permissions' (#5303)
See #5285
2020-10-13 15:30:06 +02:00
Mathieu
98591ff83d fix(xo-server/deleteResourceSet): detach VMs from resource set (#5312)
Fixes #4797
2020-10-12 11:33:29 +02:00
Mathieu
0b9d78560b feat(xo-web/home): better sort of bulk VM migrate selector (#5308)
Fixes #4462
2020-10-12 10:22:24 +02:00
Rajaa.BARHTAOUI
32a930e598 feat(xo-web/vm/network): remove unused method (#5316)
Introduced by c4d96fbc49
2020-10-12 10:05:57 +02:00
Rajaa.BARHTAOUI
edd8512196 feat(xo-web/vm): hide backup tab for non-admin users (#5317)
Fixes #5309
2020-10-12 10:02:08 +02:00
Mathieu
7a6aec34ae fix(xo-web/ips): fix the range formatting (#5314)
Fixes #3170
2020-10-09 17:15:50 +02:00
badrAZ
009a0c5703 feat(xo-web/backup/overview): add link from backup job/schedule to corresponding logs (#5260)
Fixes #4564
2020-10-09 14:54:23 +02:00
badrAZ
a99086b6bd chore(xo-web/log-alert-body): remove unused subscription (#5292)
Introduced By 3370014ddf
2020-10-07 15:17:29 +02:00
badrAZ
a186672447 feat(xo-web/sorted-table): ability to collapse actions (#5311)
See #5148
2020-10-07 11:13:10 +02:00
badrAZ
0b8a7c0d09 feat(xo-web/backup/new): enable created schedules by default (#5280)
See xoa-support#2921
2020-10-07 10:36:10 +02:00
BenjiReis
1990bf3d7a fix(sdn-controller): use correct bridge address to create tunnels (#5281)
Fixes xoa-support#2919
2020-10-06 23:54:02 +02:00
Julien Fontanet
ea74a7e401 fix(backups-cli clean-vms): fix limit-concurrency-decorator import 2020-10-06 18:35:35 +02:00
Nicolas Raynaud
bf12c3ff74 fix(xo-server/backup-ng): use getRemoteWithCredentials (#5315)
Introduced in #4907

Fix #5253

Otherwise the handler will be incorrectly defined due to the obfuscation of credentials.
2020-10-06 18:13:27 +02:00
Rajaa.BARHTAOUI
9d261aae76 fix(xo-web/home): hide backup filter for non-admin users (#5287)
See #5285
2020-10-06 16:47:20 +02:00
badrAZ
3d8c8fd745 feat(xo-web/backup-reports): hide merge task when no merge (#5263) 2020-10-06 16:08:12 +02:00
Rajaa.BARHTAOUI
6ad7db522a fix(xo-web/vm/disks): fix "not enough permissions" error (#5299)
Introduced by 1116530a6b
2020-10-06 15:16:27 +02:00
Rajaa.BARHTAOUI
385984b1d8 fix(xo-web/vm/disks): VDI disappears after migration (#5296)
Related to 1116530a6b
2020-10-06 10:38:33 +02:00
Mathieu
4f3d4b06b5 fix(xo-web/user): fix custom filters in default filter select (#5298) 2020-10-02 14:40:17 +02:00
badrAZ
2291986e2c fix(xo-web/new/network): omit bond slave PIFs from selection (#5262)
See xcp-ng.org/forum/topic/3524/old-networks-not-removed-after-creating-bond/8
2020-10-02 14:12:53 +02:00
Nicolas Raynaud
fc81cf4d70 fix(xo-web/remotes): fix S3 secret key edit UI (#5305)
Fixes #5233
2020-10-02 11:38:18 +02:00
Pierre Donias
fdeab86a87 fix(xo-web/xoa): don't show expired notifications (#5304) 2020-10-01 16:40:27 +02:00
Julien Fontanet
3616b7a67b feat(xo-server/sensitive-values): make obfuscated value obvious 2020-10-01 15:01:21 +02:00
Julien Fontanet
83ea57d825 feat(xo-server/vm.migrate): ensure original error is logged
Fixes https://github.com/vatesfr/xen-orchestra/pull/4364/files#r488539823
2020-10-01 14:52:42 +02:00
Mathieu
24a69bcade feat(xo-server,xo-web/host/advanced): add IOMMU state (#5294)
Fixes #4936
2020-10-01 10:40:10 +02:00
badrAZ
58dc3244be feat: release 5.51.0 (#5295) 2020-09-30 14:19:35 +02:00
badrAZ
61e580b992 feat: technical release (#5293) 2020-09-29 16:40:26 +02:00
Rajaa.BARHTAOUI
1116530a6b feat(xo-web/vm/disks): ability to migrate VDIs to other SRs within resource set (#5201)
See #5020
2020-09-29 16:07:10 +02:00
Pierre Donias
8cfaabedeb feat(xo-server-auth-ldap): import LDAP groups (#5279)
See #1884

When a user logs into XO using LDAP:

- Create a XO user if it doesn't already exist
- Mark it as being provided by LDAP and bind it to the LDAP user with an ID
- If group synchronization is enabled:
  - Fetch all the LDAP groups based on the Base and Filter (plugin config)
  - Create and delete the corresponding XO groups based on the LDAP groups that
    were found
  - Add and remove the XO users from the XO groups based on the LDAP data
2020-09-29 15:35:30 +02:00
Rajaa.BARHTAOUI
66ba05dcd0 feat(xo-web/tasks): display linked objects (#5267)
Fixes #4275
2020-09-29 15:13:56 +02:00
Julien Fontanet
d1db616d1e feat(backups-cli/clean-vms): limit VHD merging concurrency to 1 2020-09-29 10:43:48 +02:00
Nicolas Raynaud
aed09b152a fix(import/ova): speedup the import of gziped vmdk disks nested in .ova (#5275)
This the followup to #5085

Avoid unzipping the entire file from the beginning before each read.
The test case when from 10min down to 26 seconds.

When reading a block from the gzipped file, we keep the current state in memory, if the next read happens at an offset greater than the previous read, we just carry one decompressing the file until the desired position.

The previous code would decompress from the start of the file for every read operation.
2020-09-28 15:42:55 +02:00
Nicolas Raynaud
f755365e23 fix(xo-web/remotes): fix editing bucket and directory for S3 (#5276) 2020-09-28 15:33:06 +02:00
badrAZ
ccd34c1610 fix(CHANGELOG): update advanced filter entry (#5290)
Introduced by 45fe70f0fa
2020-09-28 12:12:15 +02:00
badrAZ
f9104e6cc9 fix(xo-web/messages): remove unused messages (#5289)
Introduced by 45fe70f0fa
2020-09-28 12:10:21 +02:00
Nicolas Raynaud
4bb702fe89 fix(fs/S3): support 50GB+ files (#5242) 2020-09-27 20:49:41 +02:00
Julien Fontanet
511a04dad5 feat(xo-server-auth-ldap/configuration): add titles and reorder settings 2020-09-27 20:37:00 +02:00
Nicolas Raynaud
f3527a44d7 fix(vm/import): make the UI respond instantly to .ova file drop (#5274)
When dropping a file on the import zone, the UI didn't acknowledge the file until the vmdk table were parsed.

Now the UI parses the XML instantly, displays it on the UI, and start parsing the tables in the background. If the user clicks the "import" button, the system will finish parsing the tables and start the upload in when fell swoop. Hiding the parsing time in the upload time.
2020-09-27 19:45:32 +02:00
Julien Fontanet
fdbe84cb1e chore(xo-server-test): format with Prettier 2020-09-27 19:42:35 +02:00
badrAZ
45fe70f0fa feat(xo-web/logs/backup-ng): advanced filter (#5208)
See #4406
2020-09-25 16:58:33 +02:00
badrAZ
2aed2fd534 feat(xo-web/logs/backup-ng): log tasks pagination (#5209)
See #4406
2020-09-24 16:36:18 +02:00
Julien Fontanet
a523fa9733 feat(@xen-orchestra/backups-cli): 0.2.0 2020-09-24 15:14:07 +02:00
Julien Fontanet
0f42f032e4 feat(backups-cli/info): compute the used space per job 2020-09-24 15:12:38 +02:00
Dom Del Nano
4575b98fd5 fix(xo-server#removeSubjectToResourceSet): rename to removeSubjectFromResourceSet (#5266) 2020-09-21 17:50:55 +02:00
Pierre Donias
3a0cc0d6f6 fix(xo-server/subjects/addToArraySet): dont erase previous values (#5269)
Prior to this change, adding a value to an existing set that already contains
that value would replace the whole set with a new one containing only that
value.
2020-09-21 12:14:50 +02:00
Pierre Donias
626e2fcb12 fix(xo-server/users): serialize properties on user create as well (#5273)
This didn't break anything because we usually don't assign `groups` and/or
`preferences` (which are the only 2 properties that need serialization) on user
creation.

This also prepares a minimal change to add a `authProviders` object property on
users.
2020-09-18 12:11:20 +02:00
Pierre Donias
592feb54b7 fix(xo-server/_authenticateUser): remove broken/unused provider API (#5270) 2020-09-18 10:54:20 +02:00
badrAZ
9c6b63e7e4 feat: release 5.50.3 (#5272) 2020-09-17 16:19:30 +02:00
badrAZ
4364a74b7a feat: technical release (patch) (#5271) 2020-09-17 16:07:58 +02:00
badrAZ
00f13102f8 feat(xo-server-audit): API method to clean DB (#5150) 2020-09-17 15:03:03 +02:00
badrAZ
3f17389871 fix(xo-server-audit): remove unused variable (#5268) 2020-09-17 10:51:09 +02:00
Julien Fontanet
726ba287b1 chore(xo-server-audit/_uploadLastHash): simplify conditions 2020-09-17 10:07:32 +02:00
Julien Fontanet
42ee29cb3c fix(xo-server-audit/_uploadLastHash): dont hide errors 2020-09-17 10:06:28 +02:00
badrAZ
8a98b6b012 feat(xo-server-audit/_uploadLastHash): check integrity sequentially (#5250)
- implementation is simpler
- stop on first error
2020-09-17 09:35:42 +02:00
Julien Fontanet
14ab694804 fix(xo-cli): mkdirp must not be promisified
Introduced by d622f7a65
2020-09-16 15:56:38 +02:00
Nicolas Raynaud
14b8cda543 fix(xo-vmdk-to-vhd/grabTables): read each entry independently (#5255)
Reading all entries at once cause problems on some VMDKs (those generated by VirtualBox) because they appear to be distributed throughout the VMDK thus making the buffer not fit in memory.

See https://xcp-ng.org/forum/topic/3374/cannot-import-ova-from-virtualbox/14?_=1599689219209
2020-09-16 11:46:10 +02:00
Julien Fontanet
4264e34ffd feat(xo-web/createSubscription): support lazy subscribers (#5158)
These subscribers follow the value of the subscription but do not make the
subscription refresh itself.

A lazy subscriber triggers an initial fetch if no value is available.
2020-09-16 10:49:54 +02:00
Pierre Donias
bd9bf55e43 feat(xo-web/groups): bulk deletion (#5264) 2020-09-16 10:46:35 +02:00
Albin Hedman
7c802bbd33 feat(xo-web/dashboard/health): add 'too many snapshots' section (#5238) 2020-09-14 10:45:37 +02:00
Julien Fontanet
9e37f3f586 feat(xo-web/new VM): hide missing VDIs
See #5222

Related to 15bc30a2d
2020-09-11 11:11:25 +02:00
Nicolas Raynaud
1d4f5d068a fix(xo-web/VM import): make description optional (#5258) 2020-09-11 08:45:10 +02:00
badrAZ
5be5eb80e8 feat: release 5.50.2 (#5257) 2020-09-10 17:03:26 +02:00
Julien Fontanet
12c774a34a feat(travis-tests): dont stop on first failure on master 2020-09-10 16:42:56 +02:00
badrAZ
14c3fa4378 feat: technical release (patch) (#5256) 2020-09-10 16:36:25 +02:00
badrAZ
2f17420721 feat(xo-web/backup/overview): add link from log to its job (#5202)
See #4564
2020-09-10 16:05:36 +02:00
badrAZ
8d7f8d156f fix(xo-server,xo-web/orphan VDIs): ignore irrelevant VDI types (#5249)
Fixes #5248
2020-09-10 16:00:20 +02:00
Julien Fontanet
38248d8c35 fix(test): auto map @xen-orchestra/*, @vates/* and xo-* 2020-09-10 15:32:08 +02:00
badrAZ
edaae02892 fix(xo-web,xo-server#probeIscsiLuns): handle undefined lun size (#5212)
See xoa-support#2815
See https://xcp-ng.org/forum/topic/3409/getting-error-when-trying-to-mount-iscsi-lun
2020-09-09 12:11:50 +02:00
Rajaa.BARHTAOUI
846eff4984 feat(xo-web/vm/networks): improve tooltip messages (#5227)
See https://github.com/vatesfr/xen-orchestra/issues/4713#issuecomment-667655321
2020-09-09 11:59:54 +02:00
badrAZ
481adf3a1e feat(xo-server-audit): don't save last hash when it doesn't change (#5251) 2020-09-08 14:35:19 +02:00
Julien Fontanet
d622f7a65c chore: update dependencies 2020-09-07 10:26:51 +02:00
badrAZ
a479501aef feat: release 5.50.1 (#5246) 2020-09-04 12:04:55 +02:00
badrAZ
2456374e5a feat: technical release (patch) (#5247) 2020-09-04 11:55:01 +02:00
badrAZ
c77016ea44 feat(xo-server-usage-report): ignore replicated VMs (#5241)
Fixes #4778
2020-09-04 11:42:32 +02:00
badrAZ
6fd45a37e2 feat: technical release (patch) (#5245) 2020-09-04 11:16:45 +02:00
badrAZ
9be56d3ab8 fix(xo-server-audit): handle non-existent XOA plugin (#5239)
See 38de5048bc (commitcomment-41875481)
2020-09-04 10:31:46 +02:00
Julien Fontanet
24b264b6c9 fix(xo-server): TX checksumming is enabled by default
Introduced by fe2de9c1154c5a0b183c6d7897f1d9c376fa4031

Fixes #5234
2020-08-28 16:01:26 +02:00
tonyuh
7f9130470b feat(docs/backup_troubleshooting): SR_OPERATION_NOT_SUPPORTED (#5232)
Add SR_OPERATION_NOT_SUPPORTED error troubleshooting.
2020-08-28 11:49:47 +02:00
Julien Fontanet
b82aa1daa5 feat: release 5.50 2020-08-27 15:06:49 +02:00
Julien Fontanet
53cb325974 feat: technical release 2020-08-27 14:46:33 +02:00
Julien Fontanet
1256c320e3 feat(xo-web/host/network): button to scan PIFs
Fixes #5230
2020-08-27 11:42:28 +02:00
Julien Fontanet
15bc30a2d5 feat(xo-web/iso-device): hide missing VDIs
Fixes #5222
2020-08-27 11:13:59 +02:00
Julien Fontanet
fc3bc8468f feat(xo-server/backup): add proxyId to job log 2020-08-27 10:54:44 +02:00
Julien Fontanet
b4e068f630 chore(xo-server/backup executor): proxyId = job.proxy 2020-08-26 16:50:33 +02:00
Pierre Donias
08eef80673 feat(xo-web/orphan VDIs): show VDI(-snapshot)s that don't have VBDs (#5228)
In the Dashboard > Health > Orphan VDIs table, show non-ISO VDIs and
VDI-snapshot that don't have any VBDs.
2020-08-25 09:32:21 +02:00
Pierre Donias
152f73ebf0 feat: technical release (#5226) 2020-08-20 15:15:34 +02:00
badrAZ
38de5048bc feat(xo-server-audit): backup last hash (#5077) 2020-08-20 12:32:22 +02:00
Rajaa.BARHTAOUI
c4d96fbc49 feat(xo-web/vm/network): ability to change VIF locking mode (#5188)
See #4713
2020-08-20 09:48:50 +02:00
BenjiReis
ff25d402c1 fix(sdn-controller): host.$PIFs can have undefined element (#5217) 2020-08-20 09:25:41 +02:00
Julien Fontanet
f957024605 chore(xo-web): use js-cookie instead of cookies-js (#5224)
See #5223

`cookies-js` is no longer maintained.
2020-08-19 17:18:03 +02:00
badrAZ
006e54e2fd feat(xo-web, xo-server/proxy): improve proxy health check errors (#5191)
Fixes #5161
2020-08-19 16:20:05 +02:00
badrAZ
5f7bc58788 fix(xo-server/sensitive-values): obfuscate params containing "password" (#5220)
Fixes #5219
2020-08-19 10:56:40 +02:00
Fabian Untermoser
bdd93603aa fix(docs/backups): fix typo (#5225) 2020-08-18 21:46:30 +02:00
Rajaa.BARHTAOUI
8392a17cb2 fix(xo-server/authentication): add missing 'createPredicate' (#5221)
Fixes #5218
Introduced by 9ded2641a7
2020-08-18 16:15:35 +02:00
Julien Fontanet
5f7f0b777e fix(xo-server): use http.cookies config everywhere 2020-08-17 11:06:45 +02:00
Julien Fontanet
3f574606d9 feat(backups-cli/clean-vms): display merge progress 2020-08-17 11:06:45 +02:00
badrAZ
45f0f93895 feat(xo-server,xo-web/VM): ability to set VIF TX checksumming (#5182)
Fixes #5095
See xoa-support#2619
2020-08-14 17:14:48 +02:00
badrAZ
af2710135b fix(xo-web/proxies): remove upgrade button style (#5216)
See https://github.com/vatesfr/xen-orchestra/pull/5167/files?file-filters%5B%5D=.md#r469763760

...when the proxy is already up to date
2020-08-13 16:52:29 +02:00
Rajaa.BARHTAOUI
95ed6094fe fix(xo-web/vm/snapshot): fix redirection when copying a VM (#5213)
Introduced by d9211053ce
2020-08-13 11:12:56 +02:00
BenjiReis
6af8ce9eeb feat(sdn-controller): specify tunnel protocol at its creation (#5210) 2020-08-13 11:11:11 +02:00
badrAZ
3ff37f00fe fix(xo-web/deploy-proxy): throw error on trial start failure (#5196)
Introduced by 902953a1fa
2020-08-12 15:11:49 +02:00
Pierre Donias
ed5b066cbe fix(CHANGELOG.unreleased): remove sdn-controller package (#5214)
Introduced by cec5593c70
2020-08-12 12:21:18 +02:00
Mark Martin
cec5593c70 feat(xo-web/vm): protect from accidental shutdown (#5107)
Fixes #5090
2020-08-12 12:17:30 +02:00
Julien Fontanet
04924884ad feat(@xen-orchestra/backups-cli): 0.1.0 2020-08-11 09:57:01 +02:00
Julien Fontanet
3ccf64fcd3 feat(backups-cli/clean-vms): merge single children 2020-08-11 09:56:25 +02:00
Julien Fontanet
8eb7f9b91c fix(xo-server-sdn-controller): remove deprecated uuid import 2020-08-10 11:15:40 +02:00
Julien Fontanet
f25c50c629 chore: update dev deps 2020-08-10 11:15:40 +02:00
Rajaa.BARHTAOUI
e524a1b865 feat: release 5.49.1 (#5207) 2020-08-05 14:46:12 +02:00
Rajaa.BARHTAOUI
ac15e3355e feat: technical release (#5206)
* feat(xo-server-sdn-controller): 1.0.2

* feat(xo-web): 5.67.0

* chore(CHANGELOG): update next
2020-08-05 13:39:50 +02:00
Julien Fontanet
0930a37819 fix(CHANGELOG.unreleased): add xo-server patch
Due to 2789ead99
2020-08-05 12:33:30 +02:00
Rajaa.BARHTAOUI
d62f91a9e6 feat(xo-web/sr/advanced): show thin/thick provisioning for missing SR types (#5204) 2020-08-05 11:15:55 +02:00
Julien Fontanet
2789ead999 fix(xo-server/pool.listMissingPatches): really dont log errors
Previous fix (e1bf68ab3) was incorrect.
2020-08-05 11:10:35 +02:00
BenjiReis
f25fd267dd fix(sdn-controller): only admin can create private networks (#5200) 2020-08-04 14:09:33 +02:00
BenjiReis
47999f1f72 doc(sdn-controller): indicate correct version in OpenFlow requirements (#5199) 2020-08-03 16:47:13 +02:00
Pierre Donias
095bbcd15c feat: release 5.49.0 (#5195) 2020-07-31 14:14:32 +02:00
Pierre Donias
9177bb8451 feat: technical release (patch) (#5194) 2020-07-31 09:41:11 +02:00
Pierre Donias
119bf9b0ff feat(xo-web/VM/network): click on IP address to copy it (#5186)
Fixes #5185
2020-07-31 09:17:37 +02:00
Julien Fontanet
015c6037c4 fix: add prepublishOnly to replace removed prepare scripts
Introduced by 452a7e744
2020-07-30 19:07:36 +02:00
Adam Stankiewicz
452a7e7445 feat(test): remove need for prepare scripts (#5192) 2020-07-30 18:56:13 +02:00
Nicolas Raynaud
407586e2d5 feat(remotes): AWS S3 backup storage (#5037) 2020-07-30 16:47:04 +02:00
badrAZ
ffa431a3cd fix(xo-web/vm/tab-network): add default value to plugins (#5190)
Introduced by 2a74a49995

Plugins can be `undefined` on fetching which triggers the error `Cannot read property "some" of undefined`
2020-07-30 14:57:06 +02:00
Julien Fontanet
281a5ff991 chore: remove unused JSHint comments 2020-07-30 14:32:19 +02:00
BenjiReis
92db9bd284 fix(xo-server-sdn-controller): deactive DH for TLS connections (#5187)
Fixes #5074
2020-07-30 13:17:40 +02:00
Julien Fontanet
ea8f319f45 feat(self-signed): expose days option 2020-07-30 11:20:57 +02:00
Olivier Lambert
a11e9fe04e fix(changelog): caps typo (#5184) 2020-07-29 16:58:10 +02:00
Pierre Donias
27367bd1fc fix(CHANGELOG): wrong xo-server version (#5183) 2020-07-29 16:50:16 +02:00
Pierre Donias
c6f48ae054 feat: technical release (#5181) 2020-07-29 16:32:55 +02:00
Rajaa.BARHTAOUI
7d6efe3694 feat(xo-web/vm/network): improve the VIF locking mode feedback (#5170)
See #4713
2020-07-29 15:55:59 +02:00
Rajaa.BARHTAOUI
f4aad05edc feat(xo-web/backup): show warning if min(fullBackupInterval, retention)>50 (#5144)
See https://xcp-ng.org/forum/post/27539
2020-07-29 15:30:38 +02:00
Pierre Donias
d8f7637ca0 feat(xo-web/self): ability to cancel edition of resource set (#5174)
See xoa-support#2767
2020-07-29 13:59:45 +02:00
badrAZ
f9a7bd199e fix(xo-server#createVm): change network boot priority (#5119)
Fixes #4980
2020-07-29 11:34:24 +02:00
Rajaa.BARHTAOUI
68b7ed284a feat(xo-web/backup/health): show detached VM snapshots (#5125)
Fixes #5086
2020-07-29 10:56:31 +02:00
badrAZ
e782895cf5 feat(xo-server-audit): add extension to exported records (#5180) 2020-07-29 10:52:06 +02:00
Julien Fontanet
a5935b40d5 feat(xo-server/api): user must be signed in by default (#5175)
It's a lot more secure than previous default value.
2020-07-29 10:40:17 +02:00
badrAZ
035d2cb440 fix(xo-server-audit): fix incorrect records content type (#5179) 2020-07-29 10:38:59 +02:00
BenjiReis
2a74a49995 feat(sdn-controller, xo-web): add & remove network rules to a VM's VIFs (#5177) 2020-07-29 09:56:06 +02:00
badrAZ
902953a1fa feat(xo-server, xo-web): display proxy available upgrades (#5167) 2020-07-28 17:13:01 +02:00
Pierre Donias
1ffef91b7a fix(xo-web/copyVm): correctly pass the VM type to copyVms (#5173)
Fixes xoa-support#2773

The modal uses the type to find the objects (either VMs or snapshots) and use
them to generate the names. The missing type caused the VM clones to be named
`undefined_clone`.
2020-07-28 16:29:37 +02:00
Julien Fontanet
3d13d9b0dc feat(xo-server/addApiMethod): check method props 2020-07-28 16:02:32 +02:00
Nicolas Raynaud
adcc5d5692 feat(import/ova): allow import of gzipped vmdk disks (#5085) 2020-07-28 11:52:44 +02:00
badrAZ
c49d70170e feat(xo-server,xo-web/proxy/deploy): ability to set HTTP proxy (#5145) 2020-07-28 11:51:57 +02:00
badrAZ
349a78a5bd fix(xo-web/file-restore): ignore proxy remotes (#5171)
See xoa-support#2741
2020-07-28 11:43:33 +02:00
badrAZ
48734c6896 fix(xo-web/proxies): don't open proxy VM in new tab (#5172) 2020-07-28 10:23:16 +02:00
Rajaa.BARHTAOUI
0f60a3b24d feat(xo-web/home): ability to filter by power state (#5118) 2020-07-27 16:52:07 +02:00
Pierre Donias
d3a88011a6 feat(xo-server/self): can ignore VM snapshots resources usage (#5164)
See xoa-support#2643

With the config option `selfService.ignoreVmSnapshotResources`
2020-07-27 16:08:20 +02:00
Rajaa.BARHTAOUI
9b6e4c605b feat(xo-web/schedules): ability to enable schedule when editing (#5111)
Fixes #5026

This change affects ordinary jobs only, not backup jobs
2020-07-27 15:46:21 +02:00
Nicolas Raynaud
7c91524111 fix(OVA import): allow import of .ova files generated by Red Hat (#5159)
See xoa-support#2713.

 - use <rasd:Address> when <rasd:AddressOnParent> is not available on disks
 - avoid dotfiles and pax headers in tar parser.
2020-07-27 08:24:01 +02:00
Olivier Lambert
e1573069e4 fix(docs/license): truly fix the warning tag (#5169) 2020-07-24 10:08:58 +02:00
marcpezin
f2459c964b Fixing warning closing tag (#5168)
Fixing warning closing tag
2020-07-24 09:20:36 +02:00
Pierre Donias
43aa0b815d feat(xo-web/VM/disks): sort disks by device by default (#5165)
Fixes #5163
2020-07-23 09:53:07 +02:00
marcpezin
0740630e05 fix(docs): rebind license documentation update (#5166) 2020-07-21 17:16:18 +02:00
Rajaa.BARHTAOUI
c9244b2b13 feat(xo-web): log Invalid XML-RPC message error as an unexpected response (#5138)
See xoa-support#2588
2020-07-21 15:11:57 +02:00
Pierre Donias
0d398f867f fix(xo-web/home): link to global filter section (#5157) 2020-07-16 15:32:44 +02:00
Julien Fontanet
b74ec2d7d3 fix(xo-web/backup/restore): dont fail if no backups for a VM (#5156)
Fixes xoa-support#2707

The API does not guarantee that each VM UUID will have at least a backup, and when it happens, the code failed because `first` and `last` where not properly defined.
2020-07-16 14:29:10 +02:00
Julien Fontanet
26a295c8ed chore(xo-web/createSubscription/run): add small comment 2020-07-13 16:13:33 +02:00
Julien Fontanet
2a71d3d20c chore(xo-web/createSubscription): rename loop to run 2020-07-13 16:10:48 +02:00
Pierre Donias
b79605b692 feat: release 5.48.3 (#5154) 2020-07-10 18:12:03 +02:00
Pierre Donias
ea0fc68a53 feat: technical release (patch) (#5153) 2020-07-10 16:38:41 +02:00
badrAZ
1ca5c32de3 feat(xo-web/audit): show warning in case of disabled logs record (#5152) 2020-07-10 15:32:30 +02:00
Julien Fontanet
f51bcfa05a feat(xo-server-audit): add active setting (default false) (#5151) 2020-07-10 14:29:30 +02:00
Pierre Donias
e1bf68ab38 fix(xo-server/pool.listMissingPatches): don't log errors (#5149)
Work-around to avoid generating too many logs
2020-07-10 12:49:37 +02:00
Pierre Donias
99e03b7ce5 fix(xo-web): broken doc links (#5146)
Introduced by 30d69dadbb
2020-07-10 09:14:55 +02:00
Julien Fontanet
cd70d3ea46 fix(Travis CI): use Node 12 (#5147) 2020-07-09 15:51:22 +02:00
Julien Fontanet
d387227cef fix(xo-server/backups): dont ignore proxy job result/error 2020-07-09 09:40:02 +02:00
Pierre Donias
2f4530e426 feat: release 5.48.2 (#5143) 2020-07-07 15:49:34 +02:00
badrAZ
4db181d8bf chore(xo-server-audit): document audit DB strucure (#5078) 2020-07-07 15:22:41 +02:00
Pierre Donias
9a7a1cc752 feat: technical release (#5142) 2020-07-07 15:03:04 +02:00
Pierre Donias
59ca6c6708 feat(xo-web): prevent XO from checking time consistency of halted hosts 2020-07-07 14:51:06 +02:00
Pierre Donias
fe7901ca7f feat(xo-web): prevent XO from listing missing patches on halted XCP-ng hosts
Otherwise it triggers a lot of errors on XCP-ng
2020-07-07 14:51:06 +02:00
Pierre Donias
9351b4a5bb feat(xo-web/backup/logs): better resolution of last run log (#5141) 2020-07-07 13:47:32 +02:00
badrAZ
dfdd0a0496 fix(xo-server-test): extend timeout of deleteTempResources (#5117) 2020-07-07 13:31:13 +02:00
Pierre Donias
cda39ec256 fix(xo-web/backup/edit): tags overwritten by default ones (#5136)
Introduced by 1c042778b6
See xoa-support#2663

It was due to a race condition between the fetch of the default excluded tags
and the fetch of the job (and its schedules) which made the component populate
the form with the job's information.

Changes:
- `Edit` waits for the `job` and the `schedules` before rendering its child
- `New`'s wrapper waits for the `remotes` and the `suggestedExcludedTags` before
  rendering `New`
- `New`: `updateParams` is now called in `initialize` because we don't need to
  wait for the job and the schedules any more to be able to populate the form
2020-07-07 09:40:40 +02:00
Olivier Lambert
3720a46ff3 feat(docs/supported_hosts): no pro support for XS < 6.5 (#5137) 2020-07-06 20:03:47 +02:00
Julien Fontanet
7ea50ea41e fix(xo-server/callProxyMethod): dont use HTTP proxy 2020-07-06 17:06:37 +02:00
Pierre Donias
60a696916b feat: release 5.48.1 (#5133) 2020-07-03 15:25:39 +02:00
Pierre Donias
b6a255d96f feat: technical release (patch) (#5132) 2020-07-03 14:24:40 +02:00
marcpezin
44a0cce7f2 fix(docs/license_management): replace confusing screenshot about activation (#5131) 2020-07-03 12:03:07 +02:00
Nicolas Raynaud
f580e0d26f fix(import/OVA): fix big size parsing in OVA files (#5129) 2020-07-03 11:48:39 +02:00
Rajaa.BARHTAOUI
6beefe86e2 feat(xo-web/backup): don't open edition in new tab (#5130) 2020-07-03 11:45:06 +02:00
Julien Fontanet
cbada35788 fix(xo-server/file restore): dont fail on LVM partitions
Fixes xoa-support#2640

Introduced by 48ce7df43

The issue was due to object spreading copying only own properties but `path` is now an inherited property due to `dedupeUnmount`.
2020-07-03 11:05:04 +02:00
Julien Fontanet
44ff2f872d feat(xo-server/getBackupNgLogs): dont fail on undefined/null errors
See xoa-support#2663

This should almost never happen but if it does, it should not prevent logs from being consolidated.
2020-07-03 09:22:28 +02:00
Julien Fontanet
2198853662 feat(xo-server/logs-cli): can match on missing props 2020-07-03 09:22:28 +02:00
badrAZ
4636109081 fix(xo-web/(file-)restore-legacy): ignore proxy remotes (#5124)
Legacy restore doesn't support proxy remotes
2020-07-02 16:23:36 +02:00
Pierre Donias
1c042778b6 feat(xo-server,xo-web/smart backup): exclude XO Proxy VMs by default (#5128) 2020-07-02 15:06:47 +02:00
Rajaa.BARHTAOUI
34b5962eac fix(xo-web/backup/health): missing noop function (#5126)
Introduced by committing a suggestion https://github.com/vatesfr/xen-orchestra/pull/5062#discussion_r446135166 
without taking into account that the `noop` function is not already defined.
2020-07-02 15:05:55 +02:00
Rajaa.BARHTAOUI
fc7af59eb7 chore(xo-web/home): remove 'tags' filter from selector (#5121)
See https://github.com/vatesfr/xen-orchestra/pull/5118#discussion_r447586676
2020-07-02 14:52:59 +02:00
Olivier Lambert
7e557ca059 feat(docs/supported hosts): add CH 8.2 LTS in the list of supported hosts (#5127) 2020-07-02 09:30:16 +02:00
Julien Fontanet
1d0cea8ad0 feat(xo-server/logs-cli): add --delete command 2020-07-01 18:04:45 +02:00
Julien Fontanet
5c901d7c1e fix(xo-server/logs-cli): dont fail on non-string value 2020-07-01 18:01:34 +02:00
Julien Fontanet
1dffab0bb8 feat(xen-api): 0.29.0 2020-07-01 17:11:19 +02:00
Julien Fontanet
ae89e14ea2 feat(xo-server/getRemoteHandler): throw for proxy remotes 2020-07-01 11:46:28 +02:00
Pierre Donias
908255060c feat: release 5.48.0 (#5123) 2020-06-30 17:25:16 +02:00
Pierre Donias
88278d0041 feat: technical release (patch) (#5122) 2020-06-30 16:51:20 +02:00
Julien Fontanet
86bfd91c9d feat(xo-server/backup): logs proxy support 2020-06-30 15:45:40 +02:00
Julien Fontanet
0ee412ccb9 feat(xo-server/callProxyMethod): allow proxy.address to contain port 2020-06-30 15:20:58 +02:00
Julien Fontanet
b8bd6ea820 chore(xo-server/callProxyMethod): use parse.result to handle errors 2020-06-30 12:14:45 +02:00
Julien Fontanet
98a1ab3033 fix(xo-server/callProxyMethod): destroy lines stream in case of error 2020-06-30 12:14:45 +02:00
Julien Fontanet
e360f53a40 fix(xo-server/callProxyMethod): all lines should be JSON parsed 2020-06-30 12:14:45 +02:00
Julien Fontanet
237ec38003 fix(xo-server/callProxyMethod): lines is an object stream 2020-06-30 12:14:45 +02:00
Julien Fontanet
30ea1bbf87 feat(xo-server/callProxyMethod): expectStream as named option 2020-06-30 12:14:45 +02:00
Pierre Donias
0d0aef6014 feat: technical release (patch) (#5120) 2020-06-30 11:40:44 +02:00
badrAZ
1b7441715c feat(xo-server-perf-alert): regroup items with missing stats in one email (#4413)
Fixes #5104
2020-06-30 09:30:20 +02:00
badrAZ
e3223b6124 fix(xo-web/audit): ref not correctly forwarded (#5106)
Introduced by 9f29a047a7

The high level component (audit UI) need to call a `SortedTable` method. The only way to do it is to have access to its ref.

All components between the high level component and the `SortedTable` should forward this ref. Unfortunately, the commit  9f29a047a7 decorate the `StortedTable` with `withRouter` without forwarding its ref which breaks the audit check integrity feedback.
2020-06-29 15:44:33 +02:00
Julien Fontanet
41fb06187b fix(coalesce-calls/README): fix import 2020-06-29 15:39:14 +02:00
Julien Fontanet
adf0e8ae3b feat(@vates/coalesce-calls): 0.1.0 2020-06-29 15:33:53 +02:00
Rajaa.BARHTAOUI
42dd1efb41 feat(xo-web/home): remove unnecessary condition (#5116)
Introduced by f736381933

Backup filter: remove the needless condition to go to the first page.
2020-06-29 15:24:28 +02:00
badrAZ
b6a6694abf fix(xo-server-test/job with non-existent VM): logged as failed task (#5112)
Since c061505bf8, missing VMs are logged as a failure tasks
2020-06-29 14:04:23 +02:00
Pierre Donias
04f2f50d6d feat: technical release (#5115) 2020-06-26 15:56:40 +02:00
Rajaa.BARHTAOUI
6d1048e5c5 feat(xo-web/backup/health): show detached backups (#5062)
See #4716
2020-06-26 14:45:01 +02:00
Pierre Donias
fe722c8b31 feat(xo-web/licenses): rebind license to this XOA (#5110)
See xoa#55
Requires xoa#58

When an XOA license is bound to another XOA, allow the user to move it to the
current XOA (thus unbinding it from the other one).
2020-06-26 13:12:53 +02:00
badrAZ
0326ce1d85 feat(xo-server-audit): ignore common methods without side effects (#5109)
Ignoring these methods reduce the number of records in the audit which makes it easier to analyze and store.
2020-06-25 16:55:57 +02:00
Rajaa.BARHTAOUI
183ddb68d3 fix(changelog): missing a parenthesis (#5113) 2020-06-25 15:53:30 +02:00
badrAZ
d7fe1afc08 fix(xo-server#listVmBackups): provide schedule ID (#5101)
Introduced by b138438036
Schedule ID is used by [xo-server-test](c1d588264c/packages/xo-server-test/src/_xoConnection.js (L216))
2020-06-25 10:20:17 +02:00
Rajaa.BARHTAOUI
ae9aeaf5fd feat(xo-server,xo-web/SR): expose thin/thick provisioning (#5081)
Fixes #2208
2020-06-24 16:21:23 +02:00
Rajaa.BARHTAOUI
ec9476216f feat(xo-web/sr/disks): add tooltip for disabled migration (#4884) 2020-06-24 16:07:48 +02:00
badrAZ
619f2ef119 fix(VM): support old ipv4 protocol (#5098)
See xoa-support#2540
Indroduced by 7f64cd1801
2020-06-24 15:44:52 +02:00
Rajaa.BARHTAOUI
52020abde8 feat(xo-web/home): don't use SortedTable for VMs (not) backed up (#5046)
Introduced by f736381933
2020-06-24 14:12:37 +02:00
badrAZ
1bd504d67e feat: differentiate PV drivers and management agent (#5007)
Fixes #4783
2020-06-24 11:50:45 +02:00
badrAZ
edc4414de4 fix(xo-server/remotes): inability to get remotes info (#5093)
Introduced by 218bd0f
2020-06-23 11:12:16 +02:00
Olivier Lambert
c1d588264c feat(docs/backups): crop delta images (#5097) 2020-06-19 10:00:25 +02:00
badrAZ
94b84b75ad feat(xo-web/backup): document full backup interval functionality (#5052)
Fixes #4986
2020-06-19 09:43:13 +02:00
Olivier Lambert
b72a4c5aa9 feat(docs/proxy): add missing image and store them locally (#5096) 2020-06-18 21:37:19 +02:00
Julien Fontanet
857a9f3efc feat(xen-api): optional sync traces (#5091)
Initial actions call stacks are often missing from the resulting error for the following reasons:

- low level Node functions don't have proper stack traces
- replies handling maybe separate from requests (eg watchers)

This commit adds the option `syncStackTraces` that works around this, it has a performance impact but is useful for debugging.
2020-06-18 17:19:21 +02:00
badrAZ
ce53128657 feat(xo-server-audit): ignore xoa.getApplianceInfo (#5083)
`xoa.getApplianceInfo` doesn't have any side effect and is called many times.
2020-06-18 15:16:12 +02:00
Rajaa.BARHTAOUI
d9211053ce feat(xo-web/home/template): ability to copy/clone VM templates (#5006)
Fixes #4734
2020-06-18 15:13:12 +02:00
Rajaa.BARHTAOUI
e8316178a0 feat(xo-web/plugins): disable "Test plugin" if not loaded (#5038) 2020-06-18 14:33:18 +02:00
badrAZ
bf763d2cf4 feat(xo-web/backup): add placeholder to report recipients input (#5051)
Fixes #5035
2020-06-17 16:22:38 +02:00
badrAZ
eba5b34982 fix(xo-server#moveVdi): moveVdi should always return a VDI (#5073)
Fixes #5072
2020-06-16 20:56:00 +02:00
Pierre Donias
afb8b3dd6b feat(xo-server,xo-web/vm): protect from accidental deletion (#5045)
Fixes #4773
2020-06-16 15:40:49 +02:00
Julien Fontanet
c5fa94894b feat(xen-api): require Node >=7.6
Native support of async functions which leads to better stack traces.
2020-06-16 12:54:51 +02:00
Pierre Donias
4137758caa fix(xo-web/tooltip): use pointer events instead of mouse events (#5084) 2020-06-15 17:29:40 +02:00
Nicolas Raynaud
3578d16e9e fix(xo-server): correctly import vmdkToVhd (#5087)
Introduced in 5ee1ceced
2020-06-15 17:00:49 +02:00
BenjiReis
3ef263a5cc fix(xo-server-sdn-controller): correctly find preferred center's pool (#5080) 2020-06-15 11:13:01 +02:00
BenjiReis
510460c966 fix(xo-web): dont pass preferredCenter to sdnController.createPrivateNetwork (#5079) 2020-06-13 10:00:08 +02:00
Julien Fontanet
f74ecc53ae chore(xo-server): use @vates/decorate-with 2020-06-12 11:18:47 +02:00
Julien Fontanet
c4121073ad feat(@vates/decorate-with): 0.0.1 2020-06-12 11:12:49 +02:00
Julien Fontanet
9ded2641a7 chore(xo-server/authentication): remove unused import 2020-06-12 11:02:42 +02:00
Julien Fontanet
295ca68d02 chore(xo-server): use @vates/parse-duration 2020-06-12 11:02:42 +02:00
Julien Fontanet
27f53f262b feat(@vates/parse-duration): 0.1.0 2020-06-12 11:02:42 +02:00
Olivier Lambert
3fc16cb414 feat(docs/backups): warn of 99 chain limit for file restore (#5070) 2020-06-11 14:29:49 +02:00
Pierre Donias
90db25d732 fix(xo-web/notifications): set cookie expiration date (#5067)
Without an expiration date, the cookie expires at the end of the session and
read notifications are marked as unread the next time the user connects.
2020-06-11 12:34:33 +02:00
Julien Fontanet
bbb359470e fix(xo-server/backup): remove enumerable xapi on SR records (#5069)
Fixes xoa-support#2527

This was causing huge logs in case of CR/DR errors because this property was included and pulled in all XAPI records.

Instead of making it non-enumerable, I was able to remove entirely because records now already include a non-enumerable `$xapi` property.
2020-06-10 11:25:32 +02:00
badrAZ
319652c7c7 fix(xo-web/migrate-vdi): remove inter-pool migration possibility (#5050) 2020-06-10 09:16:14 +02:00
Julien Fontanet
c9c271fee8 feat(xen-api): $xapi defined on prototype instead of record
This should reduce a bit memory consumption.
2020-06-09 23:17:02 +02:00
marcpezin
ca0755e92b fix(docs/delta-backup): schemas should not display XVA (#5032) 2020-06-09 15:50:13 +02:00
Rajaa.BARHTAOUI
acd38597f6 fix(xo-web/vm/network): VM addresses can be null (#5049)
Introduced by 7f64cd1801
2020-06-09 15:12:04 +02:00
Pierre Donias
f4a5a80f3c fix(xo-web/SR): fix name_label edition from the home view (#5058)
Fixes #5057
Introduced by da468c46ee
2020-06-09 13:38:42 +02:00
Pierre Donias
c45d00fee8 fix(xo-web/import): default sub-route should be /vm (#5056)
Fixes #5055
Introduced by a95d7796bc
2020-06-08 16:31:02 +02:00
Ronan Abhamon
ffae59fa1c feat(changelog): missing entries for #5054 (#5066) 2020-06-08 11:17:38 +02:00
Pierre Donias
b697178f68 feat(xo-web/SortedTable): always show amount of selected items (#5041)
Fixes #4982
2020-06-08 10:57:37 +02:00
Julien Fontanet
83ade5eecb chore(CHANGELOG.unreleased): clarify that packages are not yet released 2020-06-08 10:54:42 +02:00
Ronan Abhamon
6973b92c4a fix(load-balancer): fix memory check condition in the performance plan
We must migrate a VM if the free memory in the destination host is lower than the used VM
memory!
2020-06-08 10:22:34 +02:00
Ronan Abhamon
6261f8a778 feat(load-balancer): add various logs to explicit migration checks and steps 2020-06-08 10:22:34 +02:00
badrAZ
6048493ac6 fix(xo-server#_extractIpFromVmNetworks): support old ipv4 protocol (#5036)
See xoa-support#2540

In case of an old version of guest tools, the VM ipv4 isn't reported.

This issue is due to a non-existant `n/ipv4/m` property in the VM addresses which is a new protocol.
2020-06-08 09:52:33 +02:00
Pierre Donias
1cbd715235 feat(xo-web/new-vm): dont prefill VM description (#5047)
Fixes #4981

Except if the template is a custom template
2020-06-05 14:52:31 +02:00
Julien Fontanet
703fcbccd6 feat(xo-server/xo.exportConfig): entries param
Can be used to export a subset of the config, example:

```
xo.exportConfig entries=["acls"]
```

This will only export `acls` entries and dependencies (`groups` and `users`).
2020-06-05 13:57:54 +02:00
Julien Fontanet
2f9cbec07e feat(xo-cli): support @=- to output to stdout 2020-06-05 13:57:54 +02:00
badrAZ
9f0b22d3e9 fix(xo-server#createVm): move VDIs before resize them (#5044)
See xoa-support#2535

Otherwise resizing might file due to space limitation on the template VDI's SR.
2020-06-05 13:37:18 +02:00
Julien Fontanet
ab5907c09c feat(xo-server/logs-cli): implement --gc 2020-06-05 10:58:26 +02:00
Olivier Lambert
fae0b168f6 feat(docs/load_balancing): various improvements (#5048) 2020-06-04 10:49:26 +02:00
Julien Fontanet
f18e98a63e chore: reformat code with Prettier 2020-06-03 11:03:03 +02:00
Julien Fontanet
3524886d5d chore: update dev dependencies 2020-06-03 11:03:03 +02:00
Julien Fontanet
fb44eea06c fix(xo-server): load globally installed plugin
It has been broken by d4526e1ed

Thanks @Danp2 for the report!
2020-06-02 20:44:33 +02:00
Julien Fontanet
3ea4c757e6 feat(backups-cli): clean checksums for missing XVAs 2020-06-02 15:27:36 +02:00
badrAZ
cfb8d79049 feat: release 5.47.1 (#5043) 2020-06-02 13:40:36 +02:00
badrAZ
1ea86da7af feat: technical release (patch) (#5042) 2020-06-02 13:02:21 +02:00
Julien Fontanet
e289f2dba2 fix(auth-ldap/authenticate): dont use second param as logger (#5039) 2020-06-02 11:11:25 +02:00
Rajaa.BARHTAOUI
7f64cd1801 feat(xo-web/vm/network): show IPs in front of their VIFs (#5003)
Fixes #4882
2020-06-02 09:26:31 +02:00
Julien Fontanet
d4526e1ed2 feat(xo-server): load @xen-orchestra/server-* plugins 2020-06-01 21:06:04 +02:00
Julien Fontanet
34f42216c8 feat(*/README.md): better badges 2020-06-01 14:41:52 +02:00
Julien Fontanet
a26a24a8ad fix(normalize-packages): dont replace author in READMEs 2020-06-01 14:06:09 +02:00
Julien Fontanet
4530fd4164 chore(*/package.json): normalize author to Vates SAS 2020-06-01 14:06:09 +02:00
Olivier Lambert
9156b8f48c feat(docs): merge and clean old docs into new one (#5025) 2020-06-01 11:32:27 +02:00
Julien Fontanet
6212109fc1 feat(@vates/read-chunk): 0.1.1 2020-05-29 15:10:20 +02:00
Julien Fontanet
c22a080e23 fix(read-chunk): not an ES module 2020-05-29 15:10:20 +02:00
Julien Fontanet
834a7109f9 fix: add @vates to list of workspaces 2020-05-29 15:10:20 +02:00
badrAZ
7cbf32202d feat: release 5.47.0 (#5031) 2020-05-29 12:29:41 +02:00
Julien Fontanet
d0b9380dca fix(*/README): license link 2020-05-28 21:24:20 +02:00
Julien Fontanet
13fd9be566 feat(*/README.md): re-generate for all packages 2020-05-28 20:56:14 +02:00
Julien Fontanet
53a9aa6ad2 fix(vhd-lib): dont prefer global install 2020-05-28 20:29:10 +02:00
Julien Fontanet
c2ce4aca1b feat(async-map/package.json): add description 2020-05-28 20:28:52 +02:00
Julien Fontanet
567f6d7cc0 fix: prefer global install for CLIs 2020-05-28 20:28:28 +02:00
Julien Fontanet
489c0b27f9 fix: use AGPL-3.0-or-later licenses for xo pkgs 2020-05-28 20:27:39 +02:00
Julien Fontanet
343f988584 fix: use AGPL-3.0-or-later license identifier
`AGPL-3.0` identifier has been deprecated by SPDX.org
2020-05-28 20:26:55 +02:00
Julien Fontanet
7f676c56c8 feat(normalize-packages): add license to all packages 2020-05-28 16:05:55 +02:00
Julien Fontanet
3c0ca7026f fix(read-chunk/README): fix pkg name 2020-05-28 16:05:55 +02:00
Rajaa.BARHTAOUI
2ceba11aa7 feat: technical release (#5028) 2020-05-28 16:04:13 +02:00
Julien Fontanet
6db5e0b27c feat(@vates/read-chunk): 0.1.0 2020-05-28 14:49:00 +02:00
Julien Fontanet
dfecb801db fix(read-chunk/USAGE): fix pkg name 2020-05-28 14:48:27 +02:00
Julien Fontanet
c10bfe3db2 feat(read-chunk): module to read data from stream 2020-05-28 14:45:22 +02:00
Julien Fontanet
20fb2c99bc feat(normalize-packages): generate README.md from USAGE.md 2020-05-28 14:45:21 +02:00
Pierre Donias
b4a0b5c58b fix(xo-server/setData): dont wait for update if no changes (#5027)
If an other_config entry is set to the same value as it was before, the object
will not be updated and the _waitObject promise will "never" resolve.
2020-05-28 14:01:54 +02:00
badrAZ
faa46c2a21 fix(xo-web/modal#form): defer rendering until all props are set (#5024)
The set default value is not used in the first render due to a race condition between the modal render and the modal value.

To avoid this race condition and multiple renders, the modal should open at the end of the set of its properties.
2020-05-28 11:19:25 +02:00
badrAZ
9691199ae8 feat(xo-web/proxies): start trial if no license available (#5022)
See xoa#54
2020-05-28 10:58:43 +02:00
Rajaa.BARHTAOUI
f736381933 feat(xo-web/home): ability to list VMs which are (not) backed up (#4974)
Fixes #4777
2020-05-28 10:10:34 +02:00
Julien Fontanet
f44e5b3b7a fix(babel-config): remove auto useBuiltIns
Too magical, caused too much problems.
2020-05-27 10:25:41 +02:00
Julien Fontanet
6e24bf5f8c fix(xo-{cli,upload-ova}): remove deprecated dep @babel/polyfill 2020-05-27 10:13:54 +02:00
Julien Fontanet
8fb43e31c5 fix(babel-config): useBuiltIns only if core-js
Because `@babel/polyfill` is deprecated.

See https://babeljs.io/docs/en/babel-preset-env#usebuiltins
2020-05-27 10:13:30 +02:00
Julien Fontanet
0860c80e51 fix(*/README): legacy project URLs 2020-05-27 10:04:00 +02:00
Julien Fontanet
66fc25756f Revert "feat(xo-server): load plugins from mono-repo"
This reverts commit 3e3ce543a8.

This can cause problems due to duplicate loading.
2020-05-27 09:53:46 +02:00
Olivier Lambert
f008e240cd feat(docs/installation): banner explanation (#5023) 2020-05-27 09:44:36 +02:00
BenjiReis
8d7e95d6e9 feat(sdn-controller/new network): choose preferred center (#5000)
Fixes #4991
2020-05-26 16:56:46 +02:00
Julien Fontanet
3e3ce543a8 feat(xo-server): load plugins from mono-repo 2020-05-26 14:01:43 +02:00
Julien Fontanet
6c447a82f1 chore(audit-core): remove unused dev dep 2020-05-26 13:59:06 +02:00
Julien Fontanet
64a0918ff1 chore(yarn.lock): update dependencies 2020-05-26 13:59:06 +02:00
Nicolas Raynaud
9274223701 chore(server): dont handle errors in registerHttpRequest() handlers (#5021)
`registerHttpRequest()` has built in error handling/logging.
2020-05-26 12:19:24 +02:00
Pierre Donias
1368c18844 feat(xo-web): disclaimer banner cooldown (#5008) 2020-05-26 10:59:10 +02:00
Pierre Donias
67a60a7557 feat(xo-web/config): UI for the encrypted config export/import (#4997)
See 1da889e420
2020-05-25 14:58:48 +02:00
badrAZ
3d5fd47748 feat(audit): record failed users' connection attempt (#4900)
See #4844
2020-05-25 12:48:05 +02:00
Julien Fontanet
b9a18807ae fix(xo-server/_handleHttpRequest): dont write if something has been sent 2020-05-25 09:58:03 +02:00
marcpezin
088c0b6321 fix(docs): replace the delta backup image with the right file type (#5019)
Replace `.xva` with `.vhd`
2020-05-25 09:23:30 +02:00
Nicolas Raynaud
ecee11a24c feat(xo-server/OVA import): comptibility with version 2.0 (#4921) 2020-05-25 08:50:32 +02:00
Olivier Lambert
ec8df7ce57 fix(docs): properly add license management to menu (#5018) 2020-05-23 22:16:58 +02:00
Julien Fontanet
4159fd2ffb fix(backups-cli/_fs/readdir2): dont warn on missing dir 2020-05-22 23:48:15 +02:00
Julien Fontanet
1a1d21bbb3 fix(backups-cli/clean-vms): isValidXva is a named import 2020-05-22 23:48:14 +02:00
marcpezin
be1045fed9 feat(docs): license management (#5015)
* licensing documentation

How to bind license in XOA

* Update license-management.md

* Add files via upload

license activation image

* fix links

* fix wording

* adding license management in menu

* Update license-management.md
2020-05-22 16:47:14 +02:00
Olivier Lambert
e43773c712 feat(docs/delta_backups): manual initial seed (#5011) 2020-05-22 14:03:07 +02:00
Olivier Lambert
30d69dadbb feat(docs): major rewrite using vue-press (#4957) 2020-05-21 11:46:24 +02:00
badrAZ
b138438036 feat(xo-server#_listVmBackupsOnRemote): remove unused properties (#4985)
This reduce by 10/100 times the quantity of data sent to the clients, which should improve performance.
2020-05-19 14:25:33 +02:00
badrAZ
d649211330 fix(xo-server-backup-reports): fix No recipients defined error (#4998)
Correctly fall back to plugin recipients if `mailRecipients` is empty.
2020-05-19 14:22:24 +02:00
Nicolas Raynaud
6cf211a9ad fix(xo-server-perf-alert): make message compatible with XenCenter (#5004) 2020-05-18 14:56:11 +02:00
badrAZ
3388e5e8a4 fix(xen-api#_sessionOpen): don't log credentials on error (#4995) 2020-05-18 09:47:52 +02:00
Julien Fontanet
5d497a1908 fix(xo-server-auth-ldap): use this._tlsOptions in bind
Introduced by 5870f6f73
2020-05-17 16:48:57 +02:00
Julien Fontanet
c820646fb6 fix(xo-server-auth-ldap): upgrade ldapts dep
Necessary for 5870f6f73

Also, only pass `tlsOptions` when creating client when using `ldaps`.
2020-05-17 16:11:24 +02:00
Julien Fontanet
5870f6f734 feat(xo-server-auth-ldap): support startTLS
Fixes #4999
2020-05-17 15:24:01 +02:00
Julien Fontanet
6732150121 fix(xo-server-auth-ldap): dont pass bindDN and `bindCredentials to LDAP client
It was left from an older version of the code which was working differently.
2020-05-17 12:47:08 +02:00
Pierre Donias
1dead8b080 feat(xo-web/modal/form): don't close on click or escape (#5002)
See xoa-support#2469

When the user clicks outside of a form modal or presses escape, don't close the
modal as all the information they entered so far will be lost.
2020-05-15 16:24:16 +02:00
BenjiReis
d547aa8ebd fix(sdn-controller): recreate both sides of tunnels when host updated (#4996)
To keep password synchronized.
2020-05-15 16:05:21 +02:00
Julien Fontanet
1da889e420 feat(xo-server/xo.{export,import}Config}): support passphrase (#4935) 2020-05-14 15:23:45 +02:00
Pierre Donias
5d0a308d1d fix(xo-web/SortedTable): don't inject empty filter if there isn't a URL param (#4994) 2020-05-14 11:11:05 +02:00
badrAZ
f9886d52da feat(usage-report): include CSV raw data files to sent email (#4979)
Fixes #4970
2020-05-13 14:42:46 +02:00
badrAZ
4f8e48b7d4 fix(CHANGELOG.unreleased): add missing entry (#4992) 2020-05-12 12:26:22 +02:00
Rajaa.BARHTAOUI
258e07c2ca feat(xo-web/render-xo-item): add pool name to networks (#4990)
Fixes #4885
2020-05-12 11:24:24 +02:00
badrAZ
cc32c50665 feat(xo-web/xoa): display proxy licenses (#4944)
There are three license states:
- license bound to an `XOA` which **is** linked to a proxy: display proxy link
- license bound to an `XOA` which **isn't** linked to a proxy: display `License attached to an unknown proxy` 
- license not bound to any `XOA`: display `No proxy attached`
2020-05-12 09:17:19 +02:00
Ben
ec1d91f73e fix(@xen-orchestra/fs): fix mount for FreeBSD (#4988) (#4989) 2020-05-12 00:08:34 +02:00
badrAZ
eb2f429964 fix(xo-server#getAllRemotesInfo): ignore disabled remotes 2020-05-11 17:49:58 +02:00
Julien Fontanet
1ad067309d fix(xo-cli/README): link to xo-upload-ova 2020-05-11 17:30:12 +02:00
Julien Fontanet
48ce7df43a feat(xo-server/file restore): dedupe mount/unmount (#4961) 2020-05-07 17:36:37 +02:00
Pierre Donias
6555e2c440 chore(xo-web/VM): move boot order setting from Disks to Advanced (#4975)
See #1523
2020-05-07 09:37:00 +02:00
badrAZ
a05191e112 fix(xo-server/proxies): remove duplicated license unbind (#4977)
On destroying a proxy, the license will be unbound twice: on the proxy destruction and on the proxy unregistration.

These unbinds will lead to an error which will be displayed in the console and will have no side effects on the process. This error will not be visible by users.
2020-05-06 14:23:04 +02:00
Julien Fontanet
b8eeee1d5d feat(xo-server/listVmBackups): use backup.listingDebounce setting (#4972) 2020-05-05 14:23:22 +02:00
Pierre Donias
4aa87f3fa5 chore(xo-web/xoa/update): hide XOA build number when unknown (#4973) 2020-05-05 14:15:44 +02:00
badrAZ
40c37d923b fix(xo-web/Number): fix inability to set advanced expressions (#4690)
Fixes #4566
2020-05-05 11:20:17 +02:00
Rajaa.BARHTAOUI
5a5837b8ed feat: release 5.46.0 (#4963) 2020-04-30 16:20:04 +02:00
Julien Fontanet
1e0b521070 fix(xo-server/backup): pass correct path to isValidXva (2)
Fix incorrect change in c4a157919.
2020-04-30 15:16:30 +02:00
Julien Fontanet
35ed58cc5e feat(xo-server): auto-generate express-session secret on first run
Also, use this secret to sign all cookies.
2020-04-30 14:57:05 +02:00
Julien Fontanet
c4a1579197 fix(xo-server/backup): pass correct path to isValidXva
The path was incorrect which means there was a warning in xo-server logs and the check was not properly working.
2020-04-30 14:45:53 +02:00
badrAZ
e471706422 fix(xo-web/proxies): only fetch licenses when (re)deploy (#4962) 2020-04-30 13:49:47 +02:00
Julien Fontanet
d78b7350b5 feat(xo-server): use memorystore as express-session store
This removes a warning and potential memory leaks.
2020-04-30 09:32:42 +02:00
Rajaa.BARHTAOUI
47b29d5a49 feat: technical release (#4958) 2020-04-29 10:51:35 +02:00
Rajaa.BARHTAOUI
e5946a51d1 feat(xo-web/backup/run): show # of VMs that will be backed up (#4875) 2020-04-28 17:40:05 +02:00
Pierre Donias
a88798cc22 feat(xo-server/vm/snapshot): handle Self Service (#3693)
See #3304
2020-04-28 16:14:43 +02:00
badrAZ
6fbd32523a fix(xo-server/callProxyMethod): support IPv6 address (#4955) 2020-04-28 14:17:46 +02:00
Pierre Donias
94b1cc2bdd chore(xo-web/xosan): prevent installing XOSAN on XCP-ng pools (#4953) 2020-04-28 14:17:02 +02:00
badrAZ
0ed5c8f0ae fix(xo-server/proxies): use configured address only when no associated VM (#4950) 2020-04-28 09:49:49 +02:00
Pierre Donias
5f883f552b feat(xo-common/api-errors): notEnoughResources error (#4952) 2020-04-27 16:55:44 +02:00
Julien Fontanet
9db99ab4a5 feat(xo-server): auto self signed cert generation (#4954) 2020-04-27 15:40:15 +02:00
Julien Fontanet
287214c2b2 fix(xo-server): debounceWithKey.decorate(decorateWith(debounceWithKey
Introduced by 317a02084
2020-04-27 13:21:53 +02:00
Julien Fontanet
317a020841 chore(xo-server/decorateWith): use fn wrappers as method decorator 2020-04-27 09:35:05 +02:00
Julien Fontanet
b50e3aec5f chore(xo-server/decorators/debounce): replace with debounceWithKey 2020-04-24 17:18:15 +02:00
badrAZ
21a9e0e2a7 chore(xo-web/proxies): remove proxy address column (#4951) 2020-04-24 17:16:58 +02:00
badrAZ
7775df8ef1 fix(xo-web/proxies): proxy VM should be in RO (#4947) 2020-04-24 11:16:07 +02:00
badrAZ
53f9b5d131 fix(xo-server,xo-web): add mainIpAddress to VM objects (#4943)
Fixes #4927
2020-04-24 10:16:13 +02:00
badrAZ
bf4d4a4742 fix(xo-web/backup-ng): only show delta info if delta is enabled (#4946)
Fixes #4945
2020-04-23 10:12:51 +02:00
Nicolas Raynaud
0dbbe7104d fix(xo-server/OVA import): fix memory issue (#4920)
Affects both VDMK and OVA import because an OVA file contains VMDK disks.

The input VMDK stream was put in memory instead of braking the upload speed when the VHD stream was slower than the input stream.

The reason is that pipette/slicer makes no attempts at pausing the input stream, so it will store everything in memory if the writing of the VHD stream is slower than the reading of the VMDK stream (https://github.com/Medium/pipette#layering-philosophy "They do not make upstream calls to the flow-control methods pause() and resume()")

The proposed solution is to remove pipette and handle the case ourselves.
2020-04-22 17:25:17 +02:00
badrAZ
561ef00680 fix(xo-server/backup-ng): throw error if remote's proxy is different than backup's proxy (#4907)
See #4905
2020-04-22 14:39:28 +02:00
Pierre Donias
85428fa72e fix(xo-web/xoa): always allow users to manage the XOA (#4941) 2020-04-22 14:18:59 +02:00
badrAZ
29d0593b86 fix(xo-server/proxies): incorrect extract of network IP (#4928)
See #4927
2020-04-22 13:04:33 +02:00
badrAZ
ac524dd799 feat(xo-server/proxies): unbind license on forgetting a proxy
See xoa#52
2020-04-22 09:14:53 +02:00
badrAZ
aba8b764b6 feat(xo-server/proxies): unbind license on destroying a proxy
See xoa#52
2020-04-22 09:14:53 +02:00
badrAZ
a9050e0f41 fix(xo-server/proxies): fix inability to destroy proxy on missing VM
See xoa#52
2020-04-22 09:14:53 +02:00
badrAZ
15ef84e238 feat(xo-web/proxy): bind license to a (re)deployed proxy (#4916)
See xoa#52
2020-04-22 09:14:53 +02:00
badrAZ
09096fef5b feat(xo-server/proxy): bind license on (re)deploying (#4913)
See xoa#52
2020-04-22 09:14:53 +02:00
badrAZ
19b08e1019 feat(proxy): CHANGELOG (#4930)
See xoa#52
2020-04-22 09:14:53 +02:00
Pierre Donias
06d67642dd fix(xo-server/patching): filter out CH8x patches (#4942)
We already filter out XSxx patches from normal patches (XSxxExxx) since they're special patches that are meant to upgrade the host to the next version.

Since XenServer has been renamed Citrix Hypervisor, patches names now start with the letters "CH" so we also need to filter out CHxx patches.
2020-04-21 12:01:47 +02:00
Pierre Donias
ceb6c450c0 feat(xo-web): Italian locale (#4932)
Fixes #2888
2020-04-20 10:48:23 +02:00
Julien Fontanet
a745e42cf5 feat(xo-server/_handleHttpRequest): send directly string/Buffer results 2020-04-17 17:09:40 +02:00
Julien Fontanet
462d6a4450 chore(xo-server/{export,import}Config): handle JSON instead of raw objects 2020-04-17 17:08:38 +02:00
Julien Fontanet
a2e39c5e2e fix(xo-server-audit/_exportRecords): dont return 200 on failure
See ec899be3b
2020-04-17 16:14:34 +02:00
Julien Fontanet
ec899be3b5 fix(xo-server/xo.exportConfig): dont return 200 on failure
`writeHead` sends immediatly the response header, which has a number of undesirable side-effects.

For instance, in this case, it prevented returning a 500 code in case of error.

It's almost always preferable to use `statusCode`, `writeHead()` or Express methods like `set()`.
2020-04-17 16:12:55 +02:00
Julien Fontanet
c79ebfdd0a fix(CHANGELOG.unreleased): better syntax for variables 2020-04-16 15:09:11 +02:00
Julien Fontanet
cd95e6c552 chore(CHANGELOG.unreleased): doc for package version 2020-04-16 15:08:06 +02:00
Julien Fontanet
f676145302 fix(xen-api/putResource): compat with XS 6.5 and Node 12 2020-04-16 15:04:17 +02:00
Pierre Donias
0847267069 feat(xo-web/snapshot with memory): add confirm modal (#4917)
Fixes #4914
2020-04-09 16:51:09 +02:00
Julien Fontanet
6fe1da1587 fix(CHANGELOG): add missing released packages 2020-04-08 16:43:55 +02:00
Julien Fontanet
7ab555d869 feat: release 5.45.1 2020-04-08 15:37:09 +02:00
Julien Fontanet
4a35e9e60d feat(xo-web): 5.58.2 2020-04-08 13:59:20 +02:00
Julien Fontanet
5e8dfdfd9b feat(xo-server): 5.58.2 2020-04-08 13:59:14 +02:00
Julien Fontanet
278a1b8ab3 feat(xo-server-audit): 0.3.0 2020-04-08 13:58:30 +02:00
Julien Fontanet
6cb03dded1 feat(xo-server-auth-saml): 0.8.0 2020-04-08 13:58:25 +02:00
Julien Fontanet
4752ec1b67 fix(CHANGELOG.unreleased): xo-server-saml → xo-server-auth-saml 2020-04-08 13:58:18 +02:00
Pierre Donias
e641371544 feat(xo-server/patches): debounce listMissingPatches for XS (#4911) 2020-04-07 11:18:58 +02:00
Nicolas Raynaud
8d9a7e9af1 fix(xo-server/xosan): fix SR size limit (#4910) 2020-04-07 09:54:14 +02:00
Julien Fontanet
2b8e9bf887 feat(auth-ldap): support strategyOptions from static config 2020-04-06 15:17:14 +02:00
Julien Fontanet
a16c55c679 fix(xo-web/utils/format*): never throw (#4909)
These functions previously thew if the param was not a number.

This can breaks the UI, as a work-around, this change logs the error and returns a default value.
2020-04-06 14:09:55 +02:00
badrAZ
9a72c40149 feat(audit,xo-server): blockedList can be configure via xo-server (#4897)
Fixes #4854
See #4844
2020-04-06 11:47:09 +02:00
Julien Fontanet
8424fc4c19 fix(xen-api,xo-server): fix compatibility with XS 6.5 and Node 12
Fixes #4906
2020-04-02 16:07:54 +02:00
badrAZ
9f29a047a7 feat(xo-web/sorted-table): make url state dynamic (#4641)
See #4564
2020-04-02 09:17:37 +02:00
Pierre Donias
af4904ce8d chore(xo-web,xo-server): move "snapshot before" feature to the client (#4893)
From xo-server's API's point of view, it makes more sense for the "snapshot before" feature to be implemented in xo-web since snapshotting a VM is a whole independent process on its own that requires its own API permissions.

Making this change will be especially useful to not over-complicate the permissions checks for the incoming "Self Service snapshots" feature.

See #3693
2020-04-01 14:10:35 +02:00
Rajaa.BARHTAOUI
6f2a323063 feat(xo-web/vm/disks): add bulk migration (#4877)
See #4455
2020-04-01 11:46:01 +02:00
Rajaa.BARHTAOUI
1da8ecfaac feat(xo-web): VDI migration: remove 'Migrate all VDIs' checkbox (#4876)
See #4455
2020-04-01 09:51:17 +02:00
Rajaa.BARHTAOUI
1ba386bbd2 feat: release 5.45.0 (#4902) 2020-03-31 18:11:33 +02:00
Julien Fontanet
d00d791cda feat(@xen-orchestra/upload-ova): 0.1.3 2020-03-31 17:49:25 +02:00
Julien Fontanet
51aabd7b21 feat(xo-vmdk-to-vhd): 1.1.1
Re-release of 1.0.1 because an erroneous 1.1.0 has been published which prevents it from being matched by `^1.0.1`.
2020-03-31 17:48:06 +02:00
Julien Fontanet
7840c3bdc8 feat(@xen-orchestra/upload-ova): 0.1.2 2020-03-31 17:34:30 +02:00
Julien Fontanet
07d13002b0 feat(xo-vmdk-to-vhd): 1.0.1 2020-03-31 17:33:28 +02:00
Julien Fontanet
23abe2ba06 fix(xo-vmdk-to-vhd): tmp is a dev dep 2020-03-31 17:32:43 +02:00
Julien Fontanet
4d73821d21 fix(xo-vmdk-to-vhd): add missing dep lodash 2020-03-31 17:31:40 +02:00
Julien Fontanet
f2687cf807 fix(xo-vmdk-to-vhd): add missing dep xml2js 2020-03-31 17:30:31 +02:00
Julien Fontanet
8abce0d4cf feat(@xen-orchestra/upload-ova): 0.1.1 2020-03-31 17:21:56 +02:00
Julien Fontanet
62ad3848c4 fix(upload-ova): add shebang to bin
Also set executable permission even if not necessary when installed via npm.
2020-03-31 17:21:20 +02:00
Rajaa.BARHTAOUI
521e9969f1 feat: technical release (patch) (#4901) 2020-03-31 16:04:21 +02:00
Nicolas Raynaud
5ee1ceced3 feat(upload-ova): new CLI to import OVA VMs (#3630) 2020-03-31 14:44:10 +02:00
556 changed files with 32568 additions and 10005 deletions

View File

@@ -1,6 +1,6 @@
module.exports = {
arrowParens: 'avoid',
jsxSingleQuote: true,
semi: false,
singleQuote: true,
trailingComma: 'es5',
}

View File

@@ -1,7 +1,6 @@
language: node_js
node_js:
#- stable # disable for now due to an issue of indirect dep upath with Node 9
- 8
- 12
# Use containers.
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/

View File

@@ -0,0 +1,46 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @vates/coalesce-calls
[![Package Version](https://badgen.net/npm/v/@vates/coalesce-calls)](https://npmjs.org/package/@vates/coalesce-calls) ![License](https://badgen.net/npm/license/@vates/coalesce-calls) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@vates/coalesce-calls)](https://bundlephobia.com/result?p=@vates/coalesce-calls) [![Node compatibility](https://badgen.net/npm/node/@vates/coalesce-calls)](https://npmjs.org/package/@vates/coalesce-calls)
> Wraps an async function so that concurrent calls will be coalesced
## Install
Installation of the [npm package](https://npmjs.org/package/@vates/coalesce-calls):
```
> npm install --save @vates/coalesce-calls
```
## Usage
```js
import { coalesceCalls } from '@vates/coalesce-calls'
const connect = coalesceCalls(async function () {
// async operation
})
connect()
// the previous promise result will be returned if the operation is not
// complete yet
connect()
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

View File

@@ -0,0 +1,13 @@
```js
import { coalesceCalls } from '@vates/coalesce-calls'
const connect = coalesceCalls(async function () {
// async operation
})
connect()
// the previous promise result will be returned if the operation is not
// complete yet
connect()
```

View File

@@ -0,0 +1,14 @@
exports.coalesceCalls = function (fn) {
let promise
const clean = () => {
promise = undefined
}
return function () {
if (promise !== undefined) {
return promise
}
promise = fn.apply(this, arguments)
promise.then(clean, clean)
return promise
}
}

View File

@@ -0,0 +1,33 @@
/* eslint-env jest */
const { coalesceCalls } = require('./')
const pDefer = () => {
const r = {}
r.promise = new Promise((resolve, reject) => {
r.reject = reject
r.resolve = resolve
})
return r
}
describe('coalesceCalls', () => {
it('decorates an async function', async () => {
const fn = coalesceCalls(promise => promise)
const defer1 = pDefer()
const promise1 = fn(defer1.promise)
const defer2 = pDefer()
const promise2 = fn(defer2.promise)
defer1.resolve('foo')
expect(await promise1).toBe('foo')
expect(await promise2).toBe('foo')
const defer3 = pDefer()
const promise3 = fn(defer3.promise)
defer3.resolve('bar')
expect(await promise3).toBe('bar')
})
})

View File

@@ -0,0 +1,38 @@
{
"private": false,
"name": "@vates/coalesce-calls",
"description": "Wraps an async function so that concurrent calls will be coalesced",
"keywords": [
"async",
"calls",
"coalesce",
"decorate",
"decorator",
"merge",
"promise",
"wrap",
"wrapper"
],
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@vates/coalesce-calls",
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"repository": {
"directory": "@vates/coalesce-calls",
"type": "git",
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"files": [
"index.js"
],
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
},
"license": "ISC",
"version": "0.1.0",
"engines": {
"node": ">=8.10"
},
"scripts": {
"postversion": "npm publish --access public"
}
}

View File

@@ -0,0 +1,45 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @vates/decorate-with
[![Package Version](https://badgen.net/npm/v/@vates/decorate-with)](https://npmjs.org/package/@vates/decorate-with) ![License](https://badgen.net/npm/license/@vates/decorate-with) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@vates/decorate-with)](https://bundlephobia.com/result?p=@vates/decorate-with) [![Node compatibility](https://badgen.net/npm/node/@vates/decorate-with)](https://npmjs.org/package/@vates/decorate-with)
> Creates a decorator from a function wrapper
## Install
Installation of the [npm package](https://npmjs.org/package/@vates/decorate-with):
```
> npm install --save @vates/decorate-with
```
## Usage
For instance, allows using Lodash's functions as decorators:
```js
import { decorateWith } from '@vates/decorate-with'
class Foo {
@decorateWith(lodash.debounce, 150)
bar() {
// body
}
}
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

View File

@@ -0,0 +1,12 @@
For instance, allows using Lodash's functions as decorators:
```js
import { decorateWith } from '@vates/decorate-with'
class Foo {
@decorateWith(lodash.debounce, 150)
bar() {
// body
}
}
```

View File

@@ -0,0 +1,4 @@
exports.decorateWith = (fn, ...args) => (target, name, descriptor) => ({
...descriptor,
value: fn(descriptor.value, ...args),
})

View File

@@ -0,0 +1,30 @@
{
"private": false,
"name": "@vates/decorate-with",
"description": "Creates a decorator from a function wrapper",
"keywords": [
"apply",
"decorator",
"factory",
"wrapper"
],
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@vates/decorate-with",
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"repository": {
"directory": "@vates/decorate-with",
"type": "git",
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
},
"license": "ISC",
"version": "0.0.1",
"engines": {
"node": ">=8.10"
},
"scripts": {
"postversion": "npm publish --access public"
}
}

View File

@@ -0,0 +1,47 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @vates/parse-duration
[![Package Version](https://badgen.net/npm/v/@vates/parse-duration)](https://npmjs.org/package/@vates/parse-duration) ![License](https://badgen.net/npm/license/@vates/parse-duration) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@vates/parse-duration)](https://bundlephobia.com/result?p=@vates/parse-duration) [![Node compatibility](https://badgen.net/npm/node/@vates/parse-duration)](https://npmjs.org/package/@vates/parse-duration)
> Small wrapper around ms to parse a duration
## Install
Installation of the [npm package](https://npmjs.org/package/@vates/parse-duration):
```
> npm install --save @vates/parse-duration
```
## Usage
`ms` without magic: always parse a duration and throws if invalid.
```js
import { parseDuration } from '@vates/parse-duration'
parseDuration('2 days')
// 172800000
parseDuration(172800000)
// 172800000
parseDuration(undefined)
// throws TypeError('not a valid duration: undefined')
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later) © [Vates SAS](https://vates.fr)

View File

@@ -0,0 +1,14 @@
`ms` without magic: always parse a duration and throws if invalid.
```js
import { parseDuration } from '@vates/parse-duration'
parseDuration('2 days')
// 172800000
parseDuration(172800000)
// 172800000
parseDuration(undefined)
// throws TypeError('not a valid duration: undefined')
```

View File

@@ -1,6 +1,6 @@
import ms from 'ms'
const ms = require('ms')
export default value => {
exports.parseDuration = value => {
if (typeof value === 'number') {
return value
}

View File

@@ -0,0 +1,32 @@
{
"private": false,
"name": "@vates/parse-duration",
"description": "Small wrapper around ms to parse a duration",
"keywords": [
"duration",
"ms",
"parse"
],
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@vates/parse-duration",
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"repository": {
"directory": "@vates/parse-duration",
"type": "git",
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
},
"license": "AGPL-3.0-or-later",
"version": "0.1.0",
"engines": {
"node": ">=8.10"
},
"dependencies": {
"ms": "^2.1.2"
},
"scripts": {
"postversion": "npm publish --access public"
}
}

View File

@@ -0,0 +1,46 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @vates/read-chunk
[![Package Version](https://badgen.net/npm/v/@vates/read-chunk)](https://npmjs.org/package/@vates/read-chunk) ![License](https://badgen.net/npm/license/@vates/read-chunk) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@vates/read-chunk)](https://bundlephobia.com/result?p=@vates/read-chunk) [![Node compatibility](https://badgen.net/npm/node/@vates/read-chunk)](https://npmjs.org/package/@vates/read-chunk)
> Read a chunk of a Node stream
## Install
Installation of the [npm package](https://npmjs.org/package/@vates/read-chunk):
```
> npm install --save @vates/read-chunk
```
## Usage
- returns the next available chunk of data
- like `stream.read()`, a number of bytes can be specified
- returns `null` if the stream has ended
```js
import { readChunk } from '@vates/read-chunk'
;(async () => {
let chunk
while ((chunk = await readChunk(stream, 1024)) !== null) {
// do something with chunk
}
})()
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

View File

@@ -0,0 +1,13 @@
- returns the next available chunk of data
- like `stream.read()`, a number of bytes can be specified
- returns `null` if the stream has ended
```js
import { readChunk } from '@vates/read-chunk'
;(async () => {
let chunk
while ((chunk = await readChunk(stream, 1024)) !== null) {
// do something with chunk
}
})()
```

View File

@@ -0,0 +1,27 @@
exports.readChunk = (stream, size) =>
new Promise((resolve, reject) => {
function onEnd() {
resolve(null)
removeListeners()
}
function onError(error) {
reject(error)
removeListeners()
}
function onReadable() {
const data = stream.read(size)
if (data !== null) {
resolve(data)
removeListeners()
}
}
function removeListeners() {
stream.removeListener('end', onEnd)
stream.removeListener('error', onError)
stream.removeListener('readable', onReadable)
}
stream.on('end', onEnd)
stream.on('error', onError)
stream.on('readable', onReadable)
onReadable()
})

View File

@@ -0,0 +1,33 @@
{
"private": false,
"name": "@vates/read-chunk",
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@vates/read-chunk",
"description": "Read a chunk of a Node stream",
"license": "ISC",
"keywords": [
"async",
"chunk",
"data",
"node",
"promise",
"read",
"stream"
],
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"repository": {
"directory": "@vates/read-chunk",
"type": "git",
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"version": "0.1.1",
"engines": {
"node": ">=8.10"
},
"scripts": {
"postversion": "npm publish --access public"
},
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
}
}

View File

@@ -1,6 +1,10 @@
# @xen-orchestra/async-map [![Build Status](https://travis-ci.org/vatesfr/xen-orchestra.png?branch=master)](https://travis-ci.org/vatesfr/xen-orchestra)
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
> ${pkg.description}
# @xen-orchestra/async-map
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/async-map)](https://npmjs.org/package/@xen-orchestra/async-map) ![License](https://badgen.net/npm/license/@xen-orchestra/async-map) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/async-map)](https://bundlephobia.com/result?p=@xen-orchestra/async-map) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/async-map)](https://npmjs.org/package/@xen-orchestra/async-map)
> Similar to Promise.all + lodash.map but wait for all promises to be settled
## Install
@@ -12,25 +16,10 @@ Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/async
## Usage
**TODO**
```js
import asyncMap from '@xen-orchestra/async-map'
## Development
```
# Install dependencies
> yarn
# Run the tests
> yarn test
# Continuously compile
> yarn dev
# Continuously run the tests
> yarn dev-test
# Build for production (automatically called by npm install)
> yarn build
const array = await asyncMap(collection, iteratee)
```
## Contributions
@@ -46,4 +35,4 @@ You may:
## License
ISC © [Vates SAS](https://vates.fr)
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

View File

@@ -0,0 +1,5 @@
```js
import asyncMap from '@xen-orchestra/async-map'
const array = await asyncMap(collection, iteratee)
```

View File

@@ -3,7 +3,7 @@
"name": "@xen-orchestra/async-map",
"version": "0.0.0",
"license": "ISC",
"description": "",
"description": "Similar to Promise.all + lodash.map but wait for all promises to be settled",
"keywords": [],
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@xen-orchestra/async-map",
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
@@ -13,8 +13,8 @@
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"author": {
"name": "Julien Fontanet",
"email": "julien.fontanet@isonoe.net"
"name": "Vates SAS",
"url": "https://vates.fr"
},
"preferGlobal": false,
"main": "dist/",
@@ -37,7 +37,7 @@
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"babel-plugin-lodash": "^3.3.2",
"cross-env": "^6.0.3",
"cross-env": "^7.0.2",
"rimraf": "^3.0.0"
},
"scripts": {
@@ -46,7 +46,6 @@
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/",
"prebuild": "yarn run clean",
"predev": "yarn run prebuild",
"prepare": "yarn run build",
"prepublishOnly": "yarn run build",
"postversion": "npm publish"
}

View File

@@ -0,0 +1,28 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @xen-orchestra/audit-core
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/audit-core)](https://npmjs.org/package/@xen-orchestra/audit-core) ![License](https://badgen.net/npm/license/@xen-orchestra/audit-core) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/audit-core)](https://bundlephobia.com/result?p=@xen-orchestra/audit-core) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/audit-core)](https://npmjs.org/package/@xen-orchestra/audit-core)
## Install
Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/audit-core):
```
> npm install --save @xen-orchestra/audit-core
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later) © [Vates SAS](https://vates.fr)

View File

View File

@@ -26,15 +26,20 @@
"@babel/plugin-proposal-decorators": "^7.8.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.0",
"@babel/preset-env": "^7.7.4",
"@babel/preset-typescript": "^7.7.4",
"cross": "^1.0.0",
"rimraf": "^3.0.0"
},
"dependencies": {
"@xen-orchestra/log": "^0.2.0",
"core-js": "^3.6.4",
"golike-defer": "^0.4.1",
"lodash": "^4.17.15",
"object-hash": "^2.0.1"
},
"private": false
"private": false,
"license": "AGPL-3.0-or-later",
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
}
}

View File

@@ -2,9 +2,12 @@
import 'core-js/features/symbol/async-iterator'
import assert from 'assert'
import createLogger from '@xen-orchestra/log'
import defer from 'golike-defer'
import hash from 'object-hash'
const log = createLogger('xo:audit-core')
export class Storage {
constructor() {
this._lock = Promise.resolve()
@@ -25,7 +28,7 @@ export class Storage {
//
// http://man7.org/linux/man-pages/man3/crypt.3.html#NOTES
const ID_TO_ALGORITHM = {
'5': 'sha256',
5: 'sha256',
}
export class AlteredRecordError extends Error {
@@ -65,8 +68,17 @@ export class AuditCore {
@defer
async add($defer, subject, event, data) {
const time = Date.now()
$defer(await this._storage.acquireLock())
return this._addUnsafe({
data,
event,
subject,
time,
})
}
async _addUnsafe({ data, event, subject, time }) {
const storage = this._storage
$defer(await storage.acquireLock())
// delete "undefined" properties and normalize data with JSON.stringify
const record = JSON.parse(
@@ -139,4 +151,45 @@ export class AuditCore {
await this._storage.del(id)
}
}
@defer
async deleteRangeAndRewrite($defer, newest, oldest) {
assert.notStrictEqual(newest, undefined)
assert.notStrictEqual(oldest, undefined)
const storage = this._storage
$defer(await storage.acquireLock())
assert.notStrictEqual(await storage.get(newest), undefined)
const oldestRecord = await storage.get(oldest)
assert.notStrictEqual(oldestRecord, undefined)
const lastId = await storage.getLastId()
const recentRecords = []
for await (const record of this.getFrom(lastId)) {
if (record.id === newest) {
break
}
recentRecords.push(record)
}
for await (const record of this.getFrom(newest)) {
await storage.del(record.id)
if (record.id === oldest) {
break
}
}
await storage.setLastId(oldestRecord.previousId)
for (const record of recentRecords) {
try {
await this._addUnsafe(record)
await storage.del(record.id)
} catch (error) {
log.error(error)
}
}
}
}

View File

@@ -17,9 +17,10 @@ interface Record {
}
export class AuditCore {
constructor(storage: Storage) {}
public add(subject: any, event: string, data: any): Promise<Record> {}
public checkIntegrity(oldest: string, newest: string): Promise<number> {}
public getFrom(newest?: string): AsyncIterator {}
public deleteFrom(newest: string): Promise<void> {}
constructor(storage: Storage) { }
public add(subject: any, event: string, data: any): Promise<Record> { }
public checkIntegrity(oldest: string, newest: string): Promise<number> { }
public getFrom(newest?: string): AsyncIterator { }
public deleteFrom(newest: string): Promise<void> { }
public deleteRangeAndRewrite(newest: string, oldest: string): Promise<void> { }
}

View File

@@ -0,0 +1,18 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @xen-orchestra/babel-config
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later) © [Vates SAS](https://vates.fr)

View File

View File

@@ -32,7 +32,6 @@ const configs = {
}
return { browsers: pkg.browserslist, node }
})(),
useBuiltIns: '@babel/polyfill' in (pkg.dependencies || {}) && 'usage',
}
},
}
@@ -52,7 +51,7 @@ const pluginsOrder = [
'@babel/plugin-proposal-class-properties',
]
module.exports = function(pkg, plugins, presets) {
module.exports = function (pkg, plugins, presets) {
plugins === undefined && (plugins = {})
presets === undefined && (presets = {})

View File

@@ -11,5 +11,10 @@
},
"engines": {
"node": ">=6"
},
"license": "AGPL-3.0-or-later",
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
}
}

View File

@@ -0,0 +1,28 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @xen-orchestra/backups-cli
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/backups-cli)](https://npmjs.org/package/@xen-orchestra/backups-cli) ![License](https://badgen.net/npm/license/@xen-orchestra/backups-cli) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/backups-cli)](https://bundlephobia.com/result?p=@xen-orchestra/backups-cli) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/backups-cli)](https://npmjs.org/package/@xen-orchestra/backups-cli)
## Install
Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/backups-cli):
```
> npm install --global @xen-orchestra/backups-cli
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later) © [Vates SAS](https://vates.fr)

View File

View File

@@ -3,7 +3,7 @@ const getopts = require('getopts')
const { version } = require('./package.json')
module.exports = commands =>
async function(args, prefix) {
async function (args, prefix) {
const opts = getopts(args, {
alias: {
help: 'h',

View File

@@ -3,6 +3,17 @@ const { dirname } = require('path')
const fs = require('promise-toolbox/promisifyAll')(require('fs'))
module.exports = fs
fs.getSize = path =>
fs.stat(path).then(
_ => _.size,
error => {
if (error.code === 'ENOENT') {
return 0
}
throw error
}
)
fs.mktree = async function mkdirp(path) {
try {
await fs.mkdir(path)
@@ -34,14 +45,15 @@ fs.readdir2 = path =>
return entries
},
error => {
if (
error != null &&
(error.code === 'ENOENT' || error.code === 'ENOTDIR')
) {
const { code } = error
if (code === 'ENOENT') {
// do nothing
} else if (code === 'ENOTDIR') {
console.warn('WARN: readdir(%s)', path, error)
return []
} else {
throw error
}
throw error
return []
}
)

View File

@@ -8,12 +8,13 @@ let force
const assert = require('assert')
const flatten = require('lodash/flatten')
const getopts = require('getopts')
const isValidXva = require('@xen-orchestra/backups/isValidXva')
const limitConcurrency = require('limit-concurrency-decorator').default
const lockfile = require('proper-lockfile')
const pipe = require('promise-toolbox/pipe')
const { default: Vhd } = require('vhd-lib')
const { default: Vhd, mergeVhd } = require('vhd-lib')
const { dirname, resolve } = require('path')
const { DISK_TYPE_DIFFERENCING } = require('vhd-lib/dist/_constants')
const { isValidXva } = require('@xen-orchestra/backups/isValidXva')
const asyncMap = require('../_asyncMap')
const fs = require('../_fs')
@@ -26,10 +27,10 @@ const handler = require('@xen-orchestra/fs').getHandler({ url: 'file://' })
//
// the whole chain will be merged into parent, parent will be renamed to child
// and all the others will deleted
async function mergeVhdChain(chain) {
const mergeVhdChain = limitConcurrency(1)(async function mergeVhdChain(chain) {
assert(chain.length >= 2)
const child = chain[0]
let child = chain[0]
const parent = chain[chain.length - 1]
const children = chain.slice(0, -1).reverse()
@@ -46,15 +47,36 @@ async function mergeVhdChain(chain) {
// `mergeVhd` does not work with a stream, either
// - make it accept a stream
// - or create synthetic VHD which is not a stream
return console.warn('TODO: implement merge')
// await mergeVhd(
// handler,
// parent,
// handler,
// children.length === 1
// ? child
// : await createSyntheticStream(handler, children)
// )
if (children.length !== 1) {
console.warn('TODO: implement merging multiple children')
children.length = 1
child = children[0]
}
let done, total
const handle = setInterval(() => {
if (done !== undefined) {
console.log('merging %s: %s/%s', child, done, total)
}
}, 10e3)
await mergeVhd(
handler,
parent,
handler,
child,
// children.length === 1
// ? child
// : await createSyntheticStream(handler, children),
{
onProgress({ done: d, total: t }) {
done = d
total = t
},
}
)
clearInterval(handle)
}
await Promise.all([
@@ -66,7 +88,7 @@ async function mergeVhdChain(chain) {
return force && handler.unlink(child)
}),
])
}
})
const listVhds = pipe([
vmDir => vmDir + '/vdis',
@@ -152,11 +174,12 @@ async function handleVm(vmDir) {
await Promise.all(deletions)
}
const [jsons, xvas] = await fs
const [jsons, xvas, xvaSums] = await fs
.readdir2(vmDir)
.then(entries => [
entries.filter(_ => _.endsWith('.json')),
new Set(entries.filter(_ => _.endsWith('.xva'))),
entries.filter(_ => _.endsWith('.xva.cheksum')),
])
await asyncMap(xvas, async path => {
@@ -274,6 +297,15 @@ async function handleVm(vmDir) {
console.warn('')
return force && handler.unlink(path)
}),
asyncMap(xvaSums, path => {
// no need to handle checksums for XVAs deleted by the script, they will be handled by `unlink()`
if (!xvas.has(path.slice(0, -'.checksum'.length))) {
console.warn('Unused XVA checksum', path)
force && console.warn(' deleting…')
console.warn('')
return force && handler.unlink(path)
}
}),
])
}

View File

@@ -0,0 +1,58 @@
const groupBy = require('lodash/groupBy')
const { createHash } = require('crypto')
const { dirname, resolve } = require('path')
const asyncMap = require('../_asyncMap')
const { readdir2, readFile, getSize } = require('../_fs')
const sha512 = str => createHash('sha512').update(str).digest('hex')
const sum = values => values.reduce((a, b) => a + b)
module.exports = async function info(vmDirs) {
const jsonFiles = (
await asyncMap(vmDirs, async vmDir =>
(await readdir2(vmDir)).filter(_ => _.endsWith('.json'))
)
).flat()
const hashes = { __proto__: null }
const info = (
await asyncMap(jsonFiles, async jsonFile => {
try {
const jsonDir = dirname(jsonFile)
const json = await readFile(jsonFile)
const hash = sha512(json)
if (hash in hashes) {
console.log(jsonFile, 'duplicate of', hashes[hash])
return
}
hashes[hash] = jsonFile
const metadata = JSON.parse(json)
return {
jsonDir,
jsonFile,
metadata,
size:
json.length +
(await (metadata.mode === 'delta'
? asyncMap(Object.values(metadata.vhds), _ =>
getSize(resolve(jsonDir, _))
).then(sum)
: getSize(resolve(jsonDir, metadata.xva)))),
}
} catch (error) {
console.error(jsonFile, error)
}
})
).filter(_ => _ !== undefined)
const byJobs = groupBy(info, 'metadata.jobId')
Object.keys(byJobs)
.sort()
.forEach(jobId => {
console.log(jobId, sum(byJobs[jobId].map(_ => _.size)))
})
}

View File

@@ -13,6 +13,12 @@ require('./_composeCommands')({
},
usage: 'xo-vm-backups <field path>',
},
info: {
get main() {
return require('./commands/info')
},
usage: 'xo-vm-backups/*',
},
})(process.argv.slice(2), 'xo-backups').catch(error => {
console.error('main', error)
process.exitCode = 1

View File

@@ -3,12 +3,14 @@
"bin": {
"xo-backups": "index.js"
},
"preferGlobal": true,
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"dependencies": {
"@xen-orchestra/backups": "^0.1.1",
"@xen-orchestra/fs": "^0.10.3",
"@xen-orchestra/fs": "^0.11.1",
"filenamify": "^4.1.0",
"getopts": "^2.2.5",
"limit-concurrency-decorator": "^0.4.0",
"lodash": "^4.17.15",
"promise-toolbox": "^0.15.0",
"proper-lockfile": "^4.1.1",
@@ -31,5 +33,10 @@
"scripts": {
"postversion": "npm publish --access public"
},
"version": "0.0.0"
"version": "0.2.1",
"license": "AGPL-3.0-or-later",
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
}
}

View File

@@ -0,0 +1,28 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @xen-orchestra/backups
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/backups)](https://npmjs.org/package/@xen-orchestra/backups) ![License](https://badgen.net/npm/license/@xen-orchestra/backups) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/backups)](https://bundlephobia.com/result?p=@xen-orchestra/backups) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/backups)](https://npmjs.org/package/@xen-orchestra/backups)
## Install
Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/backups):
```
> npm install --save @xen-orchestra/backups
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later) © [Vates SAS](https://vates.fr)

View File

View File

@@ -16,7 +16,12 @@
"postversion": "npm publish --access public"
},
"dependencies": {
"d3-time-format": "^2.2.3",
"fs-extra": "^8.1.0"
"d3-time-format": "^3.0.0",
"fs-extra": "^9.0.0"
},
"license": "AGPL-3.0-or-later",
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
}
}

View File

@@ -0,0 +1,28 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @xen-orchestra/cr-seed-cli
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/cr-seed-cli)](https://npmjs.org/package/@xen-orchestra/cr-seed-cli) ![License](https://badgen.net/npm/license/@xen-orchestra/cr-seed-cli) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/cr-seed-cli)](https://bundlephobia.com/result?p=@xen-orchestra/cr-seed-cli) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/cr-seed-cli)](https://npmjs.org/package/@xen-orchestra/cr-seed-cli)
## Install
Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/cr-seed-cli):
```
> npm install --global @xen-orchestra/cr-seed-cli
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later) © [Vates SAS](https://vates.fr)

View File

View File

@@ -5,7 +5,7 @@ const { NULL_REF, Xapi } = require('xen-api')
const pkg = require('./package.json')
Xapi.prototype.getVmDisks = async function(vm) {
Xapi.prototype.getVmDisks = async function (vm) {
const disks = { __proto__: null }
await Promise.all([
...vm.VBDs.map(async vbdRef => {

View File

@@ -15,11 +15,17 @@
"bin": {
"xo-cr-seed": "./index.js"
},
"preferGlobal": true,
"dependencies": {
"golike-defer": "^0.4.1",
"xen-api": "^0.28.3"
"xen-api": "^0.29.0"
},
"scripts": {
"postversion": "npm publish"
},
"license": "AGPL-3.0-or-later",
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
}
}

View File

@@ -1,4 +1,8 @@
# @xen-orchestra/cron [![Build Status](https://travis-ci.org/vatesfr/xen-orchestra.png?branch=master)](https://travis-ci.org/vatesfr/xen-orchestra)
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @xen-orchestra/cron
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/cron)](https://npmjs.org/package/@xen-orchestra/cron) ![License](https://badgen.net/npm/license/@xen-orchestra/cron) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/cron)](https://bundlephobia.com/result?p=@xen-orchestra/cron) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/cron)](https://npmjs.org/package/@xen-orchestra/cron)
> Focused, well maintained, cron parser/scheduler
@@ -10,6 +14,8 @@ Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/cron)
> npm install --save @xen-orchestra/cron
```
## Usage
### Pattern syntax
```
@@ -109,25 +115,6 @@ job.start()
job.stop()
```
## Development
```
# Install dependencies
> yarn
# Run the tests
> yarn test
# Continuously compile
> yarn dev
# Continuously run the tests
> yarn dev-test
# Build for production (automatically called by npm install)
> yarn build
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
@@ -141,4 +128,4 @@ You may:
## License
ISC © [Vates SAS](https://vates.fr)
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

View File

@@ -0,0 +1,98 @@
### Pattern syntax
```
<minute> <hour> <day of month> <month> <day of week>
```
Each entry can be:
- a single value
- a range (`0-23` or `*/2`)
- a list of values/ranges (`1,8-12`)
A wildcard (`*`) can be used as a shortcut for the whole range
(`first-last`).
Step values can be used in conjunctions with ranges. For instance,
`1-7/2` is the same as `1,3,5,7`.
| Field | Allowed values |
| ---------------- | ------------------------------------------------------------------ |
| minute | 0-59 |
| hour | 0-23 |
| day of the month | 1-31 or 3-letter names (`jan`, `feb`, …) |
| month | 0-11 |
| day of week | 0-7 (0 and 7 both mean Sunday) or 3-letter names (`mon`, `tue`, …) |
> Note: the month range is 0-11 to be compatible with
> [cron](https://github.com/kelektiv/node-cron), it does not appear to
> be very standard though.
### API
`createSchedule(pattern: string, zone: string = 'utc'): Schedule`
> Create a new schedule.
- `pattern`: the pattern to use, see [the syntax](#pattern-syntax)
- `zone`: the timezone to use, use `'local'` for the local timezone
```js
import { createSchedule } from '@xen-orchestra/cron'
const schedule = createSchedule('0 0 * * sun', 'America/New_York')
```
`Schedule#createJob(fn: Function): Job`
> Create a new job from this schedule.
- `fn`: function to execute, if it returns a promise, it will be
awaited before scheduling the next run.
```js
const job = schedule.createJob(() => {
console.log(new Date())
})
```
`Schedule#next(n: number): Array<Date>`
> Returns the next dates matching this schedule.
- `n`: number of dates to return
```js
schedule.next(2)
// [ 2018-02-11T05:00:00.000Z, 2018-02-18T05:00:00.000Z ]
```
`Schedule#startJob(fn: Function): () => void`
> Start a new job from this schedule and return a function to stop it.
- `fn`: function to execute, if it returns a promise, it will be
awaited before scheduling the next run.
```js
const stopJob = schedule.startJob(() => {
console.log(new Date())
})
stopJob()
```
`Job#start(): void`
> Start this job.
```js
job.start()
```
`Job#stop(): void`
> Stop this job.
```js
job.stop()
```

View File

@@ -23,8 +23,8 @@
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"author": {
"name": "Julien Fontanet",
"email": "julien.fontanet@isonoe.net"
"name": "Vates SAS",
"url": "https://vates.fr"
},
"preferGlobal": false,
"main": "dist/",
@@ -47,7 +47,7 @@
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"cross-env": "^6.0.3",
"cross-env": "^7.0.2",
"rimraf": "^3.0.0"
},
"scripts": {

View File

@@ -1,6 +1,8 @@
# @xen-orchestra/defined [![Build Status](https://travis-ci.org/${pkg.shortGitHubPath}.png?branch=master)](https://travis-ci.org/${pkg.shortGitHubPath})
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
> ${pkg.description}
# @xen-orchestra/defined
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/defined)](https://npmjs.org/package/@xen-orchestra/defined) ![License](https://badgen.net/npm/license/@xen-orchestra/defined) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/defined)](https://bundlephobia.com/result?p=@xen-orchestra/defined) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/defined)](https://npmjs.org/package/@xen-orchestra/defined)
## Install
@@ -10,29 +12,6 @@ Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/defin
> npm install --save @xen-orchestra/defined
```
## Usage
**TODO**
## Development
```
# Install dependencies
> yarn
# Run the tests
> yarn test
# Continuously compile
> yarn dev
# Continuously run the tests
> yarn dev-test
# Build for production (automatically called by npm install)
> yarn build
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
@@ -46,4 +25,4 @@ You may:
## License
ISC © [Vates SAS](https://vates.fr)
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

View File

View File

@@ -13,8 +13,8 @@
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"author": {
"name": "Julien Fontanet",
"email": "julien.fontanet@vates.fr"
"name": "Vates SAS",
"url": "https://vates.fr"
},
"preferGlobal": false,
"main": "dist/",
@@ -35,7 +35,7 @@
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"babel-plugin-lodash": "^3.3.2",
"cross-env": "^6.0.3",
"cross-env": "^7.0.2",
"rimraf": "^3.0.0"
},
"scripts": {

View File

@@ -1,6 +1,8 @@
# @xen-orchestra/emit-async [![Build Status](https://travis-ci.org/${pkg.shortGitHubPath}.png?branch=master)](https://travis-ci.org/${pkg.shortGitHubPath})
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
> ${pkg.description}
# @xen-orchestra/emit-async
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/emit-async)](https://npmjs.org/package/@xen-orchestra/emit-async) ![License](https://badgen.net/npm/license/@xen-orchestra/emit-async) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/emit-async)](https://bundlephobia.com/result?p=@xen-orchestra/emit-async) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/emit-async)](https://npmjs.org/package/@xen-orchestra/emit-async)
## Install
@@ -19,7 +21,7 @@ import emitAsync from '@xen-orchestra/emit-async'
const ee = new EE()
ee.emitAsync = emitAsync
ee.on('start', async function() {
ee.on('start', async function () {
// whatever
})
@@ -39,25 +41,6 @@ await ee.emitAsync(
)
```
## Development
```
# Install dependencies
> yarn
# Run the tests
> yarn test
# Continuously compile
> yarn dev
# Continuously run the tests
> yarn dev-test
# Build for production (automatically called by npm install)
> yarn build
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
@@ -71,4 +54,4 @@ You may:
## License
ISC © [Vates SAS](https://vates.fr)
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

View File

@@ -0,0 +1,26 @@
```js
import EE from 'events'
import emitAsync from '@xen-orchestra/emit-async'
const ee = new EE()
ee.emitAsync = emitAsync
ee.on('start', async function () {
// whatever
})
// similar to EventEmmiter#emit() but returns a promise which resolves when all
// listeners have resolved
await ee.emitAsync('start')
// by default, it will rejects as soon as one listener reject, you can customise
// error handling though:
await ee.emitAsync(
{
onError(error) {
console.warn(error)
},
},
'start'
)
```

View File

@@ -13,8 +13,8 @@
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"author": {
"name": "Julien Fontanet",
"email": "julien.fontanet@vates.fr"
"name": "Vates SAS",
"url": "https://vates.fr"
},
"preferGlobal": false,
"main": "dist/",
@@ -34,7 +34,7 @@
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-plugin-lodash": "^3.3.2",
"cross-env": "^6.0.3",
"cross-env": "^7.0.2",
"rimraf": "^3.0.0"
},
"scripts": {

View File

@@ -0,0 +1,30 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @xen-orchestra/fs
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/fs)](https://npmjs.org/package/@xen-orchestra/fs) ![License](https://badgen.net/npm/license/@xen-orchestra/fs) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/fs)](https://bundlephobia.com/result?p=@xen-orchestra/fs) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/fs)](https://npmjs.org/package/@xen-orchestra/fs)
> The File System for Xen Orchestra backups.
## Install
Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/fs):
```
> npm install --global @xen-orchestra/fs
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later) © [Vates SAS](https://vates.fr)

View File

View File

@@ -1,8 +1,8 @@
{
"private": false,
"name": "@xen-orchestra/fs",
"version": "0.10.3",
"license": "AGPL-3.0",
"version": "0.11.1",
"license": "AGPL-3.0-or-later",
"description": "The File System for Xen Orchestra backups.",
"keywords": [],
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@xen-orchestra/fs",
@@ -25,17 +25,18 @@
"@marsaud/smb2": "^0.15.0",
"@sindresorhus/df": "^3.1.1",
"@xen-orchestra/async-map": "^0.0.0",
"aws-sdk": "^2.686.0",
"decorator-synchronized": "^0.5.0",
"execa": "^3.2.0",
"fs-extra": "^8.0.1",
"get-stream": "^5.1.0",
"execa": "^4.0.2",
"fs-extra": "^9.0.0",
"get-stream": "^6.0.0",
"limit-concurrency-decorator": "^0.4.0",
"lodash": "^4.17.4",
"promise-toolbox": "^0.15.0",
"readable-stream": "^3.0.6",
"through2": "^3.0.0",
"tmp": "^0.1.0",
"xo-remote-parser": "^0.5.0"
"through2": "^4.0.2",
"tmp": "^0.2.1",
"xo-remote-parser": "^0.6.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
@@ -47,7 +48,7 @@
"@babel/preset-flow": "^7.0.0",
"async-iterator-to-stream": "^1.1.0",
"babel-plugin-lodash": "^3.3.2",
"cross-env": "^6.0.3",
"cross-env": "^7.0.2",
"dotenv": "^8.0.0",
"index-modules": "^0.3.0",
"rimraf": "^3.0.0"
@@ -58,7 +59,11 @@
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/",
"prebuild": "yarn run clean",
"predev": "yarn run clean",
"prepare": "yarn run build",
"prepublishOnly": "yarn run build",
"postversion": "npm publish"
},
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
}
}

View File

@@ -31,10 +31,7 @@ export default class MountHandler extends LocalHandler {
}
this._realPath = join(
mountsDir,
remote.id ||
Math.random()
.toString(36)
.slice(2)
remote.id || Math.random().toString(36).slice(2)
)
}
@@ -75,9 +72,12 @@ export default class MountHandler extends LocalHandler {
try {
const { type, device, options, env } = this._params
// Linux mount is more flexible in which order the mount arguments appear.
// But FreeBSD requires this order of the arguments.
await this._execa(
'mount',
['-t', type, device, realPath, '-o', options],
['-o', options, '-t', type, device, realPath],
{
env: {
LANG: 'C',

View File

@@ -5,7 +5,7 @@ import getStream from 'get-stream'
import asyncMap from '@xen-orchestra/async-map'
import limit from 'limit-concurrency-decorator'
import path from 'path'
import path, { basename } from 'path'
import synchronized from 'decorator-synchronized'
import { fromCallback, fromEvent, ignoreErrors, timeout } from 'promise-toolbox'
import { parse } from 'xo-remote-parser'
@@ -121,6 +121,7 @@ export default class RemoteHandlerAbstract {
await this.__closeFile(fd)
}
// TODO: remove method
async createOutputStream(
file: File,
{ checksum = false, ...options }: Object = {}
@@ -221,19 +222,15 @@ export default class RemoteHandlerAbstract {
)
}
createWriteStream(
file: File,
options: { end?: number, flags?: string, start?: number } = {}
): Promise<LaxWritable> {
return timeout.call(
this._createWriteStream(
typeof file === 'string' ? normalizePath(file) : file,
{
flags: 'wx',
...options,
}
)
)
// write a stream to a file using a temporary file
async outputStream(
input: Readable | Promise<Readable>,
path: string,
{ checksum = true }: { checksum?: boolean } = {}
): Promise<void> {
path = normalizePath(path)
input = await input
return this._outputStream(await input, normalizePath(path), { checksum })
}
// Free the resources possibly dedicated to put the remote at work, when it
@@ -321,18 +318,6 @@ export default class RemoteHandlerAbstract {
return this._readFile(normalizePath(file), { flags })
}
async refreshChecksum(path: string): Promise<void> {
path = normalizePath(path)
const stream = (await this._createReadStream(path, { flags: 'r' })).pipe(
createChecksumStream()
)
stream.resume() // start reading the whole file
await this._outputFile(checksumFile(path), await stream.checksum, {
flags: 'wx',
})
}
async rename(
oldPath: string,
newPath: string,
@@ -548,6 +533,22 @@ export default class RemoteHandlerAbstract {
return this._outputFile(file, data, options)
}
async _outputStream(input, path, { checksum }) {
const tmpPath = `${dirname(path)}/.${basename(path)}`
const output = await this.createOutputStream(tmpPath, { checksum })
try {
input.pipe(output)
await fromEvent(output, 'finish')
await output.checksumWritten
// $FlowFixMe
await input.task
await this.rename(tmpPath, path, { checksum })
} catch (error) {
await this.unlink(tmpPath, { checksum })
throw error
}
}
_read(
file: File,
buffer: Buffer,
@@ -648,7 +649,7 @@ function createPrefixWrapperMethods() {
return
}
descriptor.value = function() {
descriptor.value = function () {
let path
if (arguments.length !== 0 && typeof (path = arguments[0]) === 'string') {
arguments[0] = this._resolve(path)

View File

@@ -42,18 +42,6 @@ describe('createOutputStream()', () => {
})
})
describe('createReadStream()', () => {
it(`throws in case of timeout`, async () => {
const testHandler = new TestHandler({
createReadStream: () => new Promise(() => {}),
})
const promise = testHandler.createReadStream('file')
jest.advanceTimersByTime(TIMEOUT)
await expect(promise).rejects.toThrowError(TimeoutError)
})
})
describe('getInfo()', () => {
it('throws in case of timeout', async () => {
const testHandler = new TestHandler({

View File

@@ -2,7 +2,6 @@
import 'dotenv/config'
import asyncIteratorToStream from 'async-iterator-to-stream'
import getStream from 'get-stream'
import { forOwn, random } from 'lodash'
import { fromCallback } from 'promise-toolbox'
import { pipeline } from 'readable-stream'
@@ -28,7 +27,7 @@ const unsecureRandomBytes = n => {
const TEST_DATA_LEN = 1024
const TEST_DATA = unsecureRandomBytes(TEST_DATA_LEN)
const createTestDataStream = asyncIteratorToStream(function*() {
const createTestDataStream = asyncIteratorToStream(function* () {
yield TEST_DATA
})
@@ -91,31 +90,6 @@ handlers.forEach(url => {
})
})
describe('#createReadStream()', () => {
beforeEach(() => handler.outputFile('file', TEST_DATA))
testWithFileDescriptor('file', 'r', async ({ file, flags }) => {
await expect(
await getStream.buffer(
await handler.createReadStream(file, { flags })
)
).toEqual(TEST_DATA)
})
})
describe('#createWriteStream()', () => {
testWithFileDescriptor('file', 'wx', async ({ file, flags }) => {
const stream = await handler.createWriteStream(file, { flags })
await fromCallback(pipeline, createTestDataStream(), stream)
await expect(await handler.readFile('file')).toEqual(TEST_DATA)
})
it('fails if parent dir is missing', async () => {
const error = await rejectionOf(handler.createWriteStream('dir/file'))
expect(error.code).toBe('ENOENT')
})
})
describe('#getInfo()', () => {
let info
beforeAll(async () => {

View File

@@ -4,6 +4,7 @@ import execa from 'execa'
import type RemoteHandler from './abstract'
import RemoteHandlerLocal from './local'
import RemoteHandlerNfs from './nfs'
import RemoteHandlerS3 from './s3'
import RemoteHandlerSmb from './smb'
import RemoteHandlerSmbMount from './smb-mount'
@@ -13,6 +14,7 @@ export type Remote = { url: string }
const HANDLERS = {
file: RemoteHandlerLocal,
nfs: RemoteHandlerNfs,
s3: RemoteHandlerS3,
}
try {

284
@xen-orchestra/fs/src/s3.js Normal file
View File

@@ -0,0 +1,284 @@
import AWS from 'aws-sdk'
import { parse } from 'xo-remote-parser'
import RemoteHandlerAbstract from './abstract'
import { createChecksumStream } from './checksum'
// endpoints https://docs.aws.amazon.com/general/latest/gr/s3.html
// limits: https://docs.aws.amazon.com/AmazonS3/latest/dev/qfacts.html
const MIN_PART_SIZE = 1024 * 1024 * 5 // 5MB
const MAX_PART_SIZE = 1024 * 1024 * 1024 * 5 // 5GB
const MAX_PARTS_COUNT = 10000
const MAX_OBJECT_SIZE = 1024 * 1024 * 1024 * 1024 * 5 // 5TB
const IDEAL_FRAGMENT_SIZE = Math.ceil(MAX_OBJECT_SIZE / MAX_PARTS_COUNT) // the smallest fragment size that still allows a 5TB upload in 10000 fragments, about 524MB
export default class S3Handler extends RemoteHandlerAbstract {
constructor(remote, _opts) {
super(remote)
const { host, path, username, password } = parse(remote.url)
// https://www.zenko.io/blog/first-things-first-getting-started-scality-s3-server/
this._s3 = new AWS.S3({
accessKeyId: username,
apiVersion: '2006-03-01',
endpoint: host,
s3ForcePathStyle: true,
secretAccessKey: password,
signatureVersion: 'v4',
})
const splitPath = path.split('/').filter(s => s.length)
this._bucket = splitPath.shift()
this._dir = splitPath.join('/')
}
get type() {
return 's3'
}
_createParams(file) {
return { Bucket: this._bucket, Key: this._dir + file }
}
async _outputStream(input, path, { checksum }) {
let inputStream = input
if (checksum) {
const checksumStream = createChecksumStream()
const forwardError = error => {
checksumStream.emit('error', error)
}
input.pipe(checksumStream)
input.on('error', forwardError)
inputStream = checksumStream
}
const upload = this._s3.upload(
{
...this._createParams(path),
Body: inputStream,
},
{ partSize: IDEAL_FRAGMENT_SIZE }
)
await upload.promise()
if (checksum) {
const checksum = await inputStream.checksum
const params = {
...this._createParams(path + '.checksum'),
Body: checksum,
}
await this._s3.upload(params).promise()
}
await input.task
}
async _writeFile(file, data, options) {
return this._s3
.putObject({ ...this._createParams(file), Body: data })
.promise()
}
async _createReadStream(file, options) {
return this._s3.getObject(this._createParams(file)).createReadStream()
}
async _unlink(file) {
return this._s3.deleteObject(this._createParams(file)).promise()
}
async _list(dir) {
function splitPath(path) {
return path.split('/').filter(d => d.length)
}
const prefix = [this._dir, dir].join('/')
const splitPrefix = splitPath(prefix)
const request = this._s3.listObjectsV2({
Bucket: this._bucket,
Prefix: splitPrefix.join('/'),
})
const result = await request.promise()
const uniq = new Set()
for (const entry of result.Contents) {
const line = splitPath(entry.Key)
if (line.length > splitPrefix.length) {
uniq.add(line[splitPrefix.length])
}
}
return [...uniq]
}
async _rename(oldPath, newPath) {
const params = {
...this._createParams(newPath),
CopySource: `/${this._bucket}/${this._dir}${oldPath}`,
}
await this._s3.copyObject(params).promise()
await this._s3.deleteObject(this._createParams(oldPath)).promise()
}
async _getSize(file) {
if (typeof file !== 'string') {
file = file.fd
}
const result = await this._s3.headObject(this._createParams(file)).promise()
return +result.ContentLength
}
async _read(file, buffer, position = 0) {
if (typeof file !== 'string') {
file = file.fd
}
const params = this._createParams(file)
params.Range = `bytes=${position}-${position + buffer.length - 1}`
const result = await this._s3.getObject(params).promise()
result.Body.copy(buffer)
return { bytesRead: result.Body.length, buffer }
}
async _write(file, buffer, position) {
if (typeof file !== 'string') {
file = file.fd
}
const uploadParams = this._createParams(file)
const fileSize = +(await this._s3.headObject(uploadParams).promise())
.ContentLength
if (fileSize < MIN_PART_SIZE) {
const resultBuffer = Buffer.alloc(
Math.max(fileSize, position + buffer.length)
)
const fileContent = (await this._s3.getObject(uploadParams).promise())
.Body
fileContent.copy(resultBuffer)
buffer.copy(resultBuffer, position)
await this._s3
.putObject({ ...uploadParams, Body: resultBuffer })
.promise()
return { buffer, bytesWritten: buffer.length }
} else {
// using this trick: https://stackoverflow.com/a/38089437/72637
// multipart fragments have a minimum size of 5Mo and a max of 5Go unless they are last
// splitting the file in 3 parts: [prefix, edit, suffix]
// if `prefix` is bigger than 5Mo, it will be sourced from uploadPartCopy()
// otherwise otherwise it will be downloaded, concatenated to `edit`
// `edit` will always be an upload part
// `suffix` will ways be sourced from uploadPartCopy()
const multipartParams = await this._s3
.createMultipartUpload(uploadParams)
.promise()
try {
const parts = []
const prefixSize = position
let suffixOffset = prefixSize + buffer.length
let suffixSize = Math.max(0, fileSize - suffixOffset)
let hasSuffix = suffixSize > 0
let editBuffer = buffer
let editBufferOffset = position
let partNumber = 1
if (prefixSize < MIN_PART_SIZE) {
const downloadParams = {
...uploadParams,
Range: `bytes=0-${prefixSize - 1}`,
}
const prefixBuffer =
prefixSize > 0
? (await this._s3.getObject(downloadParams).promise()).Body
: Buffer.alloc(0)
editBuffer = Buffer.concat([prefixBuffer, buffer])
editBufferOffset = 0
} else {
const fragmentsCount = Math.ceil(prefixSize / MAX_PART_SIZE)
const prefixFragmentSize = Math.ceil(prefixSize / fragmentsCount)
const lastFragmentSize =
prefixFragmentSize * fragmentsCount - prefixSize
let prefixPosition = 0
for (let i = 0; i < fragmentsCount; i++) {
const copyPrefixParams = {
...multipartParams,
PartNumber: partNumber++,
CopySource: `/${this._bucket}/${this._dir + file}`,
CopySourceRange: `bytes=${prefixPosition}-${
prefixPosition + prefixFragmentSize - 1
}`,
}
const prefixPart = (
await this._s3.uploadPartCopy(copyPrefixParams).promise()
).CopyPartResult
parts.push({
ETag: prefixPart.ETag,
PartNumber: copyPrefixParams.PartNumber,
})
prefixPosition += prefixFragmentSize
}
if (lastFragmentSize) {
}
}
if (hasSuffix && editBuffer.length < MIN_PART_SIZE) {
// the edit fragment is too short and is not the last fragment
// let's steal from the suffix fragment to reach the minimum size
// the suffix might be too short and itself entirely absorbed in the edit fragment, making it the last one.
const complementSize = Math.min(
MIN_PART_SIZE - editBuffer.length,
suffixSize
)
const complementOffset = editBufferOffset + editBuffer.length
suffixOffset += complementSize
suffixSize -= complementSize
hasSuffix = suffixSize > 0
const prefixRange = `bytes=${complementOffset}-${
complementOffset + complementSize - 1
}`
const downloadParams = { ...uploadParams, Range: prefixRange }
const complementBuffer = (
await this._s3.getObject(downloadParams).promise()
).Body
editBuffer = Buffer.concat([editBuffer, complementBuffer])
}
const editParams = {
...multipartParams,
Body: editBuffer,
PartNumber: partNumber++,
}
const editPart = await this._s3.uploadPart(editParams).promise()
parts.push({ ETag: editPart.ETag, PartNumber: editParams.PartNumber })
if (hasSuffix) {
const suffixFragments = Math.ceil(suffixSize / MAX_PART_SIZE)
const suffixFragmentsSize = Math.ceil(suffixSize / suffixFragments)
let suffixFragmentOffset = suffixOffset
for (let i = 0; i < suffixFragments; i++) {
const fragmentEnd = suffixFragmentOffset + suffixFragmentsSize
const suffixRange = `bytes=${suffixFragmentOffset}-${
Math.min(fileSize, fragmentEnd) - 1
}`
const copySuffixParams = {
...multipartParams,
PartNumber: partNumber++,
CopySource: `/${this._bucket}/${this._dir + file}`,
CopySourceRange: suffixRange,
}
const suffixPart = (
await this._s3.uploadPartCopy(copySuffixParams).promise()
).CopyPartResult
parts.push({
ETag: suffixPart.ETag,
PartNumber: copySuffixParams.PartNumber,
})
suffixFragmentOffset = fragmentEnd
}
}
await this._s3
.completeMultipartUpload({
...multipartParams,
MultipartUpload: { Parts: parts },
})
.promise()
} catch (e) {
await this._s3.abortMultipartUpload(multipartParams).promise()
throw e
}
}
}
async _openFile(path, flags) {
return path
}
async _closeFile(fd) {}
}

View File

@@ -1,6 +1,8 @@
# @xen-orchestra/log [![Build Status](https://travis-ci.org/vatesfr/xen-orchestra.png?branch=master)](https://travis-ci.org/vatesfr/xen-orchestra)
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
> ${pkg.description}
# @xen-orchestra/log
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/log)](https://npmjs.org/package/@xen-orchestra/log) ![License](https://badgen.net/npm/license/@xen-orchestra/log) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/log)](https://bundlephobia.com/result?p=@xen-orchestra/log) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/log)](https://npmjs.org/package/@xen-orchestra/log)
## Install
@@ -135,25 +137,6 @@ configure(transportSyslog())
configure(transportSyslog('tcp://syslog.company.lan'))
```
## Development
```
# Install dependencies
> yarn
# Run the tests
> yarn test
# Continuously compile
> yarn dev
# Continuously run the tests
> yarn dev-test
# Build for production (automatically called by npm install)
> yarn build
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
@@ -161,10 +144,10 @@ the code.
You may:
- report any [issue](https://github.com/vatesfr/xo-web/issues/)
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
ISC © [Vates SAS](https://vates.fr)
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

122
@xen-orchestra/log/USAGE.md Normal file
View File

@@ -0,0 +1,122 @@
Everywhere something should be logged:
```js
import { createLogger } from '@xen-orchestra/log'
const log = createLogger('my-module')
log.debug('only useful for debugging')
log.info('this information is relevant to the user')
log.warn('something went wrong but did not prevent current action')
log.error('something went wrong')
log.fatal('service/app is going down')
// you can add contextual info
log.debug('new API request', {
method: 'foo',
params: [ 'bar', 'baz' ]
user: 'qux'
})
// by convention, errors go into the `error` field
log.error('could not join server', {
error,
server: 'example.org',
})
```
Then, at application level, configure the logs are handled:
```js
import { createLogger } from '@xen-orchestra/log'
import { configure, catchGlobalErrors } from '@xen-orchestra/log/configure'
import transportConsole from '@xen-orchestra/log/transports/console'
import transportEmail from '@xen-orchestra/log/transports/email'
const transport = transportEmail({
service: 'gmail',
auth: {
user: 'jane.smith@gmail.com',
pass: 'H&NbECcpXF|pyXe#%ZEb',
},
from: 'jane.smith@gmail.com',
to: ['jane.smith@gmail.com', 'sam.doe@yahoo.com'],
})
configure([
{
// if filter is a string, then it is pattern
// (https://github.com/visionmedia/debug#wildcards) which is
// matched against the namespace of the logs
filter: process.env.DEBUG,
transport: transportConsole(),
},
{
// only levels >= warn
level: 'warn',
transport,
},
])
// send all global errors (uncaught exceptions, warnings, unhandled rejections)
// to this logger
catchGlobalErrors(createLogger('app'))
```
### Transports
#### Console
```js
import transportConsole from '@xen-orchestra/log/transports/console'
configure(transportConsole())
```
#### Email
Optional dependency:
```
> yarn add nodemailer pretty-format
```
Configuration:
```js
import transportEmail from '@xen-orchestra/log/transports/email'
configure(
transportEmail({
service: 'gmail',
auth: {
user: 'jane.smith@gmail.com',
pass: 'H&NbECcpXF|pyXe#%ZEb',
},
from: 'jane.smith@gmail.com',
to: ['jane.smith@gmail.com', 'sam.doe@yahoo.com'],
})
)
```
#### Syslog
Optional dependency:
```
> yarn add split-host syslog-client
```
Configuration:
```js
import transportSyslog from '@xen-orchestra/log/transports/syslog'
// By default, log to udp://localhost:514
configure(transportSyslog())
// But TCP, a different host, or a different port can be used
configure(transportSyslog('tcp://syslog.company.lan'))
```

View File

@@ -13,8 +13,8 @@
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"author": {
"name": "Julien Fontanet",
"email": "julien.fontanet@vates.fr"
"name": "Vates SAS",
"url": "https://vates.fr"
},
"preferGlobal": false,
"main": "dist/",
@@ -39,7 +39,7 @@
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-plugin-lodash": "^3.3.2",
"cross-env": "^6.0.3",
"cross-env": "^7.0.2",
"index-modules": "^0.3.0",
"rimraf": "^3.0.0"
},
@@ -49,7 +49,7 @@
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/",
"prebuild": "yarn run clean",
"predev": "yarn run prebuild",
"prepare": "yarn run build",
"prepublishOnly": "yarn run build",
"postversion": "npm publish"
}
}

View File

@@ -12,7 +12,7 @@ const createTransport = config => {
if (Array.isArray(config)) {
const transports = config.map(createTransport)
const { length } = transports
return function() {
return function () {
for (let i = 0; i < length; ++i) {
transports[i].apply(this, arguments)
}
@@ -30,14 +30,14 @@ const createTransport = config => {
}
const orig = transport
transport = function(log) {
transport = function (log) {
if ((level !== undefined && log.level >= level) || filter(log)) {
return orig.apply(this, arguments)
}
}
} else if (level !== undefined) {
const orig = transport
transport = function(log) {
transport = function (log) {
if (log.level >= level) {
return orig.apply(this, arguments)
}

View File

@@ -38,7 +38,7 @@ const { prototype } = Logger
for (const name in LEVELS) {
const level = LEVELS[name]
prototype[name.toLowerCase()] = function(message, data) {
prototype[name.toLowerCase()] = function (message, data) {
if (typeof message !== 'string') {
if (message instanceof Error) {
data = { error: message }
@@ -54,13 +54,13 @@ for (const name in LEVELS) {
}
}
prototype.wrap = function(message, fn) {
prototype.wrap = function (message, fn) {
const logger = this
const warnAndRethrow = error => {
logger.warn(message, { error })
throw error
}
return function() {
return function () {
try {
const result = fn.apply(this, arguments)
const then = result != null && result.then

View File

@@ -13,10 +13,7 @@ export const evalTemplate = (tpl, data) => {
// -------------------------------------------------------------------
const compileGlobPatternFragment = pattern =>
pattern
.split('*')
.map(escapeRegExp)
.join('.*')
pattern.split('*').map(escapeRegExp).join('.*')
export const compileGlobPattern = pattern => {
const no = []

View File

@@ -1,6 +1,8 @@
# @xen-orchestra/mixin [![Build Status](https://travis-ci.org/${pkg.shortGitHubPath}.png?branch=master)](https://travis-ci.org/${pkg.shortGitHubPath})
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
> ${pkg.description}
# @xen-orchestra/mixin
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/mixin)](https://npmjs.org/package/@xen-orchestra/mixin) ![License](https://badgen.net/npm/license/@xen-orchestra/mixin) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/mixin)](https://bundlephobia.com/result?p=@xen-orchestra/mixin) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/mixin)](https://npmjs.org/package/@xen-orchestra/mixin)
## Install
@@ -10,29 +12,6 @@ Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/mixin
> npm install --save @xen-orchestra/mixin
```
## Usage
**TODO**
## Development
```
# Install dependencies
> yarn
# Run the tests
> yarn test
# Continuously compile
> yarn dev
# Continuously run the tests
> yarn dev-test
# Build for production (automatically called by npm install)
> yarn build
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
@@ -46,4 +25,4 @@ You may:
## License
ISC © [Vates SAS](https://vates.fr)
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

View File

View File

@@ -13,8 +13,8 @@
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"author": {
"name": "Julien Fontanet",
"email": "julien.fontanet@vates.fr"
"name": "Vates SAS",
"url": "https://vates.fr"
},
"preferGlobal": false,
"main": "dist/",
@@ -37,7 +37,7 @@
"@babel/preset-env": "^7.0.0",
"babel-plugin-dev": "^1.0.0",
"babel-plugin-lodash": "^3.3.2",
"cross-env": "^6.0.3",
"cross-env": "^7.0.2",
"rimraf": "^3.0.0"
},
"scripts": {

View File

@@ -0,0 +1,3 @@
module.exports = require('../../@xen-orchestra/babel-config')(
require('./package.json')
)

View File

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

View File

@@ -0,0 +1,141 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @xen-orchestra/openflow
[![Package Version](https://badgen.net/npm/v/@xen-orchestra/openflow)](https://npmjs.org/package/@xen-orchestra/openflow) ![License](https://badgen.net/npm/license/@xen-orchestra/openflow) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@xen-orchestra/openflow)](https://bundlephobia.com/result?p=@xen-orchestra/openflow) [![Node compatibility](https://badgen.net/npm/node/@xen-orchestra/openflow)](https://npmjs.org/package/@xen-orchestra/openflow)
> Pack and unpack OpenFlow messages
## Install
Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/openflow):
```
> npm install --save @xen-orchestra/openflow
```
## Usage
Unpacking a received OpenFlow message from a socket:
```js
import openflow from '@xen-orchestra/openflow'
import parse from '@xen-orchestra/openflow/parse-socket'
const version = openflow.versions.openFlow11
const ofProtocol = openflow.protocols[version]
function parseOpenFlowMessages(socket) {
for await (const msg of parse(socket)) {
if (msg.header !== undefined) {
const ofType = msg.header.type
switch (ofType) {
case ofProtocol.type.hello:
// Handle OFPT_HELLO
break
case ofProtocol.type.error:
// Handle OFPT_ERROR
break
case ofProtocol.type.echoRequest:
// Handle OFPT_ECHO_REQUEST
break
case ofProtocol.type.packetIn:
// Handle OFPT_PACKET_IN
break
case ofProtocol.type.featuresReply:
// Handle OFPT_FEATURES_REPLY
break
case ofProtocol.type.getConfigReply:
// Handle OFPT_GET_CONFIG_REPLY
break
case ofProtocol.type.portStatus:
// Handle OFPT_PORT_STATUS
break
case ofProtocol.type.flowRemoved:
// Handle OFPT_FLOW_REMOVED
break
default:
// Error: Invalid type
break
}
} else {
// Error: Message is unparseable
}
}
}
```
Unpacking a OpenFlow message from a buffer:
```js
import openflow from '@xen-orchestra/openflow'
const version = openflow.versions.openFlow11
const ofProtocol = openflow.protocols[version]
function processOpenFlowMessage(buf) {
const unpacked = openflow.unpack(buf)
const ofType = unpacked.header.type
switch (ofType) {
case ofProtocol.type.hello:
// Handle OFPT_HELLO
break
case ofProtocol.type.error:
// Handle OFPT_ERROR
break
case ofProtocol.type.echoRequest:
// Handle OFPT_ECHO_REQUEST
break
case ofProtocol.type.packetIn:
// Handle OFPT_PACKET_IN
break
case ofProtocol.type.featuresReply:
// Handle OFPT_FEATURES_REPLY
break
case ofProtocol.type.getConfigReply:
// Handle OFPT_GET_CONFIG_REPLY
break
case ofProtocol.type.portStatus:
// Handle OFPT_PORT_STATUS
break
case ofProtocol.type.flowRemoved:
// Handle OFPT_FLOW_REMOVED
break
default:
// Error: Invalid type
break
}
}
```
Packing an OpenFlow OFPT_HELLO message:
```js
import openflow from '@xen-orchestra/openflow'
const version = openflow.versions.openFlow11
const ofProtocol = openflow.protocols[version]
const buf = openflow.pack({
header: {
version,
type: ofProtocol.type.hello,
xid: 1,
},
})
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

View File

@@ -0,0 +1,108 @@
Unpacking a received OpenFlow message from a socket:
```js
import openflow from '@xen-orchestra/openflow'
import parse from '@xen-orchestra/openflow/parse-socket'
const version = openflow.versions.openFlow11
const ofProtocol = openflow.protocols[version]
function parseOpenFlowMessages(socket) {
for await (const msg of parse(socket)) {
if (msg.header !== undefined) {
const ofType = msg.header.type
switch (ofType) {
case ofProtocol.type.hello:
// Handle OFPT_HELLO
break
case ofProtocol.type.error:
// Handle OFPT_ERROR
break
case ofProtocol.type.echoRequest:
// Handle OFPT_ECHO_REQUEST
break
case ofProtocol.type.packetIn:
// Handle OFPT_PACKET_IN
break
case ofProtocol.type.featuresReply:
// Handle OFPT_FEATURES_REPLY
break
case ofProtocol.type.getConfigReply:
// Handle OFPT_GET_CONFIG_REPLY
break
case ofProtocol.type.portStatus:
// Handle OFPT_PORT_STATUS
break
case ofProtocol.type.flowRemoved:
// Handle OFPT_FLOW_REMOVED
break
default:
// Error: Invalid type
break
}
} else {
// Error: Message is unparseable
}
}
}
```
Unpacking a OpenFlow message from a buffer:
```js
import openflow from '@xen-orchestra/openflow'
const version = openflow.versions.openFlow11
const ofProtocol = openflow.protocols[version]
function processOpenFlowMessage(buf) {
const unpacked = openflow.unpack(buf)
const ofType = unpacked.header.type
switch (ofType) {
case ofProtocol.type.hello:
// Handle OFPT_HELLO
break
case ofProtocol.type.error:
// Handle OFPT_ERROR
break
case ofProtocol.type.echoRequest:
// Handle OFPT_ECHO_REQUEST
break
case ofProtocol.type.packetIn:
// Handle OFPT_PACKET_IN
break
case ofProtocol.type.featuresReply:
// Handle OFPT_FEATURES_REPLY
break
case ofProtocol.type.getConfigReply:
// Handle OFPT_GET_CONFIG_REPLY
break
case ofProtocol.type.portStatus:
// Handle OFPT_PORT_STATUS
break
case ofProtocol.type.flowRemoved:
// Handle OFPT_FLOW_REMOVED
break
default:
// Error: Invalid type
break
}
}
```
Packing an OpenFlow OFPT_HELLO message:
```js
import openflow from '@xen-orchestra/openflow'
const version = openflow.versions.openFlow11
const ofProtocol = openflow.protocols[version]
const buf = openflow.pack({
header: {
version,
type: ofProtocol.type.hello,
xid: 1,
},
})
```

View File

@@ -0,0 +1,40 @@
{
"description": "Pack and unpack OpenFlow messages",
"private": false,
"name": "@xen-orchestra/openflow",
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@xen-orchestra/openflow",
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"repository": {
"directory": "@xen-orchestra/openflow",
"type": "git",
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"version": "0.1.1",
"engines": {
"node": ">=8.10"
},
"main": "dist/",
"scripts": {
"build": "cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/",
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/",
"postversion": "npm publish --access public",
"prebuild": "rimraf dist/",
"predev": "yarn run prebuild",
"prepublishOnly": "yarn run build"
},
"devDependencies": {
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"cross": "^1.0.0",
"rimraf": "^3.0.0"
},
"dependencies": {
"@vates/read-chunk": "^0.1.0"
},
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
},
"license": "ISC"
}

View File

@@ -0,0 +1 @@
module.exports = require('./dist/parse-socket')

View File

@@ -0,0 +1,9 @@
export default {
size: 8,
offsets: {
version: 0,
type: 1,
length: 2,
xid: 4,
},
}

View File

@@ -0,0 +1,38 @@
import get from './util/get-from-map'
import ofVersion from './version'
// TODO: More openflow versions
import of11 from './openflow-11/index'
import scheme from './default-header-scheme'
// =============================================================================
const OPENFLOW = {
[ofVersion.openFlow11]: of11,
}
// =============================================================================
export default {
versions: ofVersion,
protocols: { [ofVersion.openFlow11]: of11.protocol },
// ---------------------------------------------------------------------------
pack: object => {
const version = object.header.version
return get(
OPENFLOW,
version,
`Unsupported OpenFlow version: ${version}`
).pack(object)
},
unpack: (buffer, offset = 0) => {
const version = buffer.readUInt8(offset + scheme.offsets.version)
return get(
OPENFLOW,
version,
`Unsupported OpenFlow version: ${version}`
).unpack(buffer, offset)
},
}

View File

@@ -0,0 +1,58 @@
import get from '../../util/get-from-map'
import ofOutput from './output'
import of from '../openflow-11'
// =============================================================================
const ACTION = {
[of.actionType.output]: ofOutput,
/* TODO:
[of.actionType.group]: ,
[of.actionType.setVlanId]: ,
[of.actionType.setVlanPcp]: ,
[of.actionType.setDlSrc]: ,
[of.actionType.setDlDst]: ,
[of.actionType.setNwSrc]: ,
[of.actionType.setNwDst]: ,
[of.actionType.setNwTos]: ,
[of.actionType.setNwEcn]: ,
[of.actionType.setTpSrc]: ,
[of.actionType.setTpDst]: ,
[of.actionType.copyTtlOut]: ,
[of.actionType.copyTtlIn]: ,
[of.actionType.setMplsLabel]: ,
[of.actionType.setMplsTc]: ,
[of.actionType.setMplsTtl]: ,
[of.actionType.decMplsTtl]: ,
[of.actionType.pushVlan]: ,
[of.actionType.popVlan]: ,
[of.actionType.pushMpls]: ,
[of.actionType.popMpls]: ,
[of.actionType.setQueue]: ,
[of.actionType.setNwTtl]: ,
[of.actionType.decNwTtl]: ,
[of.actionType.experimenter]:
*/
}
// =============================================================================
export default {
pack: (object, buffer = undefined, offset = 0) => {
const { type } = object
return get(ACTION, type, `Invalid action type: ${type}`).pack(
object,
buffer,
offset
)
},
unpack: (buffer, offset = 0) => {
const type = buffer.readUInt16BE(offset + of.offsets.actionHeader.type)
return get(ACTION, type, `Invalid action type: ${type}`).unpack(
buffer,
offset
)
},
}

View File

@@ -0,0 +1,45 @@
import assert from 'assert'
import of from '../openflow-11'
// =============================================================================
const OFFSETS = of.offsets.actionOutput
const PAD_LENGTH = 6
// =============================================================================
export default {
pack: (object, buffer = undefined, offset = 0) => {
assert(object.type === of.actionType.output)
object.len = of.sizes.actionOutput
buffer = buffer !== undefined ? buffer : Buffer.alloc(object.len)
buffer.writeUInt16BE(object.type, offset + OFFSETS.type)
buffer.writeUInt16BE(object.len, offset + OFFSETS.len)
buffer.writeUInt32BE(object.port, offset + OFFSETS.port)
buffer.writeUInt16BE(object.max_len, offset + OFFSETS.maxLen)
buffer.fill(0, offset + OFFSETS.pad, offset + OFFSETS.pad + PAD_LENGTH)
return buffer
},
unpack: (buffer, offset = 0) => {
const object = {}
object.type = buffer.readUInt16BE(offset + OFFSETS.type)
assert(object.type === of.actionType.output)
object.len = buffer.readUInt16BE(offset + OFFSETS.len)
assert(object.len === of.sizes.actionOutput)
object.port = buffer.readUInt32BE(offset + OFFSETS.port)
object.max_len = buffer.readUInt16BE(offset + OFFSETS.maxLen)
return object
},
}

View File

@@ -0,0 +1,49 @@
import get from '../util/get-from-map'
import echo from './message/echo'
import error from './message/error'
import hello from './message/hello'
import featuresRequest from './message/features-request'
import featuresReply from './message/features-reply'
import getConfigRequest from './message/get-config-request'
import switchConfig from './message/switch-config'
import flowMod from './message/flow-mod'
import of from './openflow-11'
// =============================================================================
const MESSAGE = {
[of.type.hello]: hello,
[of.type.error]: error,
[of.type.featuresRequest]: featuresRequest,
[of.type.featuresReply]: featuresReply,
[of.type.echoRequest]: echo,
[of.type.echoReply]: echo,
[of.type.getConfigRequest]: getConfigRequest,
[of.type.getConfigReply]: switchConfig,
[of.type.setConfig]: switchConfig,
[of.type.flowMod]: flowMod,
}
// =============================================================================
export default {
protocol: of,
// ---------------------------------------------------------------------------
pack: object => {
const type = object.header.type
return get(MESSAGE, type, `Invalid OpenFlow message type: ${type}`).pack(
object
)
},
unpack: (buffer, offset = 0) => {
const type = buffer.readUInt8(offset + of.offsets.header.type)
return get(MESSAGE, type, `Invalid OpenFlow message type: ${type}`).unpack(
buffer,
offset
)
},
}

View File

@@ -0,0 +1,102 @@
import assert from 'assert'
import get from '../../util/get-from-map'
import ofAction from '../action/action'
import of from '../openflow-11'
// =============================================================================
const SIZES = {
[of.actionType.output]: of.sizes.actionOutput,
[of.actionType.group]: of.sizes.actionGroup,
[of.actionType.setVlanId]: of.sizes.actionVlanId,
[of.actionType.setVlanPcp]: of.sizes.actionVlanPcp,
[of.actionType.setDlSrc]: of.sizes.actionDlAddr,
[of.actionType.setDlDst]: of.sizes.actionDlAddr,
[of.actionType.setNwSrc]: of.sizes.actionNwAddr,
[of.actionType.setNwDst]: of.sizes.actionNwAddr,
[of.actionType.setNwTos]: of.sizes.actionNwTos,
[of.actionType.setNwEcn]: of.sizes.actionNwEcn,
[of.actionType.setTpSrc]: of.sizes.actionTpPort,
[of.actionType.setTpDst]: of.sizes.actionTpPort,
[of.actionType.copyTtlOut]: of.sizes.actionHeader,
[of.actionType.copyTtlIn]: of.sizes.actionHeader,
[of.actionType.setMplsLabel]: of.sizes.actionMplsLabel,
[of.actionType.setMplsTc]: of.sizes.actionMplsTc,
[of.actionType.setMplsTtl]: of.sizes.actionMplsTtl,
[of.actionType.decMplsTtl]: of.sizes.actionMplsTtl,
[of.actionType.pushVlan]: of.sizes.actionPush,
[of.actionType.popVlan]: of.sizes.actionHeader,
[of.actionType.pushMpls]: of.sizes.actionPush,
[of.actionType.popMpls]: of.sizes.actionPopMpls,
[of.actionType.setQueue]: of.sizes.actionSetQueue,
[of.actionType.setNwTtl]: of.sizes.actionNwTtl,
[of.actionType.decNwTtl]: of.sizes.actionNwTtl,
}
// -----------------------------------------------------------------------------
const TYPES = [
of.instructionType.clearActions,
of.instructionType.writeActions,
of.instructionType.applyActions,
]
const OFFSETS = of.offsets.instructionActions
const PAD_LENGTH = 4
// =============================================================================
export default {
pack: (object, buffer = undefined, offset = 0) => {
const { type } = object
assert(TYPES.includes(type))
object.len = of.sizes.instructionActions
const { actions = [] } = object
actions.forEach(action => {
assert(Object.values(of.actionType).includes(action.type))
// TODO: manage experimenter
object.len += get(
SIZES,
action.type,
`Invalid action type: ${action.type}`
)
})
buffer = buffer !== undefined ? buffer : Buffer.alloc(object.len)
buffer.writeUInt16BE(type, offset + OFFSETS.type)
buffer.writeUInt16BE(object.len, offset + OFFSETS.len)
buffer.fill(0, offset + OFFSETS.pad, offset + OFFSETS.pad + PAD_LENGTH)
let actionOffset = offset + OFFSETS.actions
actions.forEach(action => {
ofAction.pack(action, buffer, actionOffset)
actionOffset += SIZES[action.type]
})
},
unpack: (buffer = undefined, offset = 0) => {
const type = buffer.readUInt16BE(offset + OFFSETS.type)
assert(TYPES.includes(type))
const object = { type }
object.len = buffer.readUInt16BE(offset + OFFSETS.len)
if (type === of.instructionType.clearActions) {
// No actions for this type
return object
}
object.actions = []
let actionOffset = offset + OFFSETS.actions
while (actionOffset < object.len) {
const action = ofAction.unpack(buffer, actionOffset)
actionOffset += action.len
object.actions.push(action)
}
return object
},
}

View File

@@ -0,0 +1,43 @@
import get from '../../util/get-from-map'
import actions from './actions'
// import goToTable from './goToTable'
import of from '../openflow-11'
// import writeMetadata from './writeMetadata'
// =============================================================================
const INSTRUCTION = {
/* TODO:
[of.instructionType.goToTable]: goToTable,
[of.instructionType.writeMetadata]: writeMetadata,
*/
[of.instructionType.writeActions]: actions,
[of.instructionType.applyActions]: actions,
[of.instructionType.clearActions]: actions,
}
// -----------------------------------------------------------------------------
const OFFSETS = of.offsets.instruction
// =============================================================================
export default {
pack: (object, buffer = undefined, offset = 0) => {
const { type } = object
return get(INSTRUCTION, type, `Invalid instruction type: ${type}`).pack(
object,
buffer,
offset
)
},
unpack: (buffer = undefined, offset = 0) => {
const type = buffer.readUInt16BE(offset + OFFSETS.type)
return get(INSTRUCTION, type, `Invalid instruction type: ${type}`).unpack(
buffer,
offset
)
},
}

View File

@@ -0,0 +1,46 @@
import assert from 'assert'
import ofHeader from './header'
import of from '../openflow-11'
// =============================================================================
const OFFSETS = of.offsets.echo
const TYPES = [of.type.echoRequest, of.type.echoReply]
// =============================================================================
export default {
pack: object => {
const { header, data } = object
assert(TYPES.includes(header.type))
const dataSize = data !== undefined ? data.length : 0
header.length = of.sizes.header + dataSize
const buffer = Buffer.alloc(header.length)
ofHeader.pack(header, buffer, OFFSETS.header)
if (dataSize > 0) {
data.copy(buffer, OFFSETS.data, 0, dataSize)
}
return buffer
},
unpack: (buffer, offset = 0) => {
const header = ofHeader.unpack(buffer, offset + OFFSETS.header)
assert(TYPES.includes(header.type))
const object = { header }
const dataSize = header.length - of.sizes.header
if (dataSize > 0) {
object.data = Buffer.alloc(dataSize)
buffer.copy(
object.data,
0,
offset + OFFSETS.data,
offset + OFFSETS.data + dataSize
)
}
return object
},
}

View File

@@ -0,0 +1,79 @@
import assert from 'assert'
import get from '../../util/get-from-map'
import ofHeader from './header'
import of from '../openflow-11'
// =============================================================================
const ERROR_CODE = {
[of.errorType.helloFailed]: of.helloFailedCode,
[of.errorType.badRequest]: of.badRequestCode,
[of.errorType.badAction]: of.badActionCode,
[of.errorType.badInstruction]: of.badInstructionCode,
[of.errorType.badMatch]: of.badMatchCode,
[of.errorType.flowModFailed]: of.flowModFailedCode,
[of.errorType.groupModFailed]: of.groupModFailedCode,
[of.errorType.portModFailed]: of.portModFailedCode,
[of.errorType.tableModFailed]: of.tableModFailedCode,
[of.errorType.queueOpFailed]: of.queueOpFailedCode,
[of.errorType.switchConfigFailed]: of.switchConfigFailedCode,
}
// -----------------------------------------------------------------------------
const OFFSETS = of.offsets.errorMsg
// =============================================================================
export default {
pack: (object, buffer = undefined, offset = 0) => {
const { header, type, code, data } = object
assert(header.type === of.type.error)
const errorCodes = get(ERROR_CODE, type, `Invalid error type: ${type}`)
assert(Object.values(errorCodes).includes(code))
object.length = of.sizes.errorMsg
if (data !== undefined) {
object.length += data.length
}
buffer = buffer !== undefined ? buffer : Buffer.alloc(object.length)
ofHeader.pack(header, buffer, offset + OFFSETS.header)
buffer.writeUInt16BE(type, offset + OFFSETS.type)
buffer.writeUInt16BE(code, offset + OFFSETS.code)
if (data !== undefined) {
data.copy(buffer, offset + OFFSETS.data, 0, data.length)
}
return buffer
},
unpack: (buffer, offset = 0) => {
const header = ofHeader.unpack(buffer, offset + OFFSETS.header)
assert(header.type === of.type.error)
const type = buffer.readUInt16BE(offset + OFFSETS.type)
const errorCodes = get(ERROR_CODE, type, `Invalid error type: ${type}`)
const code = buffer.readUInt16BE(offset + OFFSETS.code)
assert(Object.values(errorCodes).includes(code))
const object = { header, type, code }
const dataSize = header.length - of.sizes.errorMsg
if (dataSize > 0) {
object.data = Buffer.alloc(dataSize)
buffer.copy(
object.data,
0,
offset + OFFSETS.data,
offset + OFFSETS.data + dataSize
)
}
return object
},
}

View File

@@ -0,0 +1,73 @@
import assert from 'assert'
import ofHeader from './header'
import ofPort from '../struct/port'
import of from '../openflow-11'
// =============================================================================
const OFFSETS = of.offsets.switchFeatures
const PAD_LENGTH = 3
// =============================================================================
export default {
pack: object => {
const {
header,
datapath_id: did,
n_buffers: nBufs,
n_tables: nTables,
capabilities,
reserved,
ports,
} = object
assert(header.type === of.type.featuresReply)
header.length = of.sizes.switchFeatures + ports.length * of.sizes.port
const buffer = Buffer.alloc(header.length)
ofHeader.pack(header, buffer, OFFSETS.header)
buffer.writeBigUInt64BE(did, OFFSETS.datapathId)
buffer.writeUInt32BE(nBufs, OFFSETS.nBuffers)
buffer.writeUInt8(nTables, OFFSETS.nTables)
buffer.fill(0, OFFSETS.pad, OFFSETS.pad + PAD_LENGTH)
buffer.writeUInt32BE(capabilities, OFFSETS.capabilities)
buffer.writeUInt32BE(reserved, OFFSETS.reserved)
let portsOffset = 0
ports.forEach(port => {
ofPort.pack(port, buffer, OFFSETS.ports + portsOffset++ * of.sizes.port)
})
return buffer
},
unpack: (buffer, offset = 0) => {
const header = ofHeader.unpack(buffer, offset + OFFSETS.header)
assert(header.type === of.type.featuresReply)
const object = { header }
object.datapath_id = buffer.toString(
'hex',
offset + OFFSETS.datapathId,
offset + OFFSETS.datapathId + 8
)
object.n_buffers = buffer.readUInt32BE(offset + OFFSETS.nBuffers)
object.n_tables = buffer.readUInt8(offset + OFFSETS.nTables)
object.capabilities = buffer.readUInt32BE(offset + OFFSETS.capabilities)
object.reserved = buffer.readUInt32BE(offset + OFFSETS.reserved)
object.ports = []
const nPorts = (header.length - of.sizes.switchFeatures) / of.sizes.port
for (let i = 0; i < nPorts; ++i) {
object.ports.push(
ofPort.unpack(buffer, offset + OFFSETS.ports + i * of.sizes.port)
)
}
return object
},
}

View File

@@ -0,0 +1,24 @@
import assert from 'assert'
import ofHeader from './header'
import of from '../openflow-11'
// =============================================================================
export default {
pack: object => {
const { header } = object
assert(header.type === of.type.featuresRequest)
header.length = of.sizes.featuresRequest
return ofHeader.pack(header)
},
unpack: (buffer, offset = 0) => {
const header = ofHeader.unpack(buffer, offset)
assert(header.type === of.type.featuresRequest)
assert(header.length === of.sizes.featuresRequest)
return { header }
},
}

View File

@@ -0,0 +1,197 @@
import assert from 'assert'
import get from '../../util/get-from-map'
import ofInstruction from '../instruction/instruction'
import uIntHelper from '../../util/uint-helper'
import ofHeader from './header'
import of from '../openflow-11'
import ofMatch from '../struct/match/match'
// =============================================================================
const INSTRUCTION_SIZE = {
[of.instructionType.goToTable]: of.sizes.instructionWriteMetadata,
[of.instructionType.writeMetadata]: of.sizes.instructionGotoTable,
[of.instructionType.clearActions]: of.sizes.instructionActions,
[of.instructionType.writeActions]: of.sizes.instructionActions,
[of.instructionType.applyActions]: of.sizes.instructionActions,
}
const ACTION_SIZE = {
[of.actionType.output]: of.sizes.actionOutput,
[of.actionType.group]: of.sizes.actionGroup,
[of.actionType.setVlanId]: of.sizes.actionVlanId,
[of.actionType.setVlanPcp]: of.sizes.actionVlanPcp,
[of.actionType.setDlSrc]: of.sizes.actionDlAddr,
[of.actionType.setDlDst]: of.sizes.actionDlAddr,
[of.actionType.setNwSrc]: of.sizes.actionNwAddr,
[of.actionType.setNwDst]: of.sizes.actionNwAddr,
[of.actionType.setNwTos]: of.sizes.actionNwTos,
[of.actionType.setNwEcn]: of.sizes.actionNwEcn,
[of.actionType.setTpSrc]: of.sizes.actionTpPort,
[of.actionType.setTpDst]: of.sizes.actionTpPort,
[of.actionType.copyTtlOut]: of.sizes.actionHeader,
[of.actionType.copyTtlIn]: of.sizes.actionHeader,
[of.actionType.setMplsLabel]: of.sizes.actionMplsLabel,
[of.actionType.setMplsTc]: of.sizes.actionMplsTc,
[of.actionType.setMplsTtl]: of.sizes.actionMplsTtl,
[of.actionType.decMplsTtl]: of.sizes.actionMplsTtl,
[of.actionType.pushVlan]: of.sizes.actionPush,
[of.actionType.popVlan]: of.sizes.actionHeader,
[of.actionType.pushMpls]: of.sizes.actionPush,
[of.actionType.popMpls]: of.sizes.actionPopMpls,
[of.actionType.setQueue]: of.sizes.actionSetQueue,
[of.actionType.setNwTtl]: of.sizes.actionNwTtl,
[of.actionType.decNwTtl]: of.sizes.actionNwTtl,
}
// -----------------------------------------------------------------------------
const OFFSETS = of.offsets.flowMod
const COOKIE_LENGTH = 8
const PAD_LENGTH = 2
// =============================================================================
export default {
pack: (object, buffer = undefined, offset = 0) => {
const {
header,
cookie,
cookie_mask,
table_id = 0,
command,
idle_timeout = 0,
hard_timeout = 0,
priority = of.defaultPriority,
buffer_id = 0xffffffff,
out_port = of.port.any,
out_group = of.group.any,
flags = 0,
match,
instructions = [],
} = object
// fill header length
header.length = of.sizes.flowMod
instructions.forEach(instruction => {
header.length += get(
INSTRUCTION_SIZE,
instruction.type,
`Invalid instruction type: ${instruction.type}`
)
const { actions = [] } = instruction
actions.forEach(action => {
header.length += get(
ACTION_SIZE,
action.type,
`Invalid instruction type: ${action.type}`
)
})
})
buffer = buffer !== undefined ? buffer : Buffer.alloc(header.length)
ofHeader.pack(header, buffer, offset + OFFSETS.header)
if (cookie !== undefined) {
if (cookie_mask !== undefined) {
cookie_mask.copy(buffer, offset + OFFSETS.cookieMask)
} else {
buffer.fill(
0x00,
offset + OFFSETS.cookie_mask,
offset + OFFSETS.cookieMask + COOKIE_LENGTH
)
}
cookie.copy(buffer, offset + OFFSETS.cookie)
} else {
buffer.fill(
0x00,
offset + OFFSETS.cookie,
offset + OFFSETS.cookie + COOKIE_LENGTH
)
buffer.fill(
0xff,
offset + OFFSETS.cookieMask,
offset + OFFSETS.cookieMask + COOKIE_LENGTH
)
}
buffer.writeUInt8(table_id, offset + OFFSETS.tableId)
assert(Object.values(of.flowModCommand).includes(command))
buffer.writeUInt8(command, offset + OFFSETS.command)
buffer.writeUInt16BE(idle_timeout, offset + OFFSETS.idleTimeout)
buffer.writeUInt16BE(hard_timeout, offset + OFFSETS.hardTimeout)
buffer.writeUInt16BE(priority, offset + OFFSETS.priority)
buffer.writeUInt32BE(buffer_id, offset + OFFSETS.bufferId)
buffer.writeUInt32BE(out_port, offset + OFFSETS.outPort)
buffer.writeUInt32BE(out_group, offset + OFFSETS.outGroup)
buffer.writeUInt16BE(flags, offset + OFFSETS.flags)
buffer.fill(0, offset + OFFSETS.pad, offset + OFFSETS.pad + PAD_LENGTH)
ofMatch.pack(match, buffer, offset + OFFSETS.match)
let instructionOffset = offset + OFFSETS.instructions
instructions.forEach(instruction => {
ofInstruction.pack(instruction, buffer, instructionOffset)
instructionOffset += instruction.len
})
return buffer
},
unpack: (buffer, offset = 0) => {
const header = ofHeader.unpack(buffer, offset + OFFSETS.header)
assert(header.type === of.type.flowMod)
const object = { header }
object.cookie = Buffer.alloc(COOKIE_LENGTH)
buffer.copy(
object.cookie,
0,
offset + OFFSETS.cookie,
offset + OFFSETS.cookie + COOKIE_LENGTH
)
if (
!uIntHelper.isUInt64None([
buffer.readUInt32BE(offset + OFFSETS.cookieMask),
buffer.readUInt32BE(offset + OFFSETS.cookieMask + COOKIE_LENGTH / 2),
])
) {
object.cookie_mask = Buffer.alloc(COOKIE_LENGTH)
buffer.copy(
object.cookie_mask,
0,
offset + OFFSETS.cookieMask,
offset + OFFSETS.cookieMask + COOKIE_LENGTH
)
}
object.table_id = buffer.readUInt8(offset + OFFSETS.tableId)
object.command = buffer.readUInt8(offset + OFFSETS.command)
assert(Object.values(of.flowModCommand).includes(object.command))
object.idle_timeout = buffer.readUInt16BE(offset + OFFSETS.idleTimeout)
object.hard_timeout = buffer.readUInt16BE(offset + OFFSETS.hardTimeout)
object.priority = buffer.readUInt16BE(offset + OFFSETS.priority)
object.buffer_id = buffer.readUInt32BE(offset + OFFSETS.bufferId)
object.out_port = buffer.readUInt32BE(offset + OFFSETS.outPort)
object.out_group = buffer.readUInt32BE(offset + OFFSETS.outGroup)
object.flags = buffer.readUInt16BE(offset + OFFSETS.flags)
object.match = ofMatch.unpack(buffer, offset + OFFSETS.match)
object.instructions = []
let instructionOffset = offset + OFFSETS.instructions
while (instructionOffset < header.length) {
const instruction = ofInstruction.unpack(buffer, instructionOffset)
object.instructions.push(instruction)
instructionOffset += instruction.len
}
return object
},
}

View File

@@ -0,0 +1,24 @@
import assert from 'assert'
import ofHeader from './header'
import of from '../openflow-11'
// =============================================================================
export default {
pack: object => {
const { header } = object
assert(header.type === of.type.getConfigRequest)
header.length = of.sizes.header
return ofHeader.pack(header)
},
unpack: (buffer, offset = 0) => {
const header = ofHeader.unpack(buffer, offset)
assert(header.type === of.type.getConfigRequest)
assert(header.length === of.sizes.header)
return { header }
},
}

View File

@@ -0,0 +1,39 @@
import assert from 'assert'
import of from '../openflow-11'
// =============================================================================
const OFFSETS = of.offsets.header
// =============================================================================
export default {
pack: (object, buffer = undefined, offset = 0) => {
buffer = buffer !== undefined ? buffer : Buffer.alloc(of.sizes.header)
const { version, type, length, xid } = object
assert(version === of.version)
assert(Object.values(of.type).includes(type))
buffer.writeUInt8(version, offset + OFFSETS.version)
buffer.writeUInt8(type, offset + OFFSETS.type)
buffer.writeUInt16BE(length, offset + OFFSETS.length)
buffer.writeUInt32BE(xid, offset + OFFSETS.xid)
return buffer
},
unpack: (buffer, offset = 0) => {
const version = buffer.readUInt8(offset + OFFSETS.version)
assert(version === of.version)
const type = buffer.readUInt8(offset + OFFSETS.type)
assert(Object.values(of.type).includes(type))
const length = buffer.readUInt16BE(offset + OFFSETS.length)
const xid = buffer.readUInt32BE(offset + OFFSETS.xid)
return { version, type, length, xid }
},
}

View File

@@ -0,0 +1,27 @@
import assert from 'assert'
import ofHeader from './header'
import of from '../openflow-11'
// =============================================================================
const OFFSETS = of.offsets.hello
// =============================================================================
export default {
pack: object => {
const { header } = object
assert(header.type === of.type.hello)
header.length = of.sizes.hello
return ofHeader.pack(header)
},
unpack: (buffer, offset = 0) => {
const header = ofHeader.unpack(buffer, offset + OFFSETS.header)
assert(header.type === of.type.hello)
return { header }
},
}

View File

@@ -0,0 +1,38 @@
import assert from 'assert'
import ofHeader from './header'
import of from '../openflow-11'
// =============================================================================
const OFFSETS = of.offsets.switchConfig
const TYPES = [of.type.getConfigReply, of.type.setConfig]
// =============================================================================
export default {
pack: object => {
const { header, flags, miss_send_len } = object
assert(TYPES.includes(header.type))
header.length = of.sizes.switchConfig
const buffer = Buffer.alloc(header.length)
ofHeader.pack(header, buffer, OFFSETS.header)
buffer.writeUInt16BE(flags, OFFSETS.flags)
buffer.writeUInt16BE(miss_send_len, OFFSETS.missSendLen)
return buffer
},
unpack: (buffer, offset = 0) => {
const header = ofHeader.unpack(buffer, offset + OFFSETS.header)
assert(TYPES.includes(header.type))
assert(header.length === of.sizes.switchConfig)
const flags = buffer.readUInt16BE(offset + OFFSETS.flags)
const miss_send_len = buffer.readUInt16BE(offset + OFFSETS.missSendLen)
return { header, flags, miss_send_len }
},
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,374 @@
import assert from 'assert'
import addressParser from '../../../util/addrress-parser'
import uIntHelper from '../../../util/uint-helper'
import of from '../../openflow-11'
// =============================================================================
const OFFSETS = of.offsets.match
const WILDCARDS = of.flowWildcards
const IP4_ADDR_LEN = 4
const METADATA_LENGTH = 8
const PAD_LENGTH = 1
const PAD2_LENGTH = 3
// =============================================================================
export default {
pack: (object, buffer = undefined, offset = 0) => {
assert(object.type === of.matchType.standard)
object.length = of.sizes.match
buffer = buffer !== undefined ? buffer : Buffer.alloc(object.length)
buffer.writeUInt16BE(object.type, offset + OFFSETS.type)
buffer.writeUInt16BE(object.length, offset + OFFSETS.length)
let wildcards = 0
let inPort = 0
if (object.in_port !== undefined) {
inPort = object.in_port
} else {
wildcards |= WILDCARDS.inPort
}
buffer.writeUInt32BE(inPort, offset + OFFSETS.inPort)
if (object.dl_src !== undefined) {
if (object.dl_src_mask !== undefined) {
addressParser.stringToEth(
object.dl_src_mask,
buffer,
offset + OFFSETS.dlSrcMask
)
} else {
buffer.fill(
0x00,
offset + OFFSETS.dlSrcMask,
offset + OFFSETS.dlSrcMask + of.ethAddrLen
)
}
addressParser.stringToEth(object.dl_src, buffer, offset + OFFSETS.dlSrc)
} else {
buffer.fill(
0x00,
offset + OFFSETS.dlSrc,
offset + OFFSETS.dlSrc + of.ethAddrLen
)
buffer.fill(
0xff,
offset + OFFSETS.dlSrcMask,
offset + OFFSETS.dlSrcMask + of.ethAddrLen
)
}
if (object.dl_dst !== undefined) {
if (object.dl_dst_mask !== undefined) {
addressParser.stringToEth(
object.dl_dst_mask,
buffer,
offset + OFFSETS.dlDstMask
)
} else {
buffer.fill(
0x00,
offset + OFFSETS.dlDstMask,
offset + OFFSETS.dlDstMask + of.ethAddrLen
)
}
addressParser.stringToEth(object.dl_dst, buffer, offset + OFFSETS.dlDst)
} else {
buffer.fill(
0x00,
offset + OFFSETS.dlDst,
offset + OFFSETS.dlDst + of.ethAddrLen
)
buffer.fill(
0xff,
offset + OFFSETS.dlDstMask,
offset + OFFSETS.dlDstMask + of.ethAddrLen
)
}
let dlVlan = 0
if (object.dl_vlan !== undefined) {
dlVlan = object.dl_vlan
} else {
wildcards |= WILDCARDS.dlVlan
}
buffer.writeUInt16BE(dlVlan, offset + OFFSETS.dlVlan)
let dlVlanPcp = 0
if (object.dl_vlan_pcp !== undefined) {
dlVlanPcp = object.dl_vlan_pcp
} else {
wildcards |= WILDCARDS.dlVlanPcp
}
buffer.writeUInt8(dlVlanPcp, offset + OFFSETS.dlVlanPcp)
buffer.fill(0, offset + OFFSETS.pad1, offset + OFFSETS.pad1 + PAD_LENGTH)
let dlType = 0
if (object.dl_type !== undefined) {
dlType = object.dl_type
} else {
wildcards |= WILDCARDS.dlType
}
buffer.writeUInt16BE(dlType, offset + OFFSETS.dlType)
let nwTos = 0
if (object.nw_tos !== undefined) {
nwTos = object.nw_tos
} else {
wildcards |= WILDCARDS.nwTos
}
buffer.writeUInt8(nwTos, offset + OFFSETS.nwTos)
let nwProto = 0
if (object.nw_proto !== undefined) {
nwProto = object.nw_proto
} else {
wildcards |= WILDCARDS.nwProto
}
buffer.writeUInt8(nwProto, offset + OFFSETS.nwProto)
if (object.nw_src !== undefined) {
if (object.nw_src_mask !== undefined) {
addressParser.stringToip4(
object.nw_src_mask,
buffer,
offset + OFFSETS.nwSrcMask
)
} else {
buffer.fill(
0x00,
offset + OFFSETS.nwSrcMask,
offset + OFFSETS.nwSrcMask + IP4_ADDR_LEN
)
}
addressParser.stringToip4(object.nw_src, buffer, offset + OFFSETS.nwSrc)
} else {
buffer.fill(
0x00,
offset + OFFSETS.nwSrc,
offset + OFFSETS.nwSrc + IP4_ADDR_LEN
)
buffer.fill(
0xff,
offset + OFFSETS.nwSrcMask,
offset + OFFSETS.nwSrcMask + IP4_ADDR_LEN
)
}
if (object.nw_dst !== undefined) {
if (object.nw_dst_mask !== undefined) {
addressParser.stringToip4(
object.nw_dst_mask,
buffer,
offset + OFFSETS.nwDstMask
)
} else {
buffer.fill(
0x00,
offset + OFFSETS.nwDstMask,
offset + OFFSETS.nwDstMask + IP4_ADDR_LEN
)
}
addressParser.stringToip4(object.nw_dst, buffer, offset + OFFSETS.nwDst)
} else {
buffer.fill(
0x00,
offset + OFFSETS.nwDst,
offset + OFFSETS.nwDst + IP4_ADDR_LEN
)
buffer.fill(
0xff,
offset + OFFSETS.nwDstMask,
offset + OFFSETS.nwDstMask + IP4_ADDR_LEN
)
}
let tpSrc = 0
if (object.tp_src !== undefined) {
tpSrc = object.tp_src
} else {
wildcards |= WILDCARDS.tpSrc
}
buffer.writeUInt16BE(tpSrc, offset + OFFSETS.tpSrc)
let tpDst = 0
if (object.tp_dst !== undefined) {
tpDst = object.tp_dst
} else {
wildcards |= WILDCARDS.tpDst
}
buffer.writeUInt16BE(tpDst, offset + OFFSETS.tpDst)
let mplsLabel = 0
if (object.mpls_label !== undefined) {
mplsLabel = object.mpls_label
} else {
wildcards |= WILDCARDS.mplsLabel
}
buffer.writeUInt32BE(mplsLabel, offset + OFFSETS.mplsLabel)
let mplsTc = 0
if (object.mpls_tc !== undefined) {
mplsTc = object.mpls_tc
} else {
wildcards |= WILDCARDS.mplsTc
}
buffer.writeUInt8(mplsTc, offset + OFFSETS.mplsTc)
buffer.fill(0, offset + OFFSETS.pad2, offset + OFFSETS.pad2 + PAD2_LENGTH)
if (object.metadata !== undefined) {
if (object.metadata_mask !== undefined) {
buffer.copy(
object.metadata_mask,
0,
offset + OFFSETS.metadataMask,
offset + OFFSETS.metadataMask + METADATA_LENGTH
)
} else {
buffer.fill(
0x00,
offset + OFFSETS.metadataMask,
offset + OFFSETS.metadataMask + METADATA_LENGTH
)
}
buffer.copy(
object.metadata,
0,
offset + OFFSETS.metadata,
offset + OFFSETS.metadata + METADATA_LENGTH
)
} else {
buffer.fill(
0x00,
offset + OFFSETS.metadata,
offset + OFFSETS.metadata + METADATA_LENGTH
)
buffer.fill(
0xff,
offset + OFFSETS.metadataMask,
offset + OFFSETS.metadataMask + METADATA_LENGTH
)
}
buffer.writeUInt32BE(wildcards, offset + OFFSETS.wildcards)
return buffer
},
unpack: (buffer, offset = 0) => {
const object = {}
object.type = buffer.readUInt16BE(offset + OFFSETS.type)
assert(object.type === of.matchType.standard)
object.length = buffer.readUInt16BE(offset + OFFSETS.length)
assert(object.length === of.sizes.match)
// Wildcards indicate which value to use for the match.
// if `wildcards & of.wildcards.<value>` === 0 then `value` is not wildcarded and must be used.
const wildcards = (object.wildcards = buffer.readUInt32BE(
offset + OFFSETS.wildcards
))
if ((wildcards & WILDCARDS.inPort) === 0) {
object.in_port = buffer.readUInt32BE(offset + OFFSETS.inPort)
}
if (!addressParser.isEthMaskAll(buffer, offset + OFFSETS.dlSrcMask)) {
if (!addressParser.isEthMaskNone(buffer, offset + OFFSETS.dlSrcMask)) {
object.dl_src_mask = addressParser.ethToString(
buffer,
offset + OFFSETS.dlSrcMask
)
}
object.dl_src = addressParser.ethToString(buffer, offset + OFFSETS.dlSrc)
}
if (!addressParser.isEthMaskAll(buffer, offset + OFFSETS.dlDstMask)) {
if (!addressParser.isEthMaskNone(buffer, offset + OFFSETS.dlDstMask)) {
object.dl_dst_mask = addressParser.ethToString(
buffer,
offset + OFFSETS.dlDstMask
)
}
object.dl_dst = addressParser.ethToString(buffer, offset + OFFSETS.dlDst)
}
if ((wildcards & WILDCARDS.dlVlan) === 0) {
object.dl_vlan = buffer.readUInt16BE(offset + OFFSETS.dlVlan)
}
if ((wildcards & WILDCARDS.dlVlanPcp) === 0) {
object.dl_vlan_pcp = buffer.readUInt16BE(offset + OFFSETS.dlVlanPcp)
}
if ((wildcards & WILDCARDS.dlType) === 0) {
object.dl_type = buffer.readUInt16BE(offset + OFFSETS.dlType)
}
if ((wildcards & WILDCARDS.nwTos) === 0) {
object.nw_tos = buffer.readUInt8(offset + OFFSETS.nwTos)
}
if ((wildcards & WILDCARDS.nwProto) === 0) {
object.nw_proto = buffer.readUInt8(offset + OFFSETS.nwProto)
}
if (!addressParser.isIp4MaskAll(buffer, offset + OFFSETS.nwSrcMask)) {
if (!addressParser.isIp4MaskNone(buffer, offset + OFFSETS.nwSrcMask)) {
object.nw_src_mask = addressParser.ip4ToString(
buffer,
offset + OFFSETS.nwSrcMask
)
}
object.nw_src = addressParser.ip4ToString(buffer, offset + OFFSETS.nwSrc)
}
if (!addressParser.isIp4MaskAll(buffer, offset + OFFSETS.nwDstMask)) {
if (!addressParser.isIp4MaskNone(buffer, offset + OFFSETS.nwDstMask)) {
object.nw_dst_mask = addressParser.ip4ToString(
buffer,
offset + OFFSETS.nwDstMask
)
}
object.nw_dst = addressParser.ip4ToString(buffer, offset + OFFSETS.nwDst)
}
if ((wildcards & WILDCARDS.tpSrc) === 0) {
object.tp_src = buffer.readUInt16BE(offset + OFFSETS.tpSrc)
}
if ((wildcards & WILDCARDS.tpDst) === 0) {
object.tp_dst = buffer.readUInt16BE(offset + OFFSETS.tpDst)
}
if ((wildcards & WILDCARDS.mplsLabel) === 0) {
object.mpls_label = buffer.readUInt32BE(offset + OFFSETS.mplsLabel)
}
if ((wildcards & WILDCARDS.mplsTc) === 0) {
object.mpls_tc = buffer.readUInt32BE(offset + OFFSETS.mplsTc)
}
const metadataMask = [
buffer.readUInt32BE(offset + OFFSETS.metadataMask),
buffer.readUInt32BE(offset + OFFSETS.metadataMask + METADATA_LENGTH / 2),
]
if (!uIntHelper.isUInt64All(metadataMask)) {
if (!uIntHelper.isUInt64None(metadataMask)) {
object.metadata_mask = Buffer.alloc(METADATA_LENGTH)
buffer.copy(
object.metadata_mask,
0,
offset + OFFSETS.metadataMask,
offset + OFFSETS.metadataMask + METADATA_LENGTH
)
}
object.metadata = Buffer.alloc(METADATA_LENGTH)
buffer.copy(
object.metadata,
0,
offset + OFFSETS.metadata,
offset + OFFSETS.metadata + METADATA_LENGTH
)
}
return object
},
}

View File

@@ -0,0 +1,79 @@
import of from '../openflow-11'
import addressParser from '../../util/addrress-parser'
// =============================================================================
const OFFSETS = of.offsets.port
const PAD_LENGTH = 4
const PAD2_LENGTH = 2
// =============================================================================
export default {
pack: (object, buffer = undefined, offset = 0) => {
buffer = buffer !== undefined ? buffer : Buffer.alloc(of.sizes.port)
const {
port_no: portNo,
hw_addr: hwAddr,
name,
config,
state,
curr,
advertised,
supported,
peer,
curr_speed: currSpeed,
max_speed: maxSpeed,
} = object
buffer.writeUInt32BE(portNo, offset + OFFSETS.portNo)
buffer.fill(0, offset + OFFSETS.pad, offset + OFFSETS.pad + PAD_LENGTH)
addressParser.stringToEth(hwAddr, buffer, offset + OFFSETS.hwAddr)
buffer.fill(0, offset + OFFSETS.pad, offset + OFFSETS.pad + PAD2_LENGTH)
buffer.write(name, offset + OFFSETS.name, of.maxPortNameLen)
if (name.length < of.maxPortNameLen) {
buffer.fill(
0,
offset + OFFSETS.name + name.length,
offset + OFFSETS.name + of.maxPortNameLen
)
}
buffer.writeUInt32BE(config, offset + OFFSETS.config)
buffer.writeUInt32BE(state, offset + OFFSETS.state)
buffer.writeUInt32BE(curr, offset + OFFSETS.curr)
buffer.writeUInt32BE(advertised, offset + OFFSETS.advertised)
buffer.writeUInt32BE(supported, offset + OFFSETS.supported)
buffer.writeUInt32BE(peer, offset + OFFSETS.peer)
buffer.writeUInt32BE(currSpeed, offset + OFFSETS.currSpeed)
buffer.writeUInt32BE(maxSpeed, offset + OFFSETS.maxSpeed)
return buffer
},
unpack: (buffer, offset = 0) => {
const body = {}
body.port_no = buffer.readUInt32BE(offset + OFFSETS.portNo)
body.hw_addr = addressParser.ethToString(buffer, offset + OFFSETS.hwAddr)
const name = buffer.toString(
'utf8',
offset + OFFSETS.name,
offset + OFFSETS.name + of.maxPortNameLen
)
body.name = name.substr(0, name.indexOf('\0')) // Remove useless 0 if name.length < of.maxPortNameLen
body.config = buffer.readUInt32BE(offset + OFFSETS.config)
body.state = buffer.readUInt32BE(offset + OFFSETS.state)
body.curr = buffer.readUInt32BE(offset + OFFSETS.curr)
body.advertised = buffer.readUInt32BE(offset + OFFSETS.advertised)
body.supported = buffer.readUInt32BE(offset + OFFSETS.supported)
body.peer = buffer.readUInt32BE(offset + OFFSETS.peer)
body.curr_speed = buffer.readUInt32BE(offset + OFFSETS.currSpeed)
body.max_speed = buffer.readUInt32BE(offset + OFFSETS.maxSpeed)
return body
},
}

View File

@@ -0,0 +1,45 @@
import assert from 'assert'
import of from './index'
import scheme from './default-header-scheme'
import { readChunk } from '@vates/read-chunk'
// =============================================================================
export default async function* parse(socket) {
let buffer = Buffer.alloc(1024)
let data
// Read the header
while ((data = await readChunk(socket, scheme.size)) !== null) {
// Read OpenFlow message size from its header
const msgSize = data.readUInt16BE(scheme.offsets.length)
data.copy(buffer, 0, 0, scheme.size)
if (buffer.length < msgSize) {
buffer = resize(buffer, msgSize)
}
// Read the rest of the openflow message
if (msgSize > scheme.size) {
data = await readChunk(socket, msgSize - scheme.size)
assert.notStrictEqual(data, null)
data.copy(buffer, scheme.size, 0, msgSize - scheme.size)
}
yield of.unpack(buffer)
}
}
// -----------------------------------------------------------------------------
function resize(buffer, size) {
let newLength = buffer.length
do {
newLength *= 2
} while (newLength < size)
const newBuffer = Buffer.alloc(newLength)
buffer.copy(newBuffer)
return newBuffer
}

View File

@@ -0,0 +1,64 @@
import assert from 'assert'
import util from 'util'
// =============================================================================
export default {
isEthMaskNone: (buffer, offset) =>
buffer.readUInt32BE(offset) === 0x00000000 &&
buffer.readUInt16BE(offset + 4) === 0x0000,
isEthMaskAll: (buffer, offset) =>
buffer.readUInt32BE(offset) === 0xffffffff &&
buffer.readUInt16BE(offset + 4) === 0xffff,
isIp4MaskNone: (buffer, offset) => buffer.readUInt32BE(offset) === 0x00000000,
isIp4MaskAll: (buffer, offset) => buffer.readUInt32BE(offset) === 0xffffffff,
ethToString: (buffer, offset) =>
buffer.toString('hex', offset, offset + 1) +
':' +
buffer.toString('hex', offset + 1, offset + 2) +
':' +
buffer.toString('hex', offset + 2, offset + 3) +
':' +
buffer.toString('hex', offset + 3, offset + 4) +
':' +
buffer.toString('hex', offset + 4, offset + 5) +
':' +
buffer.toString('hex', offset + 5, offset + 6),
stringToEth: (string, buffer, offset) => {
const eth = /^([0-9A-Fa-f]{2}):([0-9A-Fa-f]{2}):([0-9A-Fa-f]{2}):([0-9A-Fa-f]{2}):([0-9A-Fa-f]{2}):([0-9A-Fa-f]{2})$/.exec(
string
)
assert(eth !== null)
buffer.writeUInt8(parseInt(eth[1], 16), offset)
buffer.writeUInt8(parseInt(eth[2], 16), offset + 1)
buffer.writeUInt8(parseInt(eth[3], 16), offset + 2)
buffer.writeUInt8(parseInt(eth[4], 16), offset + 3)
buffer.writeUInt8(parseInt(eth[5], 16), offset + 4)
buffer.writeUInt8(parseInt(eth[6], 16), offset + 5)
},
ip4ToString: (buffer, offset) =>
util.format(
'%d.%d.%d.%d',
buffer.readUInt8(offset),
buffer.readUInt8(offset + 1),
buffer.readUInt8(offset + 2),
buffer.readUInt8(offset + 3)
),
stringToip4: (string, buffer, offset) => {
const ip = /^([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])\.([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])\.([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])\.([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])$/.exec(
string
)
assert(ip !== null)
buffer.writeUInt8(parseInt(ip[1], 10), offset)
buffer.writeUInt8(parseInt(ip[2], 10), offset + 1)
buffer.writeUInt8(parseInt(ip[3], 10), offset + 2)
buffer.writeUInt8(parseInt(ip[4], 10), offset + 3)
},
}

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