com.stackstate.stackpack.ProvisioningScript
. The provisioning script can be split into multiple groovy scripts. The provisioning
directory inside the StackPack is part of the classpath, so any groovy script referred to inside the provisioning
directory is also loaded.StackState
environment. The capabilities are restricted to those that are defined as part of com.stackstate.stackpack.ProvisioningContext
which is passed as a constructor parameter for the ProvisioningScript
.preInstall
- this action is run when installing the very first instance of a StackPack - it is meant to install all the objects that each of the instances will share.install
- this action is run for every installed instance of a StackPack - it is meant to install instance-specific objects, that will be of use for this instance only.waitingForData
- this action allows the StackPack creator to check wether any external service that this StackPack communicates with is properly sending data that this StackPack can process. By default it just transitions to the INSTALLED
state.upgrade
- this action is run for every installed instance of a StackPack when the user upgrades their StackPack version.uninstall
- this action is run for every instance when it is being uninstalled - it is meant to clean up all the instance-specific objects.postUninstall
- this action is run when uninstalling the very last instance of a StackPack - it is meant to clean up all the StackPack-shared objects.context()
function.context()
function:context()
function returns an object that provides the following functions:scriptsDirectory()
- returns the path to the directory where this script resides.fail(errorMessage)
- marks this StackPack instance as broken (StackPack is in ERROR
state) with errorMessage
error message.sts
) objectsts()
function:sts()
function returns an object that provides the following functions:intakeApi()
- returns an object representing the StackState intake API that receives incoming data. The object supplies functions apiKey()
(returns the API key for the intake API) and baseUrl()
(returns the base URL for the intake API).log()
- allows logging to be done in the provisioning script. Example: context().sts().log().debug("Installing test StackPack")
.install(stackpackName, parameters)
- triggers installation of StackPack stackpackName
with parameters parameters
.onDataReceived(topic, callback)
- runs a callback
function whenever data is received by the StackState API on topic topic
.provisioningComplete()
- called when provisioning is done, marks this StackPack instance state as INSTALLED
.createTopologyTopicName(sourceType, sourceId)
- formats a StackState Kafka topic name using sourceType
and sourceId
parameters.stackPack
) objectstackPack()
function:stackPack()
function returns an object that provides the following functions:importSnapshot(filename, parameters)
- imports a template from filename
in the StackPack's namespace, filling in the optional parameters
substitutions.instance
) objectinstance()
function:instance()
function returns an object that provides the following functions:id()
- returns the current StackPack instance id.importSnapshot(filename, parameters)
- imports a template from filename
in the StackPack's namespace, filling in the optional parameters
substitutions.env
) objectenv()
function:env()
function returns an object that provides the following functions:execute(commandLine, directory, environment)
- runs a shell script command commandLine
in directory
with environment
setup..stj
template file.topicName
that generates a topic name for this instance, based on the data provided by the user in the StackPack installation step.templateArguments
in your .stj
template file. In case of the topicName
you can replace the topic
value in the config
section of your StackState DataSource with this parameter: