Skip to content

Instantly share code, notes, and snippets.

View lamw's full-sized avatar

William Lam lamw

View GitHub Profile
@lamw
lamw / gist:11322180
Last active August 29, 2015 14:00
Enhancement to RVC cluster.add_host to extract SSL Thumbprint of ESXi host w/o having to run commmand twice
opts :add_host2 do
summary "Add a host to a cluster"
arg :cluster, nil, :lookup => VIM::ClusterComputeResource
arg :hostnames, nil, :multi => true
opt :username, "Username", :short => 'u', :default => 'root'
opt :password, "Password", :short => 'p', :default => ''
opt :force, "Force, e.g when host is already managed by other VC"
end
def add_host2 cluster, hostnames, opts
@lamw
lamw / gist:4a7182994200f74e890a
Last active August 29, 2015 14:21
Having some fun with VSAN HCL JSON
#!/usr/bin/env python
# William Lam
# www.virtuallyghetto.com
import json
import urllib2
# download json
response = urllib2.urlopen('http://partnerweb.vmware.com/service/vsan/all.json')
@lamw
lamw / gist:d5b8b725f466ee37feb8
Created May 17, 2015 16:34
Lists of all VSAN Storage Controller sorted from smallest to largest Queue Depth
#!/usr/bin/env python
# William Lam
# www.virtuallyghetto.com
# Lists of all VSAN Storage Controller sorted from smallest to largest Queue Depth
import json
import urllib2
# download json
response = urllib2.urlopen('http://partnerweb.vmware.com/service/vsan/all.json')
####### PS Script (test2.ps1)
if ( !(Get-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) ) {
. "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
}
$vcserver = "172.30.0.112"
$vcusername = "administrator@vghetto.local"
$vcpassword = "VMware1!"
@lamw
lamw / getDrsRules.ps1
Created November 20, 2015 19:23
Listing all vSphere DRS Rules that have been defined for a VM
$clusterName = "VSAN-Cluster"
$cluster = Get-Cluster -Name $clusterName
$vms = Get-View ($cluster| Get-VM)
$cluster_view = Get-View ($cluster)
foreach ($vm in $vms) {
# Using new vSphere 6.0 API (http://www.virtuallyghetto.com/2015/02/handy-new-vsphere-6-0-apis-to-be-aware-of.html)
$cluster_view.FindRulesForVm($vm.MoRef)
}
#!/usr/bin/perl -w
use strict;
use warnings;
use VMware::VIRuntime;
use VMware::VILib;
Opts::parse();
Opts::validate();
Util::connect();
@lamw
lamw / gist:bae9687faa14c7d7ee18
Created June 17, 2015 05:46
Automate silent install of VMware Tools including enabling Automatic Kernel Module Update
#!/bin/bash
# Create temp workign directory
mkdir -p /mnt/vmw-tools
# Mount VMware Tools ISO
mount /dev/cdrom /mnt/vmw-tools
# Retrieve the VMware Tools package name from the directory
VMW_TOOLS=$(ls /mnt/vmw-tools/ | grep .gz)
@lamw
lamw / keybase.md
Created February 5, 2016 17:15
Verifying myself on Keybase.io

Keybase proof

I hereby claim:

  • I am lamw on github.
  • I am lamw (https://keybase.io/lamw) on keybase.
  • I have a public key whose fingerprint is E88C 6F19 C677 D636 B010 D47B 5106 881E 8111 94BD

To claim this, I am signing this object:

@lamw
lamw / gist:c6eb8b5a7229c807bd1b
Created February 18, 2016 16:24
Retrieve ESXi Major / Update version number using ESXCLI
$esxcli = Get-EsxCli
### To retrieve Major/Update version number of ESXi via ESXCLI
PS C:\Users\lamw\Desktop> $esxcli.system.version.get().version + " Update" + $esxcli.system.version.get().update
6.0.0 Update1
### To retrieve all version information from ESXi via ESXCLI
PS C:\Users\lamw\Desktop> $esxcli.system.version.get()
@lamw
lamw / vcsa-embed.json
Created April 4, 2016 19:15
Example govc import.ova spec for VCSA 6.x Embedded deployment
{
"Deployment": "tiny",
"DiskProvisioning": "thin",
"IPAllocationPolicy": "dhcpPolicy",
"IPProtocol": "IPv4",
"InjectOvfEnv": true,
"Name": "VCSA-60u2-Embedded",
"PowerOn": true,
"PropertyMapping": [
{