HewlettPackard/ilo-sdk-ruby

Name: ilo-sdk-ruby

Owner: Hewlett Packard Enterprise

Description: iLO Software Development Kit for Ruby Programmers.

Created: 2016-06-03 21:29:16.0

Updated: 2017-07-20 05:58:47.0

Pushed: 2017-06-23 22:09:06.0

Homepage: https://rubygems.org/gems/ilo-sdk

Size: 160

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Ruby SDK for HPE iLO

Gem Version Yard Docs

Software Development Kit for interacting with the Hewlett Packard Enterprise iLO (Integrated Lights-Out) server management technology.

Supported iLO versions:
Installation
Client

Everything you do with this API happens through a client object. Creating the client object is the first step; then you can perform actions on the client.

ire 'ilo-sdk'
nt = ILO_SDK::Client.new(
st: 'https://ilo.example.com',
er: 'Administrator',              # This is the default
ssword: 'secret123',
l_enabled: true,                  # This is the default and strongly encouraged
gger: Logger.new(STDOUT),         # This is the default
g_level: :info,                   # This is the default
sable_proxy: true                 # Default is false. Set to disable, even if ENV['http_proxy'] is set

:lock: Tip: Check the file permissions when storing passwords in clear-text.

Environment Variables

You can also set many client options using environment variables. For bash:

rt ILO_HOST='https://oneview.example.com'
rt ILO_USER='Administrator'
rt ILO_PASSWORD='secret123'
rt ILO_SSL_ENABLED=false # NOTE: Disabling SSL is strongly discouraged. Please see the CLI section for import instructions.

:lock: Tip: Be sure nobody can access to your environment variables

Custom logging

The default logger is a standard logger to STDOUT, but if you want to specify your own, you can. However, your logger must implement the following methods:

g(String)
(String)
(String)
r(String)
l=(Symbol, etc.) # The parameter here will be the log_level attribute
Actions

Actions are performed on the client, and defined in the helper modules.

Account Service
t list of users:
s = client.get_users

eate a user:
nt.create_user('user1', 'password123')

ange a user's password:
nt.change_password('user1', 'newpassword123')

lete a user:
nt.delete_user('user1')
Bios
t all BIOS settings
ings = client.get_bios_settings

t BIOS settings
nt.set_bios_settings(
fiShellStartup: 'Enabled',
v4Gateway: '10.0.1.1',
rviceEmail: 'admin@domain.com'
Note: You can set many more options here. This is just an example.


t BIOS base configuration:
config = client.get_bios_baseconfig

vert BIOS:
nt.revert_bios

t UEFI shell startup settings:
_shell_startup = client.get_uefi_shell_startup

t UEFI shell startup settings:
_shell_startup_location = 'Auto'
_shell_startup_url = 'http://wwww.uefi.com'
nt.uefi_shell_startup('Enabled', uefi_shell_startup_location, uefi_shell_startup_url)

t BIOS DHCP settings:
_dhcp = client.get_bios_dhcp

t BIOS DHCP settings:
_address = '10.1.1.111'
_gateway = '10.1.1.0'
_primary_dns = '10.1.1.1'
_secondary_dns = '10.1.1.2'
_subnet_mark = '255.255.255.0'
nt.set_bios_dhcp('Disabled', ipv4_address, ipv4_gateway, ipv4_primary_dns, ipv4_secondary_dns, ipv4_subnet_mark)

t the URL boot file:
boot_file = client.get_url_boot_file

t the URL boot file:
nt.set_url_boot_file('http://www.urlbootfile.iso')

t BIOS service settings:
_service_settings = client.get_bios_service

t BIOS service settings:
ice_name = 'my_name'
ice_email = 'my_name@domain.com'
nt.set_bios_service(service_name, service_email)
Boot Settings
t boot order base configuration:
config = client.get_boot_baseconfig

vert the boot:
nt.revert_boot

t boot order:
_order = client.get_boot_order

t boot order:
nt.set_boot_order([
"Generic.USB.1.1",
"NIC.LOM.1.1.IPv4",
"NIC.LOM.1.1.IPv6",
"NIC.Slot.1.1.IPv6",
"HD.Emb.5.2",
"HD.Emb.5.1",
"NIC.Slot.1.1.IPv4"


t temporary boot order:
orary_boot_order = client.get_temporary_boot_order

t temporary boot order:
_source_override_target = 'CD'
nt.set_temporary_boot_order(boot_source_override_target)
Chassis
t power metrics information:
r_metrics = client.get_power_metrics

t thermal metrics information:
mal_metrics = client.get_thermal_metrics
Computer Details
t computer details (including general, network, and array controller details):
uter_details = client.get_computer_details

t general computer details:
ral_details = client.get_general_computer_details

t computer network details:
ork_details = client.get_computer_network_details

t array controller details:
y_controller_details = client.get_array_controller_details
Computer System
t computer system settings
ings = client.get_system_settings

t computer system settings
nt.set_system_settings(
setTag: 'HP001',
dicatorLED: 'Lit'
Note: You can set more options here. This is just an example.

Date Time
t the time zone:
_zone = client.get_time_zone

t the time zone:
nt.set_time_zone('Africa/Abidjan')

t whether or not NTP servers are in use (true or false):
server_use = client.get_ntp

t whether or not to use NTP servers:
nt.set_ntp(true)

t a list of NTP servers:
servers = client.get_ntp_servers

t the NTP servers:
servers = ['10.1.1.1', '10.1.1.2']
nt.set_ntp_server(ntp_servers)
Manager EthernetInterface settings
t EthernetInteface settings
nt.get_ilo_ethernet_interface

t EthernetInterface to obtain all IPv4 parameters from DHCP server
nt.set_ilo_ipv4_dhcp

t static IPv4 address, netmask and gateway
nt.set_ilo_ipv4_static(ip: '192.168.1.1', netmask: '255.255.255.0', gateway: '192.168.1.254')

t IPv4 DNS servers
nt.set_ilo_ipv4_dns_servers(dns_servers: ['2.2.2.2', '4.4.4.4', '8.8.8.8'])

t hostname and domain name 'server-ilo.domain.local'
nt.set_ilo_hostname(hostname: 'server-ilo', domain_name: 'domain.local')
Firmware
t the firmware version:
ersion = client.get_fw_version

t the firmware URI for a firmware upgrade:
nt.set_fw_upgrade('www.firmwareupgrade.com')
HTTPS Certificate
t the current SSL Certificate and check to see if expires within 24 hours
ration = client.get_certificate.not_after.to_datetime
rrow = DateTime.now + 1

xpiration < tomorrow
Generate a Certificate Signing Request:
Params: country_code, state, city, organization, organizational_unit, common_name
ient.generate_csr('US', 'Texas', 'Houston', 'myCompany', 'myUnit', 'example.com')

Wait for the CSR to be generated (will take about 10 minutes):
r = nil
ile(csr.nil?) do
sleep(60) # 60 seconds
csr = client.get_csr
d

Here you'll need to have a step that submits the csr to a certificate authority
(or self-signs it) and gets back the signed certificate. It will look something like:
-----BEGIN CERTIFICATE-----
lines_of_secret_text
-----END CERTIFICATE-----
For this example, we're assuming we've read in the content of the certificate to the
"cert" variable (as a string).

ient.import_certificate(cert)

Log Entry
ear a specific type of logs:
type = 'IEL'
nt.clear_logs(log_type)

eck to see if a specific type of logs are empty:
y = client.logs_empty?(log_type)

t a specific type of logs based on severity level and duration:
rity_level = 'OK'
tion = 10 # hours
 = client.get_logs(severity_level, duration, log_type)
Manager Account
t the Account Privileges for a specific user:
name = 'Administrator'
nt.get_account_privileges(username)

t the Login Privilege to true for a specific user:
nt.set_account_privileges(username, LoginPriv: true)

t all of the Account Privileges for a specific user:
ileges = {
oginPriv' => true,
emoteConsolePriv' => true,
serConfigPriv' => true,
irtualMediaPriv' => true,
irtualPowerAndResetPriv' => true,
LOConfigPriv' => true

nt.set_account_privileges(username, privileges)
Manager Network Protocol
t the minutes until session timeout:
out = client.get_timeout

t the minutes until session timeout:
nt.set_timeout(60)
Power
t the power state of the system:
r_state = client.get_power_state

t the power state of the system:
nt.set_power_state('On')

set the iLO:
nt.reset_ilo
Secure Boot
t whether or not UEFI secure boot is enabled:
_secure_boot = client.get_uefi_secure_boot

t whether or not UEFI secure boot is enabled:
nt.set_uefi_secure_boot(true)
Service Root
t the schema information with a given prefix:
ma_prefix = 'Account'
ma = client.get_schema(schema_prefix)

t the registry information with a  given prefix:
stry_prefix = 'Base'
stry = client.get_registry(registry_prefix)
SNMP
t the SNMP mode:
_mode = client.get_snmp_mode

t whether or not SNMP Alerts are enabled:
_alerts_enabled = client.get_snmp_alerts_enabled

t the SNMP mode and whether or not SNMP Alerts are enabled:
_mode = 'Agentless'
_alerts_enabled = true
nt.set_snmp(snmp_mode, snmp_alerts_enabled)
Virtual Media
t the virtual media information:
ual_media = client.get_virtual_media

t whether or not virtual media is inserted for a certain id:
 1
ual_media_inserted = client.virtual_media_inserted?(id)

sert virtual media at a certain id:
e = 'http://10.254.224.38:5000/ubuntu-15.04-desktop-amd64.iso'
nt.insert_virtual_media(id, image)

ect virtual media at a certain id:
nt.eject_virtual_media(id)
Custom requests

This gem includes some useful helper methods, but sometimes you need to make your own custom requests to the iLO. This project makes it extremely easy to do with some built-in methods for the client object. Here are some examples:

t a list of schemas:
onse = client.rest_api(:get, '/rest/v1/Schemas')
 even more simple:
onse = client.rest_get('/rest/v1/Schemas')

en we can validate the response and convert the response body into a hash...
 = client.response_handler(response)

r updating iLO resources, use patch:
ons = { ServiceName: 'iLO Admin', ServiceEmail: 'admin@domain.com' }
onse = client.rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: options)

r creating new iLO resources, use post:
ons = { UserName: 'admin', Password: '123' }
onse = client.rest_post('/redfish/v1/AccountService/Accounts/', body: options)

These example are about as basic as it gets, but you can make any type of iLO API request. If a helper does not do what you need, this will allow you to do it. Please refer to the documentation and code for complete list of methods and information about how to use them.

CLI

This gem also comes with a command-line interface to make interacting with the iLO API possible without needing to create a Ruby program.

Note: In order to use this, you will need to make sure your ruby bin directory is in your path. Run $ gem environment to see where the executable paths are for your Ruby installation.

To get started, run $ ilo-ruby --help.

To communicate with an appliance, you will need to set up a few environment variables so it knows how to communicate. Run $ ilo-ruby env to see the available environment variables.

Here are a few examples of how you might want to use the CLI:

Start an interactive console session with an iLO connection:
o-ruby console
ected to https://ilo.example.com
: The @client object is available to you

License

This project is licensed under the Apache 2.0 license. Please see LICENSE for more info.

Contributing and feature requests

Contributing: You know the drill. Fork it, branch it, change it, commit it, and pull-request it. We are passionate about improving this project, and glad to accept help to make it better. However, keep the following in mind:

Feature Requests: If you have a need that is not met by the current implementation, please let us know (via a new issue). This feedback is crucial for us to deliver a useful product. Do not assume we have already thought of everything, because we assure you that is not the case.

Building the Gem

First run $ bundle (requires the bundler gem), then…

Testing

Note: run $ rake -T to get a list of all the available rake tasks.

Authors

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.