Pattern-type (Part 13): How to create shared services for IBM SmartCloud Application Workload Service

2) Deployment:

Here we will add all elements in order to be able to deploy our shared service. The shared service will not yet contain the service definition in order to be called from a client. For that we will need to define the part, topology template, packages…

2.1) Create the part/role:
We will use a role called ‘PoolManager’ and thus let’s create a directory under ‘plugin/parts’ for our package. So, this directory will be called then ‘poolmanager.scripts’. Under this directory we will create the directory corresponding to the role ‘PoolManager’ and its different lifecycle files, this can be achieve by calling the ‘New’->’Plugin Role’ of the PDK plugin.
SCAWS SS PoolManager role lifecycle filesIn the start.py, we will add the line to specify the final ‘Running’ status:

maestro.role_status = 'STARTING';
logger.debug("Start Master");
maestro.role_status = 'RUNNING';

2.2) Define the package:

This has to be done in the config.json, just add the following lines in the config.json file at the same level of the ‘patterntypes’ element (don’t forget the colon between the 2 elements).

    "packages":{
        "POOLMANAGER_PKG":[
            {
                "parts":[
                    {
                        "part":"parts/poolmanager.scripts.tgz"
                    }
                ]

            }
        ]
    }

2.3) Define the OSGI files for the topology provider.

Using the PDK plugin, right-click ‘New’->’OSGI Service Component’; provide ‘POOLMANAGER’ as name and leave all other value as-is.
A new poolmanger.file will be created in the OSGI-INF directory:

SCAWS SS PoolManager OSGI poolmanager

A new entry will be added in the META-INF/MANIFEST.MF to register the OSGI service and a new poolmanager.vm will be created in the plugin/templates directory.

2.4) Update the topology template.

The previous step generate a poolmanger.vm in the templates directory we have to update it to represent the topology we would like to deploy for the specific role and including the package. The poolmanager.vm should look like:

{
    "vm-templates": [
        {
            "persistent": true,
            "name": "SharedService-PoolManager", 
            "roles": [
                {
                    "parms": {
                        "poolsize": "$attributes.poolsize",
                    },
                    "type": "PoolManager", 
                    "name": "PoolManager"
                }
            ], 
            "packages": [
                "POOLMANAGER_PKG"
            ]
        }
    ]
}

2.5) Test the deployment

After having increasing the config.json version element, you can build and redeploy the plugin and finally deploy your shared service as in step “1.4 Presentation Test”

SCAWS SS PoolManager deployment