Using the IBM Pattern Development Kit to build virtual application patterns, Part 1: Create virtual application pattern plug-in projects to install Tomcat and an HTTP Server

Virtual application patterns in IBM® PureApplication™ System provide easy and powerful capabilities to construct a Platform as a Service Pattern. This 3-part article series shows how to use the IBM Pattern Development Kit to build virtual application patterns to deploy several classic web platform topologies. To demonstrate these capabilities, open source software Apache Tomcat, Apache HTTP server, and LiveJournal Memcached are included in this pattern.

Share:

Qi Liu (lqliulq@cn.ibm.com), Software Engineer, IBM

Photo of Qi LiuQi (Colin) Liu is a Software Engineer leading the IBM Pattern Development Kit (PDK) development from Version 1.0.1.0. Previously, he worked as a key developer on the Composite Application Pattern (CAP) project and the lead for BPM Process Server plug-in development.



Scott Walden (sw@us.ibm.com), Software Engineer, IBM

Photo of Scott WaldenScott Walden works on the enablement team for IBM PureApplication System. The team charter includes customer enablement and internal enablement for various teams. Previously, he was the technical lead for IBM Business Monitor on the AIM Early Programs team that managed early design programs, beta programs, customer acceleration programs, and skills transfers.


developerWorks Contributing author
        level

Qiang Wang (wqwqbj@cn.ibm.com), Software Engineer, IBM

Photo of Qiang WangQiang (Ace) Wang is a Staff Software Engineer in the PureApplication Pattern Enablement and Pattern Development Kit team in IBM Software Group. He has participated in many industry solutions, which include digital media, banking, healthcare, and so on. Currently, he is working in the cloud computing area.



Wei Feng Li (lwfli@cn.ibm.com), Software Engineer, IBM

Photo of Wei Feng LiWei Feng (Banny) Li is a key developer of the PureApplication System Pattern Development Kit. He has rich experience in pattern development and is now mainly responsible for the PDK Eclipse user interface part. He is a key contributor in such projects as Application Delivery Pattern (ADP) and Composite Application Pattern (CAP). He also participates in Digital Media Management (DMM) and Knowledge Driver Application (KDA) accelerators development.



27 November 2013

Also available in Chinese Japanese

Introduction

In June 2013, the IBM Pattern Development Kit V1.0.1.0 was released with IBM PureApplication System V1.1. The IBM Pattern Development Kit package can be accessed from the following:

The IBM Pattern Development Kit (PDK) package includes the Eclipse plug-in tools installation file, virtual application pattern developer documentation, and Hello/WASCE sample projects. The IBM PDK for Eclipse provides two perspectives in Eclipse:

  • Workload Plug-in Development Perspective: This includes wizards, editors, and utilities to help build, package, and install virtual application pattern plug-in projects.
  • Workload Plug-in Runtime Perspective: This includes views and utilities to view instance execution logs, upload script files, and resume pending instances.

Apache Tomcat, Apache HTTP Server, and LiveJournal Memcached are widely used in small- to medium-sized web projects and they are popular among Java™ developers and students. Web platform topologies built with this software are familiar and easy to understand, which eases learning on how to construct virtual application patterns. To demonstrate pattern capabilities, this series includes three parts:

  • Part 1: This article (that you are currently reading) provides separate components that users can configure and deploy.
  • Part 2: This article helps you create a component link and scaling and intent policy. It provides a link and policy that can be applied to components created in Part 1 and takes effect during deployment.
  • Part 3: This article helps you build a Memcached as shared service. It provides singleton Memcached servers pool that can be shared by multiple Tomcat serer instances.

Along with this article, the code for the sample projects are attached, including pattern type projects and several plug-in projects. Keep in mind that projects used in this series are intended to reveal virtual application pattern capabilities and demonstrate how to build plug-in projects. However, these projects are also the first steps to make this open source software productive in PureApplication System.


Target scenarios

