Class: CloudProvider

CloudProvider(optionsopt)

Abstract cloud provider implementation.

This class should be inherited from to implement cloud-provider specific implementations. Any method in this class that throws must be overridded. Methods that do not throw may be optionally overridden.

Constructor

new CloudProvider(optionsopt)

Constructor.

Parameters:
Name Type Attributes Description
options Ojbect <optional>

Options for the instance.

Properties
Name Type Attributes Description
clOptions Object <optional>

Command line options if called from a script.

logger Object <optional>

Logger to use. Or, pass loggerOptions to get your own logger.

loggerOptions Object <optional>

Options for the logger. See module:logger.getLogger for details.

Methods

bigIpReady() → {Promise}

BIG-IP is now ready and providers can run BIG-IP functions if necessary

Returns:

A promise which will be resolved when init is complete.

Type
Promise

(abstract) electPrimary(instances) → {Promise}

Elects a new primary instance from the available instances

Parameters:
Name Type Description
instances Object

Dictionary of instances as returned by getInstances.

Returns:

A promise which will be resolved with the instance ID of the elected primary.

Type
Promise

(abstract) getDataFromUri(uri) → {Promise}

Gets data from a provider specific URI

Override for implementations that wish to allow retrieval of data from a provider specific URI (for example, an ARN to an S3 bucket).

Parameters:
Name Type Description
uri String

The cloud-specific URI of the resource.

Returns:

A promise which will be resolved with the data from the URI or rejected if an error occurs.

Type
Promise

(abstract) getInstanceId() → {Promise}

Gets the instance ID of this instance

Returns:

A promise which will be resolved with the instance ID of this instance or rejected if an error occurs;

Type
Promise

(abstract) getInstances(optionsopt) → {Promise}

Gets info for each instance

Retrieval is cloud specific. Likely either from the cloud infrastructure itself, stored info that we have in a database, or both.

Parameters:
Name Type Attributes Description
options Object <optional>

Optional parameters

Properties
Name Type Attributes Description
externalTag String <optional>

Also look for instances with this tag (outside of the autoscale group/set)

Returns:

A promise which will be resolved with a dictionary of instances keyed by instance ID. Each instance value should be:

              {
                  isPrimary: <Boolean>,
                  hostname: <String>,
                  mgmtIp: <String>,
                  privateIp: <String>,
                  publicIp: <String>,
                  providerVisible: <Boolean> (does the cloud provider know about this instance),
                  external: <Boolean> (true if this instance is external to the autoscale group/set)
              }
Type
Promise

(abstract) getPrimaryCredentials(mgmtIp, port) → {Promise}

Called to retrieve primary instance credentials

Must be implemented if FEATURE_MESSAGING is not supported.

If FEATURE_MESSAGING is not supported, when joining a cluster we need the username and password for the primary instance.

If FEATURE_MESSAGING is supported, the primary will be sent a message to add an instance.

Management IP and port are passed in so that credentials can be validated desired.

Parameters:
Name Type Description
mgmtIp String

Management IP of primary.

port String

Management port of primary.

Returns:

A promise which will be resolved with:

               {
                   username: <admin_user>,
                   password: <admin_password>
               }
Type
Promise

getPrimaryStatus() → {Promise}

Gets info on what this instance thinks the primary status is

Info is retrieval is cloud specific. Likely either from the cloud infrastructure itself, stored info that we have in a database, or both.

Returns:

A promise which will be resolved with a dictionary of primary status:

               {
                   "instanceId": primaryInstanceId
                   "status": CloudProvider.STATUS_*
                   "lastUpdate": Date,
                   "lastStatusChange": Date
               }
Type
Promise

getMessages(actions, optionsopt) → {Promise}

Gets messages from other instances in the scale set

Parameters:
Name Type Attributes Description
actions Array.<String>

Array of actions to get. Other messages will be ignored. Default (empty or undefined) is all actions.

options Object <optional>

Optional parameters

Properties
Name Type Attributes Description
toInstanceId String <optional>

toInstanceId of messsages we are interested in

Returns:

