# # Copyright (c) 2001-2010 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # # ## @summary Transition ComponentState Module ## @author rohit4@netapp.com, dl-nacl-dev@netapp.com ## @status Shared ## @pod here ################################################################################ =head1 NAME NACL::CS::Client::Transition =head1 DESCRIPTION C is a derived class of L. It represents the state of Transition element. A related class is L, which represents access to a Transition element. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Transition element are the individual attributes of the Transition ComponentState . =over =item C<< 'session_name' >> Name of the transition session =item C<< 'session_status' >> Status of the session =item C<< 'session_state' >> State of the session =item C<< 'session_type' >> Transition session type =item C<< 'vfiler_unit' >> Vfiler unit from where the volumes are getting transitioned =item C<< 'vserver_name' >> Gives the name of the vserver =item C<< 'vserver_comment' >> Mentions whether the vserver is tool created or pre-existing =item C<< 'cluster_mode_system_fqdn' >> Cluster mode fully qualified domain name =item C<< '_7_mode_system_fqdn' >> 7 mode fully qualified domain name =item C<< 'data_copy_ip_address' >> 7-Mode Ip address over which data is copied =item C<< 'multipath_ip_address' >> The multipathing IP address which is in use by the session =item C<< '_7_mode_version' >> 7-mode version =item C<< 'cluster_mode_system_version' >> C-mode version =item C<< 'snapmirror_schedule' >> 7-C snapmirror schedules =item C<< 'apply_configuration' >> Whether 7mode configurations has to be applied at cutover to Cmode =item C<< 'version' >> 7MTT version =item C<< 'primary_7_mode_details' >> Primary 7 mode details =item C<< 'secondary_cluster_details' >> Secondary cluster details =item C<< 'snapmirror_status' >> 7-C snapmirror relationships status =item C<< 'schedule_info' >> All the schedule information added to the session =item C<< 'lif_info' >> All the lif information added to the session =item C<< 'error_count' >> If any error present in the session =item C<< 'host_name' >> Host name of the 7-mode filer =item C<< 'svm_information' >> All the vserver information added to the session =item C<< 'target_volume_mount_policy' >> All the volume mount information added to the session =back =cut ################### # Package package NACL::CS::Client::Transition; ################### # 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::Exceptions::NoElementsFound qw(:try); use NACL::APISet::Exceptions::InvalidParamValueException qw(:try); use base 'NACL::CS::ComponentState::Client'; use Class::MethodMaker [ scalar => "session_name", scalar => "session_status", scalar => "session_state", scalar => "session_type", scalar => "vfiler_unit", scalar => "vserver_name", scalar => "vserver_comment", scalar => "cluster_mode_system_fqdn", scalar => "_7_mode_system_fqdn", scalar => "data_copy_ip_address", scalar => "multipath_ip_address", scalar => "_7_mode_version", scalar => "cluster_mode_system_version", scalar => "snapmirror_schedule", scalar => "apply_configuration", scalar => "version", scalar => "primary_7_mode_details", scalar => "secondary_cluster_details", array => "snapmirror_status", array => "schedule_info", array => "lif_info", scalar => "error_count", scalar => "svm_information", scalar => "target_volume_mount_policy", scalar => "host_name", scalar => "project_status", scalar => "project_type", scalar => "project_state", scalar => "project_name", ]; =head1 METHODS =head2 fetch my $trans_obj = NACL::CS::Client::Transition->fetch(command_interface=>$Client) my @trans_obj = NACL::CS::Client::Transition->fetch(command_interface=>$Client); my $trans_obj=NACL::CS::Client::Transition->fetch( command_interface => $Client, filter => {"session-name" => $session_name }, ); my @trans_obj=NACL::CS::Client::Transition->fetch( command_interface => $Client, filter => {"session_status" => "Preparation" }, ); my @trans_obj=NACL::CS::Client::Transition->fetch( command_interface => $Client, filter => {"session-name" => $session_name }, requested_fields => [ qw(session_type session_state ) ], ); my @trans_obj=NACL::CS::Client::Transition->fetch( command_interface => $Client, filter => {"session_name" => "S1*" }, requested_fields => [ qw(session_type session_name snapmirror_status) ], ); see L =cut sub fetch { $Log->enter(); my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::fetch( @args, choices => [ { method => "_fetch_smtt_cli", interface => "CLI", set => "SMTT" }, ], exception_text => 'No matching sessions found' ); $Log->exit(); return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_smtt_cli { $Log->enter(); my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my ( @state_objs, $caught_exception ); my %filter = %{$opts{filter}}; if (!defined $filter{session_name} && defined $filter{'session-name'}) { $filter{session_name} = delete $filter{'session-name'}; } if (!defined $filter{project_name} && defined $filter{'project-name'}) { $filter{project_name} = delete $filter{'session-name'}; } if ( exists $filter{'session_name'} ){ delete $filter{session_name} if ( $pkg->_check_relational_regex_filter(filter_value => $filter{session_name}) ); } my %req_field_filter = ( requested_fields => $opts{requested_fields}, filter => \%filter ); my ($need_to_provide_session, @session_names); if ($pkg->_want_any_field_of(%req_field_filter, fields_filled_by_api => [qw(vserver_comment multipath_ip_address data_copy_ip_address snapmirror_status schedule_info lif_info snapmirror_schedule version apply_configuration primary_7_mode_details cluster_mode_system_version 7_mode_version secondary_cluster_details)]) ) { $need_to_provide_session = 1; } if (defined $filter{session_name}) { $need_to_provide_session = 1; @session_names = $filter{session_name}; } if ($need_to_provide_session) { if (!@session_names) { # Get all session names by using transition_show and # populate @session_names my $output = $apiset->transition_show()->get_parsed_output(); foreach (@$output){ push @session_names , $_->{session_name} if($_->{session_name}); } } foreach my $session_name (@session_names) { try { my $response = $apiset->transition_show( 'session-name' => $session_name); my $only_row = $response->get_parsed_output()->[0]; my $obj = $pkg->new( command_interface => $opts{command_interface}, ); $obj->_set_fields( row => $only_row ); push @state_objs, $obj; } catch NACL::APISet::Exceptions::InvalidParamValueException with { $caught_exception = 1; }; } } else { try{ my $response = $apiset->transition_show(); my $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; } }catch NACL::APISet::Exceptions::InvalidParamValueException with { $caught_exception = 1; }; } $Log->exit(); return if $caught_exception; return @state_objs; } 1;