Skip to content

Instantly share code, notes, and snippets.

View michaelrice's full-sized avatar

Michael Rice michaelrice

View GitHub Profile
# first get the disks...
disks = [d for d in vm.config.hardware.device
if isinstance(d, pyVmomi.vim.vm.device.VirtualDisk) and
isinstance(d.backing, pyVmomi.vim.vm.device.VirtualDisk.RawDiskMappingVer1BackingInfo)]
print d.deviceInfo.deviceName
# then later
ss = vm.runtime.host.configManager.storageSystem
@michaelrice
michaelrice / gist:632f92a43828f77514d2
Created May 9, 2014 05:52
fabric success on esxi
errr@ubuntu-12-04-python$ /usr/bin/fab -H 10.12.254.10 hello
[10.12.254.10] Executing task 'hello'
[10.12.254.10] run: vmkping -c 1 -X 10.12.254.1
[10.12.254.10] out: <?xml version="1.0"?><esxcli:output xmlns:esxcli="http://www.vmware.com/Products/ESX/5.0/esxcli/">
[10.12.254.10] out: <esxcli:list type="struct">
[10.12.254.10] out: <esxcli:struct type="VMKPing">
[10.12.254.10] out: <esxcli:field name="Trace">
[10.12.254.10] out: <esxcli:list type="struct">
[10.12.254.10] out: <esxcli:struct type="VMKPingTrace">
[10.12.254.10] out: <esxcli:field name="Recieved Bytes"><esxcli:int>64</esxcli:int></esxcli:field>
@michaelrice
michaelrice / RemoteSCP.groovy
Created May 11, 2014 07:27
example of SCPClient
String runCommandWithOutput(Connection connection) {
log.trace("SCP command to place ${file} on ${host} at ${remotedir}")
output = new StringBuilder()
try {
SCPClient scp = connection.createSCPClient()
scp.put(file, 0, remotedir, "0600")
connection.close()
output.append("File $file should now be copied to $host:$remotedir\n")
}
catch (Exception e) {
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/**
* This program will demonstrate how to use "aes128-cbc".
*
*/
import com.jcraft.jsch.*;
import java.awt.*;
import javax.swing.*;
public class AES{
2014-05-11 23:39:11,599 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient - starting ssh process.
2014-05-11 23:39:11,601 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient - opened session to host
2014-05-11 23:39:11,607 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient - created user info
2014-05-11 23:39:11,608 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient - set user info
2014-05-11 23:39:11,689 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient$MyUserInfo - showMessage:
2014-05-11 23:39:11,700 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient$MyUserInfo - prompt: Password:
2014-05-11 23:39:11,700 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient$MyUserInfo - The server is asking us for a password.
2014-05-11 23:39:11,777 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient$MyUserInfo - echo: false
2014-05-11 23:39:11,796 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient - connected to server.
2014-05-11 23:39:11,797 [http-bio-8080-exec-7] TRACE jschssh.SecureJs
```xml
<?xml version="1.0"?><esxcli:output xmlns:esxcli="http://www.vmware.com/Products/ESX/5.0/esxcli/">
<esxcli:list type="struct">
<esxcli:struct type="VMKPing">
<esxcli:field name="Trace">
<esxcli:list type="struct">
<esxcli:struct type="VMKPingTrace">
<esxcli:field name="Recieved Bytes"><esxcli:int>64</esxcli:int></esxcli:field>
<esxcli:field name="Host"><esxcli:string>10.12.254.1</esxcli:string></esxcli:field>
<esxcli:field name="ICMP Seq"><esxcli:int>0</esxcli:int></esxcli:field>
configure:10660: $PKG_CONFIG --exists --print-errors " xrandr >= 1.4.0 "
Requested 'xrandr >= 1.4.0' but version of Xrandr is 1.3.2
configure:10663: $? = 1
configure:10677: $PKG_CONFIG --exists --print-errors " xrandr >= 1.4.0 "
Requested 'xrandr >= 1.4.0' but version of Xrandr is 1.3.2
configure:10680: $? = 1
configure:10694: result: no
Requested 'xrandr >= 1.4.0' but version of Xrandr is 1.3.2
@michaelrice
michaelrice / ResetAlarm.groovy
Last active August 29, 2015 14:01
Resets an alarm from red to green using the unexposed soap api in vsphere.
import com.budjb.requestbuilder.RequestBuilder
import com.rackspace.vmaintenance.hba.exception.RescanHbaException
import com.vmware.vim25.mo.HostSystem
import groovy.xml.StreamingMarkupBuilder
import groovy.xml.XmlUtil
import org.apache.log4j.Logger
/**
* Ported Michael Rice code from perl to Groovy
Vagrant::Config.run do |config|
config.vm.box = "esxi-test"
config.ssh.username = "root"
config.ssh.password = "password"
config.vm.network :bridged
end
.idea
*.iml