# # Copyright (c) 2001-2011 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary StorageArrayConfig ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::StorageArrayConfig =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP StorageArrayConfig. A related class is L, which represents access to an ONTAP StorageArrayConfig. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the StorageArrayConfig element are the attributes of the StorageArrayConfig ComponentState. =over =item C<< "target_wwpn" >> Filled in for CMode CLI, 7Mode CLI and CMode ZAPI. CMode ZAPI: Accessible through the field "target-wwpn" in the output of ZAPI "storage_array_get_config_summary" CMode CLI: Accessible through the field "target-wwpn" in the output of command "storage_array_config_show" 7Mode CLI: Accessible through the field "target-wwpn" in the output of command "storage_array_config_show" =item C<< "lun_count" >> Filled in for CMode CLI, 7Mode CLI and CMode ZAPI. CMode ZAPI: Accessible through the field "lun-count" in the output of ZAPI "storage_array_get_config_summary" CMode CLI: Accessible through the field "lun-count" in the output of command "storage_array_config_show" 7Mode CLI: Accessible through the field "lun-count" in the output of command "storage_array_config_show" =item C<< "node" >> Filled in for CMode CLI, CMode ZAPI and 7Mode CLI. CMode ZAPI: Accessible through the field "node" in the output of ZAPI "storage_array_get_config_summary" CMode CLI: Accessible through the field "node" in the output of command "storage_array_config_show" =item C<< "initiator" >> Filled in for CMode CLI, 7Mode CLI and CMode ZAPI. CMode ZAPI: Accessible through the field "initiator-port" in the output of ZAPI "storage_array_get_config_summary" CMode CLI: Accessible through the field "initiator" in the output of command "storage_array_config_show" 7Mode CLI: Accessible through the field "initiator" in the output of command "storage_array_config_show" =item C<< "array_name" >> Filled in for CMode CLI, 7Mode CLI and CMode ZAPI. CMode ZAPI: Accessible through the field "array-name" in the output of ZAPI "storage_array_get_config_summary" CMode CLI: Accessible through the field "array-name" in the output of command "storage_array_config_show" 7Mode CLI: Accessible through the field "array-name" in the output of command "storage_array_config_show" =item C<< "target_side_switch_port" >> Filled in for CMode CLI, 7Mode CLI and CMode ZAPI. CMode ZAPI: Accessible through the field "target-side-switch-port" in the output of ZAPI "storage_array_get_config_summary" CMode CLI: Accessible through the field "target-side-switch-port" in the output of command "storage_array_config_show" 7Mode CLI: Accessible through the field "target-side-switch-port" in the output of command "storage_array_config_show" =item C<< "group" >> Filled in for CMode CLI, 7Mode CLI and CMode ZAPI. CMode ZAPI: Accessible through the field "group-number" in the output of ZAPI "storage_array_get_config_summary" CMode CLI: Accessible through the field "group" in the output of command "storage_array_config_show" 7Mode CLI: Accessible through the field "group" in the output of command "storage_array_config_show" =item C<< "initiator_side_switch_port" >> Filled in for CMode CLI, 7Mode CLI and CMode ZAPI. CMode ZAPI: Accessible through the field "switch-port" in the output of ZAPI "storage_array_get_config_summary" CMode CLI: Accessible through the field "initiator-side-switch-port" in the output of command "storage_array_config_show" 7Mode CLI: Accessible through the field "initiator-side-switch-port" in the output of command "storage_array_config_show" =item C<< "ownership" >> Filled in for CMode, 7Mode CLI and CMode ZAPI. CMode ZAPI: Accessible through the field "ownership" in the output of ZAPI "storage_array_get_config_summary" CMode CLI: Accessible through the field "ownership" in the output of command "storage_array_config_show" =back =cut package NACL::CS::StorageArrayConfig; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw(_dump_one Dumper); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'target_wwpn', scalar => 'lun_count', scalar => 'node', scalar => 'initiator', scalar => 'array_name', scalar => 'target_side_switch_port', scalar => 'group', scalar => 'initiator_side_switch_port', scalar => 'ownership', ]; =head1 METHODS =head2 fetch my $StorageArrayConfig_state = NACL::CS::StorageArrayConfig->fetch(command_interface => $ci, ...); my @StorageArrayConfig_states = NACL::CS::StorageArrayConfig->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. See L for a more detailed description along with a complete explanation of the options it accepts. =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_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', }, ], exception_text => 'No matching storage array config(s) found', show_cmd => 'storage array config show', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_cmode_cli { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@_, api => 'storage_array_config_show'); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $caught_exception; my $status_response; my %summary_args; $pkg->_hash_copy( source => $opts{filter}, target => \%summary_args, copy => [qw(node)], map => {ownership => 'ownership-type'} ); try { $status_response = $apiset->storage_array_get_config_summary(%summary_args); } catch NACL::APISet::Exceptions::ResponseException with { #The ZAPI allows us to filter by node and ownership-type, #if an invalid value is provided for either we would reach this catch block $caught_exception = 1; }; if ($caught_exception) { $Log->exit() if $may_exit; return; } my $status_output = $status_response->get_parsed_output(); $Log->debug(Dumper($status_output)); my @state_objs; my @output = (); if ($opts{command_interface}->version_manager()->is_version_ge(release => '8.3.1')){ @output = @{$status_output->[0]->{'config-summary'}->[0]{'storage-array-config-summary'}} if(keys %{$status_output->[0]}); }else{ @output = @{$status_output->[0]{'attributes'}[0]{'storage-array-config-summary'}} if(keys %{$status_output->[0]} ) ; } foreach my $row (@output) { my $state_fields = $pkg->_zapi_hash_copy( source => $row, copy => [ qw(array-name lun-count target-side-switch-port target-wwpn)], map => [ "group-number" => "group", "initiator-port" => "initiator", "switch-port" => "initiator-side-switch-port", ], ); my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => $state_fields); push @state_objs, $obj; } ## end foreach my $row ( @{ $status_output... $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi sub _fetch_7mode_cli { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = delete $opts{apiset}; my @state_objs; my %copy_filter = %{$opts{filter}}; my @copy_requested_fields = @{$opts{requested_fields}}; my $deleted_filter = $pkg->_remove_relational_regex_filters( filter => \%copy_filter, requested_fields => \@copy_requested_fields ); my $filter = \%copy_filter; my $requested_fields = \@copy_requested_fields; my $response = $apiset->storage_array_show_config(); my $output = $response->get_parsed_output(); my $row_modified; foreach my $row (@$output) { foreach my $initiator (@{$row->{'initiator'}}) { my $obj = $pkg->new(); $row_modified = $pkg->_hash_copy( source => $row, copy => [qw( array_name lun_count )], map => {'lun_group' => 'group'}, ); $row_modified->{'initiator'} = $initiator; $row_modified->{'target_wwpn'} = shift @{$row->{'array_target_ports'}}; $row_modified->{'target_side_switch_port'} = shift @{$row->{'switch_port'}}; $row_modified->{'node'} = $opts{'command_interface'}->name(); $row_modified->{'command_interface'} = $opts{'command_interface'}; $obj->_set_fields(row => $row_modified); push @state_objs, $obj; } ## end foreach my $initiator ( @{ ... } ## end foreach my $row (@$output) $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli 1;