Apache Tomcat (or simply Tomcat) is an open source Java web server and servlet container. Apache HTTP Server (or simply HTTPD) is a "heavy-duty" network server that subversion can leverage. LiveJournal Memcached (or simply Memcached) is a high-performance, distributed memory object caching system. In a traditional topology, Tomcat servers register to HTTPD servers as workers and store Tomcat session data in Memcached to make failed Tomcat nodes recoverable in clustered environments. From simple to complex, three types of topologies are provided here:

  • Development (this article and in Part 3): Deploy Tomcat server, HTTPD server, or Memcached server separately. There is no connection between them, as shown in Figure 1.
    Figure 1. Development deployment
    Development deployment
  • Testing (Part 2 and Part 3 articles): Deploy one HTTPD server, two Tomcat servers, and link to one Memcached server, as shown in Figure 2.
    Figure 2. Testing deployment
    Testing deployment
  • Production (Part 2 and Part 3 articles): With the default settings, it will deploy two HTTPD servers and four Tomcat servers, which link to one Memcached server (see Figure 3).
    Figure 3. Production deployment
    Production deployment

Create a pattern type project

A pattern type project is a group definition that contains plug-in projects. It can generate one whole package, including all plug-in projects and installation files used in plug-in projects. In a pattern type project, you define:

  • Pattern type attributes in patterntype.json, including name, shortname, version, description, prerequisites (for pattern types and versions), categories (for grouping component display in the pattern builder palette), and license (for tracing product usage).
  • License declaration files.
  • "About" files.
  • Internalization message JSON files for attributes shown in web pages, for example, name, shortname, and description.

Steps to create a samples pattern type project

Start Eclipse with the IBM Pattern Development Kit installed. First, create a new pattern type project.

  1. Select menu File > New > Project... > IBM Workload Plug-in Development > IBM Workload Pattern Type Project.
  2. In the New Project wizard, input the project name as patterntype.samples.apache and leave the pattern type name with the same.
  3. Click Finish, the wizard generates a skeleton of a new pattern type project.

Second, configure attributes in patterntype.json.

  1. Double-click patterntype.json to open the pattern type page with the following two tabs: Overview and patterntype.json. The Overview tab is a form editor and the patterntype.json tab is a source editor.
  2. In the Overview tab, you can set basic information. The form editor validates the settings immediately, including validation for forbidden characters in the name, the version format, and so on.
  3. In the Prerequisite section, click Add. Set the attributes Name and Version with the values of foundation and *, respectively. This creates a prerequisite for any version of the pattern type foundation.
  4. In the Categories section, click Add. Set the attributes ID, Label, and Description with the values of samples.apache, Apache and Apache, respectively.
  5. To internationalize the attributes name and description, first define the key/value pairs in message.json in the JSON format. Then, replace the name and description attribute values in patterntype.json with the related key. See Listings 1 and 2 for examples. This sample pattern type only supports the English language, so only the "locales/en/messages.json" file is updated.
    Listing 1. locales/en/message.json file
    {
    "PATTERN_TYPE_NAME":"Samples with OpenSources",
    "PATTERN_TYPE_DESC":"This pattern type includes Apache tomcat,
    http server and memcached, which are used as samples. No license/responsibility
    for these"
    }
    Listing 2. patterntype.json
    {
       "name": "PATTERN_TYPE_NAME",
       "shortname": "patterntype.samples.apache",
       "version": "1.0.0.0",
       "description": "PATTERN_TYPE_DESC",
       "status": "",
       "prereqs": {
          "foundation": "*"
       },
       "categories": [
          {
             "id": "samples.apache",
             "label": "Apache",
             "description": "Apache"
          }
       ]
    }
  6. The pattern type project is completed. Select Window > Preferences > IBM Pattern Toolkit. Enter the host name, user ID, and password for your PureApplication System, then click OK. Right-click your project.
  7. In the popup menu, select IBM Toolkit > Install/Update to Deployer. The tools build the project and install it to the target system. Currently, this pattern type project does not contain a plug-in project. It is only a type definition that cannot deploy anything.

Further to do

