HyperCloud™ Plugins
Overview
Note
Among various Blueprint types, only VMs support Plugins.
The HyperCloud™ Platform (HCP) lets you create and execute scripts on Virtual Machines (VMs.) These scripts are called Plugins on the HCP portal. The HCP portal supports these interpreters:
Bash
Python
Perl
Ruby
PowerShell
Puppet
To run a Plugin on a VM, you’ll need to install the HCP agent. You can install the HCP agent on the VM using a Blueprint or the Free-from wizard.
Refer to these sections to:
Create your Plugin
Plugins are Docker containers that perform pre-defined tasks. These tasks are executed as steps in your HCP pipeline. You can use Plugins to deploy code, publish artifacts, send notifications, etcetera.
Follow these steps to create a Plugin:
Log in to your HCP portal account.
Click Service Orchestration and navigate to Appstore > Plugins > Click New > Select the Plugin Type from the drop-down list.
Enter these details in your Script Plugin dialog:
Provide a Name for your Plugin.
Click +Advance Configuration and enter these details:
Enter a plugin Version.
Enter a brief description of your new Script Plugin.
Select the License from the drop-down list.
Enter the Timeout for your Plugin in seconds.
Enter the following in the Scripts text-box:
#!/bin/bash
[1] Use the script below to update your packages:echo "Updating OS packages" sudo apt-get update && sudo apt-get upgrade -y || yum update -y echo "Ping Test to Google DNS Server" ping $IP_ADDRESS -c 8|
If you want to add conditions for your Script Plugin run:
Click Arguments+
Enter the argument Key and its Value.
Example:
Key:IP_ADDRESS
Value:8.8.8.8
To entitle users to your Plugin, select:
Only Me: if you do not want anyone to access your Plugin.
Everyone: if you want to share your Plugin with everyone.
Groups & Users: if you want to share the Plugin with specific users or groups.
Enter the first three alphabets of the username in the Users drop-down and select the username.
Type the first three alphabets of the Group Name in the Groups drop-down and select the group name.
Click Save Changes.
Once you create your Plugin, the HCP portal will create a unique REFERENCE ID for the same.
Example: Q5G9A
Note
[1] The HCP portal will replace all occurrences of:
$IP_ADDRESS
in the Plugin with the value8.8.8.8
The HCP portal will ignore all occurrences of:
${IP_ADDRESS}
in the Plugin
Run your plugin on-demand
Follow these steps to run your plugins on-demand on an existing VM without having to connect to the VM: [1]
Log in to your HCP portal account.
Click on Service Orchestration and navigate to Services > VM > Click open your VM > Click Plugins.
From the Add Plugins drop-down, select your Plugin. [2]
To add more plugins, click Add Plugins and select your Plugin from the drop-down list.
You can provide conditional arguments for each Plugin under +Advance Configuration. Enter the following details under +Advance Configuration:
Valid Exit Codes: when you state a valid exit code, the HCP portal will ignore these codes. If you do not provide an exit code, the HCP portal will substitute it with the default value, which is 0.
Order: this lets you define the sequence for the Order of executing the Plugin. [3]
Click Run Plugin.
Click Timeline Tab and wait for a few minutes to see the status of your run.
Note
[1] You’ll need to install the HyperCloud™ Agent on the VM before running a plugin.
The Agent Status must be Connected.
[2] If your Plugin has conditional arguments, you can view the same under +Advanced Configuration.
[3] If you do not provide the Order for executing a plugin, all plugins added to the VM will run simultaneously.
Add Plugin to a Blueprint using parameters
You can use parameters in blueprints to pass or override the default plugin values. You can add a plugin to different blueprints and customize your deployments using parameters. Follow these steps to add parameters to your Plugin for an existing blueprint:
Log in to the HCP portal account.
Click Service Orchestration and navigate to AppStore > Plugins > Copy the REFERENCE ID of your Plugin.
Click AppStore and navigate to New > Select Machine Compose Blueprint from the drop-down list.
Enter the following details in your Machine Compose Blueprint dialog:
Enter a Name for the new Machine Compose Blueprint.
Enter the brief description of your Machine Compose Blueprint.
Select the blueprint Type from the drop-down list.
Enter the plugin snippet in the YAML text-box as shown below: [1]
Select the Resource Pool from the drop-down list
Click Customizable Params + and enter the following details:
Enter the internal reference to the Plugin.
Example: Machine.plugins.Q5G9A.arguments.IP_ADDRESS
The HCP portal will use this reference to run the Plugin on your VM using the YAML blueprint parameter values.Enter the Host in the Key text-box. The Key is visible to your HCP user.
Enter the Value for your Key. If you do not enter a value for your Key, the HCP portal will default the value to
8.8.8.8
.Select the Mandatory check-box to make it compulsory for your HCP users to provide a Key-Value before creating a VM. [2]
Select the Password check-box to ensure that your sensitive data is masked during input and execution.
Click Save Changes
To use these parameters in your blueprint:
Click open your blueprint.
Click Request Params.
Enter the Host value that you provided in Step-f above.
[1] Sample YAML
Machine:
region: westus
group: hg-poc
image: Canonical:UbuntuServer:16.04-LTS
instanceType: Standard_D13_v2
resourceGroup: hg-dojo-rg
network: hg-dojo-vnet1
subnet: hg-dojo-vnet1-subnet1
securityGroup: hg-dojo-nsg
skipAgentInstall: false
assignFloatingIP: true
publicIPSku: basic
password: "{{credentials | 2c9180876f0dbccb016f4f9d87a66886 }}"
count: 1
terminationProtection: DISABLED
plugins:
-!plugin
# Install Packages
id: Q5G9A
order: 1
-!plugin
# Download & Install Security Agent
id: P5H7K
order: 2
Add Plugin to a blueprint without using parameters
You can add a plugin to a blueprint by appending the plugin YAML values to the blueprint YAML. To add a plugin to an existing MACHINE_COMPOSE Blueprint YAML:
Log in to your HCP portal account.
Click Service Orchestration and navigate to AppStore > Plugins > Copy your plugin REFERENCE ID.
Navigate to AppStore > Click New > Select Machine Compose Blueprint from the drop-down list.
Enter the following details in the Machine Compose Blueprint dialog:
Enter a Name for your new Machine Compose Blueprint.
Enter a brief Description of your Machine Compose Blueprint.
Select the blueprint Type from the drop-down list.
Enter the plugin snippet in the YAML text-box. [1]
Select the Resource Pool from the drop-down list.
Select the Cost Profile.
To entitle users to your blueprint, select:
Only Me: if you do not want anyone to access your blueprint.
Everyone: if you want to share your blueprint with everyone.
Groups & Users: if you want to share the blueprint with specific users or groups.
Enter the first three alphabets of the username in the Users drop-down and select the username.
Type the first three alphabets of the Group Name in the Groups drop-down and select the group name.
If you are a Cloud Administrator, you can select All Tenants to share your template with all the HCP tenants.
Click Save Changes.
Once you’ve configured your plugin parameters, you can create your VM. Follow these steps to create your VM:
Click open your blueprint.
Click Create Machine.
Once your VM is provisioned:
The HyperCloudTM Agent will be automatically installed and,
All the plugins in the blueprint are executed in the Order defined in the Blueprint YAML.
[1] Sample YAML
Machine:
region: westus
group: hg-poc
image: Canonical:UbuntuServer:16.04-LTS
instanceType: Standard_D13_v2
resourceGroup: hg-dojo-rg
network: hg-dojo-vnet1
subnet: hg-dojo-vnet1-subnet1
securityGroup: hg-dojo-nsg
skipAgentInstall: false
assignFloatingIP: true
publicIPSku: basic
password: "{{credentials | 2c9180876f0dbccb016f4f9d87a66886 }}"
count: 1
terminationProtection: DISABLED
plugins:
-!plugin
# Install Packages
id: Q5G9A
order: 1
-!plugin
# Download & Install Security Agent
id: P5H7K
order: 2
© 2020 CloudSphere