Using a Perl Script to Access the NSM API
This example shows how to log into the server and retrieve system information for the
server.
#!/usr/bin/perl -w
use SOAP::Lite +trace => 'all';
#use SOAP::Lite;
delete $ENV{'https_proxy'};
use constant NS_XSD=> 'http://www.w3.org/1999/XMLSchema'; #XSD 1999 schema
use constant NS_XSI=> 'http://www.w3.org/1999/XMLSchema-instance'; #XSI 1999
schema
our @NSM_SERVERS = qw(
10.157.39.201:8443
8443
);
our $LOGIN_TOKEN;
sub soap_call($$$) {
my $service = shift;
my $method = shift;
my $input = shift;
my $nbi_method = "https://";
my $nbi_uri = "/axis2/services";
my $jp_url = "http://juniper.net/webproxy";
if ( !defined $main::ACTIVE_SERVER ) {
if ( scalar @main::NSM_SERVERS == 0 ) {
print ("Couldn't connect to any NSM Servers", "\n");
exit 1;
} else {
$main::ACTIVE_SERVER = shift @main::NSM_SERVERS;
}
}
my $nsm_url = qq|${nbi_method}${main::ACTIVE_SERVER}${nbi_uri}|;
my $soap_service = SOAP::Lite
-> proxy ("$nsm_url/$service")
-> uri ( "$jp_url/" . lc($service) )
-> on_fault (
sub {
if ( $_[0]->transport->status =~ /^503/ ) {
undef $main::ACTIVE_SERVER;
soap_call($service,$method,$input);
}
}
) ;
my $soap_method = SOAP::Data->name($method)->attr( {'xmlns' => "$jp_url/" .
lc($service),'xmlns:xsd'=>NS_XSD, 'xmlns:xsi'=>NS_XSI} );
# Execute and grab response
my $response;
77
Copyright © 2010, Juniper Networks, Inc.
Chapter 6: Installing the Perl Client Environment
Содержание NETWORK AND SECURITY MANAGER 2010.4 - API GUIDE REV 1
Страница 6: ...Copyright 2010 Juniper Networks Inc vi...
Страница 10: ...Copyright 2010 Juniper Networks Inc x Network and Security Manager 2010 4 API Guide...
Страница 12: ...Copyright 2010 Juniper Networks Inc xii Network and Security Manager 2010 4 API Guide...
Страница 20: ...Copyright 2010 Juniper Networks Inc 2 Network and Security Manager 2010 4 API Guide...
Страница 24: ...Copyright 2010 Juniper Networks Inc 6 Network and Security Manager 2010 4 API Guide...
Страница 34: ...Copyright 2010 Juniper Networks Inc 16 Network and Security Manager 2010 4 API Guide...
Страница 58: ...Figure 10 IDP Rulebase Copyright 2010 Juniper Networks Inc 40 Network and Security Manager 2010 4 API Guide...
Страница 92: ...Copyright 2010 Juniper Networks Inc 74 Network and Security Manager 2010 4 API Guide...
Страница 98: ...Copyright 2010 Juniper Networks Inc 80 Network and Security Manager 2010 4 API Guide...
Страница 100: ...Copyright 2010 Juniper Networks Inc 82 Network and Security Manager 2010 4 API Guide...
Страница 112: ...Copyright 2010 Juniper Networks Inc 94 Network and Security Manager 2010 4 API Guide...
Страница 128: ...Copyright 2010 Juniper Networks Inc 110 Network and Security Manager 2010 4 API Guide...
Страница 138: ...Copyright 2010 Juniper Networks Inc 120 Network and Security Manager 2010 4 API Guide...
Страница 152: ...Copyright 2010 Juniper Networks Inc 134 Network and Security Manager 2010 4 API Guide...
Страница 165: ...PART 6 Index Index on page 149 147 Copyright 2010 Juniper Networks Inc...
Страница 166: ...Copyright 2010 Juniper Networks Inc 148 Network and Security Manager 2010 4 API Guide...