Resource Actions
Overview¶
Resource actions in VCF Automation allow you to create custom day-2 operation action for already provisioned resources or deployments that allow entitled users to modify, manage, or interact with that resource. Custom resource actions can be based on VCF Operations Orchestrator workflows or extensibility actions.
Project Structure¶
Build Tools for VMware Aria stores resource action objects in several files in a directory with the resource action name under the src/main/resources/resource-actions directory in the project content on the local filesystem.
Following is a sample listing of the local filesystem for a resource action with the name Add CD-ROM to Deployment.
src/
└─ main/
└── resources/
└── resource-actions/
└── Add CD-ROM to Deployment/
├── Add CD-ROM to Deployment__FormData.json
├── details.json
└── styles.css
Following is a list of the files for each resource action object with a short description of their content and purpose.
- The
details.jsonfile contains the full definition of the resource action, including the metadata information. - The
<resource action name>__FormData.json1 file contains the custom form definition for the resource action. - The
style.cssfile is optional and contains the CSS for the custom form of the resource, if available.
Sample Project File Content¶
This section contains sample listings of the content of the files for each resource action object as they are stored in the src/main/resources/resource-actions/<resource action name>/2 directory in the project content on the local filesystem.
Following is a sample listing of the content of the details.json file for the Add CD-ROM to Deployment resource action (as defined in the project archetype).
src/main/resources/resource-actions/Add CD-ROM to Deployment/details.json
{
"id" : "Deployment.custom.add_cdrom",
"name" : "add_cdrom",
"displayName" : "Add CD-ROM to Deployment",
"description" : "Sample resource action",
"providerName" : "vro-workflow",
"resourceType" : "Deployment",
"status" : "RELEASED",
"orgId" : "457e4ab6-727f-446c-9d20-ba150e18950b",
"runnableItem" : {
"id" : "f146b992-71d3-431d-872e-2b22eb3b0f78",
"name" : "Mount CD-ROM",
"description" : "Mounts the CD-ROM of a virtual machine. If the virtual machine has no IDE controller and/or CD-ROM drive, the workflow creates them.\n",
"type" : "vro.workflow",
"inputParameters" : [ {
"type" : "VC:VirtualMachine",
"name" : "vm",
"description" : "Virtual machine to which to add a CD-ROM"
}, {
"type" : "boolean",
"name" : "connectAtPowerOn",
"description" : "Connect the CD-ROM when the virtual machine powers on"
}, {
"type" : "string",
"name" : "deviceType",
"description" : "Device type"
}, {
"type" : "string",
"name" : "filePath",
"description" : "ISO file path"
} ],
"endpointLink" : "/resources/endpoints/d88757a9-cda8-4efe-8d8c-866006b86782"
}
}
Following is a sample listing of the content of the Add CD-ROM to Deployment__FormData.json file (custom form) for the Add CD-ROM to Deployment resource action (as defined in the project archetype).
src/main/resources/resource-actions/Add CD-ROM to Deployment/Add CD-ROM to Deployment__FormData.json
{
"tenant" : "457e4ab6-727f-446c-9d20-ba150e18950b",
"id" : "37f28d52-48ec-409b-a899-9efeb046c43e",
"name" : "add_cdrom",
"form" : {
"layout" : {
"pages" : [ {
"id" : "page_1",
"title" : "VM",
"sections" : [ {
"id" : "section_0",
"fields" : [ {
"id" : "vm",
"display" : "valuePicker"
} ]
} ]
}, {
"id" : "page_2",
"title" : "CD-ROM",
"sections" : [ {
"id" : "section_2",
"fields" : [ {
"id" : "connectAtPowerOn",
"display" : "checkbox"
} ]
}, {
"id" : "section_3",
"fields" : [ {
"id" : "deviceType",
"display" : "dropDown"
} ]
}, {
"id" : "section_4",
"fields" : [ {
"id" : "filePath",
"display" : "textField"
} ]
} ]
} ]
},
"schema" : {
"deviceType" : {
"label" : "Device type\n",
"type" : {
"dataType" : "string",
"isMultiple" : false
},
"default" : "Client Device",
"valueList" : [ "Client Device", "Host Device", "Datastore ISO File" ],
"constraints" : {
"required" : true
}
},
"connectAtPowerOn" : {
"label" : "Connect the CD-ROM when the virtual machine powers on\n",
"type" : {
"dataType" : "boolean",
"isMultiple" : false
},
"default" : false,
"constraints" : { }
},
"vm" : {
"label" : "Virtual machine on which to mount a CD-ROM\n",
"type" : {
"dataType" : "reference",
"referenceType" : "VC:VirtualMachine",
"isMultiple" : false
},
"constraints" : {
"required" : true
}
},
"filePath" : {
"label" : "ISO file path in datastore file format, for example [MY_DATASTORE] data/image.iso\n",
"type" : {
"dataType" : "string",
"isMultiple" : false
},
"constraints" : { }
}
}
},
"sourceType" : "resource.action",
"sourceId" : "Deployment.custom.add_cdrom",
"type" : "requestForm",
"status" : "ON",
"formFormat" : "JSON"
}
Export¶
To export the definition of a resource action from the VCF Automation server (pull the content), you need to add the resource action name as a list item of the resource-action element in the content.yaml content descriptor file for the project.
Tip
Alternatively, if you want to export all resource action objects from the project on the VCF Automation server, you can configure the resource-action element with no value (i.e. its value is null). For details, see the Content Filtering section.
Following is a sample listing of the content.yaml file for a project that exports only the Add CD-ROM to Deployment resource action from the project on the VCF Automation server.
resource-action:
- Add CD-ROM to Deployment
# ...
Import¶
When you import a resource action to a project on a VCF Automation server (push operation), Build Tools for VMware Aria matches the resource action object by its name (the name of the directory under src/main/resources/resource-actions in the project content on your local filesystem) and performs one of the following operations.
Warning
Note that for push operations for VCF Automation projects for All Apps organizations, Build Tools for VMware Aria uses the content filtering rules that you define in the content.yaml content descriptor file. For details, see the Content Filtering section.
- If a resource action with the same name does not exist on the server, Build Tools for VMware Aria creates a new resource action with the details from the local project files.
- If a resource action with the same name already exists on the server, Build Tools for VMware Aria checks if there are any differences between the local copy and the server copy and performs one of the following operations.
- If there are no differences between the local copy and the server copy, BTVA skips the operation and does not update the resource action on the server.
- If there are differences between the local copy and the server copy, BTVA deletes the existing resource action object on the server and creates it again with the definition from the local project.