Skip to content

Instantly share code, notes, and snippets.

View imcleod's full-sized avatar

Ian McLeod imcleod

  • Red Hat
  • Chicago
View GitHub Profile
@imcleod
imcleod / delete_ec2_ami.py
Created February 16, 2012 15:12
A rough script that deletes AMIs including their backing storage on EBS or S3.
#!/usr/bin/python
#from boto.ec2.connection import EC2Connection
import boto.ec2
import sys
import pdb
from time import *
from pprint import pprint
from string import split, rsplit
from xml.etree import ElementTree
@imcleod
imcleod / RedHat.py
Created April 4, 2012 15:08
A modified /usr/lib/python2.6/site-packages/oz/RedHat.py for oz 0.8.0-5 - lists full cert content in debug output - helpful for pulp debugging
# Copyright (C) 2010,2011 Chris Lalancette <clalance@redhat.com>
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation;
# version 2.1 of the License.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@imcleod
imcleod / walk_vsphere_objects.py
Created July 19, 2012 00:33
A simple tool that uses psphere to enumerate some vSphere API objects starting with the root folder - requires psphere - http://packages.python.org/psphere/index.html
#!/usr/bin/python
# walk_vsphere_objects.py
# Attempt to walk the vSphere object heirarchy starting at the root folder
import sys
from psphere.client import Client
# This is python afterall
TABWIDTH = 4
# Callable class that is used to launch a thread
import httplib
import threading
import time
class CallbackWorker():
def __init__(self, callback_url, send_all_updates = False):
# callback_url - the URL to which we will send the full object JSON for each STATUS update
# send_all_updates - if true, if more than one update has accumulated, send them all
#!/usr/bin/python
from EC2Cloud import EC2Cloud
import sys
sys.argv[0]="/usr/bin/imagefactoryd"
co = EC2Cloud()
# This allows us to use "setup.py install" in our SPEC file without getting auto deps
import sys
if "--rpm-build-install" in sys.argv:
print "Monkey Patch"
sys.argv.pop(sys.argv.index("--rpm-build-install"))
from setuptools.command.easy_install import easy_install as _easy_install
class easy_install(_easy_install):
def easy_install(self, spec, deps=False):
_easy_install.easy_install(self, spec, False)
import setuptools.command.easy_install
#!/usr/bin/python
import guestfs
import sys
def inspect_and_mount(diskfile):
g = guestfs.GuestFS ()
g.add_drive (diskfile)
g.launch()
@imcleod
imcleod / make_extlinux.py
Created March 25, 2013 13:07
Make a 200 MB qcow2 image that has extlinux and a DOS MBR
#!/usr/bin/python
import guestfs
import sys
import os
from subprocess import check_output
from subprocess import STDOUT as sp_STDOUT
from time import sleep
from tempfile import mkdtemp, NamedTemporaryFile
@imcleod
imcleod / make_syslinux.py
Created March 25, 2013 13:08
Create a 200 MB qcow2 image containing syslinux and a DOS MBR
#!/usr/bin/python
import guestfs
import sys
import os
from subprocess import check_output
from subprocess import STDOUT as sp_STDOUT
from time import sleep
from tempfile import mkdtemp, NamedTemporaryFile
@imcleod
imcleod / gist:5312111
Created April 4, 2013 17:02
Diff between Fedora Core 1 JEOS kickstart and Fedora 18 JEOS kickstart
--- fedoracore-1-jeos.ks 2013-03-08 13:00:15.418666202 -0600
+++ fedora-18-jeos.ks 2013-03-08 13:00:15.418666202 -0600
@@ -2,26 +2,28 @@
text
keyboard us
lang en_US.UTF-8
-langsupport --default en_US.UTF-8 en_US.UTF-8
-mouse generic3ps/2 --device psaux
skipx
network --device eth0 --bootproto dhcp