Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added host affinity mgmt blueprint #73

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions host-affinity/Host_Affinity_Update.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions host-affinity/auto-reassign-host/Auto Update VM Hosts.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pcVersion":"6.1","pcUuid":"edf58913-382f-4449-bcab-a6884fa4345a","hashValue":"QHZve0rdRdEp1NR6Pb2bg6voVuphfd6zHb1YLdpZzs8=","actionRuleList":[{"uuid":"75bc0cbc-de07-4a9d-a519-d6fd170916e0","name":"Place VMs to right hosts","isEnabled":true,"validated":true,"executionUserName":"kazi.ahmed@gso.lab","executionUserUuid":"b745c124-88a0-5ae4-9b65-8814659ab6e4","triggerList":[{"uuid":"7d12d74a-9e74-4565-a915-e9bf96f6ed28","triggerType":{"type":"trigger_type","uuid":"","name":"event_trigger"},"displayName":"Event","inputParameterList":[{"name":"operation_type","value":"2"},{"name":"category_filter_list","value":"[]"},{"name":"type","value":"VmUpdateAudit"},{"name":"source_entity_info_list","value":"[]"}]}],"actionList":[{"uuid":"e1ac6c02-42af-483c-b2e4-342a4efa9f5c","actionType":{"type":"action_type","uuid":"","name":"branch_action"},"displayName":"Branch","inputParameterList":[{"name":"values","value":"[\"{{trigger[0].source_entity_info.name}}\",\"^L-[a-zA-Z0-9]*$\",\"{{trigger[0].source_entity_info.name}}\",\"^W-[a-zA-Z0-9]*$\"]"},{"name":"condition","value":"[\"if\",\"if\"]"},{"name":"branch","value":"[\"1717b1ce-97d6-4b35-9c9a-13a829aad257\",\"15db89a9-8c46-4b4e-ac8a-d1fed37d0e9e\"]"},{"name":"conditional_expression","value":"[\"{0}=regexp={1}\",\"{2}=regexp={3}\"]"}],"maxRetries":2,"description":"@|","childActionUuids":["1717b1ce-97d6-4b35-9c9a-13a829aad257","15db89a9-8c46-4b4e-ac8a-d1fed37d0e9e"]},{"uuid":"1717b1ce-97d6-4b35-9c9a-13a829aad257","actionType":{"type":"action_type","uuid":"","name":"rest_api_action"},"displayName":"REST API","inputParameterList":[{"name":"username","value":"kazi.ahmed@gso.lab"},{"name":"request_body","value":"{\n\t\"spec\": {\n\t\t\"args\": [{\n\t\t\t\t\"val_type\": \"STRING\",\n\t\t\t\t\"is_mandatory\": true,\n\t\t\t\t\"description\": \"Enter the name of the approval item\",\n\t\t\t\t\"data_type\": \"BASE\",\n\t\t\t\t\"name\": \"host_category_value\",\n\t\t\t\t\"value\": \"Linux\"\n\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"val_type\": \"STRING\",\n\t\t\t\t\"is_mandatory\": true,\n\t\t\t\t\"description\": \"VM name to upgrade\",\n\t\t\t\t\"data_type\": \"BASE\",\n\t\t\t\t\"name\": \"vm_name\",\n\t\t\t\t\"value\": \"{{trigger[0].source_entity_info.name}}\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"val_type\": \"STRING\",\n\t\t\t\t\"is_mandatory\": true,\n\t\t\t\t\"description\": \"VM uuid to upgrade\",\n\t\t\t\t\"data_type\": \"BASE\",\n\t\t\t\t\"name\": \"vm_uuid\",\n\t\t\t\t\"value\": \"{{trigger[0].source_entity_info.uuid}}\"\n\t\t\t}\n\t\t]\n\t}\n}"},{"name":"url","value":"https://10.48.108.12:9440/api/nutanix/v3/runbooks/eb39f2a5-ab9b-7c94-56d6-ad94cd988908/run"},{"name":"headers","value":"Content-Type: application/json"},{"name":"password","value":""},{"name":"method","value":"POST"}],"maxRetries":2},{"uuid":"15db89a9-8c46-4b4e-ac8a-d1fed37d0e9e","actionType":{"type":"action_type","uuid":"","name":"rest_api_action"},"displayName":"REST API","inputParameterList":[{"name":"username","value":"kazi.ahmed@gso.lab"},{"name":"request_body","value":"{\n\t\"spec\": {\n\t\t\"args\": [{\n\t\t\t\t\"val_type\": \"STRING\",\n\t\t\t\t\"is_mandatory\": true,\n\t\t\t\t\"description\": \"Enter the name of the approval item\",\n\t\t\t\t\"data_type\": \"BASE\",\n\t\t\t\t\"name\": \"host_category_value\",\n\t\t\t\t\"value\": \"Windows\"\n\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"val_type\": \"STRING\",\n\t\t\t\t\"is_mandatory\": true,\n\t\t\t\t\"description\": \"VM name to upgrade\",\n\t\t\t\t\"data_type\": \"BASE\",\n\t\t\t\t\"name\": \"vm_name\",\n\t\t\t\t\"value\": \"{{trigger[0].source_entity_info.name}}\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"val_type\": \"STRING\",\n\t\t\t\t\"is_mandatory\": true,\n\t\t\t\t\"description\": \"VM uuid to upgrade\",\n\t\t\t\t\"data_type\": \"BASE\",\n\t\t\t\t\"name\": \"vm_uuid\",\n\t\t\t\t\"value\": \"{{trigger[0].source_entity_info.uuid}}\"\n\t\t\t}\n\t\t]\n\t}\n}"},{"name":"url","value":"https://10.48.108.12:9440/api/nutanix/v3/runbooks/eb39f2a5-ab9b-7c94-56d6-ad94cd988908/run"},{"name":"headers","value":"Content-Type: application/json"},{"name":"password","value":""},{"name":"method","value":"POST"}],"maxRetries":2,"description":"Copy 1"}],"lastUpdateUser":"kazi.ahmed@gso.lab","isPrepackaged":false,"checkTriggerValidity":true,"triggerFilterableInputParamName":"type","triggerFilterableInputParamValue":"VmUpdateAudit","ruleType":"kXPlay"}]}
13 changes: 13 additions & 0 deletions host-affinity/auto-reassign-host/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Automatically reassign a VM to a host on update