Several features need to be added to the pattern type project:

  1. Add the license declaration files. First, create folder licenses in the project root folder. Then, add the license's content file with the name "[language code].html". For English, the file name is "en.html".
  2. Add the product ID to track the product license. First, declare this product ID in patterntype.json. Second, set the license usage in the "vm-templates" JSON part in the plug-in project. Listing 3 shows a sample configuration in the Hello sample projects.
    Listing 3. Product ID in patterntype.json and VM template
    # Declaration in patterntype.json
    "license": {
        "pid": "5725D65",
        "type": "PVU"
    }
    
    # Usage in VM template which can use more than one license in one VM
    {
        "vm-templates": [
            {
                "name": "${prefix}-HVM",
                "packages": [
                    "Hello",
                    "HCUtils"
                ],
                "roles": [
                    {
                        "plugin": "$provider.PluginScope",
                        "type": "Hello",
                        "name": "Hello",
                        "parms": {
                            "Hello_Sender": "$attributes.sender"
                        }
                    }
                ],
              "licenses": [
                    {
                        "ptype.hello": "2.0"
                    }
                ]
            }
        ]
    }
  3. Add the "about" information for the pattern type. First, create the "about" folder under the project. Then, add the content file with "[language code].html".

Create a Tomcat plug-in project

This plug-in project will:

  • Install Tomcat server. Download the Tomcat installation file and install to a specified location.
  • Configure and start the server. The running Tomcat server requires some environment variables, including JAVA_HOME and CLASS_PATH. Also, update the configuration with settings from the user, port, password, and so on.
  • Deploy the applications if the user requested it when building a pattern.
  • Provide management operations, which can be used in the console page after the instances are deployed, including new application deployment and a server restart.

The Tomcat installation binary in this plug-in project is "apache-tomcat-7.0.40.tar.gz" for Linux. The next section provides the instructions to create this project.

Step 1: Create a plug-in project skeleton

The PDK provides a wizard to generate a plug-in project skeleton.

  1. In Eclipse, select menu File > New > Project... > IBM Workload Plug-in Development > IBM Workload Plug-in Project.
  2. Input the project name with the value plugin.com.ibm.samples.tomcat and leave the plug-in name with the same. Click Next.
  3. Click the Select the pattern type in workspace option. It lists all the pattern types in the current workspace. Select patterntype.samples.apache as shown in Figure 4.
    Figure 4. Select a pattern type
    Select a pattern type
  4. Click Finish, which generates the plug-in project skeleton.

    The following shows the structure of the generated project skeleton. These three folders can be updated and are packaged in the exported .tgz file:

    • src: This is the folder for the Java code.
    • META-INF, OSGI-INF: This is the OSGI component definition.
    • plugin: These are the plug-in configuration files, locales message files, images, scripts, and so on.

    Other folders are used for the build, validation, and class path library.

    • build: This builds the script and related libraries.
    • lib: These are the Java libraries.
    • build.xml: This provides the package tasks.

Note: If the current workspace includes the plugin.depends project, which provides folders lib and builds to reference, the skeleton of the newly created pattern plug-in project does not contain them. The build.patterntype.xml will import the related task definition files in the plugin.depends project.

Step 2: Configure the plug-in project

This step configures the attributes and sets the code skeleton for incorporating scripts into the virtual application pattern framework. The pattern plug-in project provides many configuration files to define different capabilities, including config.json, config_meta.json, metadata.json, operation.json, tweak.json, monitoring_ui.json, OSGI definition files, VM template, and so on. Among these files, config.json, metadata.json, OSGI definition files, and VM template are most commonly used. In this project, operation.json is also required to define management operations.

Define the component and attributes in metadata.json

The metadata.json file defines the components, policies, and links, which are visible elements that are used to construct patterns in the Virtual Application Builder in the PureApplication System console. Developers also define attributes exposed for users to set when building a pattern in the Virtual Application Builder.

