Infoblox Exchange Cybersecurity Roadshow 2020 – Join us!
North America | Europe | Middle East/Africa | Asia-Pacific

Security

Reply

Automatic API Module Update

DBotham
Techie
Posts: 10
1105     0

Here is a sub that might help:

sub init_session {
    ############################################
    # Usage      : init_session()
    # Purpose    : Initialize / Re-initialize the Infoblox:Smiley Frustratedession
    # Returns    : The Infoblox:Smiley Frustratedession object.
    # Parameters : See class attributes list.
    # Throws     : Fatal exception on failure.
    # Comments   : none
    # See Also   : n/a

    my ($args_href)  = @_;
    
    my $requested_return_value = defined $args_href->{return} ? $args_href->{return} : '';
    
    if ($dryrun) {
        pslog("Skipping initialization of Session. dry_run!", $WARNING);
        return $TRUE;
    }
    # Values for attributes passed into this call override those that are
    # already stored in the class attributes.
    my $gmip       = defined $args_href->{gmip}     ? $args_href->{gmip}     : '';
    my $username   = defined $args_href->{username} ? $args_href->{username} : '';
    my $password   = defined $args_href->{password} ? $args_href->{password} : '';

    # Now, intialize the method variables from the Class attributes.
    # Determine if required attributes are missing, and what those are.
    my $session_request_status
        = $gmip  && $username   && $password    ? $OK
        : !$gmip && !$username  && !$password   ? $NONE
        : !$gmip && $username   && $password    ? 'Missing Grid Master IP'
        : !$gmip && !$username  && $password    ? 'Missing Grid Master IP & Username'
        : $gmip  && !$username  && $password    ? 'Missing Username'
        : $gmip  && !$username  && !$password   ? 'Missing Username & Password'
        : $gmip  && $username   && !$password   ? 'Missing Password'
        :                                         'Missing Grid Master IP & Password'
        ;
    if ($session_request_status eq $OK) {
        pslog("Attempting to initialize session with Grid at IP '$gmip', for user '$username'.", $INFO);
        $session = Infoblox:Smiley Frustratedession->new(
            master      => $gmip,
            username    => $username,
            password    => $password,
        );
        my $failure_code = $session->status_code();
        
        if (!$failure_code) {
            pslog("Opened session to Grid Master at IP '$gmip', for user '$username'.", $INFO);
            return  $requested_return_value eq 'username' ?  $username
                    :                                        $session
                    ;

        }
        else {
            my $failure_description = $session->status_detail();
            
            if ($^O eq 'MSWin32') {
                if ($failure_description =~ m{version\s+of\s+perl\s+module\s+\[.+\]\s+doesn't\s+match}xmsi) {
                        pslog("Your Infoblox Perl Module version does not match that of the Grid.  Attempting to synchronize...", $CRITICAL);
                        my $upgrade_module_results = `ppm install --force https://$gmip/api/dist/ppm/Infoblox.ppd`;
                        pslog("Upgrade attempt complete.  Attempting to re-connect.", $CRITICAL);
                        pslog("Sync of Infoblox.pm is complete.  Re-Execute your application!", $CRITICAL);
                        exit;
                }
            }
            croak "Failed to open session with Grid Master at IP '$gmip', for user '$username': ($failure_code: $failure_description)";
        }
    }
    elsif ( !($session_request_status eq $NONE) ) {
        croak "One or more required arguments are missing to intialize an Infoblox Session: '$session_request_status'";
    }

}

 

http://www.infoblox.com/community/downloads/automatic-api-module-update

Showing results for 
Search instead for 
Do you mean 

Recommended for You