Luke Poskitt > Cisco-UCS-0.01 > Cisco::UCS

Download:
Cisco-UCS-0.01.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  1
View/Report Bugs
Module Version: 0.01   Source   Latest Release: Cisco-UCS-0.33

NAME ^

Cisco::UCS - A Perl interface to the Cisco UCS XML API

SYNOPSIS ^

        use Cisco::UCS;

        my $ucs = new Cisco::UCS (      cluster         => $cluster, 
                                        port            => $port,
                                        proto           => $proto,
                                        username        => $username,
                                        passwd          => $password
                                );

        $ucs->login();

        @errors = $ucs->get_errors(severity=>"critical",ack="no");

        foreach my $error_id (@errors) {
                my %this_error = $ucs->get_error_id($error_id);
                print "Error ID: $error_id.  Severity: $this_error{severity}.  Description: $this_error{descr}\n";
        }

        $ucs->logout();

DESCRIPTION ^

This package provides an abstracted interface to the Cisco UCS Manager XML API and Cisco UCS Management Information Model.

The Cisco UCS Manager (UCSM) is an embedded software agent providing access to the hardware and configuration management features of attached Cisco UCS hardware. The Management Information Model for the UCSM is organised into a structured heirachy of both physical and virtual objects. Accessing objects within the heirachy is done through a number of high level calls to heirachy search and traversal methods.

The primary aim of this package is to provide a simplified and abstract interface to this management heirachy.

Most methods in this package return an anonymous hash, array, or array of anonymous hashes, representing the requested object. Unfortunately, this means that the documentation on return types and specific values may seem a little lacking.

METHODS

new

        my $ucs = new Cisco::UCS (      cluster         => $cluster, 
                                        port            => $port,
                                        proto           => $proto,
                                        username        => $username,
                                        passwd          => $passwd
                                );

Constructor method. Creates a new Cisco::UCS object representing a connection to the Cisco UCSM XML API.

Required parameters are:

cluster

The common name of the target cluster. This name should be resolvable on the host from which the script is run.

port

The port on which to connect to the UCSM XML API on the target cluster. This value must be 80 or 443.

proto

The protocol with which to connect to the UCSM XML API on the target cluster. This value must be one of either 'http' or 'https' and should be dictated by the value specified for the port attribute.

username

The username to use for the connection. This username needs to have the correct RBAC role for the operations that one intends to perform.

passwd

The plaintext password of the username specified for the username attribute for the connection.

login

        $ucs->login;
        print "Authentication token is $ucs->{cookie}\n";

Creates a connection to the XML API interface of a USCM management instance. If sucessful, the attributes of the UCSM management instance are inherited by the object. Most important of these parameters is 'cookie' representing the authetication token that uniquely identifies the connection and which is subsequently passed transparently on all further communications.

The default time-out value for a token is 10 minutes, therefore if you intend to create a long-running session you should periodicalily call refresh.

refresh

        $ucs->refresh;

Resets the expiry time limit of the existing authentication token to the default timeout period of 10m. Usually not necessary for short-lived connections.

logout

        $ucs->logout;

Expires the current authentication token. This method should always be called on completion of a script to expire the authentication token and free the current session for use by others. The UCS XML API has a maximum number of available connections, and a maximum number of sessions per user. In order to ensure that the session remain available (especially if using common credentials), you should always call this method on completion of a script, as an argument to die, or in any eval where a script may fail and exit before logging out;

get_error_id

        my %error = $ucs->get_error_id($id);

        while (my($key,$value) = each %error) {
                print "$key:\t$value\n";
        }

Returns a hash containing the UCSM event detail for the given error id. This method takes a single argument; the UCSM error_id of the desired error.

See get_errors for an example of how to obtain error_id values.

get_errors

        my @errors      = $ucs->get_errors;
        my %error       = $ucs->get_error_id($errors[0]);
        print "Error $id: $error->{description}\n";

Returns an array of UCSM event ID's. The full event description of the returned event ID's can be retrieved by passing the ID to get_error_id (see above).

resolve_class

This method is used to retrieve objects from the UCSM management heirachy by resolving the classId for specific object types. This method reflects one of the base methods provided by the UCS XML API for resolution of objects. The method returns an XML::Simple parsed object from the UCSM containing the response.

Unless you have read the UCS XML API Guide and are certain that you know what you want to do, you shouldn't need to alter this method.

resolve_classes

This method is used to retrieve objects from the UCSM management heirachy by resolving several classIds for specific object types. This method reflects one of the base methods provided by the UCS XML API for resolution of objects. The method returns an XML::Simple object from the UCSM containing the parsed response.

