Created
November 18, 2014 17:33
-
-
Save brandt/38562fb4bed46d8c8cea to your computer and use it in GitHub Desktop.
Grant a user created with IPMI privileges to login to the Dell DRAC web management interface.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Description: | |
# | |
# Quick hack to grant a user the privileges necessary to login to the Dell DRAC web management interface. | |
# | |
# This is a workaround for a bug where a user created in IPMI can't login to the Dell DRAC web management portal. | |
# The user would be denied with error: Login failed. User does not have 'Login to Dell BMC' privilege. | |
# | |
# We assume that the default user and password are still enabled (root:root). | |
# | |
# Tested with firmware version 2.53 | |
# | |
# Usage: ./grant-drac-web-privileges.rb <csv_file> | |
# | |
# Requirements: | |
# | |
# - PhantomJS (brew install phantomjs OR npm install -g phantomjs) | |
# - Watir with webdriver (gem install watir-webdriver) | |
# | |
# Example CSV file format: | |
# | |
# 34:17:EB:B4:0D:45,10.4.8.133 | |
# 34:17:EB:B4:0D:27,10.4.8.134 | |
# 34:17:EB:B4:0D:3F,10.4.8.135 | |
# | |
require 'watir-webdriver' | |
require 'csv' | |
class DellAdmin | |
attr_accessor :ips, :user | |
def initialize | |
@browser = Watir::Browser.new :phantomjs, :args => ['--ignore-ssl-errors=yes'] | |
end | |
def run | |
@ips.map do |ip| | |
puts "Making Administrator: #{ip}" | |
make_admin(ip) | |
end | |
end | |
def close | |
@browser.close | |
end | |
def make_admin(ip) | |
@browser.goto("https://#{ip}") | |
@browser.text_field(:name, "user").when_present.set("root") | |
@browser.text_field(:name, "password").set("root") | |
@browser.a(:id, "btnOK").click | |
users_nav = @browser.frame(:name, "bmcTree").span(:text, "Users") | |
users_nav.wait_until_present | |
users_nav.click | |
data_frame = @browser.frame(:name, "dataPage") | |
users_table = data_frame.table(:id, 'userList') | |
users_table.wait_until_present | |
uid = users_table.to_a.select {|row| row[2] == "collins" }[0][0] | |
users_table.a(:text, uid).click | |
priv_dropdown = data_frame.select(:id, "userPriv") | |
priv_dropdown.wait_until_present | |
priv_dropdown.select("Administrator") | |
apply = @browser.frame(:name, "headerFrame").td(:id, "btn2").span(:text, "Apply Changes").parent | |
apply.click | |
sleep 1 # probably don't need to do this | |
end | |
end | |
file = ARGV[0] | |
unless File.exist?(file) | |
$stderr.puts "ERROR: CSV file does not exist!" | |
exit 1 | |
end | |
csv = CSV.read(file) | |
ip_list = [] | |
CSV.foreach(file) {|row| ip_list << row[1] } | |
d = DellAdmin.new | |
d.user = "collins" | |
d.ips = ip_list | |
d.run | |
d.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment