This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createSnapshotOfAllVms(){ | |
vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1":"$2}' | grep '^[0-9]' | while read VM | |
do | |
VMID=$(echo $VM | cut -d: -f1) | |
vmName=$(echo $VM | cut -d: -f2) | |
echo "INFO: `date '+%Y.%m.%d_%H:%M'`: create Snapshot of VM: $vmName ---" | |
echo exec: vim-cmd vmsvc/snapshot.create $VMID backup-`date '+%Y%m%d%H%M%S'` includeMemory | |
vim-cmd vmsvc/snapshot.create $VMID backup-`date '+%Y%m%d%H%M%S'` | |
done | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
listAllSnapshots(){ | |
vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1":"$2}' | grep '^[0-9]' | while read VM | |
do | |
VMID=$(echo $VM | cut -d: -f1) | |
vmName=$(echo $VM | cut -d: -f2) | |
echo | |
echo "INFO: `date '+%Y.%m.%d_%H:%M'`: snapshots of VM: $vmName ---" | |
vim-cmd vmsvc/get.snapshot $VMID | egrep 'name = |createTime = ' | sed 's/createTime = / createTime = /' | |
done | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shutdownWaitvmName (){ | |
vmName=$1 | |
vmId=`vim-cmd vmsvc/getallvms | grep " $vmName " | cut -d\ -f1` | |
echo $vmId | grep -q '[0-9]' | |
if [ $? -ne 0 ] | |
then | |
echo "vm $vmName not found" | |
return 1 | |
exit 1 | |
kill -9 $$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
startupVmName (){ | |
vmName=$1 | |
echo "`vim-cmd vmsvc/getallvms | grep " $vmName " | cut -d\ -f1 | xargs vim-cmd vmsvc/power.on` $vmName" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thincopy (){ | |
FROM="$1" | |
TO="$2" | |
mkdir -p "$TO" | |
echo "INFO: tincopy $FROM/ $TO/$F" | |
find "$FROM" -type f -not -iname '*.vmdk' -exec cp -a "{}" "$TO/" \; | |
find "$FROM" -type f -iname '*.vmdk' | while read vmdk | |
do | |
F="`basename $vmdk`" | |
vmkfstools -i "$vmdk" -d thin "$TO/$F" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
removeAllSnapshots(){ | |
vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1":"$2}' | grep '^[0-9]' | while read VM | |
do | |
VMID=$(echo $VM | cut -d: -f1) | |
vmName=$(echo $VM | cut -d: -f2) | |
echo "INFO: `date '+%Y.%m.%d_%H:%M'`: search Snapshots of VM: $vmName ---" | |
vim-cmd vmsvc/get.snapshot $VMID | grep -A5 'snapshot = ' | sed '/id =/!d;s/.*id = //g;s/,//g' | while read SNAPID | |
do | |
echo exec: vim-cmd vmsvc/snapshot.remove $VMID $SNAPID | |
vim-cmd vmsvc/snapshot.remove $VMID $SNAPID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Retrieve the machine properties ------------------ | |
var machine = payload.get("machine"); | |
if(machine == null) { | |
throw("no machine found in payload, burn with fire!"); | |
} | |
var machineProperties = machine.get('properties'); | |
vmName = machine.get('name'); // vra vm hostname | |
// Find vcacVm and its relatives --------------------- | |
var virtualMachineId = machine.get("id"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vCenters=VcPlugin.allSdkConnections; | |
for each (vCenter in vCenters){ | |
System.log(vCenter.name); | |
var clusters = vCenter.getAllClusterComputeResources(); | |
for each (cluster in clusters) { | |
System.log(cluster.name); | |
var vms = vCenter.allVirtualMachines | |
for each (vm in vms) | |
System.log(vm.name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Ansible role test shim. | |
# | |
# Usage: [OPTIONS] ./tests/test.sh | |
# - distro: a supported Docker distro version (default = "centos7") | |
# - playbook: a playbook in the tests directory (default = "test.yml") | |
# - cleanup: whether to remove the Docker container (default = true) | |
# - container_id: the --name to set for the container (default = timestamp) | |
# - test_idempotence: whether to test playbook's idempotence (default = true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/env python | |
# | |
# USAGE | |
# $ python ad_utils.py "My Group Name" | |
# | |
# Author: | |
# Trinh Nguyen | |
# dangtrinhnt@gmail.com | |
# www.dangtrinh.com |