# $Id$ # # Copyright (c) 2001-2014 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SystemLicenseEntitlementRisk ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SystemLicenseEntitlementRisk =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP SystemLicenseEntitlementRisk. A related class is L, which represents access to an ONTAP SystemLicenseEntitlementRisk. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SystemLicenseEntitlementRisk element are the attributes of the SystemLicenseEntitlementRisk ComponentState. Additionally, the command_interface used to obtain the ComponentState object is also an attribute of the object. This makes it easier to obtain the component object corresponding to the CS object, using L. =over =item command_interface The command_interface with which the CS object was obtained. (Available in all CS objects regardless of requested_fields and the mode/interface) =item C<< serial_number >> Node Serial Number Filled in for CMode CLI/ZAPI iter Mapping for CMode ZAPI iter: =item C<< is_licensed >> Is Node-Locked License Present possible value(s) are, true,false Filled in for CMode CLI/ZAPI iter Mapping for CMode ZAPI iter: =item C<< action_code >> Corrective Action Code possible value(s) are, acquire-license,verify-entitlement,verify-system-health,none Filled in for CMode CLI/ZAPI iter Mapping for CMode ZAPI iter: =item C<< action >> Corrective Action Filled in for CMode CLI/ZAPI iter =item C<< package >> Package Name Filled in for CMode CLI/ZAPI iter Mapping for CMode ZAPI iter: =item C<< node_name >> Node Name Filled in for CMode CLI/ZAPI iter Mapping for CMode ZAPI iter: =item C<< action >> Corrective Action Filled in for CMode CLI/ZAPI iter =item C<< in_use >> Usage Status possible value(s) are, true,false Filled in for CMode CLI/ZAPI iter Mapping for CMode ZAPI iter: =item C<< missing_serial_numbers >> Serial Numbers Missing a Node-Locked License (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $missing_serial_numbers = $obj->missing_serial_numbers(); # $missing_serial_numbers contains a reference to the array of values my @missing_serial_numbers = $obj->missing_serial_numbers(); # @missing_serial_numbers 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 => { missing_serial_numbers = [ value1, value2...] } Filled in for CMode CLI/ZAPI iter =item C<< risk >> Entitlement Risk possible value(s) are, high,medium,low,unlicensed,unknown Filled in for CMode CLI/ZAPI iter Mapping for CMode ZAPI iter: =item C<< missing_node_names >> Node Names Missing a Node-Locked License (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $missing_node_names = $obj->missing_node_names(); # $missing_node_names contains a reference to the array of values my @missing_node_names = $obj->missing_node_names(); # @missing_node_names 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 => { missing_node_names = [ value1, value2...] } Filled in for CMode CLI/ZAPI iter =back =cut package NACL::CS::SystemLicenseEntitlementRisk; use strict; use warnings; use Params::Validate qw(validate); use NATE::Log qw(log_global); 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 base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'serial_number', scalar => 'is_licensed', scalar => 'action_code', scalar => 'package', scalar => 'node_name', scalar => 'action', scalar => 'in_use', array => 'missing_serial_numbers', scalar => 'risk', array => 'missing_node_names', ]; my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); =head1 METHODS =head2 fetch my $SystemLicenseEntitlementRisk_state = NACL::CS::SystemLicenseEntitlementRisk->fetch(command_interface => $ci, ...); my @SystemLicenseEntitlementRisk_states = NACL::CS::SystemLicenseEntitlementRisk->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. Uses CMode CLI/ZAPI. Invokes license-v2-entitlement-risk-get-iter API for CMode ZAPI iter. =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, show_cmd => 'system license entitlement-risk show', choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', zapi_type => 'none', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', zapi_type => 'iter' }, ], exception_text => 'No matching SystemLicenseEntitlementRisk(s) found', frontend => 'NACL::CS::SystemLicenseEntitlementRisk::fetch', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _update_state_objs_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->SUPER::_update_state_objs_cmode_zapi(@args, zapi_field_translations => {hyphenate_value => [qw(action-code risk)],},); $Log->exit() if $may_exit; } sub _fetch_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@args, api => 'system_license_entitlement_risk_show',); $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @args, copy => [ qw(action-code package risk action ) ], map => { 'is-licensed' => [ make_zapi_array('node-license-usage'), make_zapi_skip('node-license-usage-info'), 'is-licensed', ], 'serial-number' => [ make_zapi_array('node-license-usage'), make_zapi_skip('node-license-usage-info'), 'serial-number', ], 'node-name' => [ make_zapi_array('node-license-usage'), make_zapi_skip('node-license-usage-info'), 'node-name', ], 'in-use' => [ make_zapi_array('node-license-usage'), make_zapi_skip('node-license-usage-info'), 'in-use', ], }, # # Burt 869005 has details of why this is needed. # In short, each row in the CLI is for a package on a particular node. # For the ZAPI, each row is for a particular package. So if there # are 2 nodes in the cluster, the CLI will show 2 rows, but the ZAPI # will only show one. (hence the CLI will return 2 CS objects, while # the ZAPI will return only 1) # To handle this, we modify the parsed output and expand the single # ZAPI row into multiple rows. # Example: # # Original parsed output: # { # 'action-code' => 'verify_entitlement', # 'node-license-usage' => [ # { # 'node-license-usage-info' => [ # { # 'in-use' => 'false', # 'is-licensed' => 'false', # 'node-name' => 'sti3220-210', # 'serial-number' => '1-81-0000000000000500000303583' # }, # { # 'in-use' => 'false', # 'is-licensed' => 'false', # 'node-name' => 'sti3220-209', # 'serial-number' => '1-81-0000000000000500000303624' # } # ] # } # ], # 'package' => 'nfs', # 'risk' => 'medium' # } # # Final parsed output: # [ # { # 'action-code' => 'verify_entitlement', # 'node-license-usage' => [ # { # 'node-license-usage-info' => [ # { # 'in-use' => 'false', # 'is-licensed' => 'false', # 'node-name' => 'sti3220-210', # 'serial-number' => '1-81-0000000000000500000303583' # } # ] # } # ], # 'package' => 'nfs', # 'risk' => 'medium' # }, # { # 'action-code' => 'verify_entitlement', # 'node-license-usage' => [ # { # 'node-license-usage-info' => [ # { # 'in-use' => 'false', # 'is-licensed' => 'false', # 'node-name' => 'sti3220-209', # 'serial-number' => '1-81-0000000000000500000303624' # } # ] # } # ], # 'package' => 'nfs', # 'risk' => 'medium' # } # ] # fix_records => sub { my %opts = @_; my $records = $opts{records}; my @new_records; foreach my $record (@$records) { my %record_deep_copy = %$record; my $node_license_usage = delete $record_deep_copy{'node-license-usage'}; my @license_usage_info = @{$node_license_usage->[0]{'node-license-usage-info'}}; foreach my $single_usage_info_hashref (@license_usage_info) { my %new_record = %record_deep_copy; $new_record{'node-license-usage'}[0]{'node-license-usage-info'} = [$single_usage_info_hashref]; push @new_records, \%new_record; } } return \@new_records; }, # make_zapi_array() makes the base-class think these fields are # array fields, but they're actually scalar fields. For example, # the values will be single-value arrays, like: # 'is-licensed' => [ 'true' ] # We fix this and store the values as scalars fix_response => sub { my %opts = @_; my $cli = $opts{cli}; foreach my $field (qw(is-licensed serial-number node-name in-use)) { if (defined $cli->{$field}) { $cli->{$field} = $cli->{$field}[0]; } } }, api => "license-v2-entitlement-risk-get-iter", ); $Log->exit() if $may_exit; return @state_objs; } 1;