Skip to content

Instantly share code, notes, and snippets.

View hartsock's full-sized avatar

Shawn Hartsock hartsock

View GitHub Profile
@hartsock
hartsock / vmware_cache_wsdl.py
Last active March 16, 2022 23:04
A tool to help you create a local cache of vSphere WSDLs. This tool is only necessary if you are running vSphere 4.1 or 5.0 and need to fix the malformed XML in the WSDL for your local python parser. This script will fill in the missing XML files and create a cache that the OpenStack nova-compute driver for vSphere can use. The last line of the …
#!/usr/bin/python
import collections
import optparse
import os
import sys
import urllib
ROOT_WSDL_FILE = 'vimService.wsdl'
WSDL_FILES = frozenset([
@hartsock
hartsock / gist:6198781
Created August 10, 2013 02:34
Contents for reflect-messagetypes.xsd and reflect-types.xsd ... if a *single* character is out of place (even invisible characters) then the parser will fail with a cryptic error like <something>:2:79 where <something> is the filename the parser *thinks* its looking at (may not be real), the line number and the column number where the parser fai…
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="urn:reflect" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
</schema>
@hartsock
hartsock / gist:6198768
Created August 10, 2013 02:28
All the files for a given vSphere 5.0 WS installation. There are two files missing ... reflect-messagetypes.xsd and reflect-types.xsd. Fortunately, if we cache them locally, we can recreate them.
$ wget --no-check-certificate https://$VMWAREAPI_IP/sdk/vimService.wsdl
$ wget --no-check-certificate https://$VMWAREAPI_IP/sdk/vim.wsdl
$ wget --no-check-certificate https://$VMWAREAPI_IP/sdk/core-types.xsd
$ wget --no-check-certificate https://$VMWAREAPI_IP/sdk/query-messagetypes.xsd
$ wget --no-check-certificate https://$VMWAREAPI_IP/sdk/query-types.xsd
$ wget --no-check-certificate https://$VMWAREAPI_IP/sdk/reflect-messagetypes.xsd
$ wget --no-check-certificate https://$VMWAREAPI_IP/sdk/reflect-types.xsd
$ wget --no-check-certificate https://$VMWAREAPI_IP/sdk/vim-messagetypes.xsd
@hartsock
hartsock / screen-n-cpu.log
Last active December 20, 2015 21:38
An example of the failure you might see if you are using OpenStack Grizzly or Havana with vSphere 5.0. Fortunately, this doesn't happen on vSphere 5.1... but there is a way to work around the issue. It's the vmwareapi_wsdl_loc setting. See: http://hartsock.blogspot.com/2013/08/openstack-vsphere-50-how-to-solve-wsdl.html See also: https://wiki.op…
2013-08-09 19:12:36.184 CRITICAL nova [-] imported schema (urn:reflect) at (https://192.168.14.22/sdk/reflect-messagetypes.xsd), failed
2013-08-09 19:12:36.184 TRACE nova Traceback (most recent call last):
2013-08-09 19:12:36.184 TRACE nova File "/usr/local/bin/nova-compute", line 10, in <module>
2013-08-09 19:12:36.184 TRACE nova sys.exit(main())
2013-08-09 19:12:36.184 TRACE nova File "/opt/stack/nova/nova/cmd/compute.py", line 68, in main
2013-08-09 19:12:36.184 TRACE nova db_allowed=False)
2013-08-09 19:12:36.184 TRACE nova File "/opt/stack/nova/nova/service.py", line 260, in create
2013-08-09 19:12:36.184 TRACE nova db_allowed=db_allowed)
2013-08-09 19:12:36.184 TRACE nova File "/opt/stack/nova/nova/service.py", line 142, in __init__
2013-08-09 19:12:36.184 TRACE nova self.manager = manager_class(host=self.host, *args, **kwargs)
@hartsock
hartsock / trustAllSSL.groovy
Created September 20, 2012 15:41
Make the JVM trust all SSL certs
void trustAllSSL() {
def trustAllTrustManager = [
checkClientTrusted: { chain, authType -> },
checkServerTrusted: { chain, authType -> },
getAcceptedIssuers: { null }
]
def trustAllHostnameVerifier = [
verify: { hostname, session -> true }
]
@hartsock
hartsock / mirrorWSDL.groovy
Created September 20, 2012 15:39
mirror a WSDL from a server using Groovy
File mirrorWsdl(URL firstUrl, File dest) {
assert firstUrl.getText(), "Can't read from ${firstUrl} "
assert dest.mkdir() || dest.exists() && dest.isDirectory(), "Can't read/write to directory ${dest}"
def file = firstUrl.getFile()
def parentPath = file.substring(0,file.lastIndexOf('/') + 1)
def files = [:]
def urls = [firstUrl]
while(urls) {
URL url = urls.pop()
def path = url.getFile()
@hartsock
hartsock / sound-kick.sh
Created January 25, 2012 15:55
for MacBook Pro with Bluetooth sound issues...
#!/bin/sh
# My MacBook Pro's bluetooth transmitter will sometimes get into an error state where it will not
# connect to my bluetooth headset without a reboot. This seems to happen when I walk out of range
# with the device on.
#
# This script stops and starts the bluetooth daemon itself effectively restarting the bluetooth
# services. NOTE: bluetooth must be turned off in the UI when you do this. It's clumsy but it
# beats rebooting.
# Note: edited to add a kick to the audio daemon that often gets confused if switching between sources.
@hartsock
hartsock / tools.sh
Created January 12, 2012 16:31
A shell script to automatically add any command line utility to your path works with any OS that uses BASH
#!/bin/bash
# relies on the conventions:
# 1. all tools go into ~/tools
# 2. all tools are configured with a 'current' symlink for
# the currently in-use version
# 3. all tools have a 'bin' directory
# for example: to upgrade from grails 1.3.6 to 1.3.7
# $ cd ~/tools/grails
# $ rm current
@hartsock
hartsock / tools.sh
Created December 1, 2011 12:30
automatically add the tool to your path
#!/bin/bash
# which programs do you want to install into your path?
programs=( groovy grails gradle scala )
# relies on the conventions:
# 1. all tools go into ~/tools
# 2. all tools are configured with a 'current' symlink for
# the currently in-use version
# 3. all tools have a 'bin' directory
@hartsock
hartsock / gist:819222
Created February 9, 2011 20:33
Titanium Developer trace 2011/02/09 on new project with new tiapp.xml (different values)
1. delete old project
2. create fresh project
3. Emulator now launches
4. get new trace...
[INFO] Launching Android emulator...one moment
[INFO] Building com.example.test.Groosfabas for Android ... one moment
[INFO] Titanium SDK version: 1.6.0 (02/07/11 19:30 49c5b13...)
[INFO] Waiting for the Android Emulator to become available
[ERROR] Timed out waiting for android.process.acore
[INFO] Copying project resources..