Skip to content
This repository was archived by the owner on Jun 6, 2023. It is now read-only.

Commit cc3809f

Browse files
committed
add additional machines states to machines show, list, create, and waitfor methods
1 parent 2dab15b commit cc3809f

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

lib/machines/create.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ var assign = require('lodash.assign');
9999
* "agentType": "WindowsDesktop",
100100
* "dtCreated": "2017-02-16T20:26:54.880Z",
101101
* "state": "provisioning",
102+
* "updatesPending": false,
102103
* "networkId": null,
103104
* "privateIpAddress": null,
104105
* "publicIpAddress": "169.255.255.254",

lib/machines/list.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var assign = require('lodash.assign');
2626
* @param {string} [filter.agentType] - Optional agentType value to match on
2727
* @param {string} [filter.dtCreated] - Optional datetime created value to match on
2828
* @param {string} [filter.state] - Optional state value to match on
29+
* @param {boolean} [filter.updatesPending] - Optional updatesPending value to match on
2930
* @param {string} [filter.networkId] - Optional networkId to match on
3031
* @param {string} [filter.privateIpAddress] - Optional privateIpAddress to match on
3132
* @param {string} [filter.publicIpAddress] - Optional publicIpAddress to match on
@@ -69,6 +70,7 @@ var assign = require('lodash.assign');
6970
* "agentType": "WindowsDesktop",
7071
* "dtCreated": "2016-11-18T05:18:29.533Z",
7172
* "state": "ready",
73+
* "updatesPending": false,
7274
* "networkId": "n789ghi",
7375
* "privateIpAddress": "10.64.21.47",
7476
* "publicIpAddress": null,

lib/machines/show.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ var assign = require('lodash.assign');
77
* @memberof machines
88
* @method show
99
* @description Show machine information for the machine with the given id.
10+
*
11+
* The state property can take on the follow values:
12+
* - off
13+
* - starting - machine is in the process of changing to the ready or serviceready state
14+
* - stopping - machine is in the process of changing to the off state
15+
* - restarting - combines stopping follow immediately by starting
16+
* - serviceready - services are running on the machine but the Paperspace agent is not yet available
17+
* - ready - services are running on machine and the Paperspace agent is ready to stream or accept logins
18+
* - upgrading - the machine specification are being upgraded, which involves a shutdown and startup sequence
19+
* - provisioning - the machine is in the process of being created for the first time
20+
*
21+
* The updatesPending property is either true or false and reflects whether the operating system has scheduled updates
22+
* for the next machine state transition, e.g, stopping, starting, restarting or upgrading.
23+
*
24+
* Note: in some cases the operating system can force installation of critical updates immediately upon a state
25+
* transition, or automatically restart a machine to install updates. In such cases the updatesPending property
26+
* may not always be set accurately by the underlying os.
1027
* @param {object} params - Machine show parameters
1128
* @param {string} params.machineId - Id of the machine to show
1229
* @param {function} cb - Node-style error-first callback function
@@ -46,6 +63,7 @@ var assign = require('lodash.assign');
4663
* "agentType": "WindowsDesktop",
4764
* "dtCreated": "2016-11-18T05:18:29.533Z",
4865
* "state": "ready",
66+
* "updatesPending": false,
4967
* "networkId": "n789ghi",
5068
* "privateIpAddress": "10.64.21.47",
5169
* "publicIpAddress": null,

lib/machines/waitfor.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ var assign = require('lodash.assign');
88
* @method waitfor
99
* @description Wait for the machine with the given id to enter a certain machine
1010
* state. This action polls the server and returns only when we detect that the machine
11-
* has transitioned into the given state. States available are:
11+
* has transitioned into the given state. States available to check for are:
1212
* - off
13-
* - ready
13+
* - serviceready - services are running on the machine but the Paperspace agent is not yet available
14+
* - ready - services are running on machine and the Paperspace agent is ready to stream or accept logins
1415
*
1516
* When the callback is called, the returned object will be information about the machine.
1617
* @param {object} params - Machine waitfor parameters
1718
* @param {string} params.machineId - Id of the machine to wait for
18-
* @param {string} params.state - Name of the state to wait for
19+
* @param {string} params.state - Name of the state to wait for, either 'off', 'serviceready', 'ready'
1920
* @param {function} cb - Node-style error-first callback function
2021
* @returns {object} machine - The machine JSON object
2122
* @example
@@ -53,6 +54,7 @@ var assign = require('lodash.assign');
5354
* "agentType": "WindowsDesktop",
5455
* "dtCreated": "2016-11-18T05:18:29.533Z",
5556
* "state": "ready",
57+
* "updatesPending": false,
5658
* "networkId": "n789ghi",
5759
* "privateIpAddress": "10.64.21.47",
5860
* "publicIpAddress": null,
@@ -74,11 +76,12 @@ function waitfor(params, cb) {
7476
var targetState;
7577
switch (state) {
7678
case 'ready':
79+
case 'serviceready':
7780
case 'off':
7881
targetState = state;
7982
break;
8083
default:
81-
return cb(new Error('state must be either off or ready'));
84+
return cb(new Error('state must be either off, serviceready, or ready'));
8285
}
8386
return method(waitfor, params, function _cb(err, machine) {
8487
if (err) {

0 commit comments

Comments
 (0)