Skip to content

Instantly share code, notes, and snippets.

View chelnak's full-sized avatar
👀
What's cooking?

Craig Gumbley chelnak

👀
What's cooking?
View GitHub Profile
@chelnak
chelnak / createCloudClientScript-BusinessGroups.ps1
Last active August 29, 2015 14:26
Migrate vRealize Business Groups with PowerShell
<#
Usage:
1. Generate vra-businessgroups.json by running the following cloudclient command
./cloudclient.bat vra businessgroup list --export D:\vRAExports\vra-businessgroups.json --format "JSON"
2. Configure the variables and run this script to generate businessgroup-cloudclient-commands.ps1
3. Get a replace all of the machine prefix Ids in businessgroup-cloudclient-commands.ps1 with ones obtained from the new server
@chelnak
chelnak / createRes-vRAAPICLIENT.py
Created August 4, 2015 14:00
Create reservations from a csv of business groups
#!/usr/bin/python
import csv
import getpass
import json
import os
from jinja2 import Environment, FileSystemLoader
from globalconfig import url, usr, passwd
from vraapiclient import reservation
@chelnak
chelnak / createReservation-AllBusinessGroups.py
Last active August 29, 2015 14:26
Create reservations for all business groups in vRealize Automation using vRAAPIClient
#!/usr/bin/python
import getpass
import json
import os
from globalconfig import passwd, url, usr
from jinja2 import Environment, FileSystemLoader
from vraapiclient import reservation
#Get the current directory
@chelnak
chelnak / Template.js
Last active June 22, 2021 06:06
A vRO Scriptable task that will parse a JSON Resource Element
//vRO Scriptable task to parse a resource element and
//edit values
//inputs:
//jsonTemplate : ResourceElement
//reservationName : String
//subtenantId : String
//outputs
//payload : String
@chelnak
chelnak / parseResponse.js
Created September 15, 2015 15:38
parseResponse.js action used in OTS package
//Input: string - Response in a JSON string
//Output: Any - Return the parsed object
//Parse the json string
var jsonResponse = JSON.parse(response);
//loop through and print out each key and value
for(var i in jsonResponse) {
System.log(i + ": " + jsonResponse[i]);
}
@chelnak
chelnak / getRESTHostByName.js
Last active September 16, 2015 07:18
Get rest hosts and operations by name
//get REST host by name
//Input: [String]name - The name of the rest host
//Output: [RESTHost]host - The rest host object
var hostsIds = RESTHostManager.getHosts();
for(var currentHostId in hostsIds){
var currentHost = RESTHostManager.getHost(hostsIds[currentHostId]);
System.log(currentHost.name);
if(currentHost.name == name){
@chelnak
chelnak / getRESTOperationByName.js
Created September 15, 2015 21:17
Get rest operation by name
//get REST operation by name
//Inputs:
//host = RESTHost - The rest host object
//operationName: String - The name of the rest operation
//Outputs:
//operation: RESTOperation - the rest operation object
var operationIds = host.getOperations();
for(var currentIndex in operationIds){
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Doc>
<CustomProperties>
<Property Name="xv.propertyset.a" DefaultValue="value a" Encrypted="false" PromptUser="false"/>
<Property Name="xv.propertyset.b" DefaultValue="value b" Encrypted="false" PromptUser="false"/>
<Property Name="xv.propertyset.c" DefaultValue="value c" Encrypted="false" PromptUser="false"/>
<Property Name="xv.propertyset.d" DefaultValue="value d" Encrypted="false" PromptUser="false"/>
<Property Name="xv.propertyset.e" DefaultValue="value e" Encrypted="false" PromptUser="false"/>
</CustomProperties>
</Doc>
/*
input: vCACMachinePrefixEntity [vCAC:Entity
input: vCACCAFEHost [vCACCAFE:vCACHost]
output: vCACCAFEMachinePrefixObject [vCACCAFE:MachinePrefix]
Description: Maps a vCAC:Entity machine prefix to a vCACCAFEMahcinePrefix object
*/
var vCACCAFEMachinePrefixEntityName = vCACMachinePrefixEntity.getProperty('MachinePrefix');
var vCACCAFEMachinePrefixArray = vCACCAFEEntitiesFinder.findMachinePrefixes(vCACCAFEHost,vCACCAFEMachinePrefixEntityName);
/*
Name: getvCACCAFEMachinePrefixFromEntity.action
Input: vCACCAFEHost - vCACCAFE:VCACHost
Input: machinePrefixEntity - vCAC:Entity
Output: vCACCAFEMachinePrefixObject - vCACCAFE:MachinePrefix
Description: Maps a vCAC:Entity machine prefix to a vCACCAFEMahcinePrefix object
*/
var vCACCAFEMachinePrefixObject;
var vCACCAFEMachinePrefixArray = new Array();