Unless you have read the UCS XML API Guide and are certain that you know what you want to do, you shouldn't need to alter this method.

resolve_dn

        my $blade = $ucs->resolve_dn( dn => 'sys/chassis-1/blade-2');

This method is used to retrieve objects from the UCSM management heirachy by resolving a specific distinguished name (dn) for a managed object. This method reflects one of the base methods provided by the UCS XML API for resolution of objects. The method returns an XML::Simple parsed object from the UCSM containing the response.

The method accepts a single key/value pair, with the value being the distinguished name of the object. If not known, the dn can be usually be retrieved by first using one of the other methods to retrieve a list of all object types (i.e. get_blades) and then enumerating the results to extract the dn from the desired object.

        my @blades = $ucs->get_blades;i

        foreach my $blade in (@blades) {
                print "Dn is $blade->{dn}\n";
        }

Unless you have read the UCS XML API Guide and are certain that you know what you want to do, you shouldn't need to alter this method.

resolve_children

        use Data::Dumper;

        my $children = $ucs->resolve_children(dn => 'sys');
        print Dumper($children);

This method is used to resolve all child objects for a given distinguished named (dn) object in the UCSM management heirachy. This method reflects one of the base methods provided by the UCS XML API for resolution of objects. The method returns an XML::Simple parsed object from the UCSM containing the response.

In combination with Data::Dumper this is an extremely useful method for further development by enumerating the child objects of the specified dn. Note however, that the response returned from UCSM may not always accurately reflect all elements due to folding.

Unless you have read the UCS XML API Guide and are certain that you know what you want to do, you shouldn't need to alter this method.

resolve_class_filter

        my $associated_servers = $ucs->resolve_class_filter(    classId         => 'computeBlade',
                                                                association     => 'associatied'        );

This method is used to retrieve objects from the UCSM management heirachy by resolving the classId for specific object types matching a specified filter composed of any number of key/value pairs that correlate to object attributes.

This method is very similar to the <B>resolve_class method, however a filter can be specified to restrict the objects returned to thse having certain characteristics. This method is largely exploited by subclasses to return specific object types.

The filter is to be specified as any number of name/value pairs in addition to the classId parameter.

get_cluster_status

        my $status = $ucs->get_cluster_status;

This method returns an anonymous hash representing a brief overall cluster status. In the standard configuration of a HA pair of Fabric Interconnects, this status is representative of the cluster as a single managed entity.

get_mgmt_entities

        my @mgmt_entities = $ucs->get_mgmt_entities;

        foreach $entity (@mgmt_entities) {
                print "Management entity $entity->{id} is the $entity->{role} entity\n";
        }

Returns an anonymous array containing information on the UCSM management entity objects. The management entity is representitive of an instance of the UCSM agent running on a supported hardware platform (Fabric Interconnects).

Note that there is a difference between the Fabric Interconnect as a hardware platform that provides the physical hardware platform for hosting UCSM management entity instance and providing the cluster capabilties and the management entity as a logical construct.

get_primary_mgmt_entity

        my $primary = $ucs->get_primary_mgmt_entity;
        print "Management entity $entity->{id} is primary\n";

Returns an anonymous hash contaiing information on the primary UCSM management entity object. This is the active managing instance of UCSM in the target cluster.

get_subordinate_mgmt_entity

        print 'Management entity ', $ucs->get_subordinate_mgmt_entity->{id}, ' is the subordinate management entity in cluster ',$ucs->{cluster},"\n";

Returns an anonymous hash containing information on the subordinate UCSM management entity object.

get_service_profile

Returns an anonymous hash containing information on the requested service profile object.

get_service_profiles

        my @service_profiles = $ucs->get_service_profiles;

        foreach my $service_profile (@service_profiles) {
                print "Service Profile: $service_profile->{name}\n";
        }

Returns an array of anonymous hashs representing configured service profile objects.

get_interconnect

        my @interconnects = $ucs->get_interconnects;

        foreach my $ic (@interconnects) {
                print "Interconnect $ic HA status is $ic->{ha_ready}\n";
        }

Returns an array of anonymous hashs representing UCS Fabric Interconnect objects.

get_interconnect

        my $interconnect = $ucs->get_interconnect(dn => 'sys/switch-A');

        or

        my $interconnect = $ucs->get_interconnect(id => 'A');

Returns an anonymous hash containing information on the specified UCS Fabric Interconnect object. The method accepts either the distinguished name of the desired Interconnect, or the ID of the Fabric Interconnect in the target cluster.

