This document describes the functionality provided by the Generic Model plugin.
See the Deployit Reference Manual for background information on Deployit and deployment concepts.
Deployit supports a number of middleware platforms. Sometimes, though, it is necessary to extend Deployit with new middleware support. The Generic Model plugin provides a way to do this, without having to write Java code. Instead, using Deployit's flexible type system and the base CIs from the Generic Model plugin, new CIs can be defined by writing XML and providing scripts for functionality.
Several of Deployit's standard plugins are also built on top of the Generic Model plugin.
The plugin requires:
The Generic Model plugin provides several CIs that can be used as base classes for creating Deployit extensions. There are base CIs for each of Deployit's CI types (deployables, deployeds and containers). A typical usage scenario is to create custom, synthetic CIs (based on one of the provided CIs) and using it to invoke the required behavior (scripts) in a deployment plan.
A Container is a topology CI and models middleware in your infrastructure. This would typically be used to model middleware for Deployit does not have out of the box support or that is custom to your environment. The other CIs in the plugin can be deployed to (subclasses of) the container. The behavior of the container in a deployment is configured by specifying scripts to be executed when it is started, stopped or restarted. Deployit will invoke these scripts as needed.
A CopiedArtifact is an artifact as copied over to a Container. It manages the copying of any generic artifact (File, Folder, Archive, Resource) in the deployment package to the container. It is possible to indicate that this copied artifact requires a container restart.
An ExecutedScript encapsulates a script that is executed on a generic container. The script is processed by the templating engine (see below) before being copied to the target container. The behavior of the script is configured by specifying scripts to be executed when it is deployed, upgraded or undeployed.
An ExecutedFolder encapsulates a folder containing installation and rollback scripts that are executed on a generic container. Installation scripts are executed when the folder is deployed or updated, rollback scripts are executed when it is undeployed. Execution of the scripts happens in order. Scripts are processed by the templating engine (see below) before being copied to the target container.
A ProcessedTemplate is a Freemarker template that is processed by the templating engine (see below), then copied to a Container.
When defining and using CIs with the Generic Model plugin, the need arises to use variables in certain CI properties and scripts. The most obvious use is to include properties from the deployment itself, such as the names or locations of files in the deployment package. Deployit uses the Freemarker templating engine for this.
When performing a deployment using the Generic Model plugin, all CIs and scripts are processed in Freemarker. This means that placeholders can be used in CI properties and scripts to make them more flexible. Freemarker resolves placeholders using a context, a set of objects defining the template's environment. This context depends on the type of CI being deployed.
For deployed CIs, the context deployed refers to the current CI instance. For example:
<type type="tc.DeployedDataSource" extends="generic.ProcessedTemplate" deployable-type="tc.DataSource"
container-type="tc.Server">
...
<property name="targetFile" default="${deployed.name}-ds.xml" hidden="true"/>
...
</type>
For container CIs, the context container refers to the current container instance. For example:
<type type="tc.Server" extends="generic.Container">
<property name="home" default="/tmp/tomcat"/>
<property name="targetDirectory" default="${container.home}/webapps" hidden="true"/>
</type>
A special case is when referring to an artifact in the placeholder. For example, when deploying a CI representing a WAR file, the following placeholder can be used to refer to that file (assuming there is a file property on the deployable):
${deployed.deployable.file}
In this case, Deployit will copy the referred artifact to the target container so that the file is available to the executing script. A script containing a command like the following would therefore copy the file represented by the deployable to it's installation path on the remote machine:
cp ${deployed.deployable.file} /install/path
CIs based on the Container, CopiedArtifact, ExecutedScript or ProcessedTemplate can also define control tasks to manage them. Control tasks are implemented using scripts that will be loaded and executed on the target middleware when executed.
This is an example of defining a control task:
<type type="tc.DeployedDataSource" extends="generic.ProcessedTemplate" deployable-type="tc.DataSource"
container-type="tc.Server">
<generate-deployable type="tc.DataSource" extends="generic.Resource"/>
...
<property name="pingScript" default="tc/ping.sh" hidden="true"/>
<method name="ping" description="Test whether the datasource is available"/>
</type>
The method XML fragment defines that control task ping is available on the CI. The pingScript property indicates the script that must be executed when it is invoked. The script will be resolved from the classpath. The same mechanism applies to a container.
The following table describes which deployable / container combinations are possible. Note that the CIs can only be targeted to containers derived from generic container.
| Deployable | Containers | Generated deployed |
|---|---|---|
| generic.File generic.Archive | generic.Container | generic.CopiedArtifact |
| any deployable | generic.Container | generic.ExecutedScript |
| any folder deployable | generic.Container | generic.ExecutedFolder |
| any deployable | generic.Container | generic.ProcessedTemplate |
The following table describes the effect a deployed has on its container.
| Deployed | Create | Destroy | Modify |
|---|---|---|---|
| generic.CopiedArtifact |
|
|
|
| generic.ExecutedScript |
|
|
|
| generic.ExecutedFolder |
For each installation script in the folder (ordered alphabetically by name, ascending):
|
For each rollback script in the folder (ordered alphabetically by name, descending):
|
For each installation script in the folder that was not part of the deployment being upgraded (ordered alphabetically by name, ascending):
|
| generic.ProcessedTemplate |
|
|
|
This section describes an example of using the Generic Model plugin to implement support for a simple middleware platform. Deployment to this platform is done by simply copying a WAR archive to the right directory on the container. Resources are created by copying configuration files into the container's configuration directory. The Tomcat application server works in a very similar manner.
By defining a container and several other CIs based on CIs from the Generic Model plugin, it is possible to add support for deploying to this platform to Deployit.
To use any of the CIs in the Generic Model plugin, they need to be targeted to a Container. This snippet shows how to define a generic container as a synthetic type:
<type type="tc.Server" extends="generic.Container">
<property name="home" default="/tmp/tomcat"/>
</type>
<type type="tc.UnmanagedServer" extends="tc.Server">
<property name="startScript" default="tc/start.sh" hidden="true"/>
<property name="stopScript" default="tc/stop.sh" hidden="true"/>
<property name="restartScript" default="tc/restart.sh" hidden="true"/>
</type>
Note that the tc.UnmanagedServer CI defines a start, stop and restart script. Deployit Server reads these scripts from the classpath. When targetting a deployment to the tc.UnmanagedServer, Deployit will include steps executing the start, stop and restart scripts in appropriate places in the deployment plan.
The following snippet defines a CI based on the CopiedArtifact. The tc.DeployedFile CI can be targeted to the tc.Server. The target directory is specified as a hidden property. Note the placeholder syntax used here.
<type type="tc.DeployedFile" extends="generic.CopiedArtifact" deployable-type="tc.File"
container-type="tc.Server">
<generate-deployable type="tc.File" extends="generic.File"/>
<property name="targetDirectory" default="${deployed.container.home}/conf" hidden="true"/>
</type>
Using the above snippet, it is possible to create a package with a tc.File deployable and deploy it to an environment containing a tc.UnmanagedServer. This will result in a tc.DeployedFile deployed.
To deploy a WAR file to the tc.Server, one possibility is to define a tc.DeployedWar CI that extends the ExecutedScript. The tc.DeployedWar CI is generated when deploying a jee.War to the tc.Server CI. This is what the XML looks like:
<type type="tc.DeployedWar" extends="generic.ExecutedScript" deployable-type="jee.War"
container-type="tc.Server">
<generate-deployable type="tc.War" extends="jee.War"/>
<property name="createScript" default="tc/install-war" hidden="true"/>
<property name="modifyScript" default="tc/reinstall-war" hidden="true" required="false"/>
<property name="destroyScript" default="tc/uninstall-war" hidden="true"/>
</type>
When performing an initial deployment, the create script, tc/install-war is executed on the target container. Inside the script, a reference to the file property is replaced by the actual archive. Note that the script files do not have an extension. Depending on the target platform, the extension sh (Unix) or bat (Windows) is used.
Configuration files can be deployed by creating a CI based on the ProcessedTemplate. By including a Resource in the package that is a Freemarker template, a configuration file can be generated during the deployment and copied to the container. This snippet defines such a CI, tc.DeployedDataSource:
<type type="tc.DeployedDataSource" extends="generic.ProcessedTemplate" deployable-type="tc.DataSource"
container-type="tc.Server">
<generate-deployable type="tc.DataSource" extends="generic.Resource"/>
<property name="jdbcUrl"/>
<property name="port" kind="integer"/>
<property name="targetDirectory" default="${deployed.container.home}/webapps" hidden="true"/>
<property name="targetFile" default="${deployed.name}-ds.xml" hidden="true"/>
<property name="template" default="tc/datasource.ftl" hidden="true"/>
</type>
The template property specifies the Freemarker template file that Deployit Server reads from the classpath. The targetDirectory controls where the template is copied to. Inside the template, properties like jdbcUrl on the datasource can be used to produce a proper configuration file.
| CI | Description |
|---|---|
| generic.Archive | A generic, compressed binary artifact |
| generic.File | A generic binary artifact |
| generic.Folder | A generic folder artifact |
| generic.Resource | A generic resource specification |
| CI | Description |
|---|---|
| generic.AbstractDeployed | Abstract deployed that can target any deployable to a generic container |
| generic.AbstractDeployedArtifact | Abstract deployed that can target any artifact to a generic container |
| generic.CopiedArtifact | An artifact deployed on a generic container |
| generic.ExecutedFolder | Scripts in the folder are executed against a Container based on a naming convention |
| generic.ExecutedScript | A script executed on a generic container |
| generic.ExecutedScriptWithDerivedArtifact | A script executed on a generic container whose deployable artifact supports placeholder replacement |
| generic.ProcessedTemplate | A template deployed to a generic container |
| CI | Description |
|---|---|
| generic.Container | A container to which generic CIs can be deployed |
| generic.GenericContainer | |
| generic.NestedContainer | A container that is nested with another container |
| Hierarchy | udm.BaseDeployed >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Deployed, udm.ConfigurationItem |
Abstract deployed that can target any deployable to a generic container
| Public Properties |
|---|
container : CI<udm.Container>The container on which this deployed runs. |
| deployable : CI<udm.Deployable> The deployable that this deployed is derived from. |
| Hierarchy | generic.AbstractDeployed >> udm.BaseDeployed >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Deployed, udm.ConfigurationItem |
Abstract deployed that can target any artifact to a generic container
| Hierarchy | udm.BaseDeployableArchiveArtifact >> udm.BaseDeployableFileArtifact >> udm.BaseDeployableArtifact >> udm.BaseDeployable >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.Deployable, udm.SourceArtifact, udm.ArchiveArtifact, udm.Artifact, udm.DeployableArtifact, udm.ConfigurationItem, udm.FileArtifact |
A generic, compressed binary artifact
| Public Properties |
|---|
| placeholders : SET_OF_STRING Placeholders detected in this artifact |
| scanPlaceholders : BOOLEAN = true Scan Placeholders |
| tags : SET_OF_STRING The tags to map deployables to containers. |
| Hierarchy | udm.BaseContainer >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.ConfigurationItem, udm.Container, generic.GenericContainer, overthere.HostContainer |
A container to which generic CIs can be deployed. Start, stop and restart behavior of this container can be controlled using the corresponding script properties.
| Hierarchy | generic.AbstractDeployedArtifact >> generic.AbstractDeployed >> udm.BaseDeployed >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Artifact, udm.Deployed, udm.ConfigurationItem, udm.DerivedArtifact |
An artifact deployed on a generic container
| Hierarchy | generic.AbstractDeployed >> udm.BaseDeployed >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Artifact, udm.Deployed, udm.ConfigurationItem, udm.DerivedArtifact |
Scripts in the folder are executed against a Container based on a naming convention
| Hierarchy | generic.AbstractDeployed >> udm.BaseDeployed >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Deployed, udm.ConfigurationItem |
A script executed on a generic container
| Public Properties |
|---|
container : CI<udm.Container>The container on which this deployed runs. |
| deployable : CI<udm.Deployable> The deployable that this deployed is derived from. |
| Hierarchy | generic.ExecutedScript >> generic.AbstractDeployed >> udm.BaseDeployed >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Artifact, udm.Deployed, udm.ConfigurationItem, udm.DerivedArtifact |
A script executed on a generic container whose deployable artifact supports placeholder replacement
| Hierarchy | udm.BaseDeployableFileArtifact >> udm.BaseDeployableArtifact >> udm.BaseDeployable >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.Deployable, udm.SourceArtifact, udm.Artifact, udm.DeployableArtifact, udm.ConfigurationItem, udm.FileArtifact |
A generic binary artifact
| Public Properties |
|---|
| placeholders : SET_OF_STRING Placeholders detected in this artifact |
| scanPlaceholders : BOOLEAN = true Scan Placeholders |
| tags : SET_OF_STRING The tags to map deployables to containers. |
| Hierarchy | udm.BaseDeployableFolderArtifact >> udm.BaseDeployableArtifact >> udm.BaseDeployable >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.Deployable, udm.SourceArtifact, udm.Artifact, udm.DeployableArtifact, udm.ConfigurationItem, udm.FolderArtifact |
A generic folder artifact
| Public Properties |
|---|
| placeholders : SET_OF_STRING Placeholders detected in this artifact |
| scanPlaceholders : BOOLEAN = true Scan Placeholders |
| tags : SET_OF_STRING The tags to map deployables to containers. |
null
| Hierarchy | udm.BaseContainer >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.ConfigurationItem, udm.Container, generic.GenericContainer, overthere.HostContainer |
A container that is nested with another container
| Public Properties |
|---|
| envVars : MAP_STRING_STRING Environment variables for container |
| tags : SET_OF_STRING The tags to map deployables to containers. |
| Hierarchy | generic.AbstractDeployedArtifact >> generic.AbstractDeployed >> udm.BaseDeployed >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Deployed, udm.ConfigurationItem |
A template deployed to a generic container
| Hierarchy | udm.BaseDeployable >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.Deployable, udm.ConfigurationItem |
A generic resource specification
| Public Properties |
|---|
| tags : SET_OF_STRING The tags to map deployables to containers. |