3.0.0 • Published 1 month ago

xen-api v3.0.0

Weekly downloads
76
License
ISC
Repository
github
Last release
1 month ago

xen-api

Package Version License PackagePhobia Node compatibility

Connector to the Xen API

Install

Installation of the npm package:

npm install --save xen-api

Usage

Tested with:

  • XenServer 7.6
  • XenServer 7.5
  • XenServer 7.4
  • XenServer 7.3
  • XenServer 7.2
  • XenServer 7.1
  • XenServer 7
  • XenServer 6.5
  • XenServer 6.2
  • XenServer 5.6

Library

const { createClient } = require('xen-api')

const xapi = createClient({
  url: 'https://xen1.company.net',
  allowUnauthorized: false,
  auth: {
    user: 'root',
    password: 'important secret password',
  },
  readOnly: false,
})

Options:

  • url: address of a host in the pool we are trying to connect to
  • allowUnauthorized: whether to accept self-signed certificates
  • auth: credentials used to sign in (can also be specified in the URL)
  • readOnly = false: if true, no methods with side-effects can be called
  • callTimeout: number of milliseconds after which a call is considered failed (can also be a map of timeouts by methods)
  • httpProxy: URL of the HTTP/HTTPS proxy used to reach the host, can include credentials
// Force connection.
xapi.connect().catch(error => {
  console.error(error)
})

// Watch objects.
xapi.objects.on('add', objects => {
  console.log('new objects:', objects)
})

Note: all objects are frozen and cannot be altered!

Custom fields on objects (hidden − ie. non enumerable):

  • $type: the type of the object (VM, task, …);
  • $ref: the (opaque) reference of the object;
  • $id: the identifier of this object (its UUID if any, otherwise its reference);
  • $pool: the pool object this object belongs to.

Furthermore, any field containing a reference (or references if an array) can be resolved by prepending the field name with a $:

console.log(xapi.pool.$master.$resident_VMs[0].name_label)
// vm1

CLI

A CLI is provided to help exploration and discovery of the XAPI.

> xen-api xen1.company.net root
Password: ******
root@xen1.company.net> xapi.status
'connected'
root@xen1.company.net> xapi.pool.master
'OpaqueRef:ec7c5147-8aee-990f-c70b-0de916a8e993'
root@xen1.company.net> xapi.pool.$master.name_label
'xen1'

You can optionally prefix the address by a protocol: https:// (default) or http://.

In case of error due to invalid or self-signed certificates you can use the --allow-unauthorized flag (or --au):

> xen-api --au xen1.company.net root

To ease searches, find() and findAll() functions are available:

root@xen1.company.net> findAll({ $type: 'VM' }).length
183

Contributions

Contributions are very welcomed, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

ISC © Vates SAS

3.0.0

1 month ago

2.0.1

3 months ago

2.0.0

5 months ago

1.3.6

8 months ago

1.3.5

8 months ago

1.3.4

9 months ago

1.3.3

10 months ago

1.3.2

10 months ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.3.1

12 months ago

1.3.0

1 year ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.36.0

2 years ago

0.35.1

2 years ago

0.35.0

2 years ago

0.34.3

3 years ago

0.34.2

3 years ago

0.34.1

3 years ago

0.34.0

3 years ago

0.33.1

3 years ago

0.33.0

3 years ago

0.32.0

3 years ago

0.31.1

3 years ago

0.31.0

3 years ago

0.30.0

3 years ago

0.29.1

3 years ago

0.29.0

4 years ago

0.28.5

4 years ago

0.28.4

4 years ago

0.27.5

4 years ago

0.28.3

4 years ago

0.28.2

4 years ago

0.27.4

4 years ago

0.28.1

4 years ago

0.28.0

4 years ago

0.27.3

4 years ago

0.27.2

5 years ago

0.27.1

5 years ago

0.27.0

5 years ago

0.26.0

5 years ago

0.25.2

5 years ago

0.25.1

5 years ago

0.25.0

5 years ago

0.24.6

5 years ago

0.24.5

5 years ago

0.24.4

5 years ago

0.24.3

5 years ago

0.24.2

5 years ago

0.24.1

5 years ago

0.24.0

5 years ago

0.23.0

5 years ago

0.22.0

5 years ago

0.21.0

5 years ago

0.20.0

5 years ago

0.19.0

6 years ago

0.18.0

6 years ago

0.17.1

6 years ago

0.17.0

6 years ago

0.16.12

6 years ago

0.16.11

6 years ago

0.16.10

6 years ago

0.16.9

6 years ago

0.16.8

6 years ago

0.16.7

6 years ago

0.16.6

6 years ago

0.16.5

6 years ago

0.16.4

6 years ago

0.16.3

6 years ago

0.16.2

6 years ago

0.16.1

6 years ago

0.16.0

6 years ago

0.15.1

6 years ago

0.15.0

6 years ago

0.14.3

7 years ago

0.14.2

7 years ago

0.14.1

7 years ago

0.14.0

7 years ago

0.13.7

7 years ago

0.13.6

7 years ago

0.13.5

7 years ago

0.13.4

7 years ago

0.13.3

7 years ago

0.13.2

7 years ago

0.13.1

7 years ago

0.13.0

7 years ago

0.12.3

7 years ago

0.12.2

7 years ago

0.12.1

7 years ago

0.12.0

7 years ago

0.11.0

7 years ago

0.10.0

7 years ago

0.10.0-2

7 years ago

0.10.0-1

7 years ago

0.10.0-0

7 years ago

0.9.6

7 years ago

0.9.5

7 years ago

0.9.4

8 years ago

0.9.3

8 years ago

0.9.2

8 years ago

0.9.1

8 years ago

0.9.1-0

8 years ago

0.9.0

8 years ago

0.8.0

8 years ago

0.8.0-0

8 years ago

0.7.4

8 years ago

0.7.3

8 years ago

0.7.2

8 years ago

0.7.1

8 years ago

0.7.0

8 years ago

0.6.9

8 years ago

0.6.8

8 years ago

0.6.7

9 years ago

0.6.6

9 years ago

0.6.5

9 years ago

0.6.4

9 years ago

0.6.3

9 years ago

0.6.2

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.6

9 years ago

0.5.5

9 years ago

0.5.4

9 years ago

0.5.3

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.0

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.0

9 years ago