# # Copyright (c) 2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # # ## @summary Sfp ComponentState Module ## @author pbala@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here ################################################################################ =head1 NAME NACL::CS::Switch::Sfp =head1 DESCRIPTION C is a derived class of L. It represents the state of Sfp element. A related class is L, which represents access to a Sfp element. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Port element are the individual attributes of the Port ComponentState =over =item C<< 'port_number'=>$string >> =item C<< vendor_name >> =item C<< pwr_on_time >> =item C<< alarm_flags_0_1 >> =item C<< date_code >> =item C<< identifier >> =item C<< wavelength >> =item C<< o_wrap_control >> =item C<< status_ctrl >> =item C<< encoding >> =item C<< length_50u >> =item C<< warn_flags_0_1 >> =item C<< transceiver >> =item C<< voltage >> (Array) =item C<< enh_options >> =item C<< length_cu >> =item C<< br_max >> =item C<< baud_rate >> =item C<< length_62_5u >> =item C<< vendor_rev >> =item C<< options >> =item C<< e_wrap_control >> =item C<< serial_no >> =item C<< length_9u >> =item C<< vendor_pn >> =item C<< tx_power >> (Array) =item C<< vendor_oui >> =item C<< current >> (Array) =item C<< connector >> =item C<< dd_type >> =item C<< state_transitions >> =item C<< rx_power >> (Array) =item C<< br_min >> =item C<< temparature >> (Array) =back =cut ################### # Package package NACL::CS::Switch::Sfp; ################### # Everytime use strict; use warnings; ################### # Module includes use Params::Validate qw (validate); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NATE::BaseException qw(:try); use base 'NACL::CS::ComponentState::Switch'; use Class::MethodMaker [ scalar => "port_number", scalar => "vendor_name", scalar => "pwr_on_time", scalar => "alarm_flags_0_1", scalar => "date_code", scalar => "identifier", scalar => "wavelength", scalar => "o_wrap_control", scalar => "status_ctrl", scalar => "encoding", scalar => "length_50u", scalar => "warn_flags_0_1", scalar => "transceiver", array => "voltage", scalar => "enh_options", scalar => "length_cu", scalar => "br_max", scalar => "baud_rate", scalar => "length_62_5u", scalar => "vendor_rev", scalar => "options", scalar => "e_wrap_control", scalar => "serial_no", scalar => "length_9u", scalar => "vendor_pn", array => "tx_power", scalar => "vendor_oui", array => "current", scalar => "connector", scalar => "dd_type", scalar => "state_transitions", array => "rx_power", scalar => "br_min", array => "temparature", ]; =head1 METHODS =head2 fetch my $port = NACL::CS::Switch::Sfp->fetch(command_interface=>$ci,...); my @port = NACL::CS::Switch::Sfp->fetch(command_interface=>$ci,...); see L =cut sub fetch { my ($pkg, @args) = @_; $Log->enter() if $may_enter; my @state_objs = $pkg->SUPER::fetch( @args, choices => [ { method => "_fetch_brocadefc_cli", interface => "CLI", set => "BrocadeFC" }, ], exception_text => 'No matching elements found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_brocadefc_cli { my ($pkg, @args) = @_; $Log->enter() if $may_enter; my %opts = validate @args,$pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $port_number = $opts{filter}->{'port-number'}; my $command_interface = delete $opts{command_interface}; my @state_objs; my ( $output, $response, $caught_exception ); if ( !(defined $port_number) ) { $Log->exit() if $may_exit; NATE::Exceptions::Argument->throw("No port number was passed in filter"); } try{ $response = $apiset->sfpshow( 'port-number' => $port_number ); } catch NACL::APISet::Exceptions::InvalidParamException with{ $caught_exception = 1; }; if ($caught_exception) { $Log->exit() if $may_exit; return; } $output = $response->get_parsed_output(); foreach my $row (@$output) { my $obj = $pkg->new( command_interface => $command_interface, 'port-number' => $port_number ); $obj->_set_fields( row => $row ); push @state_objs, $obj; } $Log->exit() if $may_exit; return @state_objs; } #end sub _fetch_brocadefc_cli 1;