# # Copyright (c) 2001-2017 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary ClusterPeer ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::ClusterPeer =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP ClusterPeer. A related class is L, which represents access to an ONTAP ClusterPeer. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the ClusterPeer element are the attributes of the ClusterPeer ComponentState. =over =item C<< "cluster" >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: $value =item C<< "admin_role" >> Filled in for CMode CLI. =item C<< "peer_addrs" >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $peer_addrs = $obj->peer_addrs(); # $peer_addrs contains a reference to the array of values my @peer_addrs = $obj->peer_addrs(); # @peer_addrs contains the array of values Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: @values =item C<< "ip_addrs" >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $ip_addrs = $obj->ip_addrs(); # $ip_addrs contains a reference to the array of values my @ip_addrs = $obj->ip_addrs(); # @ip_addrs contains the array of values Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: @values =item C<< "name_status" >> Filled in for CMode CLI. =item C<< "username" >> Filled in for CMode CLI. =item C<< "local_profile" >> Filled in for CMode CLI. =item C<< "rcluster" >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: $value =item C<< "clusterID" >> Filled in for CMode CLI/ZAPI. =item C<< "cluster_uuid" >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: $value =item C<< "password" >> Filled in for CMode CLI. =item C<< "availability" >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: $value =item C<< "timeout" >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: $value =item C<< "serialnumber" >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: $value =item C<< "stable_addrs" >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $stable_addrs = $obj->stable_addrs(); # $stable_addr contains a reference to the array of values my @stable_addrs = $obj->stable_addrs(); # @stable_addrs contains the array of values Filled in for CMode CLI. =item C<< remote_cluster_health >> Remote Cluster Health possible value(s) are, true,false Filled in for CMode CLI. =item C<< unreachable_local_nodes >> Unreachable Local Nodes (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $unreachable_local_nodes = $obj->unreachable_local_nodes(); # $unreachable_local_nodes contains a reference to the array of values my @unreachable_local_nodes = $obj->unreachable_local_nodes(); # @unreachable_local_nodes contains the array of values If this field needs to be passed to the filter hash, the value for this field should be passed in as an arrayref # filter => { unreachable_local_nodes = [ value1, value2...] } Filled in for CMode CLI. =item C<< remote_cluster_nodes >> Remote Cluster Nodes (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $remote_cluster_nodes = $obj->remote_cluster_nodes(); # $remote_cluster_nodes contains a reference to the array of values my @remote_cluster_nodes = $obj->remote_cluster_nodes(); # @remote_cluster_nodes contains the array of values If this field needs to be passed to the filter hash, the value for this field should be passed in as an arrayref # filter => { remote_cluster_nodes = [ value1, value2...] } Filled in for CMode CLI. =item C<< address_family >> Address Family of Relationship possible value(s) are, ipv4,ipv6,ipv6z Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: $value =item C<< salt_time >> Authentication Offer Creation Time Filled in for CMode CLI. =item C<< offer_expiration >> Authentication Offer Expiration Time Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: $value =item C<< auth_status_admin >> Authentication Status Administrative Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: $value =item C<< auth_status_operational >> Authentication Status Operational Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For 'requested_fields', 'filter' and Output mapping: $value =item C<< last_updated >> Last Update Time Filled in for CMode CLI/ZAPI iter, non-iter. Mapping for CMode ZAPI: =item C<< update_ping_timeout >> Timeout for Update Pings ranges from 1 to 10 Filled in for CMode CLI/ZAPI iter. Mapping for CMode ZAPI iter: =item C<< rpc_connect_timeout >> Timeout for RPC Connect ranges from 5 to 30 Filled in for CMode CLI/ZAPI. Mapping for CMode ZAPI iter: =item C<< ipspace >> IPspace for the Relationship Filled in for CMode CLI/ZAPI. Mapping for CMode ZAPI iter: =back =cut package NACL::CS::ClusterPeer; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw(_dump_one Dumper convert_to_system_time); 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 NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use NACL::C::_Mixins::ClusterPeer qw(:all); use NACL::ComponentUtils qw (enumerate_month); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'cluster', scalar => 'admin_role', array => 'peer_addrs', array => 'ip_addrs', scalar => 'name_status', scalar => 'username', scalar => 'local_profile', scalar => 'rcluster', scalar => 'clusterID', scalar => 'cluster_uuid', scalar => 'password', scalar => 'availability', scalar => 'timeout', scalar => 'serialnumber', array => 'stable_addrs', scalar => 'remote_cluster_health', array => 'unreachable_local_nodes', array => 'remote_cluster_nodes', scalar => 'address_family', scalar => 'salt_time', scalar => 'offer_expiration', scalar => 'auth_status_admin', scalar => 'auth_status_operational', scalar => 'last_updated', scalar => 'update_ping_timeout', scalar => 'rpc_connect_timeout', scalar => 'ipspace', scalar => 'intercluster_lif_ip', scalar => 'passphrase', scalar => 'expiration_time', scalar => 'initial_allowed_vserver_peers', scalar => 'peer_cluster_name', scalar => 'warning', ]; =head1 METHODS =head2 fetch my $ClusterPeer_state = NACL::CS::ClusterPeer->fetch(command_interface => $ci, ...); my @ClusterPeer_states = NACL::CS::ClusterPeer->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. Supports CMode CLI/ZAPI. Invokes "cluster-peer-get-iter" API for CMode ZAPI. =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', }, ], exception_text => 'No matching cluster peer(s) found', show_cmd => 'cluster peer 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 => 'cluster_peer_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, %opts) = @_; my %filter = %{$opts{filter}}; if ($filter{'offer-expiration'}) { $filter{'offer-expiration'} = $pkg->_convert_to_unix_time( command_interface => $opts{command_interface}, 'offer-expiration' => $filter{'offer-expiration'} ); $opts{filter} = \%filter; } my @objs = $pkg->SUPER::_fetch_cmode_zapi( %opts, api => "cluster_peer_get_iter", copy => [ qw(availability timeout cluster-uuid address-family auth-status-admin auth-status-operational offer-expiration rpc-connect-timeout update-ping-timeout last-updated) ], map => { "cluster" => 'cluster-name', "clusterID" => 'cluster-uuid', "peer-addrs" => [ make_zapi_array('peer-addresses'), make_zapi_skip('remote-inet-address') ], "ip-addrs" => [ make_zapi_array('active-addresses'), make_zapi_skip('remote-inet-address'), ], "remote-cluster-nodes" => [ make_zapi_array('remote-cluster-nodes'), make_zapi_skip('peer-node-name') ], "unreachable-local-nodes" => [ make_zapi_array('unreachable-local-nodes'), make_zapi_skip('peer-node-name') ], "rcluster" => 'remote-cluster-name', "serialnumber" => 'serial-number', "ipspace" => 'ipspace-name' }, ); my $timezone; foreach my $obj (@objs) { if ($obj->offer_expiration_isset && $obj->offer_expiration ne "-") { $timezone = $opts{command_interface} ->get_timezone(apiset_should => {interface => 'ZAPI'}) if !$timezone; my $hash = $pkg->convert_to_system_time( unixtime => $obj->offer_expiration(), timezone => $timezone ); my $value = "$hash->{month}\/$hash->{day}\/$hash->{year} $hash->{hour}:$hash->{minute}:$hash->{second}"; $obj->offer_expiration('"' . $value . '"'); } } $Log->exit() if $may_exit; return @objs; } ## end sub _fetch_cmode_zapi sub _update_state_objs_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; $pkg->SUPER::_update_state_objs_cmode_zapi( %opts, zapi_field_translations => { ucfirst => [qw(availability)], hyphenate_value => [qw(auth-status-admin)], timestamp_to_mmddyyyy => [qw(last-updated)], }, ); $Log->exit() if $may_exit; } 1;