├── .idea
├── .name
├── encodings.xml
├── iControl-GettingStarted.iml
├── misc.xml
├── modules.xml
└── vcs.xml
├── REST-CreatePoolInPartition.js
├── REST-CreatePoolInPartition.pl
├── REST-CreatePoolInPartition.ps1
├── REST-CreatePoolInPartition.py
├── REST-DataGroup.js
├── REST-DataGroup.pl
├── REST-DataGroup.ps1
├── REST-DataGroup.py
├── REST-Stats.js
├── REST-Stats.ps1
├── REST-Stats.py
├── REST-system.ps1
├── REST-system.py
├── SOAP-CreatePoolInPartition.java
├── SOAP-CreatePoolInPartition.pl
├── SOAP-CreatePoolInPartition.ps1
├── SOAP-CreatePoolInPartition.py
├── SOAP-DataGroup.pl
├── SOAP-DataGroup.ps1
├── SOAP-DataGroup.py
├── SOAPCreatePoolInPartition.java
├── SOAPDataGroup.java
├── ignoreSSL.ps1
├── lib
├── activation.jar
├── axis-ant.jar
├── axis.jar
├── commons-discovery-0.2.jar
├── commons-discovery.jar
├── commons-logging-1.0.4.jar
├── commons-logging.jar
├── iControl.jar
├── jaxrpc.jar
├── log4j-1.2.8.jar
├── log4j.jar
├── mail.jar
├── saaj.jar
├── wsdl4j-1.5.1.jar
└── wsdl4j.jar
└── makejava.sh
/.idea/.name:
--------------------------------------------------------------------------------
1 | iControl-GettingStarted
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/iControl-GettingStarted.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Buildout
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/REST-CreatePoolInPartition.js:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/node
2 |
3 | //=========================================================
4 | //
5 | //=========================================================
6 | var net = require('net');
7 | var stdio = require('stdio');
8 | var https = require('https');
9 | var net = require('net');
10 | var url = require('url');
11 | var request = require('request');
12 | var util = require('util');
13 |
14 | var ops = stdio.getopt({
15 | 'bigip' : { key: 'b', args: 1, description: 'BIG-IP address', default: 'bigip.joesmacbook.com'},
16 | 'user' : { key: 'u', args: 1, description: 'Username', default: 'admin'},
17 | 'pass' : { key: 'p', args: 1, description: 'Password', default: 'admin'},
18 | 'pool' : { key: 'o', args: 1, description: 'Pool'},
19 | 'partition' : { key: 'a', args: 1, description: 'Partition'},
20 | 'debug' : { key: 'd', description: 'Print Debug Messages'}
21 | });
22 |
23 | var BIGIP = ops.bigip;
24 | var USER = ops.user;
25 | var PASS = ops.pass;
26 | var POOL = ops.pool;
27 | var PARTITION = ops.partition;
28 | var DEBUG = ops.debug;
29 |
30 | var args = ops.args;
31 |
32 |
33 | //--------------------------------------------------------
34 | function buildUrl(resource) {
35 | //--------------------------------------------------------
36 | return "https://" + BIGIP + resource;
37 | }
38 |
39 | //--------------------------------------------------------
40 | function getAuthToken(callback) {
41 | //--------------------------------------------------------
42 | var resource = "/mgmt/shared/authn/login";
43 | var user = USER;
44 | var pass = PASS;
45 | var body = "{'username':'" + user + "','password':'" + pass + "','loginProviderName':'tmos'}";
46 |
47 | httpRequest("POST", resource, body, user, pass, null, function(json) {
48 | var obj = JSON.parse(json);
49 | var token = obj["token"]["token"];
50 | callback(token);
51 | });
52 | }
53 |
54 | //--------------------------------------------------------
55 | function httpRequest(verb, resource, body, user, pass, token, callback) {
56 | //--------------------------------------------------------
57 |
58 | if ( DEBUG ) { console.log("\n: " + resource + "\n"); }
59 |
60 | var http_opts = {
61 | host: BIGIP,
62 | method: verb,
63 | port: 443,
64 | rejectUnauthorized: 0,
65 | path: resource
66 | };
67 |
68 | var http_headers = {
69 | 'Content-Type': 'application/json'
70 | };
71 |
72 | // Authentication Method
73 | if ( user && pass ) { http_opts["auth"] = user + ":" + pass; }
74 | else if ( token ) { http_headers["X-F5-Auth-Token"] = token; }
75 |
76 | // BODY?
77 | if ( body ) { http_headers["Content-Length"] = body.length; }
78 |
79 | http_opts["headers"] = http_headers;
80 |
81 | var content = "";
82 | var req = https.request(http_opts, function(res) {
83 | res.setEncoding("utf8");
84 | res.on('data', function(chunk) {
85 | content += chunk;
86 | }),
87 | res.on('end', function() {
88 | callback(content);
89 | })
90 | });
91 |
92 | req.on('error', function(e) {
93 | console.log("ERROR: " + JSON.stringify(e) + "\n");
94 | });
95 |
96 | if ( body ) {
97 | req.write(body + "\n");
98 | }
99 | req.end();
100 | }
101 |
102 |
103 | //--------------------------------------------------------
104 | function handleVERB(verb, resource, body, callback) {
105 | //--------------------------------------------------------
106 | getAuthToken( function(token) {
107 | httpRequest(verb, resource, body, null, null, token, function(json) {
108 | callback(json);
109 | });
110 | });
111 | }
112 |
113 |
114 | function handleGetPoolList(callback) {
115 | var uri = "/mgmt/tm/ltm/pool";
116 | handleVERB("GET", uri, null, function(json) {
117 | callback(json);
118 | });
119 | }
120 |
121 | function handleCreatePool(pool, partition, callback) {
122 | var uri = "/mgmt/tm/ltm/pool";
123 | var body = '{"name":"' + pool + '", "partition":"' + partition + '"}';
124 |
125 | console.log("BODY: " + body);
126 | handleVERB("POST", uri, body, function(json) {
127 | callback(json);
128 | });
129 | }
130 |
131 | //========================================================
132 | //
133 | //========================================================
134 |
135 | if ( (null == POOL) || (PARTITION == null) ) {
136 | handleGetPoolList(function(json) {
137 | var obj = JSON.parse(json);
138 | var items = obj.items;
139 | var len = items.length;
140 | console.log("POOL NAMES");
141 | console.log("==========");
142 | for(var i=0; inew->allow_nonref;
17 |
18 | my $BIGIP = "";
19 | my $USER = "";
20 | my $PASS = "";
21 | my $POOL = "";
22 | my $PARTITION = "";
23 | my $AUTH_TOKEN = "";
24 | my $RESOURCE = "";
25 | my $DEBUG = 0;
26 |
27 | GetOptions(
28 | 'bigip=s' => \$BIGIP,
29 | "user=s" => \$USER,
30 | "pass=s" => \$PASS,
31 | "user=s" => \$USER,
32 | "pool=s" => \$POOL,
33 | "partition=s" => \$PARTITION,
34 | "debug" => \$DEBUG
35 | );
36 |
37 | sub usage() {
38 | print "Usage: REST-CreatePoolInPartition.pl [options] \n";
39 | print " options\n";
40 | print " ----------------\n";
41 | print " --bigip bigip_addr\n";
42 | print " --user bigip_username\n";
43 | print " --pass bigip_password\n";
44 | print " --pool pool_name\n";
45 | print " --partition partition_name\n";
46 | print "\n";
47 | exit();
48 | };
49 |
50 | #---------------------------------------------------
51 | sub getAuthToken() {
52 | #---------------------------------------------------
53 | $url = "https://${BIGIP}/mgmt/shared/authn/login";
54 | $user = $USER;
55 | $pass = $PASS;
56 |
57 | $body = "{'username':'$user','password':'$pass','loginProviderName':'tmos'}";
58 |
59 | $json = postHttpRequest($url, $body, 1);
60 |
61 | $obj = decode_json($json);
62 | $AUTH_TOKEN = $obj->{token}->{token};
63 |
64 | if ( $DEBUG ) {
65 | print "TOKEN: $AUTH_TOKEN\n";
66 | }
67 |
68 | return $AUTH_TOKEN;
69 | }
70 |
71 | #---------------------------------------------------
72 | sub getHttpRequest() {
73 | #---------------------------------------------------
74 | my ($url) = (@_);
75 |
76 | if ( $DEBUG ) {
77 | print "REQUESTING URL : ${url}\n";
78 | }
79 |
80 | $content = "";
81 | if ( $url ) {
82 | my $ua = LWP::UserAgent->new;
83 | my $req = HTTP::Request->new(GET => $url);
84 | #$req->authorization_basic($USER, $PASS);
85 | my $auth_token = &getAuthToken();
86 | if ( "" ne $auth_token ) {
87 | $req->header("X-F5-Auth-Token" => $auth_token);
88 | }
89 |
90 | $resp = $ua->request($req);
91 | if ( $DEBUG ) {
92 | print Dumper($resp);
93 | }
94 |
95 | if ( $resp->is_success ) {
96 | $content = $resp->content;
97 | #print "CONTENT: ${content}\n";
98 | } else {
99 | $code = $resp->code;
100 | $msg = $resp->message;
101 | $content = $resp->content;
102 | die "HTTP ERROR ${code} : \"${msg}\" : \"${content}\"\n";
103 | }
104 | }
105 | return $content;
106 | }
107 |
108 | #---------------------------------------------------
109 | sub postHttpRequest() {
110 | #---------------------------------------------------
111 | my ($url, $body, $basicauth) = (@_);
112 |
113 | if ( $DEBUG ) {
114 | print "REQUESTING URL (POST) : ${url}\n";
115 | }
116 |
117 | $content = "";
118 | if ( $url ) {
119 | my $ua = LWP::UserAgent->new;
120 | my $req = HTTP::Request->new(POST => $url);
121 |
122 | if ( $basicauth == 1 ) {
123 | $req->authorization_basic($USER, $PASS);
124 | } else {
125 | my $auth_token = &getAuthToken();
126 | if ( "" ne $auth_token ) {
127 | $req->header("X-F5-Auth-Token" => $auth_token);
128 | }
129 | }
130 |
131 | $req->header("Content-Type" => "application/json");
132 | $req->content($body);
133 |
134 | $resp = $ua->request($req);
135 | if ( $DEBUG ) {
136 | print Dumper($resp);
137 | }
138 |
139 | if ( $resp->is_success ) {
140 | $content = $resp->content;
141 | #print "CONTENT: ${content}\n";
142 | } else {
143 | $code = $resp->code;
144 | $msg = $resp->message;
145 | $content = $resp->content;
146 | die "HTTP ERROR ${code} : \"${msg}\" : \"${content}\"\n";
147 | }
148 | }
149 | return $content;
150 | }
151 |
152 | #---------------------------------------------------
153 | sub buildURL() {
154 | #---------------------------------------------------
155 | my ($resource) = @_;
156 |
157 | $url = "https://${BIGIP}/$resource";
158 |
159 | return $url;
160 | }
161 |
162 | #---------------------------------------------------
163 | sub handleGET() {
164 | #---------------------------------------------------
165 | my ($resource) = @_;
166 |
167 | $url = &buildURL($resource);
168 |
169 | $resp = &getHttpRequest($url);
170 |
171 | return $resp;
172 | }
173 |
174 | #---------------------------------------------------
175 | sub handlePOST() {
176 | #---------------------------------------------------
177 | my ($resource, $body) = @_;
178 |
179 | if ( $body eq "" ) { &usage(); }
180 |
181 | $url = &buildURL($resource);
182 |
183 | $resp = &postHttpRequest($url, $body);
184 |
185 | return $resp;
186 | }
187 |
188 | #---------------------------------------------------
189 | sub getPoolList() {
190 | #---------------------------------------------------
191 | $resp_json = &handleGET("/mgmt/tm/ltm/pool");
192 | $resp = decode_json($resp_json);
193 | @items = @{$resp->{"items"}};
194 |
195 | print "POOL NAMES\n";
196 | print "----------\n";
197 | foreach $item (@items) {
198 | $fullPath = $item->{"fullPath"};
199 | print " $fullPath\n";
200 | print Dumper($item);
201 | }
202 | }
203 |
204 | #---------------------------------------------------
205 | sub createPool() {
206 | #---------------------------------------------------
207 | my ($pool, $partition) = @_;
208 |
209 | my $poolObj;
210 | $poolObj->{"name"} = $pool;
211 | $poolObj->{"partition"} = $partition;
212 |
213 | my $json = encode_json($poolObj);
214 |
215 | print "JSON: $json\n";
216 | exit();
217 |
218 | $resp = &handlePOST("/mgmt/tm/ltm/pool", $json);
219 |
220 | print Dumper($resp);
221 | }
222 |
223 |
224 |
225 | #===================================================
226 |
227 | #===================================================
228 |
229 |
230 | if ( ($BIGIP eq "") || ($USER eq "") || ($PASS eq "") ) {
231 | &usage();
232 | } else {
233 | if ( ($POOL eq "") || ($PARTITION eq "") ) {
234 | &getPoolList($POOL, $PARTITION);
235 | } else {
236 | &createPool($POOL, $PARTITION);
237 | }
238 | }
239 |
--------------------------------------------------------------------------------
/REST-CreatePoolInPartition.ps1:
--------------------------------------------------------------------------------
1 | #----------------------------------------------------------------------------
2 | # The contents of this file are subject to the "END USER LICENSE AGREEMENT
3 | # FOR F5 Software Development Kit for iControl"; you may not use this file
4 | # except in compliance with the License. The License is included in the
5 | # iControl Software Development Kit.
6 | #
7 | # Software distributed under the License is distributed on an "AS IS"
8 | # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9 | # the License for the specific language governing rights and limitations
10 | # under the License.
11 | #
12 | # The Original Code is iControl Code and related documentation
13 | # distributed by F5.
14 | #
15 | # The Initial Developer of the Original Code is F5 Networks,
16 | # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2009
17 | # F5 Networks, Inc. All Rights Reserved. iControl (TM) is a registered
18 | # trademark of F5 Networks, Inc.
19 | #
20 | # Alternatively, the contents of this file may be used under the terms
21 | # of the GNU General Public License (the "GPL"), in which case the
22 | # provisions of GPL are applicable instead of those above. If you wish
23 | # to allow use of your version of this file only under the terms of the
24 | # GPL and not to allow others to use your version of this file under the
25 | # License, indicate your decision by deleting the provisions above and
26 | # replace them with the notice and other provisions required by the GPL.
27 | # If you do not delete the provisions above, a recipient may use your
28 | # version of this file under either the License or the GPL.
29 | #----------------------------------------------------------------------------
30 | param(
31 | [string]$Bigip = "",
32 | [string]$User = "",
33 | [string]$Pass = "",
34 | [string]$Pool = "",
35 | [string]$Partition = ""
36 | );
37 |
38 | #----------------------------------------------------------------------------
39 | function Get-PoolList()
40 | #----------------------------------------------------------------------------
41 | {
42 | $uri = "/mgmt/tm/ltm/pool";
43 | $link = "https://$Bigip$uri";
44 | $headers = @{};
45 | $headers.Add("ServerHost", $Bigip);
46 |
47 | $secpasswd = ConvertTo-SecureString $Pass -AsPlainText -Force
48 | $mycreds = New-Object System.Management.Automation.PSCredential ($User, $secpasswd)
49 |
50 | $obj = Invoke-RestMethod -Method GET -Headers $headers -Uri $link -Credential $mycreds
51 | $items = $obj.items;
52 | Write-Host "POOL NAMES";
53 | Write-Host "----------";
54 | for($i=0; $i -lt $items.length; $i++) {
55 | $name = $items[$i].fullPath;
56 | Write-Host " $name";
57 | }
58 | }
59 |
60 | #----------------------------------------------------------------------------
61 | function Create-Pool()
62 | #
63 | # Description:
64 | # This function creates a new pool if the given pool name doesn't
65 | # already exist.
66 | #
67 | # Parameters:
68 | # Name - The Name of the pool you wish to create.
69 | # Partition - The name of the partition to place the pool in.
70 | #----------------------------------------------------------------------------
71 | {
72 | param(
73 | [string]$Name,
74 | [string]$Partition
75 | );
76 |
77 | $uri = "/mgmt/tm/ltm/pool";
78 | $link = "https://$Bigip$uri";
79 | $headers = @{};
80 | $headers.Add("ServerHost", $Bigip);
81 | $headers.Add("Content-Type", "application/json");
82 | $obj = @{
83 | name=$Name
84 | partition=$Partition
85 | };
86 | $body = $obj | ConvertTo-Json
87 |
88 | $secpasswd = ConvertTo-SecureString $Pass -AsPlainText -Force
89 | $mycreds = New-Object System.Management.Automation.PSCredential ($User, $secpasswd)
90 |
91 | $obj = Invoke-RestMethod -Method POST -Uri $link -Headers $headers -Credential $mycreds -Body $body;
92 |
93 | Write-Host "Pool ${Name} created in partition ${Partition}"
94 | }
95 |
96 | #----------------------------------------------------------------------------
97 | function Show-Usage()
98 | #
99 | # Description:
100 | # This function will print the script usage information.
101 | #
102 | #----------------------------------------------------------------------------
103 | {
104 | Write-Host @"
105 | Usage: CreatePoolInPartition.ps1 Arguments
106 | Argument - Description
107 | ---------- -----------
108 | Bigip - The ip/hostname of your BIG-IP.
109 | User - The Managmenet username for your BIG-IP.
110 | Pass - The Management password for your BIG-IP.
111 | Pool - The Name of the pool to create.
112 | Partition - The Partition to place the pool in.
113 | "@;
114 | }
115 |
116 | #============================================================================
117 | # Main application logic
118 | #============================================================================
119 | if ( ($Bigip.Length -eq 0) -or ($User.Length -eq 0) -or ($Pass.Length -eq 0) ) {
120 | Show-Usage;
121 | } else {
122 | if ( ($Pool.Length -eq 0) -or ($Partition.Length -eq 0) ) {
123 | Get-PoolList;
124 | } else {
125 | Create-Pool -Name $Pool -Partition $Partition;
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/REST-CreatePoolInPartition.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | '''
3 | # The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5
4 | # Software Development Kit for iControl"; you may not use this file except in
5 | # compliance with the License. The License is included in the iControl
6 | # Software Development Kit.
7 | #
8 | # Software distributed under the License is distributed on an "AS IS"
9 | # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
10 | # the License for the specific language governing rights and limitations
11 | # under the License.
12 | #
13 | # The Original Code is iControl Code and related documentation
14 | # distributed by F5.
15 | #
16 | # The Initial Developer of the Original Code is F5 Networks,
17 | # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2004 F5 Networks,
18 | # Inc. All Rights Reserved. iControl (TM) is a registered trademark of F5 Networks, Inc.
19 | #
20 | # Alternatively, the contents of this file may be used under the terms
21 | # of the GNU General Public License (the "GPL"), in which case the
22 | # provisions of GPL are applicable instead of those above. If you wish
23 | # to allow use of your version of this file only under the terms of the
24 | # GPL and not to allow others to use your version of this file under the
25 | # License, indicate your decision by deleting the provisions above and
26 | # replace them with the notice and other provisions required by the GPL.
27 | # If you do not delete the provisions above, a recipient may use your
28 | # version of this file under either the License or the GPL.
29 | '''
30 |
31 |
32 |
33 | def get_pool_list(bigip, url):
34 | try:
35 | pools = bigip.get("%s/ltm/pool" % url).json()
36 | print "POOL LIST"
37 | print " ---------"
38 | for pool in pools['items']:
39 | print " /%s/%s" % (pool['partition'], pool['name'])
40 | except Exception, e:
41 | print e
42 |
43 |
44 | def create_pool(bigip, url, pool, part=None):
45 | try:
46 | payload = {}
47 | payload['name'] = pool
48 | if part is not None:
49 | payload['partition'] = part
50 |
51 | pool_config = bigip.post("%s/ltm/pool" % url, json.dumps(payload)).json()
52 | print pool_config
53 | except Exception, e:
54 | print e
55 |
56 |
57 | if __name__ == "__main__":
58 | import requests, json, argparse, getpass
59 | from requests.packages.urllib3.exceptions import InsecureRequestWarning
60 | requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
61 |
62 | parser = argparse.ArgumentParser(description='Create Pool')
63 |
64 | parser.add_argument("host", help='BIG-IP IP or Hostname' )
65 | parser.add_argument("username", help='BIG-IP Username')
66 | parser.add_argument("-p", "--poolname", help='Name of pool you wish to create')
67 | parser.add_argument("-f", "--folder", help='Partition you want the pool to reside in')
68 | args = vars(parser.parse_args())
69 |
70 | hostname = args['host']
71 | username = args['username']
72 | poolname = None if args['poolname'] is None else args['poolname']
73 | partition = None if args['folder'] is None else args['folder']
74 |
75 | print "%s, enter your password: " % args['username'],
76 | password = getpass.getpass()
77 |
78 | b_url_base = 'https://%s/mgmt/tm' % hostname
79 | b = requests.session()
80 | b.auth = (username, password)
81 | b.verify = False
82 | b.headers.update({'Content-Type':'application/json'})
83 |
84 | if poolname is None:
85 | get_pool_list(b, b_url_base)
86 | else:
87 | if partition is None:
88 | create_pool(b, b_url_base, poolname)
89 | else:
90 | create_pool(b, b_url_base, poolname, partition)
--------------------------------------------------------------------------------
/REST-DataGroup.js:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/node
2 |
3 | //=========================================================
4 | //
5 | //=========================================================
6 | var net = require('net');
7 | var stdio = require('stdio');
8 | var https = require('https');
9 | var net = require('net');
10 | var url = require('url');
11 | var request = require('request');
12 | var util = require('util');
13 |
14 | var ops = stdio.getopt({
15 | 'bigip' : { key: 'b', args: 1, description: 'BIG-IP address', default: 'bigip.joesmacbook.com'},
16 | 'user' : { key: 'u', args: 1, description: 'Username', default: 'admin'},
17 | 'pass' : { key: 'p', args: 1, description: 'Password', default: 'admin'},
18 | 'datagroup' : { key: 'g', args: 1, description: 'Data Group'},
19 | 'action' : { key: 'a', args: 1, description: 'Action [create|remove_from|add_to|delete]'},
20 | 'debug' : { key: 'd', description: 'Print Debug Messages'}
21 | });
22 |
23 | var BIGIP = ops.bigip;
24 | var USER = ops.user;
25 | var PASS = ops.pass;
26 | var POOL = ops.pool;
27 | var DATAGROUP = ops.datagroup;
28 | var ACTION = ops.action;
29 | var DEBUG = ops.debug;
30 |
31 | var args = ops.args;
32 |
33 |
34 | //--------------------------------------------------------
35 | function buildUrl(resource) {
36 | //--------------------------------------------------------
37 | return "https://" + BIGIP + resource;
38 | }
39 |
40 | //--------------------------------------------------------
41 | function getAuthToken(callback) {
42 | //--------------------------------------------------------
43 | var resource = "/mgmt/shared/authn/login";
44 | var user = USER;
45 | var pass = PASS;
46 | var body = "{'username':'" + user + "','password':'" + pass + "','loginProviderName':'tmos'}";
47 |
48 | httpRequest("POST", resource, body, user, pass, null, function(json) {
49 | var obj = JSON.parse(json);
50 | var token = obj["token"]["token"];
51 | callback(token);
52 | });
53 | }
54 |
55 | //--------------------------------------------------------
56 | function httpRequest(verb, resource, body, user, pass, token, callback) {
57 | //--------------------------------------------------------
58 |
59 | if ( DEBUG ) { console.log("\n: " + resource + ", verb=" + verb + "\n"); }
60 |
61 | var http_opts = {
62 | host: BIGIP,
63 | method: verb,
64 | port: 443,
65 | rejectUnauthorized: 0,
66 | path: resource
67 | };
68 |
69 | var http_headers = {
70 | 'Content-Type': 'application/json'
71 | };
72 |
73 | // Authentication Method
74 | if ( user && pass ) { http_opts["auth"] = user + ":" + pass; }
75 | else if ( token ) { http_headers["X-F5-Auth-Token"] = token; }
76 |
77 | // BODY?
78 | if ( body ) { http_headers["Content-Length"] = body.length; }
79 |
80 | http_opts["headers"] = http_headers;
81 |
82 | var content = "";
83 | var req = https.request(http_opts, function(res) {
84 | res.setEncoding("utf8");
85 | res.on('data', function(chunk) {
86 | content += chunk;
87 | }),
88 | res.on('end', function() {
89 | callback(content);
90 | })
91 | });
92 |
93 | req.on('error', function(e) {
94 | console.log("ERROR: " + JSON.stringify(e) + "\n");
95 | });
96 |
97 | if ( body ) {
98 | req.write(body + "\n");
99 | }
100 | req.end();
101 | }
102 |
103 |
104 | //--------------------------------------------------------
105 | function handleVERB(verb, resource, body, callback) {
106 | //--------------------------------------------------------
107 | getAuthToken( function(token) {
108 | httpRequest(verb, resource, body, null, null, token, function(json) {
109 | callback(json);
110 | });
111 | });
112 | }
113 |
114 |
115 | //--------------------------------------------------------
116 | function getDataGroupList() {
117 | //--------------------------------------------------------
118 | var uri = "/mgmt/tm/ltm/data-group/internal";
119 | handleVERB("GET", uri, null, function(json) {
120 | var obj = JSON.parse(json);
121 | var items = obj.items;
122 | var len = items.length;
123 | console.log("DATA GROUPS");
124 | console.log("==========");
125 | for(var i=0; inew->allow_nonref;
17 |
18 | my $BIGIP = "";
19 | my $USER = "";
20 | my $PASS = "";
21 | my $DATAGROUP = "";
22 | my $ACTION = "";
23 | my $AUTH_TOKEN = "";
24 | my $RESOURCE = "";
25 | my $DEBUG = 0;
26 |
27 | GetOptions(
28 | 'bigip=s' => \$BIGIP,
29 | "user=s" => \$USER,
30 | "pass=s" => \$PASS,
31 | "user=s" => \$USER,
32 | "datagroup=s" => \$DATAGROUP,
33 | "action=s" => \$ACTION,
34 | "debug" => \$DEBUG
35 | );
36 |
37 | sub usage() {
38 | print "Usage: REST-DataGroup.pl [options] \n";
39 | print " options\n";
40 | print " ----------------\n";
41 | print " --bigip bigip_addr\n";
42 | print " --user bigip_username\n";
43 | print " --pass bigip_password\n";
44 | print " --datagroup dg_name\n";
45 | print " --action [create|remove_from|add_to|delete]\n";
46 | print "\n";
47 | exit();
48 | };
49 |
50 | #---------------------------------------------------
51 | sub getAuthToken() {
52 | #---------------------------------------------------
53 | $url = "https://${BIGIP}/mgmt/shared/authn/login";
54 | $user = $USER;
55 | $pass = $PASS;
56 |
57 | $body = "{'username':'$user','password':'$pass','loginProviderName':'tmos'}";
58 |
59 | $json = httpRequestWithBody("POST", $url, $body, 1);
60 |
61 | $obj = decode_json($json);
62 | $AUTH_TOKEN = $obj->{token}->{token};
63 |
64 | if ( $DEBUG ) {
65 | print "TOKEN: $AUTH_TOKEN\n";
66 | }
67 |
68 | return $AUTH_TOKEN;
69 | }
70 |
71 | #---------------------------------------------------
72 | sub httpRequestWithoutBody() {
73 | #---------------------------------------------------
74 | my ($verb, $url) = (@_);
75 |
76 | if ( $DEBUG ) {
77 | print "REQUESTING URL : ${url} ${verb}\n";
78 | }
79 |
80 | $content = "";
81 | if ( $url ) {
82 | my $ua = LWP::UserAgent->new;
83 | my $req;
84 | if ( $verb eq "DELETE" ) {
85 | $req = HTTP::Request->new(DELETE => $url);
86 | } else {
87 | $req = HTTP::Request->new(GET => $url);
88 | }
89 | #$req->authorization_basic($USER, $PASS);
90 | my $auth_token = &getAuthToken();
91 | if ( "" ne $auth_token ) {
92 | $req->header("X-F5-Auth-Token" => $auth_token);
93 | }
94 |
95 | $resp = $ua->request($req);
96 | if ( $DEBUG ) {
97 | print Dumper($resp);
98 | }
99 |
100 | if ( $resp->is_success ) {
101 | $content = $resp->content;
102 | #print "CONTENT: ${content}\n";
103 | } else {
104 | $code = $resp->code;
105 | $msg = $resp->message;
106 | $content = $resp->content;
107 | die "HTTP ERROR ${code} : \"${msg}\" : \"${content}\"\n";
108 | }
109 | }
110 | return $content;
111 | }
112 |
113 | #---------------------------------------------------
114 | sub httpRequestWithBody() {
115 | #---------------------------------------------------
116 | my ($verb, $url, $body, $basicauth) = (@_);
117 |
118 | if ( $DEBUG ) {
119 | print "REQUESTING URL (POST) : ${url}\n";
120 | }
121 |
122 | $content = "";
123 | if ( $url ) {
124 | my $ua = LWP::UserAgent->new;
125 |
126 | my $req;
127 | if ( $verb eq "PUT" ) {
128 | $req = HTTP::Request->new(PUT => $url);
129 | } elsif ( $verb eq "PATCH" ) {
130 | $req = HTTP::Request->new(PATCH => $url);
131 | } else {
132 | $req = HTTP::Request->new(POST => $url);
133 | }
134 |
135 | if ( $basicauth == 1 ) {
136 | $req->authorization_basic($USER, $PASS);
137 | } else {
138 | my $auth_token = &getAuthToken();
139 | if ( "" ne $auth_token ) {
140 | $req->header("X-F5-Auth-Token" => $auth_token);
141 | }
142 | }
143 |
144 | $req->header("Content-Type" => "application/json");
145 | $req->content($body);
146 |
147 | $resp = $ua->request($req);
148 | if ( $DEBUG ) {
149 | print Dumper($resp);
150 | }
151 |
152 | if ( $resp->is_success ) {
153 | $content = $resp->content;
154 | #print "CONTENT: ${content}\n";
155 | } else {
156 | $code = $resp->code;
157 | $msg = $resp->message;
158 | $content = $resp->content;
159 | die "HTTP ERROR ${code} : \"${msg}\" : \"${content}\"\n";
160 | }
161 | }
162 | return $content;
163 | }
164 |
165 | #---------------------------------------------------
166 | sub buildURL() {
167 | #---------------------------------------------------
168 | my ($resource) = @_;
169 |
170 | $url = "https://${BIGIP}/$resource";
171 |
172 | return $url;
173 | }
174 |
175 | #---------------------------------------------------
176 | sub handleGET() {
177 | #---------------------------------------------------
178 | my ($resource) = @_;
179 |
180 | $url = &buildURL($resource);
181 |
182 | $resp = &httpRequestWithoutBody("GET", $url);
183 |
184 | return $resp;
185 | }
186 |
187 | #---------------------------------------------------
188 | sub handleDELETE() {
189 | #---------------------------------------------------
190 | my ($resource) = @_;
191 |
192 | $url = &buildURL($resource);
193 |
194 | $resp = &httpRequestWithoutBody("DELETE", $url);
195 |
196 | return $resp;
197 | }
198 |
199 | #---------------------------------------------------
200 | sub handlePOST() {
201 | #---------------------------------------------------
202 | my ($resource, $body) = @_;
203 |
204 | if ( $body eq "" ) { &usage(); }
205 |
206 | $url = &buildURL($resource);
207 |
208 | $resp = &httpRequestWithBody("POST", $url, $body);
209 |
210 | return $resp;
211 | }
212 |
213 | #---------------------------------------------------
214 | sub handlePUT() {
215 | #---------------------------------------------------
216 | my ($resource, $body) = @_;
217 |
218 | if ( $body eq "" ) { &usage(); }
219 |
220 | $url = &buildURL($resource);
221 |
222 | $resp = &httpRequestWithBody("PUT", $url, $body);
223 |
224 | return $resp;
225 | }
226 |
227 | #---------------------------------------------------
228 | sub handlePATCH() {
229 | #---------------------------------------------------
230 | my ($resource, $body) = @_;
231 |
232 | if ( $body eq "" ) { &usage(); }
233 |
234 | $url = &buildURL($resource);
235 |
236 | $resp = &httpRequestWithBody("PATCH", $url, $body);
237 |
238 | return $resp;
239 | }
240 |
241 | #---------------------------------------------------
242 | sub getDataGroupList() {
243 | #---------------------------------------------------
244 | $uri = "/mgmt/tm/ltm/data-group/internal";
245 | $resp_json = &handleGET($uri);
246 | $resp = decode_json($resp_json);
247 | @items = @{$resp->{"items"}};
248 |
249 | print "DATA GROUPS\n";
250 | print "----------\n";
251 | foreach $item (@items) {
252 | $fullPath = $item->{"fullPath"};
253 | print " $fullPath\n";
254 | #print "-----------------------------------\n";
255 | #print Dumper($item);
256 | #print "-----------------------------------\n";
257 | }
258 | }
259 |
260 | #---------------------------------------------------
261 | sub getDataGroup() {
262 | #---------------------------------------------------
263 | my ($datagroup) = @_;
264 | $datagroup =~ s/\//~/g;
265 | my $uri = "/mgmt/tm/ltm/data-group/internal/${datagroup}";
266 | $resp_json = &handleGET($uri);
267 | $resp = decode_json($resp_json);
268 |
269 | print Dumper($resp);
270 | }
271 |
272 | #---------------------------------------------------
273 | sub createDataGroup() {
274 | #---------------------------------------------------
275 | my ($datagroup) = @_;
276 |
277 | print "CREATE DATA GROUP\n";
278 |
279 | my $uri = "/mgmt/tm/ltm/data-group/internal";
280 |
281 | my $dgObj;
282 | $dgObj->{"name"} = $datagroup;
283 | $dgObj->{"type"} = "string";
284 |
285 | $dgObj->{"records"} = [
286 | { name => 'a', data => 'data 1' },
287 | { name => 'b', data => 'data 2' },
288 | { name => 'c', data => 'data 3' }
289 | ];
290 |
291 | my $json = encode_json($dgObj);
292 |
293 | $resp = &handlePOST($uri, $json);
294 | print Dumper($resp);
295 | }
296 |
297 | #---------------------------------------------------
298 | sub deleteDataGroup($DATAGROUP) {
299 | #---------------------------------------------------
300 | my ($datagroup) = @_;
301 |
302 | $datagroup =~ s/\//~/g;
303 | $uri = "/mgmt/tm/ltm/data-group/internal/${datagroup}";
304 |
305 | $resp = &handleDELETE($uri);
306 | print Dumper($resp);
307 | }
308 |
309 | #---------------------------------------------------
310 | sub removeFromDataGroup($DATAGROUP) {
311 | #---------------------------------------------------
312 | my ($datagroup) = @_;
313 |
314 | $datagroup =~ s/\//~/g;
315 | $uri = "/mgmt/tm/ltm/data-group/internal/${datagroup}";
316 |
317 | my $dgObj;
318 | $dgObj->{"name"} = $datagroup;
319 |
320 | $dgObj->{"records"} = [
321 | { name => 'a', data => 'data 1' },
322 | { name => 'b', data => 'data 2' }
323 | ];
324 |
325 | my $json = encode_json($dgObj);
326 |
327 | $resp = &handlePATCH($uri, $json);
328 | print Dumper($resp);
329 |
330 | }
331 |
332 | #---------------------------------------------------
333 | sub addToDataGroup($DATAGROUP) {
334 | #---------------------------------------------------
335 | my ($datagroup) = @_;
336 |
337 | $datagroup =~ s/\//~/g;
338 | $uri = "/mgmt/tm/ltm/data-group/internal/${datagroup}";
339 |
340 | my $dgObj;
341 | $dgObj->{"name"} = $datagroup;
342 |
343 | $dgObj->{"records"} = [
344 | { name => 'a', data => 'data 1' },
345 | { name => 'b', data => 'data 2' },
346 | { name => 'd', data => 'data 4' },
347 | { name => 'e', data => 'data 5' }
348 | ];
349 |
350 | my $json = encode_json($dgObj);
351 |
352 | $resp = &handlePUT($uri, $json);
353 | print Dumper($resp);
354 |
355 | }
356 |
357 | #===================================================
358 |
359 | #===================================================
360 |
361 |
362 | if ( ($BIGIP eq "") || ($USER eq "") || ($PASS eq "") ) {
363 | &usage();
364 | } else {
365 | if ( $DATAGROUP eq "" ) {
366 | &getDataGroupList();
367 | } else {
368 | if ( $ACTION eq "create" ) {
369 | &createDataGroup($DATAGROUP);
370 | } elsif ( $ACTION eq "remove_from" ) {
371 | &removeFromDataGroup($DATAGROUP);
372 | } elsif ( $ACTION eq "add_to" ) {
373 | &addToDataGroup($DATAGROUP);
374 | } elsif ( $ACTION eq "delete" ) {
375 | &deleteDataGroup($DATAGROUP);
376 | } else {
377 | &getDataGroup($DATAGROUP);
378 | }
379 | }
380 | }
381 |
--------------------------------------------------------------------------------
/REST-DataGroup.ps1:
--------------------------------------------------------------------------------
1 | #----------------------------------------------------------------------------
2 | # The contents of this file are subject to the "END USER LICENSE AGREEMENT
3 | # FOR F5 Software Development Kit for iControl"; you may not use this file
4 | # except in compliance with the License. The License is included in the
5 | # iControl Software Development Kit.
6 | #
7 | # Software distributed under the License is distributed on an "AS IS"
8 | # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9 | # the License for the specific language governing rights and limitations
10 | # under the License.
11 | #
12 | # The Original Code is iControl Code and related documentation
13 | # distributed by F5.
14 | #
15 | # The Initial Developer of the Original Code is F5 Networks,
16 | # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2009
17 | # F5 Networks, Inc. All Rights Reserved. iControl (TM) is a registered
18 | # trademark of F5 Networks, Inc.
19 | #
20 | # Alternatively, the contents of this file may be used under the terms
21 | # of the GNU General Public License (the "GPL"), in which case the
22 | # provisions of GPL are applicable instead of those above. If you wish
23 | # to allow use of your version of this file only under the terms of the
24 | # GPL and not to allow others to use your version of this file under the
25 | # License, indicate your decision by deleting the provisions above and
26 | # replace them with the notice and other provisions required by the GPL.
27 | # If you do not delete the provisions above, a recipient may use your
28 | # version of this file under either the License or the GPL.
29 | #----------------------------------------------------------------------------
30 | param(
31 | [string]$Bigip = "",
32 | [string]$User = "",
33 | [string]$Pass = "",
34 | [string]$Datagroup = "",
35 | [string]$Action = ""
36 | );
37 |
38 | #----------------------------------------------------------------------------
39 | function Get-DataGroupList()
40 | #
41 | # Description:
42 | # This function lists out all existing internal data groups
43 | #
44 | # Parameters:
45 | # None
46 | #----------------------------------------------------------------------------
47 | {
48 | $uri = "/mgmt/tm/ltm/data-group/internal";
49 | $link = "https://$Bigip$uri";
50 | $headers = @{};
51 | $headers.Add("ServerHost", $Bigip);
52 |
53 | $secpasswd = ConvertTo-SecureString $Pass -AsPlainText -Force
54 | $mycreds = New-Object System.Management.Automation.PSCredential ($User, $secpasswd)
55 |
56 | $obj = Invoke-RestMethod -Method GET -Headers $headers -Uri $link -Credential $mycreds
57 | $items = $obj.items;
58 | Write-Host "DATA GROUPS";
59 | Write-Host "----------";
60 | for($i=0; $i -lt $items.length; $i++) {
61 | $name = $items[$i].fullPath;
62 | Write-Host " $name";
63 | }
64 | }
65 |
66 | #----------------------------------------------------------------------------
67 | function Get-DataGroup()
68 | #
69 | # Description:
70 | # This function lists the contents of a given data group
71 | #
72 | # Parameters:
73 | # Name - The name of the data group.
74 | #----------------------------------------------------------------------------
75 | {
76 | $uri = "/mgmt/tm/ltm/data-group/internal/${Name}";
77 | $link = "https://$Bigip$uri";
78 | $headers = @{};
79 | $headers.Add("ServerHost", $Bigip);
80 |
81 | $secpasswd = ConvertTo-SecureString $Pass -AsPlainText -Force
82 | $mycreds = New-Object System.Management.Automation.PSCredential ($User, $secpasswd)
83 |
84 | $obj = Invoke-RestMethod -Method GET -Headers $headers -Uri $link -Credential $mycreds
85 | $obj | Format-List
86 | }
87 |
88 |
89 | #----------------------------------------------------------------------------
90 | function Delete-DataGroup()
91 | #
92 | # Description:
93 | # This function lists the contents of the given data group
94 | #
95 | # Parameters:
96 | # Name - The name of the data group
97 | #----------------------------------------------------------------------------
98 | {
99 | param(
100 | [string]$Name
101 | );
102 |
103 | $uri = "/mgmt/tm/ltm/data-group/internal/${Name}";
104 | $link = "https://$Bigip$uri";
105 | $headers = @{};
106 | $headers.Add("ServerHost", $Bigip);
107 |
108 | $secpasswd = ConvertTo-SecureString $Pass -AsPlainText -Force
109 | $mycreds = New-Object System.Management.Automation.PSCredential ($User, $secpasswd)
110 |
111 | $obj = Invoke-RestMethod -Method DELETE -Headers $headers -Uri $link -Credential $mycreds
112 | Write-Host "Data Group ${Name} has been deleted..."
113 | }
114 |
115 |
116 | #----------------------------------------------------------------------------
117 | function Create-DataGroup()
118 | #
119 | # Description:
120 | # This function creates a new internal data group
121 | #
122 | # Parameters:
123 | # Name - The Name of the data group
124 | #----------------------------------------------------------------------------
125 | {
126 | param(
127 | [string]$Name
128 | );
129 |
130 | $uri = "/mgmt/tm/ltm/data-group/internal";
131 | $link = "https://$Bigip$uri";
132 | $headers = @{};
133 | $headers.Add("ServerHost", $Bigip);
134 | $headers.Add("Content-Type", "application/json");
135 | $obj = @{
136 | name=$Name
137 | type="string"
138 | records= (
139 | @{ name="a"
140 | data="data 1"
141 | },
142 | @{ name="b"
143 | data="data 2"
144 | },
145 | @{ name="c"
146 | data="data 3"
147 | }
148 | )
149 | };
150 | $body = $obj | ConvertTo-Json
151 |
152 | $secpasswd = ConvertTo-SecureString $Pass -AsPlainText -Force
153 | $mycreds = New-Object System.Management.Automation.PSCredential ($User, $secpasswd)
154 |
155 | $obj = Invoke-RestMethod -Method POST -Uri $link -Headers $headers -Credential $mycreds -Body $body;
156 |
157 | Write-Host "Pool ${Name} created in partition ${Partition}"
158 | }
159 |
160 | #----------------------------------------------------------------------------
161 | function RemoveFrom-DataGroup()
162 | #
163 | # Description:
164 | # This function removes an entry from a data group
165 | #
166 | # Parameters:
167 | # Name - The Name of the data group
168 | #----------------------------------------------------------------------------
169 | {
170 | param(
171 | [string]$Name
172 | );
173 |
174 | $uri = "/mgmt/tm/ltm/data-group/internal/${Name}";
175 | $link = "https://$Bigip$uri";
176 | $headers = @{};
177 | $headers.Add("ServerHost", $Bigip);
178 | $headers.Add("Content-Type", "application/json");
179 | $obj = @{
180 | name=$Name
181 | records= (
182 | @{ name="a"
183 | data="data 1"
184 | },
185 | @{ name="b"
186 | data="data 2"
187 | }
188 | )
189 | };
190 | $body = $obj | ConvertTo-Json
191 |
192 | $secpasswd = ConvertTo-SecureString $Pass -AsPlainText -Force
193 | $mycreds = New-Object System.Management.Automation.PSCredential ($User, $secpasswd)
194 |
195 | $obj = Invoke-RestMethod -Method PATCH -Uri $link -Headers $headers -Credential $mycreds -Body $body;
196 |
197 | $obj | Format-List
198 | }
199 |
200 | #----------------------------------------------------------------------------
201 | function AddTo-DataGroup()
202 | #
203 | # Description:
204 | # This function adds records to an existing data group
205 | #
206 | # Parameters:
207 | # Name - The Name of the data group
208 | #----------------------------------------------------------------------------
209 | {
210 | param(
211 | [string]$Name
212 | );
213 |
214 | $uri = "/mgmt/tm/ltm/data-group/internal/${Name}";
215 | $link = "https://$Bigip$uri";
216 | $headers = @{};
217 | $headers.Add("ServerHost", $Bigip);
218 | $headers.Add("Content-Type", "application/json");
219 | $obj = @{
220 | name=$Name
221 | records= (
222 | @{ name="a"
223 | data="data 1"
224 | },
225 | @{ name="b"
226 | data="data 2"
227 | },
228 | @{ name="d"
229 | data="data 4"
230 | },
231 | @{ name="e"
232 | data="data 5"
233 | }
234 | )
235 | };
236 | $body = $obj | ConvertTo-Json
237 |
238 | $secpasswd = ConvertTo-SecureString $Pass -AsPlainText -Force
239 | $mycreds = New-Object System.Management.Automation.PSCredential ($User, $secpasswd)
240 |
241 | $obj = Invoke-RestMethod -Method PATCH -Uri $link -Headers $headers -Credential $mycreds -Body $body;
242 |
243 | $obj | Format-List
244 | }
245 |
246 | #----------------------------------------------------------------------------
247 | function Show-Usage()
248 | #
249 | # Description:
250 | # This function will print the script usage information.
251 | #
252 | #----------------------------------------------------------------------------
253 | {
254 | Write-Host @"
255 | Usage: DataGroup.ps1 Arguments
256 | Argument - Description
257 | ---------- -----------
258 | Bigip - The ip/hostname of your BIG-IP.
259 | User - The Managmenet username for your BIG-IP.
260 | Pass - The Management password for your BIG-IP.
261 | Datagroup - The name of the data group.
262 | Action - The action to complete [create|remove_from|add_to|delete].
263 | "@;
264 | }
265 |
266 | #============================================================================
267 | # Main application logic
268 | #============================================================================
269 | if ( ($Bigip.Length -eq 0) -or ($User.Length -eq 0) -or ($Pass.Length -eq 0) ) {
270 | Show-Usage;
271 | } else {
272 | if ( $Datagroup.Length -eq 0 ) {
273 | Get-DataGroupList;
274 | } else {
275 | if ( $Action -eq "create" ) {
276 | Create-DataGroup -Name $Datagroup;
277 | } elseif ( $Action -eq "remove_from" ) {
278 | RemoveFrom-DataGroup -Name $Datagroup;
279 | } elseif ( $Action -eq "add_to" ) {
280 | AddTo-DataGroup -Name $Datagroup;
281 | } elseif ( $Action -eq "delete" ) {
282 | Delete-DataGroup -Name $Datagroup;
283 | } else {
284 | Get-DataGroup -Name $Datagroup;
285 | }
286 | }
287 | }
288 |
--------------------------------------------------------------------------------
/REST-DataGroup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | '''
3 | # The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5
4 | # Software Development Kit for iControl"; you may not use this file except in
5 | # compliance with the License. The License is included in the iControl
6 | # Software Development Kit.
7 | #
8 | # Software distributed under the License is distributed on an "AS IS"
9 | # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
10 | # the License for the specific language governing rights and limitations
11 | # under the License.
12 | #
13 | # The Original Code is iControl Code and related documentation
14 | # distributed by F5.
15 | #
16 | # The Initial Developer of the Original Code is F5 Networks,
17 | # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2004 F5 Networks,
18 | # Inc. All Rights Reserved. iControl (TM) is a registered trademark of F5 Networks, Inc.
19 | #
20 | # Alternatively, the contents of this file may be used under the terms
21 | # of the GNU General Public License (the "GPL"), in which case the
22 | # provisions of GPL are applicable instead of those above. If you wish
23 | # to allow use of your version of this file only under the terms of the
24 | # GPL and not to allow others to use your version of this file under the
25 | # License, indicate your decision by deleting the provisions above and
26 | # replace them with the notice and other provisions required by the GPL.
27 | # If you do not delete the provisions above, a recipient may use your
28 | # version of this file under either the License or the GPL.
29 | '''
30 |
31 | def get_dg_list(rq, url):
32 | try:
33 | dg_list = rq.get('%s/ltm/data-group/internal' % url).json()
34 | for dg in dg_list['items']:
35 | print dg
36 | print ' Data Group: %s' % dg['name']
37 | print ' --------------'
38 | if 'records' in dg:
39 | for record in dg['records']:
40 | if 'data' in record:
41 | print ' %s: %s' % (record['name'], record['data'])
42 | else:
43 | print ' %s' % record['name']
44 |
45 | except Exception, e:
46 | print e
47 |
48 |
49 | def extend_dg(rq, url, dgname, additional_records):
50 | dg = rq.get('%s/ltm/data-group/internal/%s' % (url, dgname)).json()
51 |
52 | current_records = dg['records']
53 | new_records = []
54 | for record in current_records:
55 | if 'data' in record:
56 | nr = [{'name': record['name'], 'data': record['data']}]
57 | else:
58 | nr = [{'name': record['name']}]
59 | new_records.extend(nr)
60 | for record in additional_records:
61 | if 'data' in record:
62 | nr = [{'name': record['name'], 'data': record['data']}]
63 | else:
64 | nr = [{'name': record['name']}]
65 | new_records.extend(nr)
66 |
67 | payload = {}
68 | payload['records'] = new_records
69 | rq.put('%s/ltm/data-group/internal/%s' % (url, dgname), json.dumps(payload))
70 |
71 |
72 | def contract_dg(rq, url, dgname, removal_records):
73 | dg = rq.get('%s/ltm/data-group/internal/%s' % (url, dgname)).json()
74 | current_records = dg['records']
75 |
76 | new_records = []
77 | for record in removal_records:
78 | if 'data' in record:
79 | nr = [{'name': record['name'], 'data': record['data']}]
80 | else:
81 | nr = [{'name': record['name']}]
82 | new_records.extend(nr)
83 |
84 | new_records = [x for x in current_records if x not in new_records]
85 |
86 | payload = {}
87 | payload['records'] = new_records
88 | rq.put('%s/ltm/data-group/internal/%s' % (url, dgname), json.dumps(payload))
89 |
90 |
91 | def create_dg(rq, url, dgname, records):
92 | new_records = []
93 | for record in records:
94 | if 'data' in record:
95 | nr = [{'name': record['name'], 'data': record['data']}]
96 | else:
97 | nr = [{'name': record['name']}]
98 | new_records.extend(nr)
99 |
100 | payload = {}
101 | payload['type'] = 'string'
102 | payload['name'] = dgname
103 | payload['records'] = new_records
104 | try:
105 | rq.post('%s/ltm/data-group/internal' % url, json.dumps(payload))
106 | except Exception, e:
107 | print e
108 |
109 |
110 | if __name__ == "__main__":
111 | import requests, json, argparse, getpass
112 | from requests.packages.urllib3.exceptions import InsecureRequestWarning
113 | requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
114 |
115 | parser = argparse.ArgumentParser(description='Create Data-Group')
116 |
117 | parser.add_argument("host", help='BIG-IP IP or Hostname' )
118 | parser.add_argument("username", help='BIG-IP Username')
119 | parser.add_argument("-d", "--datagroup", help='Name of the data-group you want to create')
120 | args = vars(parser.parse_args())
121 |
122 | hostname = args['host']
123 | username = args['username']
124 | datagroupname = None if args['datagroup'] is None else args['datagroup']
125 |
126 | print "%s, enter your password: " % args['username'],
127 | password = getpass.getpass()
128 |
129 | b_url_base = 'https://%s/mgmt/tm' % hostname
130 | b = requests.session()
131 | b.auth = (username, password)
132 | b.verify = False
133 | b.headers.update({'Content-Type':'application/json'})
134 |
135 | dg_init = [{'name': 'blah blah'}, {'data': '1', 'name': 'a'}, {'data': '2', 'name': 'b'}, {'data': '3', 'name': 'c'}]
136 | dg_changes = [{'data': '4', 'name': 'd'}, {'data': '5', 'name': 'e'}]
137 |
138 |
139 | if datagroupname is None:
140 | get_dg_list(b, b_url_base)
141 | else:
142 | create_dg(b, b_url_base, datagroupname, dg_init)
143 | extend_dg(b, b_url_base, datagroupname, dg_changes)
144 | contract_dg(b, b_url_base, datagroupname, dg_changes)
145 |
--------------------------------------------------------------------------------
/REST-Stats.js:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/node
2 |
3 | //=========================================================
4 | //
5 | //=========================================================
6 | var net = require('net');
7 | var stdio = require('stdio');
8 | var https = require('https');
9 | var net = require('net');
10 | var url = require('url');
11 | var request = require('request');
12 | var util = require('util');
13 |
14 | var ops = stdio.getopt({
15 | 'bigip' : { key: 'b', args: 1, description: 'BIG-IP address', default: 'bigip.joesmacbook.com'},
16 | 'user' : { key: 'u', args: 1, description: 'Username', default: 'admin'},
17 | 'pass' : { key: 'p', args: 1, description: 'Password', default: 'admin'},
18 | 'type' : { key: 'g', args: 1, description: 'Object Type: [virtual|poo]'},
19 | 'name' : { key: 'a', args: 1, description: 'Object Name'},
20 | 'debug' : { key: 'd', description: 'Print Debug Messages'}
21 | });
22 |
23 | var BIGIP = ops.bigip;
24 | var USER = ops.user;
25 | var PASS = ops.pass;
26 | var TYPE = ops.type;
27 | var NAME = ops.name;
28 | var DEBUG = ops.debug;
29 |
30 | var args = ops.args;
31 |
32 |
33 | //--------------------------------------------------------
34 | function buildUrl(resource) {
35 | //--------------------------------------------------------
36 | return "https://" + BIGIP + resource;
37 | }
38 |
39 | //--------------------------------------------------------
40 | function getAuthToken(callback) {
41 | //--------------------------------------------------------
42 | var resource = "/mgmt/shared/authn/login";
43 | var user = USER;
44 | var pass = PASS;
45 | var body = "{'username':'" + user + "','password':'" + pass + "','loginProviderName':'tmos'}";
46 |
47 | httpRequest("POST", resource, body, user, pass, null, function(json) {
48 | var obj = JSON.parse(json);
49 | var token = obj["token"]["token"];
50 | callback(token);
51 | });
52 | }
53 |
54 | //--------------------------------------------------------
55 | function httpRequest(verb, resource, body, user, pass, token, callback) {
56 | //--------------------------------------------------------
57 |
58 | if ( DEBUG ) { console.log("\n: " + resource + ", verb=" + verb + "\n"); }
59 |
60 | var http_opts = {
61 | host: BIGIP,
62 | method: verb,
63 | port: 443,
64 | rejectUnauthorized: 0,
65 | path: resource
66 | };
67 |
68 | var http_headers = {
69 | 'Content-Type': 'application/json'
70 | };
71 |
72 | // Authentication Method
73 | if ( user && pass ) { http_opts["auth"] = user + ":" + pass; }
74 | else if ( token ) { http_headers["X-F5-Auth-Token"] = token; }
75 |
76 | // BODY?
77 | if ( body ) { http_headers["Content-Length"] = body.length; }
78 |
79 | http_opts["headers"] = http_headers;
80 |
81 | var content = "";
82 | var req = https.request(http_opts, function(res) {
83 | res.setEncoding("utf8");
84 | res.on('data', function(chunk) {
85 | content += chunk;
86 | }),
87 | res.on('end', function() {
88 | callback(content);
89 | })
90 | });
91 |
92 | req.on('error', function(e) {
93 | console.log("ERROR: " + JSON.stringify(e) + "\n");
94 | });
95 |
96 | if ( body ) {
97 | req.write(body + "\n");
98 | }
99 | req.end();
100 | }
101 |
102 |
103 | //--------------------------------------------------------
104 | function handleVERB(verb, resource, body, callback) {
105 | //--------------------------------------------------------
106 | getAuthToken( function(token) {
107 | httpRequest(verb, resource, body, null, null, token, function(json) {
108 | callback(json);
109 | });
110 | });
111 | }
112 |
113 | //--------------------------------------------------------
114 | function getVirtualList(name) {
115 | //--------------------------------------------------------
116 | var uri = "/mgmt/tm/ltm/virtual";
117 |
118 | handleVERB("GET", uri, null, function(json) {
119 | //console.log(json);
120 | var obj = JSON.parse(json);
121 | var items = obj.items;
122 | console.log("VIRTUALS");
123 | console.log("-----------");
124 | for(var i=0; i 3 )
80 | {
81 | poolname = args[3];
82 | }
83 | if ( args.length > 4 )
84 | {
85 | partition = args[4];
86 | }
87 |
88 | // build parameters
89 | m_interfaces.initialize(bigip, port, user, pass);
90 |
91 | if ( (null == poolname) || (null == partition) ) {
92 | displayAllPools();
93 | } else {
94 | createPool(poolname, partition);
95 | }
96 | bSuccess = true;
97 | }
98 |
99 | return bSuccess;
100 | }
101 |
102 | //--------------------------------------------------------------------------
103 | //
104 | //--------------------------------------------------------------------------
105 | public void usage()
106 | {
107 | System.out.println("Usage: SOAPCreatePoolInPartition hostname username password [pool partition]");
108 | }
109 |
110 | public void displayAllPools() throws Exception
111 | {
112 | String [] pool_list = m_interfaces.getLocalLBPool().get_list();
113 | System.out.println("Pools\n");
114 | System.out.println("-----------\n");
115 | for(int i=0; i qw(method debug);
32 | use SOAP::Lite;
33 | use MIME::Base64;
34 |
35 | $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
36 |
37 | #----------------------------------------------------------------------------
38 | # Validate Arguments
39 | #----------------------------------------------------------------------------
40 | my $sHost = $ARGV[0];
41 | my $sUID = $ARGV[1];
42 | my $sPWD = $ARGV[2];
43 | my $sPool = $ARGV[3];
44 | my $sPartition = $ARGV[4];
45 |
46 | if ( $Partition eq "") { $Partition = "/Dev"; }
47 |
48 | if ( ($sHost eq "") or ($sUID eq "") or ($sPWD eq "") )
49 | {
50 | die ("Usage: LocalLBPoolCreate.pl host uid pwd [pool_name partition]\n");
51 | }
52 |
53 | #----------------------------------------------------------------------------
54 | # Transport Information
55 | #----------------------------------------------------------------------------
56 | sub SOAP::Transport::HTTP::Client::get_basic_credentials
57 | {
58 | return "$sUID" => "$sPWD";
59 | }
60 |
61 | $Pool = SOAP::Lite
62 | -> uri('urn:iControl:LocalLB/Pool')
63 | -> proxy("https://$sHost/iControl/iControlPortal.cgi");
64 | eval { $Pool->transport->http_request->header
65 | (
66 | 'Authorization' =>
67 | 'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '')
68 | ); };
69 |
70 | if ( $sPool eq "" )
71 | {
72 | &getPoolList();
73 | #&getAllPoolInfo();
74 | }
75 | else
76 | {
77 | &createPool($sPartition, $sPool);
78 | #&getPoolInfo($sPool);
79 | }
80 |
81 | #----------------------------------------------------------------------------
82 | # checkResponse
83 | #----------------------------------------------------------------------------
84 | sub checkResponse()
85 | {
86 | my ($soapResponse) = (@_);
87 | if ( $soapResponse->fault )
88 | {
89 | print $soapResponse->faultcode, " ", $soapResponse->faultstring, "\n";
90 | exit();
91 | }
92 | }
93 |
94 | #----------------------------------------------------------------------------
95 | # getPoolList
96 | #----------------------------------------------------------------------------
97 | sub getPoolList()
98 | {
99 | $soapResponse = $Pool->get_list();
100 | &checkResponse($soapResponse);
101 | my @pool_list = @{$soapResponse->result};
102 | print "POOL LIST\n";
103 | print "---------\n";
104 | foreach $pool (@pool_list) {
105 | print " ${pool}\n";
106 | }
107 | }
108 |
109 | #----------------------------------------------------------------------------
110 | # createPool()
111 | #----------------------------------------------------------------------------
112 | sub createPool()
113 | {
114 | my ($partition, $pool) = @_;
115 |
116 | print "CREATING POOL $pool\n";
117 |
118 | my @pool_names = [$pool];
119 | my @lb_methods = ["LB_METHOD_ROUND_ROBIN"];
120 | $member =
121 | {
122 | address => "10.10.10.10",
123 | port => 80
124 | };
125 |
126 | # memberA is the 1st dimension of the array, we need one for each pool
127 | push @memberA, $member;
128 | # memberAofA is the 2nd dimension. push pool members for each pool here.
129 | push @memberAofA, [@memberA];
130 |
131 | $soapResponse = $Pool->create(
132 | SOAP::Data->name( pool_names => ["/$partition/$pool"]),
133 | SOAP::Data->name( lb_methods => ["LB_METHOD_ROUND_ROBIN"]),
134 | SOAP::Data->name(members => [@memberAofA])
135 | );
136 | &checkResponse($soapResponse);
137 |
138 | print "POOL ${pool} created in partition ${partition}...\n";
139 | }
140 |
141 |
--------------------------------------------------------------------------------
/SOAP-CreatePoolInPartition.ps1:
--------------------------------------------------------------------------------
1 | #----------------------------------------------------------------------------
2 | # The contents of this file are subject to the "END USER LICENSE AGREEMENT
3 | # FOR F5 Software Development Kit for iControl"; you may not use this file
4 | # except in compliance with the License. The License is included in the
5 | # iControl Software Development Kit.
6 | #
7 | # Software distributed under the License is distributed on an "AS IS"
8 | # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9 | # the License for the specific language governing rights and limitations
10 | # under the License.
11 | #
12 | # The Original Code is iControl Code and related documentation
13 | # distributed by F5.
14 | #
15 | # The Initial Developer of the Original Code is F5 Networks,
16 | # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2009
17 | # F5 Networks, Inc. All Rights Reserved. iControl (TM) is a registered
18 | # trademark of F5 Networks, Inc.
19 | #
20 | # Alternatively, the contents of this file may be used under the terms
21 | # of the GNU General Public License (the "GPL"), in which case the
22 | # provisions of GPL are applicable instead of those above. If you wish
23 | # to allow use of your version of this file only under the terms of the
24 | # GPL and not to allow others to use your version of this file under the
25 | # License, indicate your decision by deleting the provisions above and
26 | # replace them with the notice and other provisions required by the GPL.
27 | # If you do not delete the provisions above, a recipient may use your
28 | # version of this file under either the License or the GPL.
29 | #----------------------------------------------------------------------------
30 | param(
31 | [string]$Bigip = "",
32 | [string]$User = "",
33 | [string]$Pass = "",
34 | [string]$Pool = "",
35 | [string]$Partition = ""
36 | );
37 |
38 | #----------------------------------------------------------------------------
39 | function Get-PoolList()
40 | #----------------------------------------------------------------------------
41 | {
42 | $pool_list = $(Get-F5.iControl).LocalLBPool.get_list();
43 | Write-Host "POOL LIST";
44 | Write-Host "---------";
45 | foreach($pool in $pool_list)
46 | {
47 | Write-Host " $pool";
48 | }
49 | }
50 |
51 | #----------------------------------------------------------------------------
52 | function Create-Pool()
53 | #
54 | # Description:
55 | # This function creates a new pool if the given pool name doesn't
56 | # already exist.
57 | #
58 | # Parameters:
59 | # Name - The Name of the pool you wish to create.
60 | # MemberList - A string list of pool member addresses.
61 | # MemberPort - The port the pool members will be configured with.
62 | #----------------------------------------------------------------------------
63 | {
64 | param(
65 | [string]$Name,
66 | [string[]]$MemberList,
67 | [int]$MemberPort
68 | );
69 |
70 | $IPPortDefList = New-Object -TypeName iControl.CommonIPPortDefinition[] $MemberList.Length;
71 | for($i=0; $i-lt$MemberList.Length; $i++)
72 | {
73 | $IPPortDefList[$i] = New-Object -TypeName iControl.CommonIPPortDefinition;
74 | $IPPortDefList[$i].address = $MemberList[$i];
75 | $IPPortDefList[$i].port = $MemberPort;
76 | }
77 |
78 | Write-Host "Creating Pool $Name";
79 | $(Get-F5.iControl).LocalLBPool.create(
80 | (,$Name),
81 | (,"LB_METHOD_ROUND_ROBIN"),
82 | (,$IPPortDefList)
83 | );
84 | Write-Host "Pool '$Name' Successfully Created";
85 | }
86 |
87 | #-------------------------------------------------------------------------
88 | function Do-Initialize()
89 | #
90 | # Description:
91 | # This function will verify that the iControl PowerShell Snapin is loaded
92 | # in the current runspace.
93 | #
94 | #-------------------------------------------------------------------------
95 | {
96 | if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null )
97 | {
98 | Add-PSSnapIn iControlSnapIn
99 | }
100 | $success = Initialize-F5.iControl -HostName $Bigip -Username $User -Password $Pass;
101 |
102 | return $success;
103 | }
104 |
105 | #----------------------------------------------------------------------------
106 | function Show-Usage()
107 | #
108 | # Description:
109 | # This function will print the script usage information.
110 | #
111 | #----------------------------------------------------------------------------
112 | {
113 | Write-Host @"
114 | Usage: CreatePoolInPartition.ps1 Arguments
115 | Argument - Description
116 | ---------- -----------
117 | Bigip - The ip/hostname of your BIG-IP.
118 | User - The Managmenet username for your BIG-IP.
119 | Pass - The Management password for your BIG-IP.
120 | Pool - The Name of the pool to create.
121 | Partition - The Partition to place the pool in.
122 | "@;
123 | }
124 |
125 | #============================================================================
126 | # Main application logic
127 | #============================================================================
128 | if ( ($Bigip.Length -eq 0) -or ($User.Length -eq 0) -or ($Pass.Length -eq 0) -or`
129 | ($Pool.Length -eq 0) -or ($Partition.Length -eq 0) )
130 | {
131 | Show-Usage;
132 | }
133 | else
134 | {
135 | if ( Do-Initialize )
136 | {
137 | $PoolName = "/${Partition}/${Pool}";
138 |
139 | # HTTP Objects
140 | $MemberList = (, "10.10.10.10");
141 | $MemberPort = 80;
142 | Create-Pool -Name $PoolName -MemberList $MemberList -MemberPort $HTTPPort;
143 | Write-Host "Pool $Pool created in paritition $Partition"
144 | }
145 | else
146 | {
147 | Write-Error "ERROR: iControl subsystem not initialized"
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/SOAP-CreatePoolInPartition.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | '''
3 | # The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5
4 | # Software Development Kit for iControl"; you may not use this file except in
5 | # compliance with the License. The License is included in the iControl
6 | # Software Development Kit.
7 | #
8 | # Software distributed under the License is distributed on an "AS IS"
9 | # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
10 | # the License for the specific language governing rights and limitations
11 | # under the License.
12 | #
13 | # The Original Code is iControl Code and related documentation
14 | # distributed by F5.
15 | #
16 | # The Initial Developer of the Original Code is F5 Networks,
17 | # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2004 F5 Networks,
18 | # Inc. All Rights Reserved. iControl (TM) is a registered trademark of F5 Networks, Inc.
19 | #
20 | # Alternatively, the contents of this file may be used under the terms
21 | # of the GNU General Public License (the "GPL"), in which case the
22 | # provisions of GPL are applicable instead of those above. If you wish
23 | # to allow use of your version of this file only under the terms of the
24 | # GPL and not to allow others to use your version of this file under the
25 | # License, indicate your decision by deleting the provisions above and
26 | # replace them with the notice and other provisions required by the GPL.
27 | # If you do not delete the provisions above, a recipient may use your
28 | # version of this file under either the License or the GPL.
29 | '''
30 |
31 |
32 | def get_pool_list(bigip):
33 | try:
34 | poollist = bigip.LocalLB.Pool.get_list()
35 | print "POOL LIST"
36 | print " ---------"
37 | for pool in poollist:
38 | print " %s" % pool
39 |
40 | except Exception, e:
41 | print e
42 |
43 |
44 | def create_pool(bigip, pool):
45 | try:
46 | bigip.LocalLB.Pool.create_v2([pool], ['LB_METHOD_ROUND_ROBIN'], [[]])
47 | except Exception, e:
48 | print e
49 |
50 |
51 | if __name__ == "__main__":
52 | import bigsuds, argparse, getpass, ssl
53 | ssl._create_default_https_context = ssl._create_unverified_context
54 |
55 | parser = argparse.ArgumentParser(description='Create Pool')
56 |
57 | parser.add_argument("host", help='BIG-IP IP or Hostname' )
58 | parser.add_argument("username", help='BIG-IP Username')
59 | parser.add_argument("-p", "--poolname", help='Name of pool you wish to create')
60 | parser.add_argument("-f", "--folder", help='Partition/Folder you want the pool to reside in')
61 | args = vars(parser.parse_args())
62 |
63 | hostname = args['host']
64 | username = args['username']
65 | poolname = None if args['poolname'] is None else args['poolname']
66 | partition = None if args['folder'] is None else args['folder']
67 |
68 | print "%s, enter your password: " % args['username'],
69 | password = getpass.getpass()
70 |
71 | b = bigsuds.BIGIP(hostname, username, password)
72 |
73 | if poolname is None:
74 | get_pool_list(b)
75 | else:
76 | if partition is None:
77 | poolname = '/Common/%s' % poolname
78 | else:
79 | poolname = '/%s/%s' % (partition, poolname)
80 | create_pool(b, poolname)
--------------------------------------------------------------------------------
/SOAP-DataGroup.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #----------------------------------------------------------------------------
3 | # The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5
4 | # Software Development Kit for iControl"; you may not use this file except in
5 | # compliance with the License. The License is included in the iControl
6 | # Software Development Kit.
7 | #
8 | # Software distributed under the License is distributed on an "AS IS"
9 | # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
10 | # the License for the specific language governing rights and limitations
11 | # under the License.
12 | #
13 | # The Original Code is iControl Code and related documentation
14 | # distributed by F5.
15 | #
16 | # The Initial Developer of the Original Code is F5 Networks,
17 | # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2004 F5 Networks,
18 | # Inc. All Rights Reserved. iControl (TM) is a registered trademark of F5 Networks, Inc.
19 | #
20 | # Alternatively, the contents of this file may be used under the terms
21 | # of the GNU General Public License (the "GPL"), in which case the
22 | # provisions of GPL are applicable instead of those above. If you wish
23 | # to allow use of your version of this file only under the terms of the
24 | # GPL and not to allow others to use your version of this file under the
25 | # License, indicate your decision by deleting the provisions above and
26 | # replace them with the notice and other provisions required by the GPL.
27 | # If you do not delete the provisions above, a recipient may use your
28 | # version of this file under either the License or the GPL.
29 | #----------------------------------------------------------------------------
30 |
31 | #use SOAP::Lite + trace => qw(method debug);
32 | use SOAP::Lite;
33 | use MIME::Base64;
34 | use Data::Dumper;
35 |
36 | $Data::Dumper::Deepcopy = 1;
37 |
38 | $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
39 |
40 | #----------------------------------------------------------------------------
41 | # Validate Arguments
42 | #----------------------------------------------------------------------------
43 | my $sHost = $ARGV[0];
44 | my $sUID = $ARGV[1];
45 | my $sPWD = $ARGV[2];
46 | my $sDataGroup = $ARGV[3];
47 | my $sAction = $ARGV[4];
48 |
49 | if ( ($sHost eq "") or ($sUID eq "") or ($sPWD eq "") )
50 | {
51 | die ("Usage: DataGroup.pl host uid pwd [datagroup action (create|remove_from_add_to|delete)]\n");
52 | }
53 |
54 | #----------------------------------------------------------------------------
55 | # Transport Information
56 | #----------------------------------------------------------------------------
57 | sub SOAP::Transport::HTTP::Client::get_basic_credentials
58 | {
59 | return "$sUID" => "$sPWD";
60 | }
61 |
62 | $Class = SOAP::Lite
63 | -> uri('urn:iControl:LocalLB/Class')
64 | -> proxy("https://$sHost/iControl/iControlPortal.cgi");
65 | eval { $Class->transport->http_request->header
66 | (
67 | 'Authorization' =>
68 | 'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '')
69 | ); };
70 |
71 | if ( $sDataGroup eq "" ) {
72 | &getDataGroupList();
73 | } else {
74 | if ( $sAction eq "create" ) {
75 | &createDataGroup($sDataGroup);
76 | } elsif ( $sAction eq "remove_from" ) {
77 | &removeFromDataGroup($sDataGroup);
78 | } elsif ( $sAction eq "add_to" ) {
79 | &addToDataGroup($sDataGroup);
80 | } elsif ( $sAction eq "delete" ) {
81 | &deleteDataGroup($sDataGroup);
82 | } else {
83 | &getDataGroup($sDataGroup);
84 | }
85 | }
86 |
87 | #----------------------------------------------------------------------------
88 | sub checkResponse()
89 | #----------------------------------------------------------------------------
90 | {
91 | my ($soapResponse) = (@_);
92 | if ( $soapResponse->fault )
93 | {
94 | print $soapResponse->faultcode, " ", $soapResponse->faultstring, "\n";
95 | exit();
96 | }
97 | }
98 |
99 | #----------------------------------------------------------------------------
100 | sub getDataGroupList()
101 | #----------------------------------------------------------------------------
102 | {
103 |
104 | print "DATA GROUPS\n";
105 | print "-----------\n";
106 | $soapResponse = $Class->get_address_class_list();
107 | &checkResponse($soapResponse);
108 | @ClassList = @{$soapResponse->result};
109 | foreach $ClassName (@ClassList)
110 | {
111 | print " $ClassName - address\n";
112 | }
113 | $soapResponse = $Class->get_string_class_list();
114 | &checkResponse($soapResponse);
115 | @ClassList = @{$soapResponse->result};
116 | foreach $ClassName (@ClassList)
117 | {
118 | print " $ClassName - string\n";
119 | }
120 | $soapResponse = $Class->get_value_class_list();
121 | &checkResponse($soapResponse);
122 | @ClassList = @{$soapResponse->result};
123 | foreach $ClassName (@ClassList)
124 | {
125 | print " $ClassName - value\n";
126 | }
127 | }
128 |
129 | #----------------------------------------------------------------------------
130 | sub getDataGroup()
131 | #----------------------------------------------------------------------------
132 | {
133 | my ($datagroup) = @_;
134 | $soapResponse = $Class->get_string_class(
135 | SOAP::Data->name(class_names => [$datagroup])
136 | );
137 | my @StringClassA = @{$soapResponse->result};
138 |
139 | $soapResponse = $Class->get_string_class_member_data_value(
140 | SOAP::Data->name(class_members => [@StringClassA])
141 | );
142 | @DataValuesAofA = @{$soapResponse->result};
143 | @DataValuesA = @{$DataValuesAofA[0]};
144 |
145 | $len = scalar(@StringClassA);
146 | for ($i=0; $i < scalar(@StringClassA); $i++) {
147 | $StringClass = $StringClassA[$i];
148 | $DataValueA = $DataValueAofA[$i];
149 |
150 | $name = $StringClass->{"name"};
151 | @members = @{$StringClass->{"members"}};
152 |
153 | print "Data Group $name: [\n";
154 | for($j=0; $j < scalar(@members); $j++) {
155 | my $member = @members[$j];
156 | my $value = $DataValuesA[$j];
157 | print " { $member : $value }\n";
158 | }
159 | print "]\n";
160 | }
161 | }
162 |
163 | #----------------------------------------------------------------------------
164 | sub createDataGroup()
165 | #----------------------------------------------------------------------------
166 | {
167 | my ($datagroup) = @_;
168 |
169 | my @names = ("a", "b", "c");
170 |
171 | my $StringClass =
172 | {
173 | name => $datagroup,
174 | members => [@names]
175 | };
176 |
177 | # Create Data group with names
178 | $soapResponse = $Class->create_string_class(
179 | SOAP::Data->name(classes => [$StringClass])
180 | );
181 | &checkResponse($soapResponse);
182 |
183 | # Set values
184 | # Build Values 2-D Array for values parameter
185 | my @valuesA = ("data 1", "data 2", "data 3");
186 | my @valuesAofA;
187 | push @valuesAofA, [@valuesA];
188 | $soapResponse = $Class->set_string_class_member_data_value
189 | (
190 | SOAP::Data->name(class_members => [$StringClass]),
191 | SOAP::Data->name(values => [@valuesAofA])
192 | );
193 | &checkResponse($soapResponse);
194 |
195 | &getDataGroup($datagroup);
196 | }
197 |
198 | #----------------------------------------------------------------------------
199 | sub deleteDataGroup()
200 | #----------------------------------------------------------------------------
201 | {
202 | my ($datagroup) = @_;
203 |
204 | $soapResponse = $Class->delete_class(
205 | SOAP::Data->name(classes => [$datagroup])
206 | );
207 | &checkResponse($soapResponse);
208 |
209 | print "Data group $datagroup deleted...\n";
210 | }
211 |
212 | #----------------------------------------------------------------------------
213 | sub removeFromDataGroup()
214 | #----------------------------------------------------------------------------
215 | {
216 | my ($datagroup) = @_;
217 |
218 | my @names = ("c");
219 |
220 | my $StringClass =
221 | {
222 | name => $datagroup,
223 | members => [@names]
224 | };
225 |
226 | # Create Data group with names
227 | $soapResponse = $Class->delete_string_class_member(
228 | SOAP::Data->name(class_members => [$StringClass])
229 | );
230 | &checkResponse($soapResponse);
231 |
232 | &getDataGroup($datagroup);
233 | }
234 |
235 | #----------------------------------------------------------------------------
236 | sub addToDataGroup()
237 | #----------------------------------------------------------------------------
238 | {
239 | my ($datagroup) = @_;
240 |
241 | my @names = ("d", "e");
242 |
243 | my $StringClass =
244 | {
245 | name => $datagroup,
246 | members => [@names]
247 | };
248 |
249 | # Create Data group with names
250 | $soapResponse = $Class->add_string_class_member(
251 | SOAP::Data->name(class_members => [$StringClass])
252 | );
253 | &checkResponse($soapResponse);
254 |
255 | # Set values
256 | # Build Values 2-D Array for values parameter
257 | my @valuesA = ("data 4", "data 5");
258 | my @valuesAofA;
259 | push @valuesAofA, [@valuesA];
260 | $soapResponse = $Class->set_string_class_member_data_value
261 | (
262 | SOAP::Data->name(class_members => [$StringClass]),
263 | SOAP::Data->name(values => [@valuesAofA])
264 | );
265 | &checkResponse($soapResponse);
266 |
267 | &getDataGroup($datagroup);
268 | }
269 |
270 |
271 |
--------------------------------------------------------------------------------
/SOAP-DataGroup.ps1:
--------------------------------------------------------------------------------
1 | #----------------------------------------------------------------------------
2 | # The contents of this file are subject to the "END USER LICENSE AGREEMENT
3 | # FOR F5 Software Development Kit for iControl"; you may not use this file
4 | # except in compliance with the License. The License is included in the
5 | # iControl Software Development Kit.
6 | #
7 | # Software distributed under the License is distributed on an "AS IS"
8 | # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9 | # the License for the specific language governing rights and limitations
10 | # under the License.
11 | #
12 | # The Original Code is iControl Code and related documentation
13 | # distributed by F5.
14 | #
15 | # The Initial Developer of the Original Code is F5 Networks,
16 | # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2009
17 | # F5 Networks, Inc. All Rights Reserved. iControl (TM) is a registered
18 | # trademark of F5 Networks, Inc.
19 | #
20 | # Alternatively, the contents of this file may be used under the terms
21 | # of the GNU General Public License (the "GPL"), in which case the
22 | # provisions of GPL are applicable instead of those above. If you wish
23 | # to allow use of your version of this file only under the terms of the
24 | # GPL and not to allow others to use your version of this file under the
25 | # License, indicate your decision by deleting the provisions above and
26 | # replace them with the notice and other provisions required by the GPL.
27 | # If you do not delete the provisions above, a recipient may use your
28 | # version of this file under either the License or the GPL.
29 | #----------------------------------------------------------------------------
30 | param(
31 | [string]$Bigip = "",
32 | [string]$User = "",
33 | [string]$Pass = "",
34 | [string]$DataGroup = "",
35 | [string]$Action = ""
36 | );
37 |
38 |
39 | #-------------------------------------------------------------------------
40 | function Do-Initialize()
41 | #
42 | # Description:
43 | # This function will verify that the iControl PowerShell Snapin is loaded
44 | # in the current runspace.
45 | #
46 | #-------------------------------------------------------------------------
47 | {
48 | if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null )
49 | {
50 | Add-PSSnapIn iControlSnapIn
51 | }
52 | $success = Initialize-F5.iControl -HostName $Bigip -Username $User -Password $Pass;
53 |
54 | return $success;
55 | }
56 |
57 | #-------------------------------------------------------------------------
58 | function Get-DataGroupList()
59 | #-------------------------------------------------------------------------
60 | {
61 | Write-Host "POOL LIST";
62 | Write-Host "---------";
63 | $pool_list = $(Get-F5.iControl).LocalLBClass.get_address_class_list();
64 | foreach($pool in $pool_list)
65 | {
66 | Write-Host " $pool - address";
67 | }
68 | $pool_list = $(Get-F5.iControl).LocalLBClass.get_string_class_list();
69 | foreach($pool in $pool_list)
70 | {
71 | Write-Host " $pool - string";
72 | }
73 | $pool_list = $(Get-F5.iControl).LocalLBClass.get_value_class_list();
74 | foreach($pool in $pool_list)
75 | {
76 | Write-Host " $pool - value";
77 | }
78 | }
79 |
80 | #-------------------------------------------------------------------------
81 | function Get-DataGroup()
82 | #-------------------------------------------------------------------------
83 | {
84 | param(
85 | [string]$Name
86 | );
87 |
88 | $StringClassA = $(Get-F5.iControl).LocalLBClass.get_string_class(
89 | (, $Name)
90 | );
91 |
92 | $DataValuesAofA = $(Get-F5.iControl).LocalLBClass.get_string_class_member_data_value(
93 | $StringClassA
94 | );
95 |
96 | for($i=0; $i -lt $StringClassA.Length; $i++) {
97 | $StringClass = $StringClassA[$i];
98 | $DataValuesA = $DataValuesAofA[$i];
99 |
100 | $name = $StringClass.name;
101 | $members = $StringClass.members;
102 |
103 | Write-Host "Data Group ${Name} : [";
104 | for($j=0; $j -lt $members.Length; $j++) {
105 | $member = $members[$j];
106 | $value = $DataValuesA[$j];
107 |
108 | Write-Host " { $member : $value }";
109 | }
110 | Write-Host "]";
111 | }
112 |
113 | }
114 |
115 | #-------------------------------------------------------------------------
116 | function Delete-DataGroup()
117 | #-------------------------------------------------------------------------
118 | {
119 | param(
120 | [string]$Name
121 | );
122 |
123 | $(Get-F5.iControl).LocalLBClass.delete_class( (, $Name) );
124 | Write-Host "Data Group ${Name} deleted..."
125 | }
126 |
127 | #-------------------------------------------------------------------------
128 | function Create-DataGroup()
129 | #-------------------------------------------------------------------------
130 | {
131 | param(
132 | [string]$Name
133 | );
134 |
135 | $StringClassA = New-Object -TypeName iControl.LocalLBClassStringClass[] 1;
136 | $StringClassA[0] = New-Object -TypeName iControl.LocalLBClassStringClass;
137 | $StringClassA[0].name = $Name;
138 | $StringClassA[0].members = ("a", "b", "c");
139 |
140 | $(Get-F5.iControl).LocalLBClass.create_string_class(
141 | $StringClassA
142 | );
143 |
144 | $DataValueA = ("data 1", "data 2", "data 3");
145 | $DataValuesAofA =
146 | $(Get-F5.iControl).LocalLBClass.set_string_class_member_data_value(
147 | $StringClassA,
148 | (, $DataValueA)
149 | )
150 |
151 | Get-DataGroup -Name $Name;
152 | }
153 |
154 | #-------------------------------------------------------------------------
155 | function RemoveFrom-DataGroup()
156 | #-------------------------------------------------------------------------
157 | {
158 | param(
159 | [string]$Name
160 | );
161 |
162 | $StringClassA = New-Object -TypeName iControl.LocalLBClassStringClass[] 1;
163 | $StringClassA[0] = New-Object -TypeName iControl.LocalLBClassStringClass;
164 | $StringClassA[0].name = $Name;
165 | $StringClassA[0].members = ("c");
166 |
167 | $(Get-F5.iControl).LocalLBClass.delete_string_class_member(
168 | $StringClassA
169 | );
170 |
171 | Get-DataGroup -Name $Name;
172 | }
173 |
174 | #-------------------------------------------------------------------------
175 | function AddTo-DataGroup()
176 | #-------------------------------------------------------------------------
177 | {
178 | param(
179 | [string]$Name
180 | );
181 |
182 | $StringClassA = New-Object -TypeName iControl.LocalLBClassStringClass[] 1;
183 | $StringClassA[0] = New-Object -TypeName iControl.LocalLBClassStringClass;
184 | $StringClassA[0].name = $Name;
185 | $StringClassA[0].members = ("d", "e");
186 |
187 | $(Get-F5.iControl).LocalLBClass.add_string_class_member(
188 | $StringClassA
189 | );
190 |
191 | $DataValueA = ("data 4", "data 5");
192 | $DataValuesAofA =
193 | $(Get-F5.iControl).LocalLBClass.set_string_class_member_data_value(
194 | $StringClassA,
195 | (, $DataValueA)
196 | )
197 |
198 | Get-DataGroup -Name $Name;
199 | }
200 |
201 |
202 | #----------------------------------------------------------------------------
203 | function Show-Usage()
204 | #
205 | # Description:
206 | # This function will print the script usage information.
207 | #
208 | #----------------------------------------------------------------------------
209 | {
210 | Write-Host @"
211 | Usage: CreatePoolInPartition.ps1 Arguments
212 | Argument - Description
213 | ---------- -----------
214 | Bigip - The ip/hostname of your BIG-IP.
215 | User - The Managmenet username for your BIG-IP.
216 | Pass - The Management password for your BIG-IP.
217 | Pool - The Name of the pool to create.
218 | Partition - The Partition to place the pool in.
219 | "@;
220 | }
221 |
222 | #============================================================================
223 | # Main application logic
224 | #============================================================================
225 | if ( ($Bigip.Length -eq 0) -or ($User.Length -eq 0) -or ($Pass.Length -eq 0) )
226 | {
227 | Show-Usage;
228 | } else {
229 | if ( Do-Initialize ) {
230 | if ( $DataGroup.Length -eq 0 ) {
231 | Get-DataGroupList;
232 | } elseif ( $Action -eq "create" ) {
233 | Create-DataGroup -Name $DataGroup;
234 | } elseif ( $Action -eq "remove_from" ) {
235 | RemoveFrom-DataGroup -Name $DataGroup;
236 | } elseif ( $Action -eq "add_to" ) {
237 | AddTo-DataGroup -Name $DataGroup;
238 | } elseif ( $Action -eq "delete" ) {
239 | Delete-DataGroup -Name $DataGroup;
240 | } else {
241 | Get-DataGroup -Name $DataGroup;
242 | }
243 | } else {
244 | Write-Error "ERROR: iControl subsystem not initialized"
245 | }
246 | }
247 |
--------------------------------------------------------------------------------
/SOAP-DataGroup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | '''
3 | # The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5
4 | # Software Development Kit for iControl"; you may not use this file except in
5 | # compliance with the License. The License is included in the iControl
6 | # Software Development Kit.
7 | #
8 | # Software distributed under the License is distributed on an "AS IS"
9 | # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
10 | # the License for the specific language governing rights and limitations
11 | # under the License.
12 | #
13 | # The Original Code is iControl Code and related documentation
14 | # distributed by F5.
15 | #
16 | # The Initial Developer of the Original Code is F5 Networks,
17 | # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2004 F5 Networks,
18 | # Inc. All Rights Reserved. iControl (TM) is a registered trademark of F5 Networks, Inc.
19 | #
20 | # Alternatively, the contents of this file may be used under the terms
21 | # of the GNU General Public License (the "GPL"), in which case the
22 | # provisions of GPL are applicable instead of those above. If you wish
23 | # to allow use of your version of this file only under the terms of the
24 | # GPL and not to allow others to use your version of this file under the
25 | # License, indicate your decision by deleting the provisions above and
26 | # replace them with the notice and other provisions required by the GPL.
27 | # If you do not delete the provisions above, a recipient may use your
28 | # version of this file under either the License or the GPL.
29 | '''
30 |
31 | def get_dg_list(bigip):
32 | try:
33 | dg_str_list = bigip.LocalLB.Class.get_string_class_list()
34 | dg_str_names = bigip.LocalLB.Class.get_string_class(dg_str_list)
35 |
36 |
37 | for dg in dg_str_names:
38 | print dg
39 | print ' Data Group: %s' % dg['name']
40 | for x in dg['members']:
41 | print ' %s' % x
42 |
43 | except Exception, e:
44 | print e
45 |
46 |
47 | def extend_dg(bigip, dgname, keys, values):
48 | try:
49 | bigip.LocalLB.Class.add_string_class_member([{'name': dgname, 'members': keys}])
50 | bigip.LocalLB.Class.set_string_class_member_data_value([{'name': dgname, 'members': keys}], [[values]])
51 | except Exception, e:
52 | print e
53 |
54 |
55 | def contract_dg(bigip, dgname, keys):
56 | try:
57 | bigip.LocalLB.Class.delete_string_class_member([{'name': dgname, 'members': keys}])
58 | except Exception, e:
59 | print e
60 |
61 |
62 | def create_dg(bigip, dgname, keys, values):
63 | try:
64 | bigip.LocalLB.Class.create_string_class([{'name': dgname, 'members': keys}])
65 | bigip.LocalLB.Class.set_string_class_member_data_value([{'name': dgname, 'members': keys}], [[values]])
66 | except Exception, e:
67 | print e
68 |
69 |
70 | if __name__ == "__main__":
71 | import bigsuds, argparse, getpass, ssl
72 | ssl._create_default_https_context = ssl._create_unverified_context
73 |
74 | parser = argparse.ArgumentParser(description='Create Data-Group')
75 |
76 | parser.add_argument("host", help='BIG-IP IP or Hostname' )
77 | parser.add_argument("username", help='BIG-IP Username')
78 | parser.add_argument("-d", "--datagroup", help='Name of the data-group you want to create')
79 | args = vars(parser.parse_args())
80 |
81 | hostname = args['host']
82 | username = args['username']
83 | datagroupname = None if args['datagroup'] is None else args['datagroup']
84 |
85 | print "%s, enter your password: " % args['username'],
86 | password = getpass.getpass()
87 |
88 | b = bigsuds.BIGIP(hostname, username, password)
89 |
90 | dg_members_init = ['a', 'b', 'c']
91 | dg_values_init = [1, 2, 3]
92 |
93 | dg_members_add = ['d', 'e']
94 | dg_values_add = [4, 5]
95 |
96 | dg_members_del = ['b']
97 |
98 |
99 | if datagroupname is None:
100 | get_dg_list(b)
101 | else:
102 | create_dg(b, datagroupname, dg_members_init, dg_values_init)
103 | extend_dg(b, datagroupname, dg_members_add, dg_values_add)
104 | contract_dg(b, datagroupname, dg_members_del)
105 |
--------------------------------------------------------------------------------
/SOAPCreatePoolInPartition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5
3 | * Software Development Kit for iControl"; you may not use this file except in
4 | * compliance with the License. The License is included in the iControl
5 | * Software Development Kit.
6 | *
7 | * Software distributed under the License is distributed on an "AS IS"
8 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9 | * the License for the specific language governing rights and limitations
10 | * under the License.
11 | *
12 | * The Original Code is iControl Code and related documentation
13 | * distributed by F5.
14 | *
15 | * The Initial Developer of the Original Code is F5 Networks,
16 | * Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2002 F5
17 | * Inc. All Rights Reserved. iControl (TM) is a registered trademark of F5 Netw
18 | *
19 | * Alternatively, the contents of this file may be used under the terms
20 | * of the GNU General Public License (the "GPL"), in which case the
21 | * provisions of GPL are applicable instead of those above. If you wish
22 | * to allow use of your version of this file only under the terms of the
23 | * GPL and not to allow others to use your version of this file under the
24 | * License, indicate your decision by deleting the provisions above and
25 | * replace them with the notice and other provisions required by the GPL.
26 | * If you do not delete the provisions above, a recipient may use your
27 | * version of this file under either the License or the GPL.
28 | */
29 |
30 | import java.text.*;
31 | import java.util.*;
32 | import java.io.*;
33 |
34 | public class SOAPCreatePoolInPartition extends Object
35 | {
36 | //--------------------------------------------------------------------------
37 | // Member Variables
38 | //--------------------------------------------------------------------------
39 | public iControl.Interfaces m_interfaces = new iControl.Interfaces();
40 |
41 | //--------------------------------------------------------------------------
42 | // Constructor
43 | //--------------------------------------------------------------------------
44 | public SOAPCreatePoolInPartition()
45 | {
46 | }
47 |
48 | //--------------------------------------------------------------------------
49 | // parseArgs
50 | // [0] bigip
51 | // [1] user
52 | // [2] pass
53 | // [3] poolname
54 | // [4] partition
55 | //--------------------------------------------------------------------------
56 | public boolean parseArgs(String[] args) throws Exception
57 | {
58 | boolean bSuccess = false;
59 | int port = 443;
60 | String bigip = null;
61 | String user = null;
62 | String pass = null;
63 | String poolname = null;
64 | String partition = null;
65 |
66 | int len = args.length;
67 | System.out.println("LEN: " + len);
68 |
69 | if ( args.length < 3 )
70 | {
71 | usage();
72 | }
73 | else
74 | {
75 | bigip = args[0];
76 | user = args[1];
77 | pass = args[2];
78 |
79 | if ( args.length > 3 )
80 | {
81 | poolname = args[3];
82 | }
83 | if ( args.length > 4 )
84 | {
85 | partition = args[4];
86 | }
87 |
88 | // build parameters
89 | m_interfaces.initialize(bigip, port, user, pass);
90 |
91 | if ( (null == poolname) || (null == partition) ) {
92 | displayAllPools();
93 | } else {
94 | createPool(poolname, partition);
95 | }
96 | bSuccess = true;
97 | }
98 |
99 | return bSuccess;
100 | }
101 |
102 | //--------------------------------------------------------------------------
103 | //
104 | //--------------------------------------------------------------------------
105 | public void usage()
106 | {
107 | System.out.println("Usage: SOAPCreatePoolInPartition hostname username password [pool partition]");
108 | }
109 |
110 | public void displayAllPools() throws Exception
111 | {
112 | String [] pool_list = m_interfaces.getLocalLBPool().get_list();
113 | System.out.println("Pools\n");
114 | System.out.println("-----------\n");
115 | for(int i=0; i 3 )
77 | {
78 | datagroup = args[3];
79 | }
80 | if ( args.length > 4 )
81 | {
82 | action = args[4];
83 | }
84 |
85 | // build parameters
86 | m_interfaces.initialize(bigip, port, user, pass);
87 |
88 | if ( null == datagroup ) {
89 | getDataGroupList();
90 | } else {
91 | if ( null == action ) {
92 | getDataGroup(datagroup);
93 | } else if ( action.equals("create") ) {
94 | createDataGroup(datagroup);
95 | } else if ( action.equals("delete") ) {
96 | deleteDataGroup(datagroup);
97 | } else if ( action.equals("remove_from") ) {
98 | removeFromDataGroup(datagroup);
99 | } else if ( action.equals("add_to") ) {
100 | addToDataGroup(datagroup);
101 | } else {
102 | getDataGroup(datagroup);
103 | }
104 |
105 | }
106 |
107 | bSuccess = true;
108 | }
109 |
110 | return bSuccess;
111 | }
112 |
113 | //--------------------------------------------------------------------------
114 | //
115 | //--------------------------------------------------------------------------
116 | public void usage()
117 | {
118 | System.out.println("Usage: SOAPDataGroup hostname username password [pool partition]");
119 | }
120 |
121 |
122 | //--------------------------------------------------------------------------
123 | //
124 | //--------------------------------------------------------------------------
125 | public void getDataGroupList() throws Exception
126 | {
127 | System.out.println("Data Groups");
128 | System.out.println("-----------");
129 | String [] pool_list = m_interfaces.getLocalLBClass().get_address_class_list();
130 | for(int i=0; i