# $Id$ # # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VserverFcp ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status public ## @pod here =head1 NAME NACL::CS::VserverFcp =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP VserverFcp. A related class is L, which represents access to an ONTAP VserverFcp. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the VserverFcp element are the attributes of the VserverFcp ComponentState. =over =item C<< "nodename" >> =item C<< "status_admin" >> Filled in for CMode CLI/ZAPI. =item C<< "vserver" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< "status" >> Filled in for CMode CLI, 7M CLI. 7M CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "force" >> Filled in for CMode CLI. =item C<< "status_oper" >> Filled in for CMode CLI. =item C<< "is_available" >> =item C<< "start" >> Filled in for CMode CLI. =item C<< target_name >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< vif_owner >> Filled in for CMode CLI. =item C<< uuid >> Filled in for CMode CLI. =item C<< vserver_uuid >> Filled in for CMode CLI. =item C<< is-available >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =back =cut package NACL::CS::VserverFcp; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw(Dumper _dump_one _optional_scalars); use Params::Validate qw(validate validate_with SCALAR ARRAYREF); use NACL::Exceptions::NoElementsFound qw(:try); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'nodename', scalar => 'status_admin', scalar => 'vserver', scalar => 'status', scalar => 'force', scalar => 'status_oper', scalar => 'is_available', scalar => 'start', scalar => 'target_name', scalar => 'vif_owner', scalar => 'uuid', scalar => 'vserver_uuid', ]; =head1 METHODS =head2 fetch my $VserverFcp_state = NACL::CS::VserverFcp->fetch(command_interface => $ci, ...); my @VserverFcp_states = NACL::CS::VserverFcp->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,7Mode CLI. Invokes "fcp-service-get-iter" API for CMode ZAPI. Invokes "fcp status" command for 7Mode CLI. =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( @_, show_cmd => 'vserver fcp show', choices => [ { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', }, { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], exception_text => 'No matching vserver fcp found' ); $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 => 'vserver_fcp_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) = @_; # If status-admin is in the filter then need to update the value to true/false # status-admin will be updated to is-available by map in the fetch call. if(exists $opts{filter}{'status-admin'}) { $opts{filter}{'status-admin'} = 'true' if ($opts{filter}{'status-admin'} eq 'up'); $opts{filter}{'status-admin'} = 'false' if ($opts{filter}{'status-admin'} eq 'down'); } # Perform the fetch call, the map will translate # status-admin and is-available into eachother. my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( %opts, api => 'fcp_service_get_iter', copy => [qw( is-available vserver)], map => {'target-name' => 'node-name', 'status-admin' => 'is-available'} ); # Loop through the cs object and ensure that the status-admin is set to up|down # Map will have already handles creating status-admin in the response foreach my $cs (@state_objs) { my $status_admin = $cs->status_admin(); if (defined $status_admin) { if ($status_admin eq 'true') { $cs->status_admin('up'); } elsif ($status_admin eq 'false') { $cs->status_admin('down'); } } } $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 @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 $apiset = delete $opts{apiset}; my $command_interface = delete $opts{command_interface}; my $response = $apiset->fcp_status(); my $output = $response->get_parsed_output(); if ($output->[0]->{'status'} eq "running") { $output->[0]->{'status'} = "up"; } else { $output->[0]->{'status'} = "down"; } my $list_output = $output->[0]; my $target = $pkg->_hash_copy( source => $list_output, copy => [qw(status)], ); my $obj = $pkg->new(command_interface => $command_interface); $obj->_set_fields(row => $target); push @state_objs, $obj; $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli 1;