A promise which will be resolved when the messages have been received and processed. Promise should be resolved with an array of messages of the form

               {
                   action: message action id,
                   toInstanceId: instanceId,
                   fromInstanceId: instanceId,
                   data: message specific data used in sendMessage,
                   completionHandler: optional completionHandler to call wnen done processing
                   {
                       this: this arg for callback context,
                       callback: function to call,
                       data: data to send to function
                   }
               }
Type
Promise

getNicsByTag(tag) → {Promise}

Searches for NICs that have a given tag.

Parameters:
Name Type Description
tag Object

Tag to search for. Tag is of the format:

            {
                key: optional key
                value: value to search for
            }
Returns:

A promise which will be resolved with an array of instances. Each instance value should be:

              {
                  id: NIC ID,
                  ip: {
                      public: public IP (or first public IP on the NIC),
                      private: private IP (or first private IP on the NIC)
                  }
              }
Type
Promise

getNodesFromUri(uri, optionsopt) → {Promise}

Gets nodes from the provided URI. The resource should be in JSON format as an array of objects. JSON strings that parse to an array of objects are also supported.

Parameters:
Name Type Attributes Description
uri String

The URI of the resource.

options Object <optional>

Optional parameters

Properties
Name Type Attributes Description
headers Object <optional>

Map of headers to add to the request. Format:

{
    <header1_name>: <header1_value>,
    <header2_name>: <header2_value>
}
Returns:

A promise which will be resolved with an array of instances. Each instance value should be:

{
    id: Node ID,
    ip: {
        public: public IP,
        private: private IP
    }
}
Type
Promise

getPublicKey(instanceId) → {Promise}

Gets the public key for an instanceId.

Parameters:
Name Type Description
instanceId String

Instance ID to validate as a valid primary.

Returns:

A promise which will be resolved when the operation is complete

Type
Promise

getStoredUcs() → {Promise}

Called to get check for and retrieve a stored UCS file

Provider implementations can optionally store a UCS to be used to restore a primary instance to a last known good state

Returns:

A promise which will be resolved with a Buffer containing the UCS data if it is present, resolved with undefined if not found, or rejected if an error occurs.

Type
Promise

getVmsByTag(tag) → {Promise}

Searches for VMs that have a given tag.

Parameters:
Name Type Description
tag Object

Tag to search for. Tag is of the format:

            {
                key: optional key
                value: value to search for
            }
Returns:

A promise which will be resolved with an array of instances. Each instance value should be:

              {
                  id: instance ID,
                  ip: {
                      public: public IP (or first public IP on the first NIC),
                      private: private IP (or first private IP on the first NIC)
                  }
              }
Type
Promise

hasFeature(feature) → {Boolean}

Determines if the provider supports a feature.

Parameters:
Name Type Description
feature String

Feature to check for

Returns:

Whether or not the provider supports the feature

Type
Boolean

init(providerOptions, optionsopt) → {Promise}

Initialize class

Override for implementation specific initialization needs (read info from cloud provider, read database, etc.). Called at the start of processing.

Parameters:
Name Type Attributes Description
providerOptions Object

Provider specific options.

options Object <optional>

Options for this instance.

Properties
Name Type Attributes Description
autoscale Boolean <optional>

Whether or not this instance will be used for autoscaling.

Returns:

A promise which will be resolved when init is complete.

Type
Promise

isInstanceExpired(instance) → {Boolean}

Determines whether a stored instance is so old it should not be considered

Parameters:
Name Type Description
instance Object

Instance data

Returns:

Whether or not the instance is expired

Type
Boolean

isValidPrimary(instanceId, instances) → {Promise}

Determines if a given instanceId is a valid primary

In some cloud environments, the primary may change unexpectedly. Override this method if implementing such a cloud provider.

Parameters:
Name Type Description
instanceId String

Instance ID to validate as a valid primary.

instances Object

Dictionary of instances as returned by getInstances.

Returns:

A promise which will be resolved with a boolean indicating wether or not the given instanceId is a valid primary.

Type
Promise

primaryElected(instancId) → {Promise}

Called when a primary has been elected

In some cloud environments, information about the primary needs to be stored in persistent storage. Override this method if implementing such a cloud provider.

Parameters:
Name Type Description
instancId String

Instance ID that was elected primary.

