Skip to content

Instantly share code, notes, and snippets.

@rbenigno
rbenigno / ipinfo.rb
Created February 21, 2012 16:52
Use hostapi.info to get the public IP of a system
require "httparty"
class IPinfo
include HTTParty
base_uri('api.hostip.info')
format :xml
def self.public()
response = get('/').parsed_response
response["HostipLookupResultSet"]["featureMember"]["Hostip"]["ip"]
@rbenigno
rbenigno / parse_ems_catalog.rb
Last active December 20, 2015 20:29
Use REXML for simple XML parsing
require 'rexml/document'
include REXML
#ems_file = 'vfiler_ems.ems'
ems_file = 'ems_catalog.ems'
xmlfile = File.new(ems_file)
xmldoc = Document.new(xmlfile)
REXML::XPath.each(xmldoc, '//xmlns:event-def[xmlns:snmp]') {
@rbenigno
rbenigno / Test-DiskAccess-v2.ps1
Last active December 20, 2015 20:58
Continuous loop that writes than reads a new file on each interation
Function Test-DiskAccess {
$filesize = 10MB #rough
$tempfolder = (Convert-Path (Get-Location -PSProvider FileSystem)) + "\NetAppTestTemp\"
If (!(Test-Path $tempfolder)){ New-Item -Path "$tempfolder" -ItemType Directory | Out-Null}
$MD5 = New-Object System.Security.Cryptography.MD5CryptoServiceProvider
while (1)
{
$testfilepath = "$tempFolder" + (Get-Random) + ".tmp"
$stream = New-Object System.IO.StreamWriter $testfilepath
write-host " Writing:" $testfilepath
@rbenigno
rbenigno / 7toC-ShareACL.ps1
Created August 21, 2013 04:56
Apply CIFS share ACLs from a 7-Mode source to a matching cDOT target share
# gather ACLs from the source system
$source_filer = 'ntap3a'
$share_acl_file = 'shareacls.xml'
Connect-NaController $source_filer
Get-NaCifsShareAcl | Export-Clixml $share_acl_file
# apply the share ACL to the cluster
$dest_cluster = 'clust2.lab.stackspace.net'
@rbenigno
rbenigno / DNS-Functions.psm1
Last active December 23, 2015 07:39
NetApp cDOT: Verify reverse DNS entries hosts in export-policy rules (uses JHSoftware.DnsClient .NET Library)
Function Invoke-DNSLookup {
[CmdletBinding()]
Param (
[Parameter(Position=1,Mandatory=$true)]
[string]$record,
[Parameter(Position=2,Mandatory=$false)]
[string]$dnsserver
)
Invoke-JHDnsClientLookup $record $dnsserver
}
@rbenigno
rbenigno / sdktest.rb
Created September 26, 2013 04:43
NetApp SDK example in Ruby - print aggregate list
$:.unshift '~/Code/netapp-manageability-sdk/lib/ruby/NetApp'
require 'NaServer'
hostname = "172.27.1.104";
username = "admin";
password = "<PASS>";
port = 443;
serverType = "FILER"
transportType = "HTTPS"
@rbenigno
rbenigno / cDOT Install Commands (8.1).scpt
Last active December 24, 2015 01:19
AppleScript to generate basic cDOT install commands (for 8.1). I use this in TextExpander.
-- TODO: Need to add commands for cluster interconnect switch configuration
-- set to "true" for testing "false" for production
set Debug to false
if (not Debug) then
set platformList to {"32xx", "62xx", "VSIM"}
set platform to {choose from list platformList with title "Platform?" with prompt "Select hardware platform (no mixed clusters):"} as text
set clusterName to the text returned of (display dialog "Cluster Name:" default answer "")
set nodeCount to the text returned of (display dialog "Node Count:" default answer "2")
#***************************************************************************
#
# Update NetApp Configuration Settings for vSphere
# Original Author: Jase McCarty
# Date: 1/15/2010
#
# Updated by: Ryan Benigno
# Date: 4/26/14
# - Updates per https://library.netapp.com/ecmdocs/ECMP1392339/html/GUID-346ACB95-6AD4-4DEA-8901-C9697AC3530F.html
#***************************************************************************
@rbenigno
rbenigno / New Unintented Line.sublime-macro
Created June 3, 2014 13:00
Sublime Text macro to create a new line without indentation
[
{"command": "move_to", "args": {"to": "hardeol"}},
{"command": "insert", "args": {"characters": "\n"}},
{"command": "move_to", "args": {"to": "hardbol", "extend": true}},
{"command": "add_to_kill_ring", "args": {"forward": false}},
{"command": "left_delete"}
]
@rbenigno
rbenigno / dump_mac_table.pl
Last active July 31, 2022 16:32
Use SNMP to dump mac address to port mappings from a switch
#!/usr/bin/perl
#
# Purpose: Dump mac address to port mappings from a switch
#
# Usage: ./dump_mac_table.pl <switch ip/hostname> [community]
#
# Requires:
# - CPAN SNMP::Info module (hint: cpan SNMP::Info)
# - Cisco SNMP MIBs
# ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz