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

1) Presentation

In this chapter we will create all necessary files in order to show our share service in the portal. We will need the config.json, the metadata.json and a new file specific to the shared service the appmodel.json. The appmodel.json provides the name and the version of the shared service but also to which pattern-type it is belong to and which client version can call it.

1.1) Define the application model:

As any other type of plugin an application model must be defined, so let’s create a metadata.json under the plugin/appmodel directory with the following content:

[
   {
   "id": "poolmanager",
   "type": "component",
   "label": "Pool Manager",
   "attributes": [
      {
      "id": "poolsize",
      "type": "number",
      "required": true,
      "label": "Pool Size",
      "description": "The number of resources in the Pool."
      }
   ]
}
]

So, we defined here a component with range attribute of type ‘number’ to specify the poolsize.

1.2) The config.json file.
Again as any other plugin, we have to define a config.json file and here the primary pattern-type can be “foundation” but if you want to use your own pattern-type don’t forget to modify accordingly the appmodel.json (chap 1.3 below) to define your own pattern-type instead of the “foundation”.

{
    "name":"poolmanager",
    "version" : "1.0.0.4",
    "patterntypes":{
        "primary":{
            "foundation":"2.0"
        }
    }
}

1.3) Define the shared service application model.
A shared service needs also an application model to define the parameters that have to be captured at deployment time. This application model reference the attribute defined in the appmodel/metadata.json.

{
    "model": {
        "name": "Pool Manager (Sample)",
        "app_type": "service",
        "servicename": "poolmanager",
        "servicedisplayname": "Pool Manager (Sample)",
        "serviceversion": "1.0.0.4",
        "servicesupportedclients": "[1.0,1.0]",
        "patterntype": "foundation",
        "version": "2.0",
        "description": "This is a sample shared services which manage a dummy pool of resources.",
        "nodes": [
            {
                "attributes": {
                    "poolsize": 20
                }, 
                "id": "poolmanagerservice",
                "type": "POOLMANAGER"
            }
        ], 
        "links": [
        ]
    }
}

1.4) Test

Now, we can build and upload the plugin as a System-plugin.
You can notice that the plugin will be uploaded under the ‘Foundation 2.0’ as described in the config.json file.
Now, open the ‘Cloud’ -> ‘Shared Services’ tab and you will see our shared service ‘Pool Manager (Sample)’.

SCAWS SS PoolManager

click on it and look at the details:

SCAWS SS PoolManager Details

Click on ‘deploy’ and you see our attribute defined in the metadata.json and referenced in the appmodel.json.

SCAWS SS PoolManager Parameters