# # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary QosWorkloadStream ComponentState Module ## @author dl-nacl-dev@netapp.com, dl-perf-qa@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::QosWorkloadStream =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP QosWorkloadStream. A related class is L, which represents access to an ONTAP QosWorkloadStream. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the QosWorkloadStream element are the attributes of the QosWorkloadStream ComponentState. =over =item C<< workload >> The name of the QoS workload element whose state is being represented. =item C<< uuid >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< stream_id >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< vserver >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @value =item C<< volume >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @value =item C<< qtree >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @value =item C<< lun >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @value =item C<< protocol >> Filled in for CMode CLI. =item C<< ip >> Filled in for CMode CLI. =item C<< min_req_size >> Filled in for CMode CLI. =item C<< wwn >> Filled in for CMode CLI. =item C<< igroup >> Filled in for CMode CLI. =item C<< max_req_size >> Filled in for CMode CLI. =item C<< request_type >> Filled in for CMode CLI. =item C<< file >> Filled in for CMode CLI. =back =cut package NACL::CS::QosWorkloadStream; use strict; use warnings; 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::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'lun', scalar => 'qtree', scalar => 'stream_id', scalar => 'volume', scalar => 'vserver', scalar => 'uuid', scalar => 'workload', scalar => 'protocol', scalar => 'ip', scalar => 'min_req_size', scalar => 'wwn', scalar => 'igroup', scalar => 'max_req_size', scalar => 'request_type', scalar => 'file', ]; =head1 METHODS =head2 fetch my $workload_state = NACL::CS::QosWorkloadStream->fetch(command_interface=>$ci,...); my @workload_states = NACL::CS::QosWorkloadStream->fetch(command_interface=>$ci,...); see L Supports CMode CLI/ZAPI APIset. Invokes "qos-stream-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, @args) = @_; my @state_objs = $pkg->SUPER::fetch( @args, choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], exception_text => 'No matching qos workload stream(s) 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, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@args, api => 'qos_workload_stream_show'); $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $requested_fields = $opts{requested_fields}; # To get the value of "workload" we need the value of "uuid", so ensure it # is always populated. if (@$requested_fields) { unless (grep {/^uuid$/} @$requested_fields) { push @$requested_fields, 'uuid'; } } my @streams = $pkg->SUPER::_fetch_cmode_zapi( %opts, requested_fields => $requested_fields, api => 'qos_stream_get_iter', map => { 'uuid' => 'workload-uuid', 'stream-id' => 'stream-id', 'vserver' => [ "characteristics", make_zapi_skip("qos-stream-characteristics"), "vserver" ], 'volume' => [ "characteristics", make_zapi_skip("qos-stream-characteristics"), "volume", ], 'qtree' => [ "characteristics", make_zapi_skip("qos-stream-characteristics"), "qtree", ], 'lun' => [ "characteristics", make_zapi_skip("qos-stream-characteristics"), "lun", ], }, ); # We're invoking a ZAPI other than the -get-iter so we need to re-enable # _apply_filter. ${$opts{_apply_filter}} = 1; # "workload" is a primary key, so the CS object should always have # this populated, so unconditionally run this ZAPI. foreach my $stream (@streams) { my $response = $apiset->qos_workload_get('workload-uuid' => $stream->uuid()); my $output = $response->get_parsed_output(); my $workload = $output->[0]{'attributes'}[0]{'qos-workload-info'}[0] {'workload-name'}; $stream->workload($workload); } $Log->exit() if $may_exit; return @streams; } ## end sub _fetch_cmode_zapi 1;