This project defines a component, which performs an installation of the Tomcat server.

  1. Double-click the plugin/appmodel/metadata.json file. This starts the editor, which is a composite editor with common configuration files in different tabs.
  2. Click "+" in the Metadata section to switch to the Application Model tab automatically. In the popup dialog, select the component type and click OK.
  3. Fill in the ID, label, and description attributes. Select the category defined in the above pattern type project. Image and Thumbnail are icon images used to represent the Tomcat server in the Virtual Application Builder. Browse and select the images, or you can let the icons use the default images.
  4. In the Tomcat server, attributes port, administrator password, and application package are exposed for the user to set. In the Attributes section, click Add..., select the type, and fill in every attribute as shown in Figure 5. Listing 4 shows the details of the attributes definition.
    Figure 5. Tomcat server application model tab
    Tomcat server application model tab
    Listing 4. metadata.json source attributes part
          "attributes": [
             {
                "id": "tomcat.port",
                "type": "string",
                "required": true,
                "label": "TOMCAT_PORT_LABEL",
                "description": "TOMCAT_PORT_DESC",
                "regExp": "[0-9]+",
                "sampleValue": "8080"
             },
             {
                "id": "tomcat.admin.password",
                "type": "string",
                "required": true,
                "displayType": "password",
                "label": "TOMCAT_PASSWORD_LABEL",
                "description": "TOMCAT_PASSWORD_DESC"
             },
             {
                "id": "web_apps",
                "type": "file",
                "required": false,
                "label": "Web Application File (.war or .zip)",
                "description": "For a single application, a .war file is required;
                 For several applications, a .zip file with all .war files is required.",
                "extensions": [
                   "war",
                   " zip"
                ]
             }
          ],

Define part, role, package, and config.json

The package, part, and role structure are defined by the virtual application pattern framework. One package is the unit that is used for deployment and can include many parts. One part can include many roles. Typically, the life cycle scripts are used in roles to implement deployment and configuration. In this project, the PKG_TOMCAT_INSTALL package contains the tomcat.install part with TOMCAT_INSTALL in it.

  1. In the folder parts, rename "tomcat.scripts" to "tomcat.install". Then, delete uninstall.py in "tomcat.install" as no uninstallation operation is required.
  2. In the tomcat.install/scripts folder, rename "TOMCAT" to "TOMCAT_INSTALL". To add a new part or role: in the metadata.json editor, switch to the Overview tab. In the Package section, select node Parts to add a part or select a specific part to add a Role and click Add. Or, select menu File > New > Others… > IBM Workload Plug-in Development > Plug-in Part or Plug-in Role.
  3. In config.json, update the package definition, making sure that the attribute part matches the pattern "parts/[part folder name].tgz".
  4. In config.json, set the required OS and installation file as shown in Listing 5.
    Listing 5. File config.json source part
       "packages": {
          "PKG_TOMCAT_INSTALL": [
             {
                "requires": {
                   "arch": "x86_64"
                },
                "parts": [
                   {
                      "part": "parts\/tomcat.install.tgz",
                      "parms": {
                         "installDir": "$INSTALL_DIR"
                      }
                   }
                ]
             }
          ]
       },
       "parms": {
          "INSTALL_DIR": "\/opt\/apache"
       },
       "files": [
          "\/apache\/apache-tomcat-7.0.40.tar.gz"
       ]

Define a virtual machine (VM) template

A VM template is a JSON fragment that combines user input and the package and role to define the VM topology and the scripts running on each VM. The virtual application pattern provides two ways to construct the VM template: Java-based and template-based. In this project, the Java-based transformer, which can handle complex logic, is selected to generate the VM template.

  1. Select menu File > New > Other... > IBM Workload Plug-in Development > OSGI Service Component.
  2. In service type, select Topology Provider (java based). Then, fill in the attributes. The value of name must be the same as the ID of the target component.
  3. Click OK. It will generate the OSGI definition under the OSGI and class TomcatTransformer folder, which extends TopologyProvider (see Listings 6 and 7).
    Listing 6. OSGI definition file for samplestomcat.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="samplesTomcat">;
    	<implementation class="com.ibm.vap.samples.tomcat.TomcatTransformer" />;
    	<service>
    		<provide interface="com.ibm.maestro.model.transform.TopologyProvider" />
    	</service>
    </scr:component>
  4. In the transformComponent method, construct the target JSON fragment as a returned value (see Listing 7).
    Listing 7. Part of the transformComponent method
    JSONObject templates = new JSONObject();
    …
    roleTomcat.put(TplSysKeys.PLUGIN, getPluginScope());
    …
    #get attributes defined by users
    JSONObject attributes = (JSONObject) component.get(TplSysKeys.ATTRIBUTES);
    …
    //add storage template
    addStorageTpl(templates);
    addStorageToVM(vm);
    …
    return templates;

    The TomcatTransformer method combines the plug-in configuration and user settings to construct a JSON fragment to represent VM templates and storage templates used in the VM (see Listing 8).

    Listing 8. Returned JSON fragment of the TomcatTransformer method
    {
        "vm-templates": [
            {
                "packages": [
                    "PKG_TOMCAT_INSTALL"
                ],
                "roles": [
                    {
                        "plugin": "plugin.com.ibm.samples.tomcat/1.0.0.0",
                        "parms": {
                            "tomcat.admin.password": "<xor>PjsyNjE=",
                            "tomcat.port": "8080"
                        },
                        "type": "TOMCAT_INSTALL",
                        "external-uri": [
                            {
                                "Tomcat Console": "http://{SERVER}:8080"
                            }
                        ],
                        "name": "TOMCAT_INSTALL"
                    }
                ],
                "name": "Tomcat_Server-tomcat",
                "storage": [
                    {
                        "storage-ref": "TomcatStorage",
                        "device": "/dev/sdb",
                        "mount-point": "/opt/apache"
                    }
                ]
            }
    ],
        "storage-templates": [
            {
                "parms": {
                    "size": 10,
                    "format": "ext3",
                    "type": "auto"
                },
                "name": "TomcatStorage"
            }
        ]
    }

