Guest script manager package
Warning October 8 2020
Before upgrading to vRA 8.2 edit the version of the resource elements in the vRO designer (you can add a tag save and remove it for example).
This will create a version in the local GIT repository that is needed by the upgrade process.
Alternatively export these in a package.
In the following days I will update the package to use a new scripting method that does save a new version to the local repository to avoid this situation.
If you feel like adding it before or running it on your elements this method is called saveToVersionHistory()
Updating resource Elements and Configuration Elements programmatically requires to use this method to get the latest version of their content after a vRA 8.2 upgrade.
-----------------------
Script management : Add, edit, delete a script configuration. A script configuration contains:
- Script type (bash, batch, Powershell) : Each type involve a different way of starting the script and getting the output.
- Script content: The script itself. May contain parameters that will be replaced right before running the script.
- Timeout: The time after the script execution is
- Script interactivity: In case the script open a window that requires user interaction.
- Script working directory: Where the script will run. Where the optional file will be copied.
- File to copy: A file to be copied in addition to the script. For example a response file needed for the script.
The script configurations are stored as resource elements in the vCO database. This means :
- Updating a script does not require updating a workflow
- The scripts are in a much safer location compared to the file system
- If you run a vCO cluster, the scripts are available for every vCO nodes
- That you can export / import the script configurations in a package
The script configuration runner : "Run script in VM guest"
- Search replace specified strings in the additional file, copy it to the guest (optional).
- Search replace specified strings in the script, run it in the guest.
- Get output code and output result, display these (including special characters supported by ANSI thanks to the included cmdAnsi.exe), fails the workflow if script failed.
- File on vRO server was not closed
- Single replace on bat file instead of multiple
Cannot connect factory (Reason: java.lang.IllegalArgumentException: interface ch.dunes.model.IVSOFactory is not visible from class loader) for wfExecution[ff8080815c1b5671015c1bc8d51c093b]
Any ideas
Additionally, the re-insertion should point to the timeout decision, NOT to the Sleep / Count item.
Any ideas out there why it just up and quits after a failed "Get Processes", rather than evaluate the scripting element to parse the error?
To be very brief, when using the Guest Script Manager, attempts to install Software on a VM post-provisioning (i.e. Machine Activated Phase), the software installation fails. When I revert back to a previous version of VMTools (Version 9.4.15), the software installs successfully.
Just for info, I'm performing an unattended install of SQL Server 2012 via batch script called by a Resource Element. Just to be clear, the vRO 7 Workflow does execute properly. I'm also anticipating opening a Support Case with VMware but figured I'd post here first to see if anyone else has experienced similar issues.
I'm hoping this area is still being monitored?
I am having an issue where the Run Script in Guest fails when simultaneous operations are performed on a single machine (at approx the same time). Logs typically reveal 1 of the 2 following errors when run in succession on the same machine:
Error in (Workflow:Create temporary directory in guest / Scriptable task (item1)#8) The operation is not allowed in the current state.
Error in (Workflow:Copy file from guest to vCO / Scriptable task (item1)#9) (vim.fault.InvalidState) {
faultCause = null,
faultMessage = null
}
Is there any way to get this Script to run only once at a given time....regardless of which vRO Workflow may be calling the Guest Script Manager Package ? I understand this could delay processes somewhat but I'm thinking there may be some type of collision happening somewhere and having it execute successfully "all the time" is better than having inconsistent runs?
Running vRA/vRO 7.3 on vCenter/vSphere 6.5 at this time. I tried installing a few patches and even tested an upgrade to vRA v7.4 but still experienced the same condition when running simultaneous Guest Script Manager Operations.
Thx. Any help will be appreciated.
Ron
My team currently uses Guest script manager for all of our script management in VRO and while we each have our own personal repos, it would be nice to be able to revert a script version.
I just had a bit the same problem during the "Get-Process" stage I have the impression that it runs in loop and it doesn't work at home. Have you solved the problem? especially since for me I only need to execute a dnscmd command to delete an entry in a DNS server.
Best Regard
Mikael
You can also try this methodology to run DNS Commands.
The 1st reference is for Adding DNS Records...https://marketplace.vmware.com/vsx/solutions/add-dns-record-blueprint-for-vrealize-automation-1-0?ref=company#resources.
The 2nd is for Deleting DNS entries.. https://marketplace.vmware.com/vsx/solutions/delete-dns-record-blueprint-for-vrealize-automation-1-0?ref=company#resources
In case the links above do not work, you need to be logged into VMware Solution Exchange. Once logged in, you can locate the above by looking for ADD and/or DELETE DNS RECORD BLUEPRINT FOR VREALIZE AUTOMATION. Now you don't really need to install the vRA Blueprint components just the vRO Packages. There are installation scripts for both. There will be a supporting vRO bundle for each DNS process....e.g. com.vmware.pscoe.build.cm.dnsadd.vro-1.0.0-10-bundle.zip.. Just install them and tweak them for your vRO/vRA Environment
IMO, Somewhat less complex and easier to trace than the Guest Script Wrappers... :)
Is any possible way to get info from script result as variable? I see the output only in script execution log.
Workflow execution stack:
***
item: 'Run script in VM guest/item25', state: 'failed', business state: 'null', exception: 'Exception binding empty'
workflow: 'Run script in VM guest' (24c23d4c-12be-4889-aa66-29b8a450f1cd)
| 'attribute': name=vcoPath type=string value=
| 'attribute': name=overwrite type=boolean value=true
| 'attribute': name=guestFilePath type=string value=
| 'attribute': name=result type=boolean value=false
| 'attribute': name=scriptType type=string value=batch
| 'attribute': name=guestOperationsReady type=boolean value=true
| 'attribute': name=errorCode type=string value=
| 'attribute': name=scriptFileName type=string value=
| 'attribute': name=scriptFileNameExtension type=string value=
| 'attribute': name=guestDirectoryPath type=string value=
| 'attribute': name=scriptFileNamePrefix type=string value=
| 'attribute': name=scriptOutputText type=string value=
| 'attribute': name=scriptExitCode type=number value=__NULL__
| 'attribute': name=scriptConfigurationProperties type=Properties value=#[#scriptContent#=#string#cd c:\Install\
mkdir Deployment
ccmsetup.exe /s#+#scriptTimeOut#=#number#60.0#+#scriptWorkingDirectory#=#string##+#scriptRefreshTime#=#number#60.0#+#deleteResourceAfterRun#=#boolean#true#+#scriptType#=#string#batch#+#resourceSearchReplace#=#boolean#false#+#scriptInteractiveSession#=#boolean#false#+#resourceToCopy#=#Any#Any#__NULL__#+#copyResource#=#boolean#false#]#
| 'attribute': name=scriptContent type=string value=cd c:\Install\
mkdir Deployment
ccmsetup.exe /s
| 'attribute': name=scriptTimeOut type=number value=60.0
| 'attribute': name=scriptInteractiveSession type=boolean value=false
| 'attribute': name=scriptWorkingDirectory type=string value=
| 'attribute': name=copyResource type=boolean value=false
| 'attribute': name=resourceToCopy type=ResourceElement value=__NULL__
| 'attribute': name=resourceSearchReplace type=boolean value=false
| 'attribute': name=successEventLog type=String value=The script was successful and outputted
| 'attribute': name=deleteResourceAfterRun type=boolean value=true
| 'attribute': name=scriptConfigurationResourcePlaceHolder type=ResourceElement value=dunes://service.dunes.ch/ResourceElement?id='b0004f79-cdbf-4890-a3fd-f86b438da9f1'&dunesName='ResourceElement'
| 'attribute': name=guestOsFamily type=string value=windowsGuest
| 'attribute': name=errorEventLog type=String value=The script failed and outputted
| 'attribute': name=scriptRefreshTime type=number value=60.0
| 'input': name=vm type=VC:VirtualMachine value=dunes://service.dunes.ch/CustomSDKObject?id='vxvc15.ict.umcg.nl%2Cid:vm-266'&dunesName='VC:VirtualMachine'
| 'input': name=vmUsername type=string value=**********
| 'input': name=vmPassword type=SecureString value=__NULL__
| 'input': name=scriptConfigurationResource type=ResourceElement value=dunes://service.dunes.ch/ResourceElement?id='3585f516-1d41-42c1-bca5-01b824335237'&dunesName='ResourceElement'
| 'input': name=scriptVariables type=Array/CompositeType(stringToReplace:string,replacingString:string):scriptVariables value=null
| 'output': name=scriptExitCodeOut type=number value=__NULL__
| 'output': name=scriptOutputTextOut type=string value=
*** End of execution stack.