mirror of
https://github.com/jbowdre/vRealize.git
synced 2024-12-12 08:52:20 +00:00
add deprovision workflow
This commit is contained in:
parent
30927e8500
commit
60d78858a0
3 changed files with 46 additions and 0 deletions
14
Orchestrator/Workflows/VM Deprovision/README.md
Normal file
14
Orchestrator/Workflows/VM Deprovision/README.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# VM Deprovision workflow
|
||||||
|
Performs cleanup tasks upon deployment deletion (currently just removing the static DNS record).
|
||||||
|
|
||||||
|
![Schema](schema.png)
|
||||||
|
|
||||||
|
## Inputs/Outputs
|
||||||
|
| Name | Type | Direction | Description |
|
||||||
|
|:--- |:--- |:---|:---|
|
||||||
|
| `inputProperties` | Properties | Input | full request payload from vRA |
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
| Name | Type | Value | Description |
|
||||||
|
|:--- |:--- |:--- |:--- |
|
||||||
|
| `dnsHost` | CompositeType(sshHost:string, sshUser:string, sshPass:SecureString, dnsServers:Array/string, supportedDomains:Array/string):dnsHost | `Endpoints: dnsHost` | object which stores endpoint and credential details for DNS operations |
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* JavaScript: delete dns record
|
||||||
|
Deletes records in Microsoft DNS by way of an SSH bastion host upon deployment deletion.
|
||||||
|
Inputs: inputProperties (Properties), dnsHost (CompositeType(sshHost:string,sshUser:string,sshPass:SecureString,dnsServers:Array/string,supportedDomains:Array/string):dnsHost)
|
||||||
|
Outputs: none
|
||||||
|
*/
|
||||||
|
var hostname = inputProperties.resourceNames[0];
|
||||||
|
var dnsDomain = inputProperties.customProperties.domain;
|
||||||
|
var deleted = false;
|
||||||
|
if (dnsHost_supportedDomains.indexOf(dnsDomain) >= 0) {
|
||||||
|
System.log("Attempting to remove DNS record for " + hostname + "...");
|
||||||
|
var sshSession = new SSHSession(dnsHost_sshHost, dnsHost_sshUser);
|
||||||
|
System.debug("Connecting to " + dnsHost_sshHost + "...");
|
||||||
|
sshSession.connectWithPassword(dnsHost_sshPass);
|
||||||
|
for each (var dnsServer in dnsHost_dnsServers) {
|
||||||
|
if (deleted == false) {
|
||||||
|
System.debug("Using DNS Server " + dnsServer + "...");
|
||||||
|
var sshCommand = 'Remove-DnsServerResourceRecord -ComputerName ' + dnsServer + ' -Name ' + hostname + ' -ZoneName ' + dnsDomain + ' -RRType A -Force';
|
||||||
|
System.debug("sshCommand: " + sshCommand);
|
||||||
|
sshSession.executeCommand(sshCommand, true);
|
||||||
|
if (sshSession.exitCode == 0) {
|
||||||
|
System.log("Successfully deleted DNS record.");
|
||||||
|
deleted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sshSession.disconnect();
|
||||||
|
if (deleted == false) {
|
||||||
|
System.warn("Error! Unable to delete DNS record.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.log("No need to remove DNS records.");
|
||||||
|
}
|
BIN
Orchestrator/Workflows/VM Deprovision/schema.png
Normal file
BIN
Orchestrator/Workflows/VM Deprovision/schema.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Loading…
Reference in a new issue