Define operations in operation.json

Operations are management capabilities that you can run after the instance is deployed. This project provides operations "restart" and "deploy new application". The operation definition adheres to a specific role and implementation script file that is located in the role folder.

  1. In the metadata.json editor, switch to the Operation tab.
  2. Click the Add button to define the restart operation, then input the role, ID, category, and script attributes. The value of the role is the existing role name of TOMCAT_INSTALL. The value of the script is a concatenation of the implementation file name and the method name with a space in between. Click OK.
  3. Click the Add button to define the "deploy new application" operation. This operation requires the role, ID, category, and script attribute, but it also requires a file attribute for uploading the new application package. Click OK.
  4. Create an operation.py script file under the TOMCAT_INSTALL role folder. Listing 9 shows the details of the operations definition.
    Listing 9. File operation.json in Tomcat plug-in
    {
       "TOMCAT_INSTALL": [
          {
             "id": "tomcat_restart",
             "label": "Restart Tomcat Server",
             "description": "Restart Tomcat Server",
             "category": "Tomcat Operations",
             "script": "operations.py restart"
          },
          {
             "id": "deploy_apps",
             "label": "Deploy New Application",
             "description": "Deploy New Application",
             "category": "Tomcat Operations",
             "script": "operations.py deploy_apps",
             "attributes": [
                {
                   "id": "new_apps_pkg",
                   "type": "file",
                   "required": true,
                   "label": "New application",
                   "description": "New application",
                   "extensions": [
                      "war",
                      "zip"
                   ]
                }
             ]
          }
       ]
    }

Step 3: Build an installation and operation script for Tomcat

Installation or configuration scripts include part life cycle scripts and role life cycle scripts. Their execution contexts are different. In the part life cycle scripts, attribute parameters are defined in config.json. However, in the role life cycle scripts, attribute parameters come from the role definition in the VM template. Note that the part life cycle scripts execute before all the role life cycle scripts (see Figure 6).

Figure 6. TOMCAT_INSTALL life cycle scripts
TOMCAT_INSTALL life cycle scripts

The virtual application pattern provides the maestro Python package, which is used in the life cycle scripts to communicate with the virtual application pattern framework. The maestro package also contains a utilities module to perform functions, such as opening and closing ports through the firewall. The PDK package includes API documentation for the maestro package. There is additional documentation at the beginning of every generated life cycle script, where it includes a large paragraph of comments to depict the most commonly used methods of the maestro package.

Part life cycle script

Different parts in the same VM execute by the ordering defined in the topology configuration. You can set up dependencies between the parts so that one part waits on another part. However, in this example, only one part is defined. In this project, the install.py script is provided that is located under the tomcat.install part folder. The uninstall.py file is removed as there is no requirement to uninstall. The install.py script (see Listing 10) performs these functions:

  • Pass parameters in from part scope to role scope.
  • Download the Tomcat installation file.
  • Install the role scripts. This is necessary if a part contains a role with the life cycle scripts.
Listing 10. Part of install.py

Click to see code listing

Listing 10. Part of install.py

…
import maestro

