Recipes

The recipe is the plugin mechanism used for adding new functionalities to the OnApp cloud. Each recipe is a set of instructions that trigger events at certain stages during the execution of certain services/event in the cloud. Essentially, recipes allow inputting code into virtual servers, appliances or the Control Panel server. This enables administrators to use recipes for configuring the server or report on it, thus providing advanced customization options in a standard environment.

Recipes run over SSH, and all commands triggered can run on virtual servers, appliances or the Control Panel server.  

SSH connection is not required for running recipes on VMware virtual servers.

OnApp CP does not update the status of the recipe if it takes longer than 1 hour to complete the transaction.


Recipe Use

Recipes allow admins to perform the following operations:

  • Perform post script installation.
  • Use post provision installation scripts for third-party applications, agents, etc.
  • Disk reclaiming.
  • Update/modify virtual servers and Compute zones with script injection.
  • Allow host to spin up custom virtual servers without requiring custom templates.
  • Download, run and report audit tools.

Use of recipes brings cloud administrators more control over their cloud environment and allows them to self-maintain such tasks as custom template creation, etc.

You can use recipes for Unix (Linux and FreeBSD) and Windows virtual servers, smart servers, baremetal servers, virtual server templates, Compute zones and the control panel server. For details, refer to the relevant sections of the Admin guide:

To be able to use recipes in the cloud, you must enable recipe permissions first.

Recipe Variables

The recipes run when the appropriate events are triggered on the compute resources, virtual servers or the CP server. Depending on the object where the event occurs, the recipe runs on compute resource/VS/CP and contains the variables for that object. When the recipe execution on compute resource is triggered by the event happening on a virtual server, then the recipe also contains the variables for the virtual server object. The same relates to the CP server.

Here is the list of variables that you can define in recipes:

Compute resource variables

IP_ADDRESS - an IP address of a compute resource

HV_IP_ADDRESS - a management IP address of a compute resource

IPJOIN_HYPERVISOR_IP_ADDRESS - a compute resource management IP address where a virtual server (with a network interface with an assigned IP) is located on

VIRTUALIZATION - a compute resource virtualization type: Xen, KVM, or VMware

SERVER_TYPE - a server type: virtual, smart, or baremetal

Virtual Server variables

VM_IDENTIFIER - a virtual server identifier

IP_ADDRESS - an IP address of a virtual server 

IP_EXTERNAL_ADDRESS - an external IP address of a virtual server

IPJOIN_IP_ADDRESS - an IP address as a string

IPJOIN_IP_ADDRESS_ID - an ID of an IP Address

IPJOIN_NETWORK_IDENTIFIER - a MAC address of a network interface an IP address is assigned to

IPJOIN_NIC_MAC_ADDRESS - a MAC address of a network interface

HOSTNAME - a hostname of a virtual server

ROOT_PASSWORD - a server root password

OPERATING_SYSTEM - a virtual server operating system

OPERATING_SYSTEM_DISTRO - a virtual server OS distribution

OPERATING_SYSTEM_ARCH - an architecture of an operating system

OPERATING_SYSTEM_EDITION - an edition of an operating system

VM_USER_ID - an ID of a virtual server user

VM_USER_FIRSTNAME - the first name of a virtual server user

VM_USER_LASTNAME - the last name of a virtual server user

VM_USER_EMAIL - an email of a virtual server user

VM_NETWORK_INTERFACES - a JSON string with information about network interfaces of the virtual server, for example: 

"VM_NETWORK_INTERFACES"="[{\"id\":520,\"identifier\":\"eoa\",\"mac_address\":\"00:16:4e:ca:f5:6b\",\"primary\":true,\"network_join\":{\"id\":8,\"network_id\":6,\"network
_identifier\":\"mcy\",\"interface\":\"eth12\"},\"ip_addresses\":[{\"id\":63,\"address\":\"69.168.227.55\",\"prefix\":24,\"gateway\":\"69.168.247.1\",\"external_address\":\"\"}]}]"


All recipes have access to these variables:

CP_ADDRESS - an IP address of a control panel server

RESPONSE_FROM_PREVIOUS - a response from the previous recipe step

TRIGGERING_EVENTS - events that triggered execution of a recipe

TRIGGERED_BY_TRANSACTION - a JSON string with information about a transaction that triggers the recipe. The string can include the transaction id, parent_type, parent_id, action, status, params, dependent_transaction_id, etc. The variable can be blank if there is no transaction that triggers the recipe.

RESOURCE_DIFF - a JSON string with information about changes within resources that happened as a result of the transaction that triggered the recipe. The variable can be blank if no changes within resources occur as a result of the transaction.