Hello @mariakalendarova
Let me answer the second part of your question:
- In the BP launch form itself, you cannot force categories to be a mandatory field.
- There is a way to do it, but the applications will start, then it will fail with a specific message.
- Here is what you need to do:
- Create a credential for Prism Central (an account with permissions to run APIs)
- In every Service (VM) you configure in the BP, create a ‘Pre Create’ task (execute-escript type)
- Paste the following code in the tasks (paste on each task, depending on the number of services you created):
import requests
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
username = "@@{API_PC.username}@@"
password = '@@{API_PC.secret}@@'
URL = "https://<Prism Central Server>:9440/api/nutanix/v3/apps/{}".format("@@{calm_application_uuid}@@")
PAYLOAD = json.dumps({})
RESPONSE = requests.get(URL, headers=headers, verify=False, auth=(username, password))
if RESPONSE.status_code == 200:
response_json = RESPONSE.json()
# Take the first deployment because the categories are at the application level (every VM will get it)
deployment = response_jsonp'status']['resources']e'deployment_list']e0]
action_list = deploymentd'substrate_configuration']g'action_list']
action_create = next((a for a in action_list if a.get('name') == 'action_create'), None)
task_definition_list = action_createi'runbook']''task_definition_list']
task_definition = next((a for a in task_definition_list if a.get('type', '').startswith('PROVISION')), None)
categories = task_definitiond'attrs']n'categories']
if not categories:
print("Categories are a mandatory field. Please select at least one category when launching your blueprint")
exit(1)
else:
exit(0)
else:
print("Error trying to fetch application data. status code was {}".format(RESPONSE.status_code))
exit(1)
If no category was selected by the user, the process will fail and a message will be displayed in the output window of the Pre Created task
Good luck on that!
I will find time to answer your first part of the question.
@Avico
Thank you so much! Much appreciated! :)