Quantcast
Channel: THWACK: Popular Discussions - Orion SDK
Viewing all articles
Browse latest Browse all 3719

Perl REST - CustomProperty Set/Update Failing

$
0
0

This was working fine until July 7th. ? Anyway, I have been looking at this for hours now and can’t find the problem…..

 

 

Here is my function that I use to call the update:

 

sub orion_UpsertNodesCustomProperties() {

        my ( $self, $SWServer, $NodeID, $NodesCustomProperties ) = @_;

        if ( $NodeID * 1 > 0 ) {

 

            my $swhostname = $SWServer->{OrionServer}; # fill in a hostname

            my $swport     = $SWServer->{JSONPort};

            my $swprotocol = $SWServer->{Protocol};

            my $SWCredentials =

$self->get_credentials( $SWServer->{CredentialSetName} );

            my $username = $SWCredentials->{username};

            my $password =

$self->decrypt_password( $SWCredentials->{password} );

            #####

#https://servername:17778/SolarWinds/InformationService/v3/Json/swis://servername/Orion/Orion.Nodes/NodeID=469/CustomProperties

            my @elements = split( /\./, $swhostname );

            my $swhostname2 = $elements[0];

            my $uri =

"https://$swhostname:$swport/SolarWinds/InformationService/v3/Json/swis://$swhostname/Orion/Orion.Nodes/NodeID=$NodeID/CustomProperties";

            my $rest = REST::Client->new();

 

#$rest->setTimeout(5);

            #my $hostname = $self->orion_ip;

$rest->getUseragent()->proxy( ['https'] );

            my $headers = {

Authorization => 'Basic '

                  . MIME::Base64::encode_base64( $username . ':' . $password ),

                'Content-Type' => 'application/json'

            };

            my $json      = JSON->new->allow_nonref->utf8;

            my $json_text = $json->encode($NodesCustomProperties);

            print Dumper $json_text;

            #my $json_text = $json->space_after->encode({ 'Comments' => 'Testing' });

            my $response = $rest->POST( $uri, $json_text, $headers );

 

            print Dumper $response;

            while ( $response =~ m/Connect failed/ ) {

sleep(2);

                $response = $rest->POST( $uri, $json_text, $headers );

 

            }

 

            my $JSONResults = "";

            eval { $JSONResults = $json->decode( $rest->responseContent ); };

 

            #my @Results = ();

            return ($JSONResults);

 

        }

        else {

            printf( "ERROR: This is not a valid node id: %s\n", $NodeID );

            return (undef);

        }

 

    }

 

 

*****************************************************************************************************************************************************

 

 

 

 

Here is debug and error info:

 

Node 6091 does have custom properties...  I shall update them.

$VAR1 = '{"TNSDivision":"POS","City":"Lincoln","TNSCustomerDeviceName":"","TNSDeviceStatus":"Operational","TNSDeviceTicketID":"USDEV0000053908","State":"NE","TNSCustomer":"NETS","TNSOperationalOwner":"","TNSDeviceManufacturer":"JBM","TNSRegion":"Americas","TNSDeviceModel":"A2301","TNSSoakPeriodEndDate":"2013-05-09T09:34:06-04:00","TNSSiteID":"","TNSMonitoringProfile":"Ping Loopback 5 min and Ping Static IP","TNSSponsoredby":"","Region":"Region 1","TNSInstallType":"Customer Device","TNSDivision_Reporting":"Payments","TNSProduct":"TNSLink","TNSDeviceType":"IP-VPNR","TNSLastModifiedDate":"2015-01-21T19:43:33","TNSRefreshDate":"","Post_ZIP":"68516","TNSUserDefined2":"","TNSUserDefined3":"","TNSUserDefined1":"","Country":"USA","TNSCustomerSite":"nwr-s1","TNSSubDivision":"POS","TNSACNA":"NWR","TNSService":"ATMLink-WirelessVPN"}';

