File: HaCiSoapClient.pl

package info (click to toggle)
haci 0.98c-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,240 kB
  • sloc: perl: 23,790; javascript: 1,817; sh: 225; makefile: 8
file content (56 lines) | stat: -rwxr-xr-x 1,255 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl

# Demo script using all available functions of the HaCi API

use strict;
use warnings;
use Data::Dumper;

use SOAP::Lite
	on_fault => sub {
		my($soap, $res) = @_;
		die (defined $res && ref $res ? $res->faultstring : $soap->transport->status), "\n";
	};

my $haciApiUrl	= 'http://hacidev.larsux.de/cgi-bin/HaCiAPI.cgi?getWSDL';
#my $user		= 'admin';
#my $pass		= 'admin';
my $user		= 'test';
my $pass		= '1';
my $a			= $ARGV[0] || 0;

my $soap	= SOAP::Lite->service($haciApiUrl);
die "Cannot initiate Soap" unless defined $soap;


if ($a == 1) {
	print Dumper($soap->search($user, $pass, 'test'));
}
elsif ($a == 2) {
	print Dumper($soap->getFreeSubnets($user, $pass, 'testRoot', '192.168.0.0/24', 29, 10));
}
elsif ($a == 3) {
	print Dumper($soap->getFreeSubnetsFromSearch($user, $pass, 'HaCiAPI', 0, 0, 0, 'Pool', 'Pool-Typ=DSL', 29, 10));
}
elsif ($a == 4) {
	print Dumper($soap->addNet($user, $pass, 'testRoot', '192.168.0.100', 32, 'HaCiAPI Test Network', 'ASSIGNED PI'));
}
elsif ($a == 5) {
	print Dumper($soap->delNet($user, $pass, 'testRoot', '192.168.0.100/32'));
} else {
	print "USAGE $0 Number

Options:
	Number:
		1: search
		2: getFreeSubnets
		3: getFreeSubnetsFromSearch
		4: addNet
		5: delNet


";
	exit 0;
}

exit 0;