Skip to content

Instantly share code, notes, and snippets.

View dlinsley's full-sized avatar

Daniel Linsley dlinsley

  • Broadcom - Tanzu
  • SMF
View GitHub Profile
@dlinsley
dlinsley / attachExistingVMDK.js
Last active July 17, 2017 19:10
Attach existing VMDK disk to vCenter VM
// VMware vRealize Orchestrator (vRO) action sample
//
// Attach existing VMDK disk to vCenter VM
//
// For vRO/vRA 7.0+
//
// Action Inputs:
// vcVm - VC:VirtualMachine
// diskPath - string
//
@dlinsley
dlinsley / assignHostLicenseKey.js
Created August 6, 2017 21:08
Assign license to ESXi HostSystem
// VMware vRealize Orchestrator (vRO) action sample
//
// Assign license key to ESXi Host (HostSystem)
//
// For vRO v7.0+
//
// Action Inputs:
// host - VC:HostSystem
// license - string
//
@dlinsley
dlinsley / replaceCertificateEmbeddedPSC.sh
Last active March 18, 2019 20:07
Replace machine certificate with CA signed certificate on vCenter Appliance 6.5 with embedded PSC without using the vSphere Certificate Manager Utility in a shell script
#!/bin/bash
#
# In the local directory 3 files are required
# new_cert.crt - new machine certificate
# new_cert.key - private key for certificate
# intermediary.crt - certificate chain of the signing authority for new_cert.crt
#
# Run commands on the vCSA shell:
# import intermediary authority cert:
@dlinsley
dlinsley / replaceCertEmbedPSC_vROguestScriptManager_1.js
Created September 19, 2017 21:20
Replace machine certificate with CA signed certificate on vCenter Appliance 6.5 with embedded PSC without using the vSphere Certificate Manager Utility using vRO Guest Script manager
//Scriptable Tasks Inputs:
//
//
//Scriptable Tasks Outputs:
//
// script - String - script to execute with guest script manager
script = "/usr/lib/vmware-vmafd/bin/vecs-cli entry getcert --store MACHINE_SSL_CERT --alias __MACHINE_CERT --output /usr/lib/vmware-vmafd/bin/original.crt\n";
script += "/usr/bin/openssl x509 -in /usr/lib/vmware-vmafd/bin/original.crt -noout -sha1 -fingerprint | /usr/bin/cut -d= -f 2";
@dlinsley
dlinsley / change_storage_class.py
Last active June 27, 2022 06:25
aws s3 bucket change storage class by object size
import boto3
import argparse
import string
parser = argparse.ArgumentParser('Change storage class of s3 objects')
parser.add_argument('--bucket', dest='myBucket', default='yourBucketName', help='S3 Bucket to search')
parser.add_argument('--from', dest='fromPath', default='', help='s3 path to start search from')
cliArgs = parser.parse_args()
@dlinsley
dlinsley / find_duplicate_objects.py
Last active September 28, 2023 17:18
Find duplicate objects in an aws s3 bucket by comparing ETag
#!/usr/bin/env python3
import boto3
import argparse
import string
parser = argparse.ArgumentParser('Find duplicate objects in an aws s3 bucket')
parser.add_argument('--bucket', dest='myBucket', default='yourBucketName', help='S3 Bucket to search')
cliArgs = parser.parse_args()
@dlinsley
dlinsley / hot_relocate_vm.js
Created November 25, 2017 05:35
Hot relocate a vSphere VM to different compute and storage
// VMware vRealize Orchestrator (vRO) action sample
//
// Relocates a VM when hosts do not share storage.
// Tested with vSphere 6.0. Does not require VM to be powered off
//
// For vRO/vRA 7.0+
//
// Action Inputs:
// vm - VC:VirtualMachine
// datastore - VC:Datastore
@dlinsley
dlinsley / upgrade_vmtools_if_needed.js
Created January 5, 2018 04:59
Upgrade VMtools if needed
// VMware vRealize Orchestrator action sample
// Upgrades VMtool on a Virtual Machine if needed.
// Assumes vm tools .vib is part of ESXi host image profile
//
//
//Action Inputs:
// vm - VC:VirtualMachine
//
//Return type: void
@dlinsley
dlinsley / moveVmRootResourcePoolCluster.js
Created April 20, 2018 17:39
Move VM to root ResourcePool of Cluster
// VMware vRealize Orchestrator action sample
// Determines the ComputeResource or ClusterComputeResource of the VM.
// Assumes the VM is part of a DRS Cluster and a member of a child resoure pool in the cluster.
//
// Moves / Migrates the VM to the root ResourcePool of the Cluster.
//
//Action Inputs:
// vm - VC:VirtualMachine
//
@dlinsley
dlinsley / getKubeNodeIPs.sh
Last active May 9, 2018 04:48
Get Kubernetes Node IPs as JSON array with kubectl and jq
kubectl get nodes -o json | jq '.items[] | .status .addresses[] | select(.type=="ExternalIP") | .["address"]' | jq . -s -c