#$Id: //depot/prod/test/nacldev/lib/NACL/CS/Switch/NameServer.pm#1 $ # # Copyright (c) 2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary NameServer ComponentState Module ## @author veerap@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::Switch::NameServer =head1 DESCRIPTION C is a derived class of L. It represents the state of NameServer element. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the NameServer element are the individual attributes of the NameServer ComponentState =over =item C<< share_area >> Filled in for BrocadeFC Switch. =item C<< fabric_port_name >> Filled in for BrocadeFC Switch. =item C<< nodename >> Filled in for BrocadeFC Switch. =item C<< portname >> Filled in for BrocadeFC Switch. =item C<< device_shared_in_other_ad >> Filled in for BrocadeFC Switch. =item C<< ttlsec >> Filled in for BrocadeFC Switch. =item C<< port_index >> Filled in for BrocadeFC Switch. =item C<< cos >> Filled in for BrocadeFC Switch. =item C<< redirect >> Filled in for BrocadeFC Switch. =item C<< pid >> Filled in for BrocadeFC Switch. =item C<< permanent_port_name >> Filled in for BrocadeFC Switch. =item C<< type >> Filled in for BrocadeFC Switch. =item C<< ip_address >> Filled in for BrocadeFC Switch. =back =cut package NACL::CS::Switch::NameServer; use strict; use warnings; use Params::Validate qw(validate); use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::Switch'; use Class::MethodMaker [ new => [ '-hash', 'new' ], scalar => 'share_area', scalar => 'fabric_port_name', scalar => 'nodename', scalar => 'portname', scalar => 'device_shared_in_other_ad', scalar => 'ttlsec', scalar => 'port_index', scalar => 'cos', scalar => 'redirect', scalar => 'pid', scalar => 'permanent_port_name', scalar => 'type', scalar => 'ip_address', ]; =head1 METHODS =head2 fetch my $NameServer_state = NACL::CS::NameServer->fetch(command_interface => $ci, ...); my @NameServer_states = NACL::CS::NameServer->fetch(command_interface => $ci, ...); (Class method) Discovers which elements are present and returns their state in ComponentState objects. Called in scalar context it returns only one state object, in list context it returns all state objects. It supports BrocadeFC switches. Command invoked is nsshow. See L for a more detailed description along with a complete explanation of the options it accepts. see L =cut sub fetch { my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => "_fetch_brocadefc_cli", interface => "CLI", set => "BrocadeFC" }, ], exception_text => 'No matching name server elements found' ); return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_brocadefc_cli { my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my @state_objs; my ($output, $response); $response = $apiset->nsshow(); $output = $response->get_parsed_output(); pop(@$output); #to remove the no_of_entries key which is not required foreach my $row (@$output) { my $obj = $pkg->new( command_interface => $opts{command_interface} ); $obj->_set_fields( row => $row); push @state_objs, $obj; } return @state_objs; } 1;