In the heat-API architecture, the external virtual machine needs to communicate with the Virtual Machine and customize the Virtual Machine in detail. Write down the specific architecture later.
Today we will focus on the functions of several scripts in cfntools. Https://github.com/heat-api/heat-jeos)
Cfntools Introduction
Cfntools is a bunch of auxiliary scripts running in virtual machines. It is generally used to obtain metadata and perform some automated configuration based on metadata.
Cfntools directory structure
── CFN-get-Metadata
── Cfn_helper.py
├ ── CFN-Hup
── CFN-init
── CFN-push-Stats
── CFN-Signal
── _ Init _. py
Cfn_helper includes the main implementationCodeThe other scripts only depend on this.
CFN-init
Initialize some virtual machines, such as reading the configuration of AWS: cloudformation: init in metadata, and then perform some actions, such as installation packages and starting services. See: http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html#aws-resource-init-services
CFN-get-Metadata
Obtain metadata and save it to the/tmp/last_metadata directory. In fact, this part of work CFN-init has already been done.
CFN-push-Stats
Call psutil to obtain the internal information (CPU and memory usage) of the VM and send the information to the metadata server.
CFN-Signal
It also sends data to the metadata server, but it only sends information such as whether the cfntool operation is complete and whether an error occurs.
For example, in general, the virtual machine user-data in the template of the CFN will write:
CFN-signal-E 0-r \ "Wiki Server SETUP complete \"
-E -- exit code
-R -- reson
CFN-Hup
This is complicated. It is a daemon process that monitors metadata and performs corresponding actions based on the updated metadata. The main usage can be used to update the configuration file, such as the configuration of haproxy.