Brocade Virtual ADX OpenScript Programmer’s Guide (Support Manuale Utente Pagina 18

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 30
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 17
10 Brocade Virtual ADX OpenScript Programmer’s Guide
53-1003244-01
Sample scripts
2
Sample scripts
The following examples provide two different approaches to creating a script for the same purpose.
The first example provides a heavily commented example for high readability and the second is a
“power-user” version of the script. It is much more compact with less extensive notation. Both
scripts provide for load-balancing using a URL match in an HTTP GET request.
High readability script example
The following example provides a version of the script that demonstrates high-readability.
# Elegant load balancer with good readability
# Performs server selection based on URI in HTTP
# Request Header
# Tell the script about extensions used in this program
use OS_HTTP_Request;
use OS_SLB;
use strict;
use Sub::StrictDecl;
sub HTTP_REQUEST
{
#Get an HTTP request object to manage
# request headers or content.
# Pattern we want to match…..
$url_pattern = "index.html";
# …. with pattern data in packet
$url_in_request = OS_HTTP_REQUEST::url;
# Perform a Regular Expression Search.
if ($url_in_request =~ m/$uri_pattern/) {
# Forward to a real server identified by name
OS_SLB::forward("RS1");
} else {
# Forward to a real-server group identified by numeric ID
OS_SLB::forward(2);
}
}
Vedere la pagina 17
1 2 ... 13 14 15 16 17 18 19 20 21 22 23 ... 29 30

Commenti su questo manuale

Nessun commento