Skip to content

Instantly share code, notes, and snippets.

View jbarber's full-sized avatar

Jonathan Barber jbarber

View GitHub Profile
@jbarber
jbarber / get-datastores.ps1
Created April 27, 2011 10:56
Enumerate VMware guests and the datastores each one uses
$vms = get-view -type virtualmachine
$hosts = $vms | %{
$obj = New-Object Object
$obj | Add-Member noteproperty name $_.name
$obj | Add-Member noteproperty datastores ($_.datastore | %{(get-view -Id $_).Name})
$obj
}
# Dump to CSV
@jbarber
jbarber / add_twonode.xslt
Created May 31, 2011 14:34
XSLT for adding two-node configuration to RHCS cluster.conf
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="cluster">
<xsl:copy>
<cman expected_votes="1" two_node="1"/>
@jbarber
jbarber / gist:1000617
Created May 31, 2011 14:44
Initial RHCS config
[root@node1 ~]# yum install cman rgmanager libxml2
[root@node1 ~]# ccs_tool create new_config
[root@node1 ~]# ccs_tool addfence dummy manual -C
[root@node1 ~]# ccs_tool addnode -n 1 -f dummy node1 -C
[root@node1 ~]# ccs_tool addnode -n 2 -f dummy node1 -C
[root@node1 ~]# xmllint --format /etc/cluster/cluster.conf --output /tmp/cluster.conf && mv /{tmp,etc/cluster}/cluster.conf
@jbarber
jbarber / 10-install_binaries.sh
Created June 16, 2011 15:29
Quick Oracle 10g install on RHEL5
#!/bin/bash
set -e
. CONFIG
# Satisfy the prerequisites for Oracle 10g 10.2.0.1 and install the binaries
for i in oper dba oinstall; do groupadd $i; done
adduser -g oinstall -G dba,oper oracle
mkdir -p $ORACLE_BASE
@jbarber
jbarber / fence_vmware_ng
Created June 21, 2011 09:57
RHEL5 RHCS fence agent for VMware
#!/usr/bin/python
#
# The Following agent has been tested on:
# vmrun 2.0.0 build-116503 (from VMware Server 2.0) against:
# VMware ESX 3.5 (works correctly)
# VMware Server 2.0.0 (works correctly)
# VMware ESXi 3.5 update 2 (works correctly)
# VMware Server 1.0.7 (works but list/status show only running VMs)
#
@jbarber
jbarber / 10-install_binaries.sh
Created July 20, 2011 10:18
Quick Oracle 11g install on RHEL5
#!/bin/bash
set -e
. CONFIG
# Satisfy the prerequisites for Oracle 11g and install the binaries
for i in oinstall dba oper asmadmin asmdba asmoper; do groupadd $i; done
useradd -g oinstall -G dba,oper,asmdba oracle
useradd -g oinstall -G asmadmin,asmdba,asmoper grid
@jbarber
jbarber / rhel5.ks
Created August 25, 2011 16:34
RHEL5 kickstart example
# Example Kickstart config file for RHEL5, change $VARIABLES to suitable values
# for your site
# Usage from linux kernel boot prompt:
# linux ks=http://$SERVER_ADDR/ks/rhel5-example.ks ip=$IPADDR netmask=$NETMASK gateway=$GATEWAY [nokill] [keymap=pt-latin1] [noipv6] [debug]
#
# More boot options at http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/ch-bootopts-x86.html
# Options for this section can be found at http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/s1-kickstart2-options.html
install
@jbarber
jbarber / gist:1197216
Created September 6, 2011 10:31
List all VMs with questions (these block their running)
# Find the VMs with questions
$vms = get-view -viewtype virtualMachine | ?{ $_.runtime.question }
# Answer the questions
foreach ($vm in $vms) {
Get-VM $vm.name | Get-VMQuestion | Set-VMQuestion -DefaultOption
}
# You could also do this, but Get-VMQuestion seems to be *very* slow:
$questions = Get-VMQuestion
@jbarber
jbarber / LdapAuth.java
Created June 11, 2012 12:20
LDAP example for searching and simple binding (authentication)
/*
* First create the keystore (to allow SSL protection) by importing the LDAP
* certificate (cert.pem) with:
* keytool -import -keystore keystore -storepass changeit -noprompt -file cert.pem
*
* You can get the certificate with OpenSSL:
* openssl s_client -connect ldap.server.com:636 </dev/null 2>/dev/null | sed -n '/^-----BEGIN/,/^-----END/ { p }' > cert.pem
*
* Then compile this class with:
* javac LdapAuth.java
@jbarber
jbarber / https-server.js
Created July 18, 2013 15:09
NodeJS HTTPS daemon example showing how to access client certificate information.
var https = require('https');
var sys = require('util');
var fs = require('fs');
/* Generate certs using OpenSSL as follows:
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
rm server.pass.key
openssl req -new -key server.key -out server.csr -batch