Skip to content

Instantly share code, notes, and snippets.

@kclinden
kclinden / getNetworkProfiles.js
Last active April 3, 2018 13:14
Get vCAC Network Profiles
//Name: getNetworkProfiles
//Description: Used to get all network profiles from a given vCAC IaaS Host
//Inputs: vcacHost [vCAC:VCACHost]
//Initialize Array or JSON
var networkProfiles = [];
var netProfiles = System.getModule("com.vmware.library.vcac").getEntitiesBySystemFilter(vcacHost,"ManagementModelEntities.svc","StaticIPv4NetworkProfiles",null,null,null,null,null,null);
for each (netProfile in netProfiles){
//Create JSON Object
@kclinden
kclinden / getNetworkRanges.js
Last active April 2, 2018 18:24
Get vCAC Network Ranges
//Name: getNetworkRanges
//Description: Used to get all network ranges from a given vCAC IaaS Host
//Inputs: vcacHost [vCAC:VCACHost]
//Return Type: string
//Initialize Array or JSON
var networkRanges = [];
var netRanges = vCACEntityManager.readModelEntitiesBySystemExpandQuery(vcacHost.id,"ManagementModelEntities.svc","StaticIPv4Ranges",null,'StaticIPv4NetworkProfile/ID',null,null,null,null,null);
for each (netRange in netRanges){
@kclinden
kclinden / getApplicableReservationPoliciesDropdown.js
Last active May 7, 2018 21:19
Get Applicable Reservation Policies Custom Form Dropdown
//Description: This action is used with vRA to get applicable reservations policies using a custom form dropdown.
//Inputs:
//[STRING] blueprint -> bind with constant of blueprint id (Blueprint name with no spaces)
//[STRING] component -> bind with constant of component such vSphere_Machine_1
//[STRING] user -> Requested For
//[STRING] tenant -> Tenant reference
//[STRING] subtenantId -> Subtenant reference
//Return Type: Properties
var IDS_PER_PAGE_LIMIT = 100;
@kclinden
kclinden / getApplicableNetworksForReservationPolicyIdDropdown.js
Last active May 7, 2018 21:19
Get Applicable Networks for Reservation Policy with Custom Form Dropdown
//Description: This action is used with vRA to get applicable reservations policies using a custom form dropdown.
//Inputs:
//[STRING] resPolicyId -> bind to ReservationPolicyId
//[STRING] tenant -> bind to tenant reference
//Return Type: Properties
var result = new Properties();
if(!resPolicyId) {
return result;
}
@kclinden
kclinden / getVrmLocationsForReservationPolicy.js
Last active September 17, 2018 19:34
Filter VRM Locations By Reservation Policy ID
//Creator: Kasey Linden
//Date: Sept. 17, 2018
//Description: This action is used to filter VrmDataCenterLocation by Rservation Policy Id
//Inputs: tenant [string], resPolicyId[string]
//Output: array/string
if(!tenant){
throw "Error no tenant provided";
}
@kclinden
kclinden / SatelliteRESTRequestRetry.js
Created August 6, 2018 19:42
SatelliteRESTRequestRetry
// Creator: Les Kimmel
// Description: This function can be used in vRO to initate a retry on any REST request that fails due to an expired cookie from Satellite.
// Inputs: N/A
// Return Type: Any
// How to use: For a vRO REST Request to Red Hat Satellite input the following line to invoke the rest request `var SatelliteRESTRequest = System.getModule("module.rhsat.rest").SatelliteRESTRequest();`
var SatelliteRESTRequest = function (req) {
System.debug("Request URL: " + req.fullUrl);
var resp = req.execute();
// Check it unauthorized. If so retry once. This accounts
@kclinden
kclinden / prepare_vra_template.ps1
Created August 14, 2018 12:26
Prepare vRA Template Windows - Modified for Server 2016 Core
#
# Copyright (c) 2017 VMware, Inc. All rights reserved.
#
# Description: VMware vRealize Automation and Software Services agents installation script
#
# Parameters from the commandline to set the default variables
param(
[string]$ApplianceHost="",
#!/bin/bash
#Name: Install Satellite Tools
#Creator: Kasey Linden / Lesley Kimmel
#Version: v0.8.0
#Description: Used as a software component through vRealize Automation to install required agents for Red Hat Satellite. Inputs must be configured for SAT_ACTIVATION_KEY, SAT_ORGANIZATION, and SAT_SERVER through property bindings or with values directly configured in the software component.
###CONFIGURATION####
#SATELLITE VARIBLES#
#VARIABLES ARE ONLY USED FOR SCRIPT EXECUTION OUTSIDE OF VRA. VRA PROVIDES VARIABLES VIA SOFTWARE COMPONENT.
#CHECK FOR ENVIRONMENT VARIABLES SET BY VRA SOFTWARE COMPONENT ELSE USE DEFAULTS
@kclinden
kclinden / getTagCategories.js
Created December 11, 2018 20:01
Get Tag Categories
//Input: endpoint [VAPI:VAPIEndpoint]
//Return: Array/string
if(!endpoint){
return null
}
var client = endpoint.client();
var categories = new com_vmware_cis_tagging_category(client) ;
var catArray = [];
@kclinden
kclinden / associateTag.js
Created December 11, 2018 20:03
Associate Tag
//Inputs: vapiEndpoint [VAPI:VAPIEndpoint], object_id_type [string], object_id_id [string], tag_id [string]
//Outputs: void
var object_id = new com_vmware_vapi_std_dynamic__ID()
object_id.type = object_id_type;
object_id.id = object_id_id;
var client = vapiEndpoint.client();
var service = new com_vmware_cis_tagging_tag__association(client);
service.attach(tag_id,object_id);
client.close();