This section talk about how VM could be automatically glued to certain host groups based on its naming convention. This example here has two main components to it one the Prism Pro playbook and another is a runbook.

## Description of the components:

![playbook](/host-affinity/auto-reassign-host/images/playbook-structure.png?raw=true)

- Playbook: The above playbook (Auto Update VM Hosts.json) is hooked with a VM update event. As soon as a VM update happens, the workflow executes and it finds out if the VM is Linux or Windows type and passes that to the runbook in the following.

- Runbook: The runbook first figures out whether the VM is already on the right host or not, if it is not it picks the first host from the configured host list for that type of OS. Rest of the tasks in the runbook creates both host and vm categories and finally creates an affinity rule bonding these two entities which will put the VM to the appropriate host.

![runbook](/host-affinity/auto-reassign-host/images/runbook.png?raw=true)
Binary file added host-affinity/blob/change-action-prompt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added host-affinity/blob/delete-existing-affinity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added host-affinity/blob/set-new-affinity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions host-affinity/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Apply vm-host affinity policy during a VM deployment or update post deployment from CALM app.

This section of the blueprints repo demonstrates how to better leverage host affinities for VM deployment and management from Calm. Initially we providing a sample blueprint (Host_Affinity_Update.json) that would deploy a new Centos
VM, also has a custom action built in order to change the VM host affinity to other hosts as day 2 operation.

Here is the overview from the profile action:
![conceptual overview](/host-affinity/blob/change-vm-host-affinity-action.png?raw=true)

## Breakdown of the node blueprint actions:

Once the action is run, it will prompt following and ask for new desired hosts list:
![conceptual overview](/host-affinity/blob/change-action-prompt.png?raw=true)

The action has the following 3 main sections. First task collects the hostnames and publishes it for the successive service actions:

- Delete Affinity Policy: This is a service action that comprised of few tasks that auto collects exiting host names, deletes the associated affinity, waits a little to sync and then deletes the host and category association that it originally created.
![conceptual overview](/host-affinity/blob/delete-existing-affinity.png?raw=true)

- Replace New Affinity Policy: This service action does pretty much everything in reverse what the previous action did. It first reestablishes the category association with the new hosts. Then creates the same affinity with the VM category and new hosts category, waits a little to sync up, check for availability of newly created affinity policy, then finally republishes the host names for the sanity of the workflow and successive use. that comprised of few tasks that auto collects exiting host names, deletes the associated affinity, waits a little to sync and then deletes the host and category association that it originally created.
![conceptual overview](/host-affinity/blob/set-new-affinity.png?raw=true)

This talks leverages AOS 6.1 api for [host affinities](https://portal.nutanix.com/page/documents/details?targetId=AHV-Admin-Guide-v6_1:ahv-affinity-policies.html) that would also require Calm 3.5+ and Prism Central PC2022.1.02+