-
Notifications
You must be signed in to change notification settings - Fork 4
Home
A Promise based vSphere client. Allows you to search managed objects and execute methods. More functionality will be provided in future releases.
Creates a new vSphere client
Parameters
-
args
{Object}
- Arguments hash-
host
{string}
- viServer DNS name or IP -
[
username
]{string}
- User name to log in with. Optional if using a session id to login -
[
password
]{string}
- Password. Required if using username to log in -
[
sessionId
]{string}
- Session Id to authenticate with -
[
ignoreSSL=false
]{boolean}
- Ignore invalid SSL certificates during login -
[
autoLogin=false
]{boolean}
- If true, automatically log in after client creation -
[
exclusive=false
]{boolean}
- If true, terminate all other sessions from the same user and IP keeping the current. Useful for service crash and restart -
[
maxRetry=1
]{number}
- Number of times to try reconnecting after receiving aNotAuthenticatedFault
-
[
events
]{Object | boolean}
- Query the viServer for events and emit those events as javascript events from the client-
[
interval=60000
]{number}
- Time in milliseconds between Event queries
-
[
-
Returns
{Promise}
- Returns a Promise that resolves to a viClient instance
Log into vSphere. Not necessary if autoLogin=true
was passed to createClient()
Parameters
-
args
{Object}
- Arguments hash-
[
username
]{string}
- User name to log in with. Optional if using a session id to login -
[
password
]{string}
- Password. Required if using username to log in -
[
sessionId
]{string}
- Session Id to authenticate with -
[
exclusive=false
]{boolean}
- If true, terminate all other sessions from the same user and IP keeping the current. Useful for service crash and restart -
[
maxRetry=1
]{number}
- Number of times to try reconnecting after receiving aNotAuthenticatedFault
-
[
Returns
{Promise}
- Returns a Promise that resolves to a session object
Events
- login
Log out of vSphere
Returns
{Promise}
- Returns a Promise
Events
- logout
Executes a vSphere method
Parameters
-
name
{string}
- Method name -
args
{Object}
- Arguments for the method
Returns
{Promise}
- Returns a Promise that resolves to the method output
Creates a new vSphere client
Parameters
-
args
{Object}
- Arguments hash-
type
{string}
- Managed Object type -
[
id
]{string | string[]}
- Id or array of Ids to retrieve -
[
container=rootFolder
]{ManagedObjectReference}
- Container to start search from -
[
recursive=true
]{boolean}
- Recursive search -
[
properties
]{string | string[]}
- if "all" all properties retrieved. Otherwise array of dot notation properties
-
Returns
{Promise}
- Returns a Promise that resolves to the results of the retrieval
// require module
var connect = require('../lib');
// create a new client instance
var viclient = new connect.Client();
// connect to vsphere
viclient('myhost.mydomain.com', 'vSphereUsername', 'password', true)
.then(function(client) {
// search for a specific VM
return client.searchManagedObjects({
type: 'VirtualMachine',
id: ['vm-123'], // omit to return all VMs
properties: ['name'] // string literal all for all properties
})
.then(function(result) {
// print the results
console.log(JSON.stringify(result, null, ' '));
// log out
return client.logOut();
})
.caught(function(err) {
// handle error
});
});
// require module
var connect = require('../lib');
var util = connect.util;
// create a new client instance
var viclient = new connect.Client();
// connect to vsphere
viclient('myhost.mydomain.com', 'vSphereUsername', 'password', true)
.then(function(client) {
// create a destroy task to remove a vm
return client.method('Destroy_Task', {
_this: util.moRef('VirtualMachine', 'vm-123')
})
.then(function(result) {
return {
Task: result.$value
};
});
});
Created with Nodeclipse (Eclipse Marketplace, site)
Nodeclipse is free open-source project that grows with your contributions.