• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Net/H29-Mar-2011-2,6361,055

t/H01-Aug-2011-250154

ChangesH A D01-Aug-20112.1 KiB5342

LICENSEH A D29-Mar-201120 KiB381308

MANIFESTH A D29-Mar-2011162 1413

Makefile.PLH A D29-Mar-2011528 1917

READMEH A D29-Mar-201141 21

README.podH A D01-Aug-201121.9 KiB901599

TODOH A D29-Mar-2011167 86

README

1Please see README.pod for documentation.
2

README.pod

1
2=head1 NAME
3
4Net::ILO - Interface to HP Integrated Lights-Out
5
6=head1 SYNOPSIS
7
8    use Net::ILO;
9
10    my $ilo = Net::ILO->new({
11        address     => '192.168.128.10',
12        username    => 'Administrator',
13        password    => 'secret',
14    });
15
16    # returns 'on' or 'off'
17    my $power_status = $ilo->power or die $ilo->error;
18
19    $ilo->power('off');
20    $ilo->power('reset');
21
22    my $mac01  = $ilo->mac01;
23    my $mac02  = $ilo->mac02;
24    my $macilo = $ilo->macilo;
25
26    # see METHODS for complete listing
27
28=head1 DESCRIPTION
29
30The Net::ILO module is an interface to a subset of Hewlett-Packards
31Integrated Lights-Out out-of-band management system. HP's API is XML-based
32and cumbersome to use; this module aims to simplify accessing
33the iLO from Perl while retaining as much functionality as possible.
34
35Not every iLO function is implemented here, however most common ones are.
36
37This module is based on the sixth edition of the "HP Integrated Lights-Out
38Management Processor Scripting and Command Line Resource Guide" and has
39been successfully tested with the following server types:
40
41    DL360/G3
42    DL360/G4
43    DL360/G4p
44    DL360/G5
45    DL360/G6
46    DL360/G7 ** see note below
47    DL380/G3
48    DL380/G4
49    DL380/G5
50
51It should work with other server models; feedback (either way) is much
52appreciated.
53
54Note: iLO 3 support is in BETA, and still being tested.
55
56=head1 INTERFACE QUIRKS
57
58Wherever possible, I have mimicked HP's API to maintain consistency. However,
59certain names have been changed to reflect a more common usage, for example,
60what HP calls 'DNS_NAME' is referred to as 'hostname' by Net::ILO.
61
62Boolean types are represented in the documentation as either 'Yes' or 'No'.
63When ILO returns a boolean response, it is shortened to 'Y' or 'N'. Either form
64is acceptable when passing a value to your server's iLO.
65
66Power and UID statuses are an exception; their states can be either
67'on' or 'off'.
68
69=head1 METHODS
70
71The interface is extensive and methods have been grouped by function for
72easier digestion.
73
74=head2 GENERAL METHODS
75
76=over
77
78=item new()
79
80    my $ilo = Net::ILO->new({
81        address     => '192.168.131.185',
82        username    => 'Administrator',
83        password    => 'secret',
84    });
85
86    # can also use a hash rather than hashref
87
88    my $ilo = Net::ILO->new(
89        address     => '192.168.131.185',
90        username    => 'Administrator',
91        password    => 'secret',
92    );
93
94Creates a new ILO object, but does not attempt a connection. Parameters
95are passed as an anonymous hash or hashref.
96
97Required paramters:
98
99None, however trying to call any method without setting at least the
100address, username and password will fail. You may however, set these
101later using their associated methods if you want.
102
103Optional parameters:
104
105  address - hostname or IP of remote machine's iLO
106     port - default is 443, you may specify another port here
107 username - username for logging in to iLO
108 password - password for logging in to iLO
109  version - version of iLO API to use, '1', '2' or '3'. versions 1 and 2 are
110            the same and correspond to iLO and iLO 2 respectively, if version
111            '3' is used the module will use the new iLO 3 interface. if not
112            specified the version will be detected automatically (recommended)
113    debug - debug level (default 0). Increasing this number (to a maximum of 3)
114            displays more diagnostic information to the screen, such as the
115            data sent to and received from iLO, the Perl data structure
116            created from the XML received, etc.
117
118=item address()
119
120    # connect to a different machine
121    $ilo->address('192.168.131.186');
122
123    print $ilo->power;
124
125Returns or sets the address of the remote machine to connect to.
126
127Please note that a lot of the data gathered (power state excluded) is cached.
128Connecting to machine A, calling mac01(), then connecting to machine B and
129calling mac01() will return the same data. It is recommended that you
130instantiate a new object for each server you connect to.
131
132=item port()
133
134    # your company's machines use a non-standard SSL port
135    $ilo->port(447);
136
137Returns or sets the port to connect to the remote server on.
138Port 443 is assumed if not specified.
139
140=item username()
141
142    $ilo->username('jane_doe');
143
144    # do some non-admin tasks
145    # power-cycling machine requires elevated privileges
146
147    $ilo->username('Administrator');
148    $ilo->power('reset');
149
150Returns or sets the username to use when logging in.
151
152=item password()
153
154    # try both passwords, we forgot which one was good
155    $ilo->password('foobar');
156
157    # all methods return false on failure
158    if (!$ilo->power) {
159
160        $ilo->password('barfoo');
161
162    }
163
164Returns or sets the password to use when logging in.
165
166=item error()
167
168    $ilo->address('127.0.0.1');
169
170    my $power_status = $ilo->power or die $ilo->error;
171
172    Unable to establish SSL connection with 127.0.0.1:443
173    [IO::Socket::INET6 configuration failederror:00000000:lib(0):func(0):reason(0)] at /somescript.pl line 14.
174
175Returns the last error reported, if any. All methods return false when
176an error is encountered, and $ilo->error is set to the error message
177reported by the remote machine. Note that on success, error() is not cleared,
178and so should not be used to determine whether an error occurred.
179
180Every single method which interacts with the remote machine may throw an
181error, so it is very important that you check to ensure the command
182succeeded. Error checking has been omitted from most examples for brevity.
183
184=back
185
186=head2 POWER MANAGEMENT
187
188=over
189
190=item power()
191
192    my $power_status = $ilo->power;
193
194    if ($power_status eq 'off') {
195
196        $ilo->power('on');
197
198    }
199    else {
200
201        $ilo->power('reset');
202
203    }
204
205Calling this method without parameters will return the current power
206state of the machine, either 'on' or 'off'. Passing any of the following
207to this method will attempt to change the power state:
208
209    on
210    off
211    reset
212
213=item power_consumption()
214
215    # something like 340
216    print $ilo->power_consumption;
217
218Returns the current power consumption in watts.
219
220This method is only available when using iLO 2 and above. Calling it on an
221older machine will cause the following error to be returned:
222
223Method not supported by this iLO version
224
225=back
226
227=head2 NETWORKING
228
229=over
230
231=item hostname
232
233    # default is ILO0000000000 where 000... is your serial number
234    my $machine_name = $ilo->hostname;
235
236Returns the hostname of the remote machine. This is also the name shown
237when logging in to the iLO interface, in the SSL cert, etc.
238
239For information on changing the hostname, see the network() method.
240
241=item domain_name()
242
243    # maybe ilo.somecompany.net
244    my $domain_name = $ilo->domain_name;
245
246Returns the DNS domain name of the remote machine.
247
248For information on changing the domain name, see the network() method.
249
250=item dhcp_enabled()
251
252    # either 'Y' or 'N'
253    print $ilo->dhcp_enabled;
254
255Returns 'Y' if DHCP is enabled for the iLO networking, and 'N' if a
256static IP address is in use.
257
258=item ip_address()
259
260    # network dependent, something like 192.168.1.129
261    print $ilo->ip_address;
262
263Returns the IP address of the iLO processor. Note that the IP can NOT
264be changed using this method. For managing network settings, see
265network().
266
267=item subnet_mask()
268
269    # network dependent, something like 255.255.255.0
270    print $ilo->subnet_mask;
271
272Returns the subnet mask of the iLO processor.
273
274=item gateway()
275
276    # you guessed it, network dependent
277    print $ilo->gateway;
278
279Returns the default gateway in use for the iLO networking.
280
281=item network()
282
283    $ilo->network({
284        name            => 'testbox01',
285        domain_name     => 'mydomain.com',
286        dhcp_enabled    => 'no',
287        ip_address      => '192.168.128.10',
288        subnet_mask     => '255.255.255.0',
289        gateway         => '192.168.128.1',
290    }) or die $ilo->error;
291
292Allows you to modify the network configuration of the iLO processor. The
293following parameters are allowed, see individual methods above for more detail:
294
295    name
296    domain_name
297    dhcp_enabled
298    ip_address
299    subnet_mask
300    gateway
301
302If any parameter is not specified, current values are used.
303
304Setting dhcp_enabled to 'yes' causes all IP related settings to have no effect.
305
306If the IP address is changed here, address() is updated with the new information.
307
308Networking changes cause the iLO processor to reset, it should become
309available again within 30 seconds.
310
311The rationale behind seperate methods for viewing and changing network
312settings is as follows:
313
314Network configuration generally needs to be modified as a package, for
315example, changing both the IP address and default gateway. Without a
316separate method, calling the ip_address() method as a setter could
317cause you to lose connectivity.
318
319=back
320
321=head2 SYSTEM INFORMATION
322
323=over
324
325=item model()
326
327    # ProLiant DL380 G5
328    print $ilo->model;
329
330Returns the model name of the machine.
331
332=item serialID()
333
334    # unique to your machine
335    print $ilo->serialID;
336
337Returns the serial number of the remote machine.
338
339=item cpus()
340
341    my $cpus = $ilo->cpus;
342
343    print "Number of CPUs: ", scalar @$cpus, "\n\n";
344
345    foreach my $cpu (@$cpus) {
346
347        print "  CPU: ", $cpu->{name}, "\n";
348        print "Speed: ", $cpu->{speed}, "\n";
349        print "Cores: ", $cpu->{cores}, "\n";
350
351    }
352
353    # yields the following on a single CPU Xeon:
354    #
355    # Number of CPUs: 1
356    #
357    #   CPU: Proc 1
358    # Speed: 2000 MHz
359    # Cores: 4 of 4 cores; 4 threads
360
361Returns arrayref containing information about each CPU. Included is the
362CPU name (eg. Proc 1, Proc 2, etc.), speed in MHz and number of cores.
363
364=item ramslots()
365
366    my $ramslots = $ilo->ramslots or die $ilo->error;
367
368    print "DIMM slots: ", scalar @$ramslots, "\n\n";
369
370    foreach my $slot (@$ramslots) {
371
372        print " Slot: ", $slot->{location}, "\n";
373        print " Size: ", $slot->{size},     "\n";
374        print "Speed: ", $slot->{speed},    "\n" if defined $slot->{speed};
375
376    }
377
378    # yields the following on a DL360/G5 with 8 GB of RAM:
379    #
380    # DIMM slots: 8
381    #
382    # Slot: DIMM 1A
383    # Size: 2048 MB
384    # Speed: 667 MHz
385    #
386    # Slot: DIMM 2C
387    # Size: 1024 MB
388    # Speed: 667 MHz
389    #
390    # Slot: DIMM 3A
391    # Size: 2048 MB
392    # Speed: 667 MHz
393    #
394    # Slot: DIMM 4C
395    # Size: 1024 MB
396    # Speed: 667 MHz
397    #
398    # Slot: DIMM 5B
399    # Size: 1024 MB
400    # Speed: 667 MHz
401    #
402    # Slot: DIMM 6D
403    # Size: not installed
404    #
405    # Slot: DIMM 7B
406    # Size: 1024 MB
407    # Speed: 667 MHz
408    #
409    # Slot: DIMM 8D
410    # Size: not installed
411
412Returns arrayref containing information about installed memory modules. Includes
413slot name, module size and module speed. Speed is undefined when slot is empty.
414
415=item mac01()
416
417    my $eth0_mac = $ilo->mac01;
418
419Returns the mac address associated with the machine's primary NIC (aka eth0).
420
421This method is not supported by pre-generation 4 hardware.
422
423=item mac02()
424
425    my $eth1_mac = $ilo->mac02;
426
427Returns the mac address associated with the machine's secondary NIC (aka eth1).
428
429This method is not supported by pre-generation 4 hardware.
430
431=item mac03()
432
433    my $eth2_mac = $ilo->mac03;
434
435Returns the mac address associated with the machine's tertiary NIC, if
436installed. Note that mac addresses for add-on cards will not be available
437via this method.
438
439=item mac04()
440
441    my $eth3_mac = $ilo->mac04;
442
443Returns the mac address associated with the machine's quaternary NIC, if
444installed. Note that mac addresses for add-on cards will not be available
445via this method.
446
447=item macilo()
448
449    my $ilo_mac = $ilo->macilo;
450
451Returns the mac address associated with the machine's iLO interface.
452
453This method is not supported by pre-generation 4 hardware.
454
455=item biosdate()
456
457    # format is 11/30/2006
458    print $ilo->biosdate;
459
460Returns the release date of the system's BIOS.
461
462=back
463
464=head2 SERVER HEALTH
465
466=over
467
468=item fans()
469
470    my $fans = $ilo->fans;
471
472    foreach my $fan (@$fans) {
473
474        print "    Name: ", $fan->{name},     "\n";
475        print "Location: ", $fan->{location}, "\n";
476        print "   Speed: ", $fan->{speed},    "\n";
477        print "    Unit: ", $fan->{unit},     "\n";
478        print "  Status: ", $fan->{status},   "\n\n";
479
480    }
481
482    #     Name: Fan Block 1
483    # Location: Power Supply
484    #    Speed: 34
485    #     Unit: Percentage
486    #   Status: Ok
487    #
488    #     Name: Fan Block 2
489    # Location: CPU 2
490    #    Speed: 29
491    #     Unit: Percentage
492    #   Status: Ok
493    #
494    #     Name: Fan Block 3
495    # Location: CPU 1
496    #    Speed: 34
497    #     Unit: Percentage
498    #   Status: Ok
499
500Returns arrayref containing the status of the fan block(s) installed in the
501system. 'status' will be 'Ok' or 'Failed'.
502
503=item temperatures()
504
505    my $temperatures = $ilo->temperatures;
506
507    foreach my $sensor (@$temperatures) {
508
509        print "    Name: ", $sensor->{name},     "\n";
510        print "Location: ", $sensor->{location}, "\n";
511        print "   Value: ", $sensor->{value},    "\n";
512        print "    Unit: ", $sensor->{unit},     "\n";
513        print " Caution: ", $sensor->{caution},  "\n";
514        print "Critical: ", $sensor->{critical}, "\n";
515        print "  Status: ", $sensor->{status},   "\n\n";
516
517    }
518
519    #     Name: Temp 1
520    # Location: I/O Board
521    #    Value: 49
522    #     Unit: Celsius
523    #  Caution: 80
524    # Critical: 90
525    #   Status: Ok
526    #
527    #     Name: Temp 2
528    # Location: Ambient
529    #    Value: 19
530    #     Unit: Celsius
531    #  Caution: 80
532    # Critical: 90
533    #   Status: Ok
534    #
535    #     Name: Temp 3
536    # Location: CPU 1
537    #    Value: 32
538    #     Unit: Celsius
539    #  Caution: 80
540    # Critical: 90
541    #   Status: Ok
542    #
543    #     Name: Temp 4
544    # Location: CPU 1
545    #    Value: 32
546    #     Unit: Celsius
547    #  Caution: 80
548    # Critical: 90
549    #   Status: Ok
550    #
551    #     Name: Temp 5
552    # Location: Power Supply
553    #    Value: 28
554    #     Unit: Celsius
555    #  Caution: 80
556    # Critical: 90
557    #   Status: Ok
558
559Returns arrayref containing the status of the temperature sensor(s) installed
560in the system. 'status' will be 'Failed' if the temperature exceeds the
561critical threshold.
562
563=item power_supplies()
564
565    my $power_supplies = $ilo->power_supplies;
566
567    foreach my $power_supply (@$power_supplies) {
568
569        print "  Name: ", $power_supply->{name},   "\n";
570        print "Status: ", $power_supply->{status}, "\n\n";
571
572    }
573
574    #   Name: Power Supply 1
575    # Status: Ok
576
577Returns arrayref containing the status of the power supplies installed in the
578system. 'status' will be 'Ok' or 'Failed'.
579
580=back
581
582=head2 ILO INFORMATION AND MANAGEMENT
583
584=over
585
586=item reset()
587
588    # iLO web interface is hung, try resetting it
589    $ilo->reset;
590
591Resets the iLO management processor.
592
593=item license()
594
595    # 25 characters, according to HP
596    $ilo->license('1111122222333334444455555');
597
598Activates iLO advanced pack licensing. An error will be returned if
599the key is not valid or if it is already in use.
600
601=item fw_type()
602
603    # either 'iLO', 'iLO2' or 'iLO3'
604    print $ilo->fw_type;
605
606Returns the type of iLO management processor in the remote machine.
607Possible values are 'iLO', 'iLO2' and 'iLO3', depending on
608how modern the server is.
609
610=item fw_version()
611
612    # something like 1.26
613    print $ilo->fw_version;
614
615Returns the version of iLO firmware currently running.
616
617=item fw_date()
618
619    # format is Nov 17 2006
620    print $ilo->fw_date;
621
622Returns the date the iLO firmware was released.
623
624=item ssh_status()
625
626    # either 'Y' or 'N'
627    print $ilo->ssh_status;
628
629    # disable SSH access to iLO
630    $ilo->ssh_status('No');
631
632Returns or modifies whether SSH access is enabled on the iLO.
633Gives 'Y' if SSH is enabled and 'N' if SSH is disabled.
634
635=item ssh_port()
636
637    if ($ilo->ssh_port == 22) {
638
639        $ilo->ssh_port(12345);
640
641    }
642
643Returns or sets the port iLO will listen on for incoming SSH connections.
644This should be an integer between 0 and 65535.
645
646Changing the SSH port causes the iLO processor to reset, it should become
647available again within about 30 seconds.
648
649=item http_port()
650
651    # default is 80
652    print $ilo->http_port;
653
654    $ilo->http_port(8000);
655
656Returns or sets the port iLO's http service listens on. Valid port numbers
657are between 0 and 65535.
658
659Changing the HTTP port causes the iLO processor to reset, it should become
660available again within about 30 seconds.
661
662=item https_port()
663
664    # default is 443
665    print $ilo->https_port;
666
667    $ilo->https_port(554);
668
669Returns or sets the port iLO's https service listens on. Valid port numbers
670are between 0 and 65535.
671
672Changing the HTTPS port causes the iLO processor to reset, it should become
673available again within about 30 seconds.
674
675=item session_timeout()
676
677    # default is 30
678    print $ilo->session_timeout;
679
680Returns the current session timeout in minutes. This applies to all sessions,
681eg. http, https, ssh, etc.
682
683=back
684
685=head2 USER MANAGEMENT
686
687=over
688
689=item add_user()
690
691    # add a user with admin privileges
692    $ilo->add_user({
693        name     => 'John Doe',
694        username => 'jdoe',
695        password => 'secret',
696        admin    => 'Yes',
697    });
698
699    # add a regular user with no privileges
700    $ilo->add_user({
701        name     => 'Jim Beam',
702        username => 'jbeam',
703        password => 'secret',
704    });
705
706    # add a regular user with full privileges (aside from managing users)
707    #
708    # for a detailed discussion of what each privilege provides, please see
709    # the document 'HP Integrated Lights-Out Management Processor Scripting and
710    # Command Line Resource Guide'
711    #
712    # if unspecified, default for each privilege is 'No'.
713
714    $ilo->add_user({
715        name     => 'Jack Daniels',
716        username => 'jdaniels',
717        password => 'secret',
718        remote_console_privilege => 'Yes',
719        reset_privilege          => 'Yes',
720        virtual_media_privilege  => 'Yes',
721        config_ilo_privilege     => 'Yes',
722        view_logs_privilege      => 'Yes',
723        clear_logs_privilege     => 'Yes',
724        update_ilo_privilege     => 'Yes',
725    })
726
727Adds an iLO user. Admin users have full priveleges, including the ability to
728add and remove other users. Non-admin users have configurable privileges which
729default to disabled. The subset of permissions implemented is listed above.
730Users can log in to iLO via any interface, ie. HTTPS, SSH, etc. When adding a
731non-admin user, passing in the parameter admin => 'No' is also acceptable.
732
733=item mod_user()
734
735    # change current user's password
736    # in this case username is optional
737
738    $ilo->mod_user({
739        password => 'supersecret',
740    });
741
742    # change another user's password
743    # this requires administrator privileges
744
745    $ilo->mod_user({
746        username => 'guest',
747        password => 'changem3!',
748    });
749
750Method for modifying existing user accounts. Currently this method is
751only able to change user's passwords; it cannot change permission
752levels.
753
754Passwords may consist of up to 39 printable characters. If you exceed
755the maximum password length, an error to that effect will be returned.
756
757If you update the current user's password the stored password used for
758logging in will be updated automatically.
759
760=item del_user()
761
762    # you're fired!
763    $ilo->del_user('jbeam');
764
765Removes an existing user from the iLO.
766
767=back
768
769=head2 MISCELLANEOUS
770
771=over
772
773=item uid()
774
775    if ($ilo->uid eq 'on') {
776
777        $ilo->uid('off');
778
779    }
780
781Get the status of or control the machine's UID light.
782
783Called without parameters simply returns the current status, either
784'on' or 'off'.
785
786You may pass values 'on' or 'off' to this method however be careful not to
787set the uid light to on when it is currently on, and vice versa, as this
788could throw an error, depending on iLO firmware version.
789
790An error will be returned if you pass an invalid state.
791
792    $ilo->uid('blinking') or die $ilo->error;
793
794    State blinking is not valid at /somescript.pl line 13.
795
796=back
797
798=head1 DIAGNOSTICS
799
800=over
801
802=item C<User login name was not found>
803
804General authentication error, eg. bad username or password when logging in.
805
806Could also mean you attempted to change the settings (eg. password) for a
807user which doesn't exist
808
809=item C<Method not supported by this iLO version>
810
811Either your machine / iLO firmware version is too old, or the method you called
812requires a more advanced license than you have.
813
814=item C<State %s is not valid>
815
816An invalid UID state was passed to uid(). Valid states are 'on' and 'off'.
817
818=item C<Unable to establish SSL connection with %s:%d [%s]>
819
820An error occurred while connecting to iLO. The message in brackets is
821propagated from IO::Socket::SSL, and is rarely useful.
822
823=item C<Error transmitting command to server>
824
825A connection was established, but something went wrong while sending the
826command to the remote iLO. Try reconnecting, and ensure that your
827network settings are correct.
828
829=item C<No response received from remote machine>
830
831A connection was established and a command successfully sent to the iLO, but
832no data was received. Again, ensure that your network settings are correct.
833
834There could also be something wrong with the remote iLO management processor.
835Troubleshooting is beyond the scope of this document.
836
837=item C<Error parsing response: %s>
838
839An error occurred while parsing the XML response from the iLO. The error
840message is propagated from XML::Simple, and could mean HP changed the iLO
841API.
842
843=back
844
845=head1 DEPENDENCIES
846
847    IO::Socket::SSL
848    XML::Simple
849
850=head1 AUTHOR
851
852Nicholas Lewis, C<< <nick.lewis at gmail.com> >>
853
854=head1 BUGS
855
856Please report any bugs or feature requests to C<bug-net-ilo at rt.cpan.org>, or through
857the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-ILO>.  I will be notified, and then you'll
858automatically be notified of progress on your bug as I make changes.
859
860
861=head1 SUPPORT
862
863You can find documentation for this module with the perldoc command.
864
865    perldoc Net::ILO
866
867
868You can also look for information at:
869
870=over 4
871
872=item * RT: CPAN's request tracker
873
874L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-ILO>
875
876=item * AnnoCPAN: Annotated CPAN documentation
877
878L<http://annocpan.org/dist/Net-ILO>
879
880=item * CPAN Ratings
881
882L<http://cpanratings.perl.org/d/Net-ILO>
883
884=item * Search CPAN
885
886L<http://search.cpan.org/dist/Net-ILO>
887
888=back
889
890
891=head1 COPYRIGHT & LICENSE
892
893Copyright 2011 Nicholas Lewis, all rights reserved.
894
895This program is free software; you can redistribute it and/or modify it
896under the same terms as Perl itself.
897
898
899=cut
900
901