sub checkCliBanConfiguration()

in AzureCloudExcellenceforSAP/azsapsca/patterns/AZSAP/cli-ban.pl [24:54]


sub checkCliBanConfiguration {
        SDP::Core::printDebug('> checkCliBanConfiguration', 'BEGIN');
        my $RCODE = 0;
        my $FILE_OPEN = 'ha.txt';
        my $SECTION = 'crm configure show';
        my @CONTENT = ();
        my $CONSTRAINT_COUNT = 0;

        if ( SDP::Core::getSection($FILE_OPEN, $SECTION, \@CONTENT) ) {
                foreach $_ (@CONTENT) {
                        next if ( m/^\s*$/ ); # Skip blank lines
                        if ( /cli-ban/i ) {
                            SDP::Core::printDebug('cli-ban location constraint', "Found");
                            $CONSTRAINT_COUNT++;
                        } elsif  ( /cli-prefer/i ) {
                            SDP::Core::printDebug('cli-prefer location constraint', "Found");
                            $CONSTRAINT_COUNT++;
                        }
                }
                if ( $CONSTRAINT_COUNT > 0 ) {
                    SDP::Core::updateStatus(STATUS_WARNING, "Found: cli-ban or cli-prefer location constraints");
                } else {
                    SDP::Core::updateStatus(STATUS_SUCCESS, "No cli-ban or cli-prefer location constraints found ")
                }

        } else {
                SDP::Core::updateStatus(STATUS_ERROR, "ERROR: checkCliBanConfiguration(): Cannot find \"$SECTION\" section in $FILE_OPEN");
        }
        SDP::Core::printDebug("< checkCliBanConfiguration", "Returns: $RCODE");
        return $RCODE;
}