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
import requests | |
import logging | |
# These two lines enable debugging at httplib level (requests->urllib3->http.client) | |
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA. | |
# The only thing missing will be the response.body which is not logged. | |
try: | |
import http.client as http_client | |
except ImportError: | |
# Python 2 |
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
/** | |
* Problem: | |
* I have some action occurring on several parallel nodes. The action may have a diffrent result on each node non-deterministically. | |
* I need to act from the master depending on the result at each node. | |
* | |
* For a contrived example, we record the name of each node used to act on the parallel actions specified in this pipeline. The | |
* names are collected in a global string and a global `Map<String,String>` object for use by the master. | |
* | |
*/ | |
value = ':' |
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
#!/usr/bin/env bash | |
STOP=30 | |
i=0; | |
while [ $i -le $STOP ] | |
do | |
i=$((i+1)) | |
echo -n "${i} :" | |
exec "$@"& | |
echo |
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
--- | |
- hosts: photon | |
remote_user: root | |
tasks: | |
- name: pip prerequisite | |
command: bash -c "tdnf -y install python-pip" | |
- name: python prerequisites | |
command: bash -c "pip install -I pexpect" |
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
if [ -d $HOME/bin ]; then export PATH=$HOME/bin:$PATH ; fi | |
# interactive only below this point | |
if [ -t 1 ]; then | |
export SOURCE_IP=`echo $SSH_CONNECTION | awk '{print $1}'` | |
export CURRENT_IP=`echo $SSH_CONNECTION | awk '{print $3}'` | |
if [[ ! -z "${CURRENT_IP}" ]]; then | |
export PS1="${CURRENT_IP}:\w $ " | |
fi | |
echo "" | |
fi |
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
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() |
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
#!/usr/bin/python | |
import collections | |
import optparse | |
import os | |
import sys | |
import urllib | |
ROOT_WSDL_FILE = 'vimService.wsdl' | |
WSDL_FILES = frozenset([ |
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
from __future__ import print_function | |
from pyVim import connect | |
from pyVmomi import vim | |
si = connect.SmartConnect(host='vcsa', user='my_user', pwd='my_password') | |
content = si.RetrieveContent() | |
# A list comprehension of all the root folder's first tier children... | |
datacenters = [entity for entity in content.rootFolder.childEntity |
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
si = connect.SmartConnect(host='vcsa', user='my_user', pwd='my_password') | |
content = si.RetrieveContent() | |
datacenters = [entity for entity in content.rootFolder.childEntity | |
if hasattr(entity, 'vmFolder')] | |
dc = None | |
for datacenter in datacenters: | |
if datacenter.name == 'my_datacenter': | |
dc = datacenter |
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
def test_vm_to_mac(self): | |
si = connect.SmartConnect(host='vcsa', | |
user='my_user', | |
pwd='my_password') | |
content = si.RetrieveContent() | |
# where the name of the VM is 'box' | |
vm = content.searchIndex.FindByInventoryPath("Datacenter0/vm/box") | |
self.assertEqual(vm.name, 'box') | |
nics = [dev for dev in vm.config.hardware.device | |
if isinstance(dev, vim.vm.device.VirtualEthernetCard)] |
NewerOlder