Skip to content

Instantly share code, notes, and snippets.

View Mierdin's full-sized avatar

Matt Oswalt Mierdin

View GitHub Profile
@Mierdin
Mierdin / PowerOnUCSBlades
Last active December 17, 2015 20:29
This script was pretty bloated - this can be done pretty easily with fewer lines, but it was one of my first.
#----------------------------------------------------------------------
# Name: PowerOnUCSBlades.ps1
# Author: Matthew Oswalt
# Created: 3/30/2012
# Revision: v0.2 - BETA
# Rev. Date: 4/30/2013
# Description: A script that powers on blades in a UCS system.
# Can be configured to boot all blades, or
# only those associated to service profiles in a
# given sub-organization.
@Mierdin
Mierdin / InstallBFS
Last active March 2, 2016 19:24
Very brief and informal PowerShell script to configure a Boot-From-SAN policy and attach it to the relevant service profile templates.
# InstallBFS.ps1
#
# Very brief and informal PowerShell script to configure a Boot-From-SAN policy and attach it to the relevant service profile templates.
Import-Module CiscoUcsPs
Disconnect-Ucs
Connect-Ucs 10.0.0.1
@Mierdin
Mierdin / JSONTest.py
Last active December 24, 2015 11:59
Just a small snippet of python that forms a connection, sends some JSON, and outputs the response. Main use case is fast testing of OVSDB using a simple script.
import socket
import json
import time
def pingOVS(HOST, PORT):
#Create socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#Establish TCP session via IP address and port specified
@Mierdin
Mierdin / AutoBFS.ps1
Last active November 2, 2018 19:16
Reaches into a Cisco UCS Instance, and iterates through every service profile, creating Netapp initiator groups and 10g boot LUNs for each one, and then putting each service profile's vHBA's WWPNs in the respective initiator groups. Each igroup that is created by this script will be mapped to the respective boot LUN. Currently tested with NetApp…
<#
Name: AutoBFS.ps1
Author: Matthew Oswalt
Created: 10/20/2013
Description: Reaches into a Cisco UCS Instance, and iterates through every service profile, creating Netapp initiator groups
and 10g boot LUNs for each one, and then putting each service profile's vHBA's WWPNs in the respective initiator groups.
Each igroup that is created by this script will be mapped to the respective boot LUN.
@Mierdin
Mierdin / CreateVMK.ps1
Last active December 27, 2015 18:49
Creates a VMKernel port on each host connected to a vCenter instance. This will eventually get rolled into the master toolkit, so look there for updates
#---------------------------------------------------------------------
# Name: CreateVMK.ps1
# Author: Matthew Oswalt
# Created: 11/8/2013
# Description: Creates a VMKernel port on each host connected to a vCenter instance. This will eventually get rolled into the master toolkit, so look there for updates
#---------------------------------------------------------------------
#Import PowerCLI Module
Add-PSSnapin VMware.VimAutomation.Core
@Mierdin
Mierdin / vShield.ps1
Created November 22, 2013 16:50
This script is largely written by Alan Renouf - I put this here for my own reference because I made some modifications. Please visit his site at: http://www.virtu-al.net/2011/09/30/automated-install-of-vshield-services/
Add-PSSnapin VMware*
Function Connect-vShieldServer {
<#
.SYNOPSIS
Connects to a vShield Manager Server.
.DESCRIPTION
Connects to a vShield Manager Server. The cmdlet starts a new session with a vShield Manager Server using the specified parameters.
@Mierdin
Mierdin / vibinstall.ps1
Created January 19, 2014 06:33
Quick snippet of PowerShell/PowerCLI that leverages the remote esxcli capabilities to install a vib. Credit to James Bowling (vSential) of http://vsential.com/
$esxhosts = Get-VMHost | Sort-Object Name
Foreach ($esxhost in $esxhosts)
{
Write-Host "Starting install on $esxhost..." -ForegroundColor Green
$esxcli = Get-EsxCli -VMHost $esxhost
$esxcli.software.vib.install($null,$false,$false,$true,$false,$true,$null,$null, "/vmfs/volumes/NFS-01/_offlinebundles/net-enic-2.1.2.42-1OEM.550.0.0.1198611.x86_64.vib")
$esxcli.software.vib.install($null,$false,$false,$true,$false,$true,$null,$null, "/vmfs/volumes/NFS-01/_offlinebundles/scsi-fnic-1.6.0.5-1OEM.550.0.0.1198611.x86_64.vib")
Write-Host "Install completed on $esxhost..." -ForegroundColor Red
}
*Mar 13 16:21:51.733: GSI: netconf app _s_ssh.[0x7FE52EF841C8]: new ssh connection from 10.12.0.7
*Mar 13 16:21:51.734: NETCONF: ns_clone.sess=0x7FE52EA3D428
*Mar 13 16:21:51.734: NETCONF: naap_accept.clone=0x7FE52EA3D428
*Mar 13 16:21:51.734: NETCONF: ns_send.sess=0x7FE52EA3D428
<?xml version="1.0" encoding="UTF-8"?><hello><capabilities><capability>urn:ietf:params:netconf:base:1.0</capability><capability>urn:ietf:params:netconf:capability:writeable-running:1.0</capability><capability>urn:ietf:params:netconf:capability:startup:1.0</capability><capability>urn:ietf:params:netconf:capability:url:1.0</capability><capability>urn:cisco:params:netconf:capability:pi-data-model:1.0</capability><capability>urn:cisco:params:netconf:capability:notification:1.0</capability></capabilities><session-id>782488616</session-id></hello>
*Mar 13 16:21:51.734: NETCONF: ne_send.sess=0x7FE52EA3D428
*Mar 13 16:21:51.738: GSI: netconf app _s_ssh.[0x7FE520C3ACE0]: <?xml version="1.0" encoding="UTF-8"?><nc:hello xmlns:nc="urn:ietf:param
#Requires ncclient - https://github.com/leopoul/ncclient
from ncclient import manager
host = '67.218.95.16'
user = 'root'
password = 'root'
with manager.connect(host=host, port=22, username=user, password=password, hostkey_verify=False) as m:
c = m.get().data_xml
#Requires ncclient - https://github.com/leopoul/ncclient
from ncclient import manager
host = '192.168.7.140'
user = 'admin'
password = 'Cisco.com'
with manager.connect(host=host, port=22, username=user, password=password, hostkey_verify=False, device_params={'name':'nexus'}) as m:
#c = m.get_capabilities()