…
download_dir = maestro.parms['installDir'] + '/download'
part_name = 'tomcat.install'
if not part_name in maestro.node['parts']:
    maestro.node['parts'][part_name] = {}
maestro.node['parts'][part_name]['installDir'] = maestro.parms['installDir']

#download tomcat binary
installer_url = urlparse.urljoin(maestro.filesurl, '/storehouse/admin/files/apache/apache-tomcat-7.0.40.tar.gz')
logger.debug('Download apache-tomcat-7.0.40.tar.gz...')
maestro.download(installer_url, download_dir + '/apache-tomcat-7.0.40.tar.gz')

#install scripts
maestro.install_scripts('scripts')

Role life cycle script

The role scripts execute in the following order: install.py > configure.py > start.py. The life cycle scripts in different roles run in parallel. The configure.py script is not required in this example.

  • install.py includes Tomcat installation, port configuration, administrator password, environment variables declaration, and web application installation. The install.py and configure.py scripts only run during deployment.
  • start.py includes changing the role status to RUNNING, opening ports, and exposing parameters that are needed at VM start.
  • stop.py handles the shutdown of the Tomcat server.

The Python object maestro.role can store or transmit data between different life cycle scripts with the same role. Also, the operation implementation file under this role can access data from the maestro.role. More details are included in the downloadable sample code provided with this article.

Operation implementation script

The operation implementation file needs to include two methods, restart and deploy_apps, which provide these functions:

  • restart: Gets Tomcat home and restarts Tomcat.
  • deploy_apps: Gets Tomcat home, downloads the new application installation file, moves the application to Tomcat webapps, and then restarts Tomcat.

Create an HTTPD plug-in project

Now it's time to create the HTTPD plug-in structure and configuration. For HTTPD installation, the "httpd-2.4.4" source code is used. The installation script builds HTTPD from the source code and installs it. For the VM template definition, this project selects the template-based topology provider as shown in Figure 7.

Figure 7. New OSGI component in the HTTPD plug-in project
New OSGI component in the HTTPD plug-in project

Click Finish. Besides the OSGI component definition, the PDK generates the basic JSON fragment of a VM velocity template in "templates/sampleshttpd.vm" (see Listing 11). The JSON structure is clear and you can build this template with predefined objects provided by maestro. It is simpler and clearer than the Java-based template. However, one limitation is that it cannot handle complex logic as easily as the Java transformer code.

Listing 11. sampleshttpd.vm in the HTTPD plug-in
{
    "vm-templates": [
        {
            "persistent":false,                 
            "name": "${prefix}-httpd",
            "roles": [
                {
                	"plugin" : "$provider.PluginScope",
                    "parms": {
                    },
                    "type": "HTTPD_INSTALL",
                    "name": "HTTPD_INSTALL",
                    "external-uri": [{"ENDPOINT":"http://{SERVER}"}]
                }
            ],
            "packages": [
                "PKG_HTTPD_INSTALL"
            ]
        }
    ]
}

Build and install a pattern type and plug-in

The PDK provides a menu to build and install a pattern type project directly into PureApplication System. For the first installation, Tomcat and HTTPD installation files have not been uploaded to the Storehouse in PureApplication System. These installation files can be packaged with the pattern type project and only require uploading once.

  1. Find the "build.patterntype.xml" file in the pattern type project. Right-click the file. Select menu Run As > Ant Build. Switch to the Main tab and set the "storage.dir (local)" or "storage.url (remote)" argument in the ant build, with the value of the folder or URL containing the defined files in config.json for all the plug-in projects for this pattern type (for example, Dstorage.dir=d:/files). Click OK to build. The pattern type build also packages its plug-in projects within it.

    Note: Packaging of the installation files is only for the first build of the pattern type.

  2. Right-click the pattern type project. Select menu IBM Pattern Toolkit > Install/update to deployer.
  3. For the first time, it will pop up a toolkit preference page to set the deployer properties for connection. Set the PureApplication System attributes and select the Deploy debugging plug-ins before deployment checkbox to install the debug plug-in and the unlock plug-in for debugging purposes later.
  4. The following are installed to PureApplication System: Pattern type project, Tomcat, and HTTPD plug-in projects and files.
  5. In the Project Explorer view toolbar, click the Navigator to Deployer button. This starts an external browser to login to PureApplication System.

