# # Copyright (c) 2011-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # # ## @summary Switch ComponentState Module ## @author rawat@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here ################################################################################ =head1 NAME NACL::CS::Switch::Switch =head1 DESCRIPTION C is a derived class of L. It represents the state of Switch element. A related class is L, which represents access to a Switch element. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Switch element are the individual attributes of the Switch ComponentState =over =item C<< 'detail'=>$boolean >> (Optional) c<< details >> are needed or not =back =cut ################### # Package package NACL::CS::Switch::Switch; ################### # 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 NACL::ComponentUtils qw (_dump_one); use NACL::Exceptions::NoElementsFound qw(:try); use NACL::APISet::Exceptions::InvalidParamValueException qw(:try); use base 'NACL::CS::ComponentState::Switch'; use Class::MethodMaker [ scalar => "switchname", scalar => "switchstate", scalar => "fabric_os", array => "chassis", scalar => "switchmode", array => "switchwwn", scalar => "zoning", scalar => "switchrole", scalar => "switchbeacon", array => "ports_information", scalar => "switchtype", scalar => "switchdomain", scalar => "switchid", scalar => "kernel", array => "fcid_info", scalar => "fcid", scalar => "vsan", ]; =head1 METHODS =head2 fetch my $mount_state = NACL::CS::Switch::Switch->fetch(command_interface=>$ci,...); my @mount_states = NACL::CS::Switch::Switch->fetch(command_interface=>$ci,...); see L =cut sub fetch { my $pkg = shift; $Log->enter() if $may_enter; # This lib is deprecated. Inform user about this $Log->warn( "This Library(NACL::CS::Switch::Switch) is deprecated. " . "No new functionality will be added to this library. " . "Use NACL::CS::Switch instead." ); my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => "_fetch_brocadefc_cli", interface => "CLI", set => "BrocadeFC" }, { method => "_fetch_ciscofc_cli", interface => "CLI", set => "CiscoFC" }, ], exception_text => 'No matching elements found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_brocadefc_cli { my $pkg = shift; $Log->enter() if $may_enter; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $filter = $opts{filter}; my $requested_fields = $opts{requested_fields}; my @state_objs; my ( $output, $response, $obj ); $obj = $pkg->new( command_interface => $opts{command_interface} ); # get Switch version/kernel version my %req_field_filter = ( requested_fields => $opts{requested_fields}, filter => $opts{filter} ); if ($pkg->_want_any_field_of(%req_field_filter, fields_filled_by_api => [ qw(kernel fabric_os) ])) { $response = $apiset->version(); $output = $response->get_parsed_output(); foreach my $row (@$output) { $obj->_set_fields( row => $row ); } } # get Switch hardware details if ($pkg->_want_any_field_of(%req_field_filter, fields_filled_by_api => [ qw(chassis) ])) { $response = $apiset->chassisshow(); $output = $response->get_parsed_output(); foreach my $row (@$output) { $obj->_set_fields( row => $row ); } } # Get Switch Software details if ($pkg->_want_any_field_of(%req_field_filter, fields_filled_by_api => [ qw(switchstate switchname ports_information) ])) { $response = $apiset->switchshow(); $output = $response->get_parsed_output(); foreach my $row (@$output) { $obj->_set_fields( row => $row ); } } push @state_objs, $obj; $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_brocadefc_cli sub _fetch_ciscofc_cli { my $pkg = shift; $Log->enter() if $may_enter; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $filter = $opts{filter}; my $requested_fields = $opts{requested_fields}; my @state_objs; my ( $output, $response, $obj ); # get Switch version/kernel version my %req_field_filter = ( requested_fields => $opts{requested_fields}, filter => $opts{filter} ); if ($pkg->_want_any_field_of(%req_field_filter, fields_filled_by_api => [ qw(fcid_info fcid vsan) ])) { $response = $apiset->show_fcns_database_local(detail => 1); $output = $response->get_parsed_output(); foreach my $row (@$output) { my $obj = $pkg->new( command_interface => $opts{command_interface} ); $obj->_set_fields( row => $row ); push @state_objs, $obj; } } $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_ciscofc_cli 1;