Constructor
new Control(options)
- Source:
- See:
-
- Cisco PxGrid 2.0 GitHub Wiki for more information on the Cisco PxGrid 2.0 implementation.
- Client
Establishes a PxGrid Control connection. Generally passed to a PxGrid REST Client session.
Example
const fs = require('fs');
certs = [];
certs.clientCert = fs.readFileSync('./certs/publiccert.cer');
certs.clientKey = fs.readFileSync('./certs/key.pem');
certs.caBundle = fs.readFileSync('./certs/caBundle.cer');
const Pxgrid = require('pxgrid-node');
const pxgridControlOptions = {
host: 'my-ise-server.domain.com',
hosts: ['ise01.domain.com', 'ise02.domain.com']
client: 'my-node-app',
clientCert: certs.clientCert,
clientKey: certs.clientKey,
caBundle: certs.caBundle,
clientKeyPassword: false,
secret: '',
port: '8910',
verifySSL: false,
httpTimeout: 3000
}
const pxgrid = new Pxgrid.Control(pxgridControlOptions);
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Options for the PxGrid Control instance. See examples for more information. Properties
|
Methods
activate(accountDescopt, retryIntervalopt, maxRetriesopt, retryAttemptopt) → {Promise}
- Source:
- See:
Activate your client pxGrid account on the controller.
This needs to happen one time before using your new client, as well as anytime its state changes to PENDING or DISABLED on the controller.
For simplicity, this is handled automatically by Client#connect, but can be done manually, as well.
If the client is not activated, you will fail to interact with pxGrid.
Sometimes, the account will return with a PENDING status which will induce a backoff timer of 60 seconds before retrying. This is normally because the account needs to be activated on the pxGrid Controller (either manually, or automatically). If configured for auto-approval, the activation should work in the next attempt.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
accountDesc |
string |
<optional> |
'pxgrid-node'
|
A description for the client you are registering. |
retryInterval |
number |
<optional> |
60000
|
Retry interval in milliseconds. |
maxRetries |
number |
<optional> |
10
|
Maximum retries that will be attempted. |
retryAttempt |
number |
<optional> |
1
|
Which attempt we are on. This is necessary since we use recursion for retries. |
Returns:
True if the PxGrid account has been activated on the upstream PxGrid controller.
- Type
- Promise
autoServiceReregister(serviceId, interval)
- Source:
- See:
Automatically reregister a service at a given interval. Reregistration will occur 5 seconds prior to provided interval to prevent inadvertent timeouts.
Parameters:
Name | Type | Description |
---|---|---|
serviceId |
string | The ID of the service to reregister. |
interval |
number | Interval to reregister (milliseconds). |
getAccessSecret(nodeName) → {Promise}
- Source:
Gets the Access Secret for a given node. AccessSecret is a unique secret between a Consumer and Provider pair.
Parameters:
Name | Type | Description |
---|---|---|
nodeName |
string | The node name to get the secret for. |
Returns:
Access Secret for node.
- Type
- Promise
getConfig() → {Object}
- Source:
Returns the control configuration.
Returns:
Control configuration.
- Type
- Object
serviceLookup(serviceName, retryIntervalopt, maxRetriesopt, retryAttemptopt) → {Promise}
- Source:
Looks up any nodes publishing the serviceName.
If no nodes are publishing, response is empty. Therefore, if subscribing, your subscription will fail until a publisher is registered for the service/topic.
Will retry every retryInterval
if no publishers are registered and activated.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
serviceName |
string | Name of the service to lookup. |
||
retryInterval |
number |
<optional> |
30000
|
Retry interval in milliseconds. |
maxRetries |
number |
<optional> |
10
|
Maximum retries that will be attempted. |
retryAttempt |
number |
<optional> |
1
|
Which attempt we are on. This is necessary since we use recursion for retries. |
Returns:
Returns a list of nodes providing the specified service, as well as their properties. Empty if no publishers registered.
- Type
- Promise
serviceRegister(serviceName, properties) → {Promise}
- Source:
Register as a publisher to a service. This could be a new service, or an existing service.
Parameters:
Name | Type | Description |
---|---|---|
serviceName |
string | Name of the service to register for. |
properties |
Object | Properties of the service you are registering. |
Returns:
The id and reregisterTimeMillis for the newly registered service.
- Type
- Promise
serviceReregister(serviceId) → {Promise}
- Source:
- See:
Reregister your node for a service. Services must reregister within the reregisterTimeMillis interval provided when initially registering.
Parameters:
Name | Type | Description |
---|---|---|
serviceId |
string | The ID of the service to reregister. |
Returns:
Empty response from controller, if successful.
- Type
- Promise
serviceUnregister(serviceId) → {Promise}
- Source:
Unregisters a service.
Parameters:
Name | Type | Description |
---|---|---|
serviceId |
string | The ID of the service to unregister. |
Returns:
Empty response from controller, if successful.
- Type
- Promise
serviceUnregisterAll()
- Source:
Unregisters all services that have been registered by the instance.