The pattern type is enabled in the console before using it to deploy instances to the cloud.


Debug with the PDK

The PDK includes a debug plug-in to provide debugging capability for virtual application pattern development. The following procedure uses the debug plug-in to debug a Tomcat plug-in project.

  1. Log in to the PureApplication System console and select menu Patterns > Virtual Applications. Then click "+".
  2. In the popup dialog, select pattern type patterntype.samples.apache, click the Start building button to open the virtual application builder.
  3. From the component palette, drag the Tomcat Server components and debug to the canvas (Figure 8). Then, set the required attributes in the Tomcat Server components.
    Figure 8. Build pattern in the Virtual Application Builder
    Build pattern in the Virtual Application Builder

    The debug plug-in has two debug modes:

    • Mock deployment: The deployed instance executes the transformer/provider to generate topology.json, but no VM is deployed.
    • Deployment for manual debugging: Select the Resumable on script error checkbox, which enables suspending the instance when an error occurs during the script execution. Then, you can update the scripts and resume instance execution. Without the debug plug-in, you have to redeploy instances to test the scripts that have been updated.
  4. Switch back to the Virtual Applications page. Select the newly created pattern and click the Deploy button. In the popup dialog, expand the Advanced section, set the SSH key, and make sure to keep it as a private key. Then click OK to deploy this pattern.

Now, one instance with the Tomcat server plug-in is running. In the PDK, switch to the Workload Plug-in Runtime perspective to trace the instance execution and debug as follows:

  1. In the Deployment Runtime Explorer, click "+".
  2. In the popup dialog, select the Add VM(s) from deployed instance radio button to trace the entire instance. Click Next.
  3. All the virtual application pattern instances are listed here. Select the newly deployed instance. Then, click the SSH Configuration button to set the SSH attributes. Select Key Mode and set the SSH key file location as shown in Figure 9. Click OK.
    Figure 9. SSH configuration with auto monitor enabled
    SSH configuration with auto monitor enabled
  4. Click Finish to add this instance, which is monitored. The logs are collected automatically until deployment is complete or no errors have occurred. In this example, the install.py role script contains one error and this suspends the instance execution as shown in Figure 10.
    Figure 10. Execution error in install.py
    Execution error in install.py
  5. To proceed, you need to fix the error in "install.py". Then, right-click the error node in the Deployment Runtime Explorer log tree view. Select the Upload And Resume menu. It updates install.py on VM and resumes the instance execution. You can repeat this process again and again to fix all the errors and to complete the execution. Some errors are not recoverable, which means you need to update the plug-ins and redeploy an instance to debug.
  6. In the console on the virtual application instance, click the TOMCAT_INSTALL endpoint. This opens the Tomcat server administration console where you can verify the installation.

Now test the HTTPD Server plug-in as described above to make sure that the HTTPD plug-ins can install the HTTPD server correctly.

Download files

See the provided sample code for samples.apache. Download the package and select from the menu, File > Import… > IBM Workload Plug-in Development > IBM Workload Pattern type Package, to import the projects.


Conclusion

Part 1 of this series showed you how to develop a virtual application pattern that includes plug-in components for Apache Tomcat and an Apache HTTPD server. You also learned how to build, deploy, and debug a pattern.

In Part 2, you will create a link and policy to that affects component deployment. In Part 3, you will create shared services to provide a singleton Memcached servers pool shared by multiple Tomcat server instances.


Download

DescriptionNameSize
Code samplepatterntype.samples.apache-1.0.0.0.zip209KB

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Cloud computing on developerWorks


  • Bluemix Developers Community

    Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.

  • developerWorks Labs

    Experiment with new directions in software development.

  • DevOps Services

    Software development in the cloud. Register today to create a project.

  • Try SoftLayer Cloud

    Deploy public cloud instances in as few as 5 minutes. Try the SoftLayer public cloud instance for one month.

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Cloud computing
ArticleID=954647
ArticleTitle=Using the IBM Pattern Development Kit to build virtual application patterns, Part 1: Create virtual application pattern plug-in projects to install Tomcat and an HTTP Server
publish-date=11272013