I'm looking to use the Vmware Aria Automation Orchestrator (only the Orchestrator, without Aria Automation) to attach a specific host profile to a host, perform the host customization and remediate the host. The Host profile only includes settings to make the installation stateful, to set the password and to configure the vSwitch (hence the host customization, the host needs the IP address, the subnet mask and the hostname).
However, during the remediation process I constistently encounter the error message "Cannot apply the host configuration" with "Error: filename must be a str or bytes object, or a file".
When I attach and customize the profile via the workflow, but perform the remediation manually, it works without any issues, so I guess the host customization via workflow works (and is valid according to the workflow "Get answer file status") and the problem must be the remediation.
I would appreciate any insights on the requirements for a successfull remediation through a workflow. How can i successfully implement this process?
var sdkConnection = vmHost.sdkConnection
var hostProfileManager = sdkConnection.hostProfileManager
var hostToConfigSpecMap = new Array();
hostToConfigSpecMap[0] = new VcHostProfileManagerHostToConfigSpecMap();
hostToConfigSpecMap[0].configSpec = new VcAnswerFileOptionsCreateSpec();
hostToConfigSpecMap[0].configSpec.validating = true;
var userInput = new Array();
userInput[0] = new VcProfileDeferredPolicyOptionParameter();
userInput[0].inputPath = new VcProfilePropertyPath();
userInput[0].inputPath.policyId = 'HostNamePolicy';
userInput[0].inputPath.profilePath = 'network.GenericNetStackInstanceProfile["key-vim-profile-host-GenericNetStackInstanceProfile-defaultTcpipStack"].GenericDnsConfigProfile';
var parameter = new Array();
parameter[0] = new VcKeyAnyValue();
parameter[0].value = vmHostName;
parameter[0].key = 'hostName';
userInput[0].parameter = parameter;
userInput[1] = new VcProfileDeferredPolicyOptionParameter();
userInput[1].inputPath = new VcProfilePropertyPath();
userInput[1].inputPath.policyId = 'IpAddressPolicy';
userInput[1].inputPath.profilePath = 'network.hostPortGroup["key-vim-profile-host-HostPortgroupProfile-ManagementNetwork"].ipConfig';
var parameter = new Array();
parameter[0] = new VcKeyAnyValue();
parameter[0].value = esxSubnet;
parameter[0].key = 'subnetmask';
parameter[1] = new VcKeyAnyValue();
parameter[1].value = esxIp;
parameter[1].key = 'address';
userInput[1].parameter = parameter;
hostToConfigSpecMap[0].configSpec.userInput = userInput;
hostToConfigSpecMap[0].host = vmHost
task = hostProfileManager.updateHostCustomizations_Task(hostToConfigSpecMap);
The host customization shows up correctly in the UI and is considered 'valid' by the workflow, as mentioned above.
Remediation (assuming the profile was already attached; vmHost is the hostSystem input):
var sdkConnection = vmHost.sdkConnection
var hostProfileManager = sdkConnection.hostProfileManager
var profile = hostProfileManager.findAssociatedProfile(vmHost)[0]
var profileExecuteResult = profile.executeHostProfile(vmHost);
task = hostProfileManager.applyHostConfig_Task(vmHost,profileExecuteResult.configSpec, profileExecuteResult.requireInput);
Thank you in advance for your assistance!
Best regards