Pattern-type (Part 10): Attach a storage to a virtual machine on SmartCloud Application Services

I was wondering how I can add a storage to a virtual machine generated from a pattern-type developed on SmartCloud Application Workload Service and, in fact, it is very simple and easy.

The only think you have to do is update your topology template to request  a storage and then reference this storage in the vm-templates array element.

Let’s take a simple *.vm file such as:

{
    "vm-templates": [
        {
            "name": "${prefix}-MasterSlave",
            "roles": [
                {
                    "type": "master",
                    "name": "master"
                }
            ],
            "packages":["PLUGIN.MASTER"],
        }
    ]
}

We have first to add a storage request, this is done by adding a storage-templates array in the json file like:

{
    "vm-templates": [
        {
            "name": "${prefix}-MasterSlave",
            "roles": [
                {
                    "type": "master",
                    "name": "master"
                }
            ],
            "packages":["PLUGIN.MASTER"],
    ],
    "storage-templates":[
      {
         "parms":{
            "size":60,
            "format":"ext3",
            "type":"auto"
         },
         "name":"master-storage"
      }
   ]
}

This request a 60 GB storage ext3 formated. Its name is “master-storage”, this name will be use to reference this request in the vm-templates element.

The available sizes on SmartCloud Application Workload Service are the same as the one available on SmartCloud Enterprise from 60 GB up to 10TB but expressed in GigaBytes. If the specified size is between to available sizes, the upper size will be taken. For example, if you set a size of 100GB then a disk of 256GB will be allocated.

Now, let’s add a reference to this storage request to the vm-templates elements. To do that, we will add a storage array element in the vm-templates element.

{
    "vm-templates": [
        {
            "name": "${prefix}-MasterSlave",
            "roles": [
                {
                    "type": "master",
                    "name": "master"
                }
            ],
            "packages":["PLUGIN.MASTER"],
            "storage":[
    	      {
         		"storage-ref":"master-storage",
         		"device":"\/dev\/sdb",
         		"mount-point":"\/mnt\/master-storage-mnt"
      	      }
   	  ]
        }
    ],
    "storage-templates":[
      {
         "parms":{
            "size":60,
            "format":"ext3",
            "type":"auto"
         },
         "name":"master-storage"
      }
   ]
}

Now, we can build our plugin and deploy it.

We create a simple virtual application pattern with this “master” component and deploy it.

Now, once the pattern is deployed, we can connect and verify that the storage is mounted with the correct size.

We can see that the new storage has the correct size and is mounted to the specified directory.