Returns:

A promise which will be resolved when processing is complete.

Type
Promise

primaryInvalidated(instanceId, instances) → {Promise}

Indicates that an instance that was primary is now invalid

Override for cloud providers that need to take some action when a primary becomes invalid.

Parameters:
Name Type Description
instanceId String

Instance ID of instnace that is no longer a valid primary.

instances Object

Dictionary of instances as returned by getInstances.

Returns:

A promise which will be resolved when processing is complete.

Type
Promise

putInstance(instanceId, instance) → {Promise}

Saves instance info

Override for cloud implementations which store instance information.

Parameters:
Name Type Description
instanceId String

ID of instance

instance Object

Instance information as returned by getInstances.

Returns:

A promise which will be resolved with instance info.

Type
Promise

putPrimaryCredentials() → {Promise}

Called to store primary credentials

When joining a cluster we need the username and password for the primary instance. This method is called to tell us that we are the primary and we should store our credentials if we need to store them for later retrieval in getPrimaryCredentials.

Returns:

A promise which will be resolved when the operation is complete

Type
Promise

putPublicKey(instanceId, publicKey) → {Promise}

Stores the public key for an instanceId.

The public key should later be able to retrieved given the instanceId. Must be implemented if provider supports FEATURE_ENCRYPTION.

Parameters:
Name Type Description
instanceId String

Instance ID to validate as a valid primary.

publicKey String

The public key

Returns:

A promise which will be resolved when the operation is complete

Type
Promise

revokeLicenses(instances, optionsopt) → {Promise}

Revokes licenses for instances licensed from BIG-IQ

We only make a best effort here. If revoke fails, this still succeeds. This allows us not to care if the license even can be revoked (perhaps it is not issued by BIG-IQ).

Parameters:
Name Type Attributes Description
instances Array.<Object>

Instances for which to revoke licenses. Instances should be as returned by getInstances

options Object <optional>

Original command line options

Properties
Name Type Attributes Description
bigIp Object <optional>

Base BigIp object.

Returns:

A promise which will be resolved when processing is complete.

Type
Promise

(abstract) sendMessage(action, optionsopt) → {Promise}

Sends a message to other instances in the scale set

Must be implemented if FEATURE_MESSAGING is supported

Parameters:
Name Type Attributes Description
action String

Action id of message to send

options Object <optional>

Optional parameters

Properties
Name Type Attributes Description
toInstanceId String <optional>

Instance ID that message is for

fromInstanceId String <optional>

Instance ID that message is from

data Object <optional>

Message specific data

Returns:

A promise which will be resolved when the message has been sent or rejected if an error occurs

Type
Promise

signalInstanceProvisioned(instanceId) → {Promise}

Informs the provider that the instance has been provisioned

Parameters:
Name Type Description
instanceId String

Instance ID of instance to mark as provisioned. If not provided, instanceId will be instanceId as set by init().

Returns:

A promise which will be resolved when the instance has been signalled to the provider as provisioned

Type
Promise

storeUcs(file, maxCopies, prefix) → {Promise}

Stores a UCS file in cloud storage

Parameters:
Name Type Description
file String

Full path to file to store.

maxCopies Number

Number of files to store. Oldest files over this number should be deleted.

prefix String

The common prefix for autosaved UCS files

Returns:

A promise which is resolved when processing is complete.

Type
Promise

syncComplete(fromUser, fromPassword) → {Promise}

Informs the provider that a sync has completed in case the password needs to be updated

When a sync is complete, the user and password will exist on the synced to device.

Parameters:
Name Type Description
fromUser String

User that was synced from

fromPassword String

Password that was synced from

Returns:

A promise which will be resolved when the messages have been received and processed

Type
Promise

tagPrimaryInstance(instanceId, instances) → {Promise}

Called after a primary has been elected.

In some cloud environments, instances running a primary should be tagged through cloud provider specific tagging. Override this method for cloud providers that support instance tagging for instances running primarys.

Parameters:
Name Type Description
instanceId String

Instance ID that was elected primary.

instances Object

Dictionary of instances as returned by getInstances

Returns:

A promise which will be resolved when processing is complete.

Type
Promise