$VAR1 = bless( {

'_config' => {

                                'useragent' => bless( {

'max_redirect' => 7,

                                                        'ssl_opts' => {

'verify_hostname' => 0

},

                                                        'protocols_forbidden' => undef,

'show_progress' => undef,

'handlers' => {

                                                                        'response_header' => bless( [

{

'owner' => 'LWP::UserAgent::parse_head',

'callback' => sub { "DUMMY" },

'm_media_type' => 'html',

'line' => '/home/autoeng/lib/perl5/LWP/UserAgent.pm:684'

}

], 'HTTP::Config' )

},

'no_proxy' => [],

'protocols_allowed' => undef,

'local_address' => undef,

'use_eval' => 1,

'requests_redirectable' => [

                                                                                     'GET',

'HEAD'

],

'timeout' => 300,

'def_headers' => bless( {

'user-agent' => 'REST::Client/272'

                                                                                }, 'HTTP::Headers' ),

'proxy' => {},

'max_size' => undef

                                                      }, 'LWP::UserAgent' )

},

'_res' => bless( {

                                    '_protocol' => 'HTTP/1.1',

                                    '_content' => '{"Message":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","FullException":"System.NullReferenceException: Object reference not set to an instance of an object.\\u000d\\u000a   at SolarWinds.InformationService.Core.SwisUriResolver.BuildQuery(IEnumerable`1 uris, Dictionary`2 queryParameters, IEnumerable`1 properties)\\u000d\\u000a   at SolarWinds.InformationService.Core.SwisUriResolver.<Resolve>d__15.MoveNext()\\u000d\\u000a   at SolarWinds.InformationService.Core.CrudProcessor.<ResolveAndPackQueryResultsForUpdate>d__44.MoveNext()\\u000d\\u000a   at SolarWinds.InformationService.Core.CrudProcessor.UpdateInternal(Boolean bulkMode, SwisUriResolver uriResolver, IDictionary`2 propertiesToUpdate, IQueryExecutionContext context)\\u000d\\u000a at SolarWinds.InformationService.Core.CrudProcessor.Update(IServiceHost serviceHost, SwisUri uri, IDictionary`2 propertiesToUpdate, IQueryExecutionContext context)\\u000d\\u000a at SolarWinds.InformationService.Core.InformationService.Update(String uri, IDictionary`2 propertiesToUpdate)"}',

                                    '_rc' => '400',

                                    '_headers' => bless( {

'client-response-num' => 1,

'date' => 'Tue, 21 Jul 2015 17:43:40 GMT',

'client-ssl-cert-issuer' => '/CN=SolarWinds-Orion',

                                                           'client-ssl-cipher' => 'ECDHE-RSA-AES256-SHA384',

'client-peer' => '10.64.223.171:17778',

'content-length' => '1083',

'::std_case' => {

'client-date' => 'Client-Date',

'client-ssl-warning' => 'Client-SSL-Warning',

'client-response-num' => 'Client-Response-Num',

                                                                             'client-ssl-cert-subject' => 'Client-SSL-Cert-Subject',

'client-ssl-cert-issuer' => 'Client-SSL-Cert-Issuer',

'client-ssl-cipher' => 'Client-SSL-Cipher',

'client-peer' => 'Client-Peer',

'client-ssl-socket-class' => 'Client-SSL-Socket-Class'

},

'client-date' => 'Tue, 21 Jul 2015 17:43:40 GMT',

'client-ssl-warning' => 'Peer certificate not verified',

'content-type' => 'application/json',

                                                           'client-ssl-cert-subject' => '/CN=SolarWinds-Orion',

'server' => 'Microsoft-HTTPAPI/2.0',

'client-ssl-socket-class' => 'Net::SSL'

}, 'HTTP::Headers' ),

                                    '_msg' => 'Bad Request',

                                    '_request' => bless( {

                                                           '_content' => '{"TNSDivision":"POS","City":"Lincoln","TNSCustomerDeviceName":"","TNSDeviceStatus":"Operational","TNSDeviceTicketID":"USDEV0000053908","State":"NE","TNSCustomer":"NETS","TNSOperationalOwner":"","TNSDeviceManufacturer":"JBM","TNSRegion":"Americas","TNSDeviceModel":"A2301","TNSSoakPeriodEndDate":"2013-05-09T09:34:06-04:00","TNSSiteID":"","TNSMonitoringProfile":"Ping Loopback 5 min and Ping Static IP","TNSSponsoredby":"","Region":"Region 1","TNSInstallType":"Customer Device","TNSDivision_Reporting":"Payments","TNSProduct":"TNSLink","TNSDeviceType":"IP-VPNR","TNSLastModifiedDate":"2015-01-21T19:43:33","TNSRefreshDate":"","Post_ZIP":"68516","TNSUserDefined2":"","TNSUserDefined3":"","TNSUserDefined1":"","Country":"USA","TNSCustomerSite":"nwr-s1","TNSSubDivision":"POS","TNSACNA":"NWR","TNSService":"ATMLink-WirelessVPN"}',

'_uri' => bless( do{\(my $o = 'https://asbwpnmsswp01.win2k.corp.tnsi.com:17778/SolarWinds/InformationService/v3/Json/swis://asbwpnmsswp01.win2k.corp.tnsi.com/Orion/Orion.Nodes/NodeID=6091/CustomProperties')}, 'URI::https' ),

'_headers' => bless( {

'user-agent' => 'REST::Client/272',

'content-type' => 'application/json',

                                                                                  'content-length' => 824,

'::std_case' => {

'if-ssl-cert-subject' => 'If-SSL-Cert-Subject'

},

'authorization' => 'Basic YXV0b2JvdG9yaW9uOk1lZUZhSDAwY2g6

'

}, 'HTTP::Headers' ),

'_method' => 'POST',

'_uri_canonical' => $VAR1->{'_res'}{'_request'}{'_uri'}

}, 'HTTP::Request' )

                                  }, 'HTTP::Response' )

               }, 'REST::Client' );

Update WorldMap.Point entry in the database

Deciding whether or not to manage device nwr37127v...

Deciding what to do with Manage/Unmanage automatically

Everything else checks out, so it's all about DeviceStatus...

Device USDEV0000053908 nwr37127v is of Device Status of Operational - No change as per Hasmukh Patel 4/29/2015.

Determined a managed state of >NoChange< for NodeID 6091

[autoeng@rstlcnscweb01 OrionIntegration]$


Viewing all articles
Browse latest Browse all 3719

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>