# # Copyright (c) 2001-2011 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Ifconfig ComponentState Module ## @author dheeraj@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::Ifconfig =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP Ifconfig. A related class is L, which represents access to an ONTAP Ifconfig. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Ifconfig element are the attributes of the Ifconfig ComponentState =over =item C<< broadcast >> =item C<< ipv6 >> (ARRAY) =item C<< ipv4 >> (ARRAY) =item C<< ipv6_info >> (ARRAY) =item C<< ipv4_info >> (ARRAY) =item C<< flags >> (ARRAY) =item C<< interface >> =item C<< macaddress >> =item C<< netmask >> =item C<< partner >> =item C<< mtu >> =item C<< mediatype >> =item C<< flowcontrol >> =item C<< dad_attempts >> =back =cut package NACL::CS::Ifconfig; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw(_dump_one); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use base qw(NACL::CS::ComponentState::ONTAP); use NATE::BaseException qw(:try); use NACL::Exceptions::NoElementsFound qw(:try); use Data::Dumper; use Class::MethodMaker [ scalar => 'broadcast', array => 'ipv6', array => 'ipv4', array => 'ipv6_info', array => 'ipv4_info', array => 'flags', scalar => 'interface', scalar => 'macaddress', scalar => 'netmask', scalar => 'mtu', scalar => 'mediatype', scalar => 'flowcontrol', scalar => 'partner', scalar => 'dad_attempts', ]; =head1 METHODS =head2 fetch my $interface_state = NACL::CS::Ifconfig->fetch(command_interface=>$ci,...); my @interface_states = NACL::CS::Ifconfig->fetch(command_interface=>$ci,...); see L Uses a 7Mode CLI or Nodescope or Systemshell APISet. =over =item Exceptions =over =item C When there are no elements matching the query specified or elements of that type doesn't exist, then this exception will be thrown. =back =back =cut sub fetch { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => "_fetch_7mode_cli", interface => "CLI", set => "7Mode|Nodescope|Systemshell", }, ], exception_text => 'No matching ifconfig(s) found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_7mode_cli { my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = delete $opts{apiset}; my $filter = delete $opts{filter}; my %cmd_opts; if ($filter->{interface}) { $cmd_opts{'interface'} = $filter->{interface}; } else { $cmd_opts{'all'} = 1; } my @state_objs; my $response = $apiset->ifconfig(%cmd_opts); my $output = $response->get_parsed_output(); foreach my $row (@$output) { my $obj = $pkg->new(); my $row_modified = $pkg->_hash_copy( source => $row, copy => [qw(broadcast ipv6 ipv4 ipv6_info ipv4_info mediatype flags flowcontrol mtu partner dad_attempts)], map => { 'mac' => 'macaddress', 'mask' => 'netmask', 'name' => 'interface' }, ); $obj->_set_fields(row => $row_modified ); push @state_objs, $obj; } ## end foreach my $row (@$output) return @state_objs; } ## end sub _fetch_7mode_cli 1;