get_fexs

        my @fexs = $ucs->get_fexs;
        print "Fabric Extender - thermal $fex[0]->{thermal} - temperature $fex[0]->{temp}\n";

Returns an array of anonymous hashes, each containing information on a UCS Fabric Extender object identified within the cluster.

get_fex

        my $fex = $ucs->get_fex(dn => 'sys/chassis-1/slot-1');

        or

        my $fex = $ucs->get_fex(chassisId => 1, id => 1);

Returns an anonymous hash containing information on a UCS Fabric Extender object. The Fabric Extender (FEX) may be given either by distinguished name (dn) or by physical locality of the residing chassis and slot.

get_blades

        my @blades = $ucs->get_blades();

        foreach my $blade (@blades) {
                print "Model: $blade->{model}\n";
        }

Returns an array of hashes each representative of a UCS server object. The returned objects are identical to those represented by the Cisco::UCS::Blade subclass.

get_blade

        my blade = $ucs->get_blade(dn => 'sys/chassis-1/blade-2'

        or

        my $blade = $ucs->get_blade(chassisId => 1, slotId => 2);

        or

        my $blade = $ucs->get_blade(serial => 'QJ547L9987');

        or

        my $blade = $ucs->get_blade(uuid => '0000-000000-000000');

Returns an anonymous hash representing a UCS server blade object. The blade may be specified either by distinguished name (dn), by physical locality of chassis and slot id, by serial number or by uuid.

get_chassiss

        my @chassis = $ucs->get_chassiss();

        foreach my $chassis (@chassis) {
                print "Chassis $chassis->{id} serial number: $chassis->{serial}\n";
        }

Returns an array of hashes with each hash containing information on a single chassis within the system.

Note that this method is named get_chassiss (spelt with two sets of double-s's) as there exists no English language collective plural for the word chassis.

get_chassis

        my $chassis = $ucs->get_chassis;
        print "Chassis serial number: $chassis->{serial}\n";
        my $chassis = new UCS::Chassis(dn => $chassis->{dn});

Returns a hash containing information about the requested chassis given the distinguished name (dn) of a chassis in the target cluster. This method is typically used for the creation of a UCS::Chassis object.

get_psus

This method provides a method for child classes that returns all power supply units for a specific object type. Arguably, this method should not be in this class as the concept of a UCS object as an abstract 'type' does not physically or logically 'have' a PSU. The justification for having this method in the parent class is to reduce code duplication, but this is a candidate for removal as it is almost always overridden in subclasses.

get_psu

This method provides a method for child classes that returns the power supply unit for a specific object type. Arguably, this method should not be in this class as a UCS object as an abstract type does not have a PSU. The justification for having this method in the parent class is to reduce code duplication, but this is a candidate for removal as it is almost always overridden in sbclasses.

full_state_backup

This method generates a new "full state" type backup for the target UCS cluster. Internally, this method is implemented as a wrapper method around the private backup method. Required parameters for this method:

backup_proto

The protocol to use for transfering the backup from the target UCS cluster to the backup host. Must be one of: ftp, tftp, scp or sftp.

backup_host

The host to which the backup will be transferred.

backup_target

The fully qualified name of the file to which the backup is to be saved on the backup host. This should include the full directory path and the target filename.

backup_username

The username to be used for creation of the backup file on the backup host. This username should have write/modify file system access to the backup target location on the backup host using the protocol specified in the backup-proto attribute.

backup_passwd

The plaintext password of the user specified for the backup_username attribute.

all_config_backup

This method generates a new "all configuration" backup for the target UCS cluster. Internally, this method is implemented as a wrapper method around the private backup method. For the required parameters for this method, please refer to the documentation of the full_state_backup method.

system_config_backup

This method generates a new "system configuration" backup for the target UCS cluster. Internally, this method is implemented as a wrapper method around the private backup method. For the required parameters for this method, please refer to the documentation of the full_state_backup method.

logical_config_backup

This method generates a new "logical configuration" backup for the target UCS cluster. Internally, this method is implemented as a wrapper method around the private backup method. For the required parameters for this method, please refer to the documentation of the full_state_backup method.

TODO ^

Quite a lot; this package started out as a way to easily reduce the amount of copying and pasting I was doing but it grew quickly. Note everything has been implemented nicely and this package barely scrapes the surface of the UCS API capabilities.

AUTHOR ^

Luke Poskitt, <luke.poskitt at gmail.com>

BUGS ^

Plenty, I'm sure.

LICENSE AND COPYRIGHT ^

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

syntax highlighting: