Scenario
Cloudify 2.7 application running a tomcat service instance
Goal
I would like to stop (shut off) and start the VM hosting tomcat using OpenStack APIs, without Cloudify re-installs the tomcat recipe.
What I tried to do
I tried to use the Maintenance Mode, following this guide:
Setting a service instance to maintenance mode will disable host machine failure detection for that specific service instance. This means that during the specified time period, a failure or a restart of a service instance host machine will NOT result in a provisioning of a new machine and service instance.
So, I have executed the following commands:
1. cloudify@default> connect VM_MNG_IP
2. cloudify@default> use-application <application_name>
3. cloudify@tommy> invoke <service_name> cloudify:start-maintenance-mode 300
4. Shut off the tomcat VM using OpenStack API
5. Start the tomcat VM using OpenStack API
After that, what I saw in the Cloudify's Orchestraotor logs was the re-installation process of the tomcat service. In other words, the tomcat VM now hosts tow tomcat Processing Units.
ls -al /root/gigaspaces/work/processing-units
<application_name>_tomcat_1_1278947587
<application_name>_tomcat_1_2029943570
Can someone suggest to me what should I do in order to reach my goal?
That is the correct behavior of the default tomcat service provided with Cloudify 2.7 - after a restart, the tomcat files are re-downloaded and deployed locally.
If you want a different behavior, you may want to tweak the tomcat recipe to save the tomcat files in a different location (the default installation saves all files in a per instance work directory, which will be replaced after a reboot). You can change the recipe to look for an existing installation and use it if it exists.
Have a look at the following files:
https://github.com/CloudifySource/cloudify-recipes/blob/master/services/tomcat/tomcat_init.groovy https://github.com/CloudifySource/cloudify-recipes/blob/master/services/tomcat/tomcat_install.groovy
These are probably the files you will need to edit to achieve what you are looking for. Note how catalina_base is set as a context property, and that AntBuilder is used to download the tomcat installation and save it to a shared location. These are the files you will need to change.
Please consider that Cloudify 2.x has reached end of life - you should consider moving to Cloudify 3: http://getcloudify.org/guide/3.1/quickstart.html