Skip to content

Instantly share code, notes, and snippets.

@fatmcgav
Created July 15, 2013 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fatmcgav/5999023 to your computer and use it in GitHub Desktop.
Save fatmcgav/5999023 to your computer and use it in GitHub Desktop.
delete_export.rb File to test NetApp export deletion...
$:.unshift '../../../../lib/ruby/NetApp'
require 'sdk/NaServer'
require 'rubygems'
require 'pp'
#require 'ap'
def print_usage
print ("Usage: \n")
print ("ruby delete_export.rb <storage> <user> <password>")
print (" <export name> \n")
exit
end
def delete_export
args = ARGV.length
if(args < 3)
print_usage
end
storage = ARGV[0]
user = ARGV[1]
pw = ARGV[2]
path = ARGV[3]
s = NaServer.new(storage, 1, 13)
s.set_admin_user(user, pw)
s.set_transport_type("HTTPS")
s.set_debug_style("NA_PRINT_DONT_PARSE")
pathnames1 = NaElement.new("pathname-info")
pathnames1.child_add_string("name", path)
print "Pathnames1 looks like:\n"
pp pathnames1
#
cmd = NaElement.new("nfs-exportfs-delete-rules")
cmd.child_add_string("persistent", 'true')
paths = NaElement.new("pathnames")
pathnames = NaElement.new("pathname-info")
pathnames.child_add_string("name", path)
paths.child_add(pathnames)
cmd.child_add(paths)
print "Cmd XML looks like: \n"
cmd.sprintf()
pp cmd
print "\nExecuting command.\n"
out = s.invoke("nfs-exportfs-delete-rules", "persistent", "true", "pathnames", pathnames)
#out = s.invoke_elem(cmd)
if(out.results_status == "failed")
print(out.results_reason + "\n")
exit
else
print("Export Deletion succeded.\n")
end
end
delete_export()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment