Here is the code that is causing the error.
use strict;
use Getopt::Long;
use NaServer;
use WFAUtil;
my $cluster;
GetOptions(
"Cluster=s" => \$cluster
) or die 'Illegal command parameters\n';
my $wfaUtil = WFAUtil->new();
$wfaUtil->sendLog('INFO',"Connecting to cluster");
my $server = $wfaUtil->connect($cluster);
$wfaUtil->sendLog('INFO',"Rename root aggregate ");
my @aggrList = aggrGetInfo();
foreach my $aggrDetails (@aggrList) {
my ($aggregate, $aggregateOwner, $aggrDiskCount, $aggrIsRoot) = split (/,/,$aggrDetails);
my $newAggrName = $aggregateOwner . "_root";
if ($aggrIsRoot =~ m/true/) {
if ($aggregate =~ m/$newAggrName/) {
$wfaUtil->sendLog('INFO',"Root aggregate for $aggregateOwner is named correctly.\n");
}
else {
#Rename aggregate
$newAggrName=~s/-/_/g;
$wfaUtil->sendLog('INFO', "Rename of aggregate $aggregate to $newAggrName ");
$server->aggr_rename('aggregate', $aggregate,'new-aggregate-name',$newAggrName);
$wfaUtil->sendLog('INFO', 'Rename of a aggregate operation completed successfully.');
}
#Fix root aggregate diskcount
if ($aggrDiskCount < 5 ) {
my $addDisks = 5 - $aggrDiskCount,;
$server->aggr_add('aggregate', $newAggrName,'disk-count',$addDisks);
$wfaUtil->sendLog('INFO', 'Rename of a aggregate operation completed successfully.');
}
}
}
sub aggrGetInfo {
# Initialize variables
my @aggrs;
my $aggrOwner;
my $in = $server->aggr_get_iter();
# Proccess the attributes
foreach my $aggrInfo (@{$in->{'attributes-list'}->{'aggr-attributes'}}) {
my $aggrName = $aggrInfo->{'aggregate-name'};
if (my $aggrOwnerAttrs = $aggrInfo->{'aggr-ownership-attributes'}) {
$aggrOwner = $aggrOwnerAttrs->{'owner-name'};
}
if (my $aggrRaidAttrs = $aggrInfo->{'aggr-raid-attributes'}) {
my $aggrIsRoot = $aggrRaidAttrs->{'has-local-root'};
my $aggrDiskCount = $aggrRaidAttrs->{'disk-count'};
my $aggrNameAndOwner = "$aggrName,$aggrOwner,$aggrDiskCount,$aggrIsRoot";
push (@aggrs, $aggrNameAndOwner);
}
}
return (@aggrs);
}