Skip to content

Instantly share code, notes, and snippets.

View hartsock's full-sized avatar

Shawn Hartsock hartsock

View GitHub Profile
@hartsock
hartsock / rdhcpd.rb
Last active August 29, 2015 14:08 — forked from telamon/rdhcpd.rb
' Copyright (c) 2007, Tony Ivanov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
@hartsock
hartsock / headless.sh
Created September 17, 2014 17:53
Run a VMware Fusion Guest without graphics.
#!/bin/bash
# use: headless.sh /full/path/to/VirtualMachine.vmwarevm/VirtualMachine.vmx
/Applications/VMware\ Fusion.app/Contents/Library/vmrun -T fusion start $1 nogui
%if 0%{?fedora}
%global _with_python3 1
%endif
%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif
// Create the updated device spec
VirtualDeviceConfigSpec nicSpec = new VirtualDeviceConfigSpec()
nicSpec.device = nic
nicSpec.operation = VirtualDeviceConfigSpecOperation.edit
// Create the VM update spec
VirtualMachineConfigSpec spec = new VirtualMachineConfigSpec()
spec.deviceChange = [nicSpec]
// Do the update
@hartsock
hartsock / test_basic_container_view.py
Created August 1, 2014 19:33
Demonstrates basic container view use.
si = connect.SmartConnect(host='vcsa',
user='my_user',
pwd='my_password')
atexit.register(connect.Disconnect, si)
content = si.RetrieveContent()
datacenter_object_view = content.viewManager.CreateContainerView(
content.rootFolder, [vim.Datacenter], True)
@hartsock
hartsock / traversal_spec.txt
Last active August 29, 2015 14:04
An example of a Traversal Spec 'language'
FilterSpec {
propSet = [
PropertySpec(type=vim.VirtualMachine, all=False, pathSet=['name' : runtime.powerState]
]
objectSet = [
ObjectSpec {
skip = False
selectSet = [
TraversalSpec(type=ContainerView, path='view', skip=False)
]
#!/usr/bin/env python
import bz2
import datetime
import os
import sys
import time
import urllib2
import warnings
@hartsock
hartsock / vpxd.cfg
Last active February 9, 2018 04:18
/etc/vmware-vpx/vpxd.cfg
<config>
<alert>
<log>
<enabled>true</enabled>
</log>
</alert>
<level id="CpuFeatures">
<logLevel>info</logLevel>
<logName>CpuFeatures</logName>
</level>
@hartsock
hartsock / putFiles_sample.java
Created July 8, 2014 18:53
An example of putting a file onto a datastore...
@SuppressWarnings("unchecked")
void putVMFiles(String remoteFilePath, String localFilePath)
throws Exception {
String url = connection.getUrl();
String serviceUrl = url.substring(0, url.lastIndexOf("sdk") - 1);
String httpUrl =
serviceUrl + "/folder" + remoteFilePath + "?dcPath=" + datacenter
+ "&dsName=" + datastore;
httpUrl = httpUrl.replaceAll("\\ ", "%20");
System.out.println("Putting VM File " + httpUrl);
@hartsock
hartsock / GetData_sample.java
Created July 8, 2014 18:51
A snippet of Java code showing how to get data...
void getData(String urlString, String fileName)
throws Exception {
HttpURLConnection conn = null;
URL urlSt = new URL(urlString);
conn = (HttpURLConnection) urlSt.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setAllowUserInteraction(true);
// Maintain session
List<String> cookies = (List<String>) headers.get("Set-cookie");