| 1 | package Net::Cisco::ACS; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # REST IO stuff here | ||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use IO::Socket::SSL qw( SSL_VERIFY_NONE ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use XML::Simple; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # Generics | ||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use URI::Escape; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # Net::Cisco::ACS::* | ||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Net::Cisco::ACS::User; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Net::Cisco::ACS::IdentityGroup; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Net::Cisco::ACS::Device; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Net::Cisco::ACS::DeviceGroup; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Net::Cisco::ACS::Host; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Exporter (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $ERROR %actions); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 1 | $VERSION = '0.04'; | |||||||||||||||||||||||||||
| 26 | 1 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 27 | 1 | @EXPORT = qw(); | |||||||||||||||||||||||||||
| 28 | 1 | @EXPORT_OK = qw(); | |||||||||||||||||||||||||||
| 29 | 1 | %EXPORT_TAGS = (); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 1 | $ERROR = ""; # TODO: Document error properly! | |||||||||||||||||||||||||||
| 32 | 1 | %actions = ( "version" => "/Rest/Common/AcsVersion", | |||||||||||||||||||||||||||
| 33 | "serviceLocation" => "/Rest/Common/ServiceLocation", | ||||||||||||||||||||||||||||
| 34 | "errorMessage" => "/Rest/Common/ErrorMessage", | ||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # Moose! | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | has 'ssl_options' => ( | ||||||||||||||||||||||||||||
| 41 | is => 'rw', | ||||||||||||||||||||||||||||
| 42 | isa => 'HashRef', | ||||||||||||||||||||||||||||
| 43 | 1 | ▶ | default => sub { { 'SSL_verify_mode' => SSL_VERIFY_NONE, 'verify_hostname' => '0' } } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | 1 | ); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 1 | has 'ssl' => ( | |||||||||||||||||||||||||||
| 47 | is => 'rw', | ||||||||||||||||||||||||||||
| 48 | isa => 'Str', | ||||||||||||||||||||||||||||
| 49 | default => '1', | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 1 | has 'hostname' => ( | |||||||||||||||||||||||||||
| 53 | is => 'rw', | ||||||||||||||||||||||||||||
| 54 | isa => 'Str', | ||||||||||||||||||||||||||||
| 55 | required => '1', | ||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 1 | has 'mock' => ( | |||||||||||||||||||||||||||
| 59 | is => 'rw', | ||||||||||||||||||||||||||||
| 60 | isa => 'Str', | ||||||||||||||||||||||||||||
| 61 | default => '0', | ||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub users # No Moose here :( | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
users: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 0 | $ERROR = ""; | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | { my %args = @_; | |||||||||||||||||||||||||||
| 69 | 0 | $self->{"Users"} = $args{"users"}; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ($self->mock()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | { return $self->{"Users"}; } | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ($args{"name"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | { $self->{"Users"} = $self->query("User","name",$args{"name"}); } | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ($args{"id"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 0 | { $self->{"Users"} = $self->query("User","id",$args{"id"}); } | |||||||||||||||||||||||||||
| 77 | } else | ||||||||||||||||||||||||||||
| 78 | 0 | ▶ | { $self->{"Users"} = $self->query("User") unless $self->mock(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 0 | return $self->{"Users"}; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | sub identitygroups # No Moose here :( | ||||||||||||||||||||||||||||
| 84 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
identitygroups: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 0 | $ERROR = ""; | |||||||||||||||||||||||||||
| 86 | 0 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 0 | { my %args = @_; | |||||||||||||||||||||||||||
| 88 | 0 | $self->{"IdentityGroups"} = $args{"identitygroups"}; | |||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ($self->mock()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | { return $self->{"IdentityGroups"}; } | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ($args{"name"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | { $self->{"IdentityGroups"} = $self->query("IdentityGroup","name",$args{"name"}); } | |||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ($args{"id"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | { $self->{"IdentityGroups"} = $self->query("IdentityGroup","id",$args{"id"}); } | |||||||||||||||||||||||||||
| 96 | } else | ||||||||||||||||||||||||||||
| 97 | 0 | { $self->{"IdentityGroups"} = $self->query("IdentityGroup"); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | 0 | return $self->{"IdentityGroups"}; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | sub devices # No Moose here :( | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
devices: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 0 | $ERROR = ""; | |||||||||||||||||||||||||||
| 105 | 0 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 0 | { my %args = @_; | |||||||||||||||||||||||||||
| 107 | 0 | $self->{"Devices"} = $args{"devices"}; | |||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ($self->mock()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 0 | { return $self->{"Devices"}; } | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ($args{"name"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 0 | { $self->{"Devices"} = $self->query("Device","name",$args{"name"}); } | |||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ($args{"id"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | { $self->{"Devices"} = $self->query("Device","id",$args{"id"}); } | |||||||||||||||||||||||||||
| 115 | } else | ||||||||||||||||||||||||||||
| 116 | 0 | { $self->{"Devices"} = $self->query("Device"); | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | 0 | return $self->{"Devices"}; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | sub devicegroups # No Moose here :( | ||||||||||||||||||||||||||||
| 122 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
devicegroups: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 123 | 0 | $ERROR = ""; | |||||||||||||||||||||||||||
| 124 | 0 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 0 | { my %args = @_; | |||||||||||||||||||||||||||
| 126 | 0 | $self->{"DeviceGroups"} = $args{"devicegroups"}; | |||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ($self->mock()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 0 | { return $self->{"DeviceGroups"}; } | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ($args{"name"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 0 | { $self->{"DeviceGroups"} = $self->query("DeviceGroup","name",$args{"name"}); } | |||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ($args{"id"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 0 | { $self->{"DeviceGroups"} = $self->query("DeviceGroup","id",$args{"id"}); } | |||||||||||||||||||||||||||
| 134 | } else | ||||||||||||||||||||||||||||
| 135 | 0 | { $self->{"DeviceGroups"} = $self->query("DeviceGroup"); | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 0 | return $self->{"DeviceGroups"}; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | sub hosts # No Moose here :( | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
hosts: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 142 | 0 | $ERROR = ""; | |||||||||||||||||||||||||||
| 143 | 0 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 0 | { my %args = @_; | |||||||||||||||||||||||||||
| 145 | 0 | $self->{"Hosts"} = $args{"hosts"}; | |||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ($self->mock()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | { return $self->{"Hosts"}; } | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ($args{"name"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | { $self->{"Hosts"} = $self->query("Host","name",$args{"name"}); } | |||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ($args{"id"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 0 | { $self->{"Hosts"} = $self->query("Host","id",$args{"id"}); } | |||||||||||||||||||||||||||
| 153 | } else | ||||||||||||||||||||||||||||
| 154 | 0 | { $self->{"Hosts"} = $self->query("Host"); | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | 0 | return $self->{"Hosts"}; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 1 | has 'username' => ( | |||||||||||||||||||||||||||
| 160 | is => 'rw', | ||||||||||||||||||||||||||||
| 161 | isa => 'Str', | ||||||||||||||||||||||||||||
| 162 | required => '1', | ||||||||||||||||||||||||||||
| 163 | ); | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 1 | has 'password' => ( | |||||||||||||||||||||||||||
| 166 | is => 'rw', | ||||||||||||||||||||||||||||
| 167 | isa => 'Str', | ||||||||||||||||||||||||||||
| 168 | required => '1', | ||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | sub version # No Moose here :( | ||||||||||||||||||||||||||||
| 172 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
version: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 173 | 0 | $ERROR = ""; | |||||||||||||||||||||||||||
| 174 | 0 | ▶ | unless ($self->{"Version"}) # Version is not going to magically change in one session | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | 0 | { $self->{"Version"} = $self->query("Version"); } | |||||||||||||||||||||||||||
| 176 | 0 | return $self->{"Version"}; | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | sub servicelocation # No Moose here :( | ||||||||||||||||||||||||||||
| 180 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
servicelocation: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 181 | 0 | $ERROR = ""; | |||||||||||||||||||||||||||
| 182 | 0 | ▶ | unless ($self->{"ServiceLocation"}) # serviceLocation is not going to magically change in one session | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | { $self->{"ServiceLocation"} = $self->query("ServiceLocation"); } | |||||||||||||||||||||||||||
| 184 | 0 | return $self->{"ServiceLocation"}; | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | sub errormessage # No Moose here :( | ||||||||||||||||||||||||||||
| 188 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
errormessage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 189 | 0 | $ERROR = ""; | |||||||||||||||||||||||||||
| 190 | 0 | $self->{"ErrorMessage"} = $self->query("ErrorMessage"); | |||||||||||||||||||||||||||
| 191 | 0 | return $self->{"ErrorMessage"}; | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | # Non-Moose | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | sub query | ||||||||||||||||||||||||||||
| 197 | 0 | ▶ | { my ($self, $type, $key, $value) = @_; | ||||||||||||||||||||||||||
|
Subroutine
query: not called CC=23 SCAR=63.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 198 | 0 | my $hostname = $self->hostname; | |||||||||||||||||||||||||||
| 199 | 0 | my $credentials = encode_base64($self->username.":".$self->password); | |||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ($self->ssl) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | 0 | { $hostname = "https://$hostname"; } else | |||||||||||||||||||||||||||
| 202 | 0 | { $hostname = "http://$hostname"; } | |||||||||||||||||||||||||||
| 203 | 0 | my $action = ""; | |||||||||||||||||||||||||||
| 204 | 0 | my $mode = ""; | |||||||||||||||||||||||||||
| 205 | 0 | ▶ | $key ||= ""; | ||||||||||||||||||||||||||
|
Condition0%0/2
$key ||= ""
MC/DC0%0/1
$key ||= ""
$key
Truth table0%0/2
A
A= $key
| |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ($type eq "User") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 0 | { $action = $Net::Cisco::ACS::User::actions{"query"}; | |||||||||||||||||||||||||||
| 208 | 0 | $mode = "Users"; | |||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ($key eq "name") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 0 | { $action = $Net::Cisco::ACS::User::actions{"getByName"}.$value; | |||||||||||||||||||||||||||
| 211 | 0 | $mode = "User"; | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if ($key eq "id") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 0 | { $action = $Net::Cisco::ACS::User::actions{"getById"}.$value; | |||||||||||||||||||||||||||
| 215 | 0 | $mode = "User"; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if ($type eq "IdentityGroup") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 0 | { $action = $Net::Cisco::ACS::IdentityGroup::actions{"query"}; | |||||||||||||||||||||||||||
| 220 | 0 | $mode = "IdentityGroups"; | |||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ($key eq "name") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | 0 | { $action = $Net::Cisco::ACS::IdentityGroup::actions{"getByName"}.$value; | |||||||||||||||||||||||||||
| 223 | 0 | $mode = "IdentityGroup"; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ($key eq "id") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 0 | { $action = $Net::Cisco::ACS::IdentityGroup::actions{"getById"}.$value; | |||||||||||||||||||||||||||
| 227 | 0 | $mode = "IdentityGroup"; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if ($type eq "Device") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 0 | { $action = $Net::Cisco::ACS::Device::actions{"query"}; | |||||||||||||||||||||||||||
| 232 | 0 | $mode = "Devices"; | |||||||||||||||||||||||||||
| 233 | 0 | ▶ | if ($key eq "name") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 0 | { $action = $Net::Cisco::ACS::Device::actions{"getByName"}.$value; | |||||||||||||||||||||||||||
| 235 | 0 | $mode = "Device"; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ($key eq "id") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 0 | { $action = $Net::Cisco::ACS::Device::actions{"getById"}.$value; | |||||||||||||||||||||||||||
| 239 | 0 | $mode = "Device"; | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ($type eq "DeviceGroup") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 0 | { $action = $Net::Cisco::ACS::DeviceGroup::actions{"query"}; | |||||||||||||||||||||||||||
| 244 | 0 | $mode = "DeviceGroups"; | |||||||||||||||||||||||||||
| 245 | 0 | ▶ | if ($key eq "name") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 0 | { $action = $Net::Cisco::ACS::DeviceGroup::actions{"getByName"}.$value; | |||||||||||||||||||||||||||
| 247 | 0 | $mode = "DeviceGroup"; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ($key eq "id") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 0 | { $action = $Net::Cisco::ACS::DeviceGroup::actions{"getById"}.$value; | |||||||||||||||||||||||||||
| 251 | 0 | $mode = "DeviceGroup"; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if ($type eq "Host") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 0 | { $action = $Net::Cisco::ACS::Host::actions{"query"}; | |||||||||||||||||||||||||||
| 256 | 0 | $mode = "Hosts"; | |||||||||||||||||||||||||||
| 257 | 0 | ▶ | if ($key eq "macAddress") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | 0 | { $action = $Net::Cisco::ACS::Host::actions{"getByName"}.$value; | |||||||||||||||||||||||||||
| 259 | 0 | $mode = "Host"; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ($key eq "id") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | 0 | { $action = $Net::Cisco::ACS::Host::actions{"getById"}.$value; | |||||||||||||||||||||||||||
| 263 | 0 | $mode = "Host"; | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if ($type eq "Version") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 268 | 0 | { $action = $Net::Cisco::ACS::actions{"version"}; | |||||||||||||||||||||||||||
| 269 | 0 | $mode = "Version"; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ($type eq "ServiceLocation") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | 0 | { $action = $Net::Cisco::ACS::actions{"serviceLocation"}; | |||||||||||||||||||||||||||
| 273 | 0 | $mode = "ServiceLocation"; | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if ($type eq "ErrorMessage") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | 0 | { $action = $Net::Cisco::ACS::actions{"errorMessage"}; | |||||||||||||||||||||||||||
| 277 | 0 | $mode = "ErrorMessage"; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 0 | $hostname = $hostname . $action; | |||||||||||||||||||||||||||
| 281 | 0 | my $useragent = LWP::UserAgent->new (ssl_opts => $self->ssl_options); | |||||||||||||||||||||||||||
| 282 | 0 | my $request = HTTP::Request->new(GET => $hostname ); | |||||||||||||||||||||||||||
| 283 | 0 | $request->header('Authorization' => "Basic $credentials"); | |||||||||||||||||||||||||||
| 284 | 0 | my $result = $useragent->request($request); | |||||||||||||||||||||||||||
| 285 | 0 | ▶ | if ($result->code eq "400") { $ERROR = "Bad Request - HTTP Status: 400"; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ($result->code eq "410") { $ERROR = "Unknown $type queried by name or ID - HTTP Status: 410"; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | 0 | $self->parse_xml($mode, $result->content); | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | sub create | ||||||||||||||||||||||||||||
| 291 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||
| 292 | 0 | my @entries = @_; | |||||||||||||||||||||||||||
| 293 | 0 | ▶ | return unless @entries; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | 0 | my $hostname = $self->hostname; | |||||||||||||||||||||||||||
| 295 | 0 | my $credentials = encode_base64($self->username.":".$self->password); | |||||||||||||||||||||||||||
| 296 | 0 | ▶ | if ($self->ssl) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 297 | 0 | { $hostname = "https://$hostname"; } else | |||||||||||||||||||||||||||
| 298 | 0 | { $hostname = "http://$hostname"; } | |||||||||||||||||||||||||||
| 299 | 0 | my $action = ""; | |||||||||||||||||||||||||||
| 300 | 0 | my $data = ""; | |||||||||||||||||||||||||||
| 301 | 0 | my $first = $entries[0]; | |||||||||||||||||||||||||||
| 302 | 0 | ▶ | while(@entries) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 303 | 0 | { my $record = shift @entries; | |||||||||||||||||||||||||||
| 304 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::User") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 0 | { $action = $Net::Cisco::ACS::User::actions{"create"}; | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::IdentityGroup") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | 0 | { $action = $Net::Cisco::ACS::IdentityGroup::actions{"create"}; | |||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::Device") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | 0 | { $action = $Net::Cisco::ACS::Device::actions{"create"}; | |||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::DeviceGroup") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 317 | 0 | { $action = $Net::Cisco::ACS::DeviceGroup::actions{"create"}; | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::Host") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 321 | 0 | { $action = $Net::Cisco::ACS::Host::actions{"create"}; | |||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | 0 | $data .= $record->toXML; | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 0 | $data = $first->header($data); | |||||||||||||||||||||||||||
| 327 | 0 | $hostname = $hostname . $action; | |||||||||||||||||||||||||||
| 328 | 0 | my $useragent = LWP::UserAgent->new (ssl_opts => $self->ssl_options); | |||||||||||||||||||||||||||
| 329 | 0 | my $request = HTTP::Request->new(POST => $hostname ); | |||||||||||||||||||||||||||
| 330 | 0 | $request->content_type("application/xml"); | |||||||||||||||||||||||||||
| 331 | 0 | $request->header("Authorization" => "Basic $credentials"); | |||||||||||||||||||||||||||
| 332 | 0 | $request->content($data); | |||||||||||||||||||||||||||
| 333 | 0 | my $result = $useragent->request($request); | |||||||||||||||||||||||||||
| 334 | 0 | my $result_ref = $self->parse_xml("result", $result->content); | |||||||||||||||||||||||||||
| 335 | 0 | my $id = ""; | |||||||||||||||||||||||||||
| 336 | 0 | ▶ | if ($result->code ne "200") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 0 | { $ERROR = $result_ref->{"errorCode"}." ".$result_ref->{"moreErrInfo"}." - HTTP Status: ".$result_ref->{"httpCode"}; | |||||||||||||||||||||||||||
| 338 | } else | ||||||||||||||||||||||||||||
| 339 | 0 | { $id = $result_ref->{"newBornId"}; } | |||||||||||||||||||||||||||
| 340 | 0 | return $id; | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | sub update | ||||||||||||||||||||||||||||
| 344 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
update: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||
| 345 | 0 | my @entries = @_; | |||||||||||||||||||||||||||
| 346 | 0 | my $hostname = $self->hostname; | |||||||||||||||||||||||||||
| 347 | 0 | my $credentials = encode_base64($self->username.":".$self->password); | |||||||||||||||||||||||||||
| 348 | 0 | ▶ | if ($self->ssl) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 349 | 0 | { $hostname = "https://$hostname"; } else | |||||||||||||||||||||||||||
| 350 | 0 | { $hostname = "http://$hostname"; } | |||||||||||||||||||||||||||
| 351 | 0 | my $action = ""; | |||||||||||||||||||||||||||
| 352 | 0 | my $data = ""; | |||||||||||||||||||||||||||
| 353 | 0 | my $first = $entries[0]; | |||||||||||||||||||||||||||
| 354 | 0 | ▶ | while(@entries) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 355 | 0 | { my $record = shift @entries; | |||||||||||||||||||||||||||
| 356 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::User") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 357 | 0 | { $action = $Net::Cisco::ACS::User::actions{"update"}; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::IdentityGroup") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | 0 | { $action = $Net::Cisco::ACS::IdentityGroup::actions{"update"}; | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::Device") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | 0 | { $action = $Net::Cisco::ACS::Device::actions{"update"}; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::DeviceGroup") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | 0 | { $action = $Net::Cisco::ACS::DeviceGroup::actions{"update"}; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::Host") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 373 | 0 | { $action = $Net::Cisco::ACS::Host::actions{"update"}; | |||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | 0 | $data .= $record->toXML; | |||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | 0 | $data = $first->header($data); | |||||||||||||||||||||||||||
| 379 | 0 | $hostname = $hostname . $action; | |||||||||||||||||||||||||||
| 380 | 0 | my $useragent = LWP::UserAgent->new (ssl_opts => $self->ssl_options); | |||||||||||||||||||||||||||
| 381 | 0 | my $request = HTTP::Request->new(PUT => $hostname ); | |||||||||||||||||||||||||||
| 382 | 0 | $request->content_type("application/xml"); | |||||||||||||||||||||||||||
| 383 | 0 | $request->header("Authorization" => "Basic $credentials"); | |||||||||||||||||||||||||||
| 384 | 0 | $request->content($data); | |||||||||||||||||||||||||||
| 385 | 0 | my $result = $useragent->request($request); | |||||||||||||||||||||||||||
| 386 | 0 | my $result_ref = undef; | |||||||||||||||||||||||||||
| 387 | 0 | ▶ | $result_ref = $self->parse_xml("result", $result->content) if $result_ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 388 | 0 | ▶ | $result_ref = {} unless $result_ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 389 | 0 | my $id = ""; | |||||||||||||||||||||||||||
| 390 | 0 | ▶ | if ($result->code ne "200" && $result_ref->{"errorCode"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$result->code ne 200 and $result_ref->{"errorCode"}
MC/DC0%0/2
$result->code ne 200 and $result_ref->{"errorCode"}
$result->code ne 200
$result_ref->{"errorCode"}
Truth table0%0/3
A and B
A= $result->code ne 200B= $result_ref->{"errorCode"}
| |||||||||||||||||||||||||||||
| 391 | 0 | { $ERROR = $result_ref->{"errorCode"}." ".$result_ref->{"moreErrInfo"}." - HTTP Status: ".$result_ref->{"httpCode"}; | |||||||||||||||||||||||||||
| 392 | } else | ||||||||||||||||||||||||||||
| 393 | 0 | { $id = $result_ref->{"newBornId"}; } | |||||||||||||||||||||||||||
| 394 | 0 | return $id; | |||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | sub delete | ||||||||||||||||||||||||||||
| 398 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||
| 399 | 0 | my $record = shift; | |||||||||||||||||||||||||||
| 400 | 0 | my $hostname = $self->hostname; | |||||||||||||||||||||||||||
| 401 | 0 | my $credentials = encode_base64($self->username.":".$self->password); | |||||||||||||||||||||||||||
| 402 | 0 | ▶ | if ($self->ssl) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 403 | 0 | { $hostname = "https://$hostname"; } else | |||||||||||||||||||||||||||
| 404 | 0 | { $hostname = "http://$hostname"; } | |||||||||||||||||||||||||||
| 405 | 0 | my $action = ""; | |||||||||||||||||||||||||||
| 406 | 0 | my $type = ""; | |||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | 0 | ▶ | if (ref($record) eq "ARRAY") { $record = $record->[0]; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::User") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 410 | 0 | { $action = $Net::Cisco::ACS::User::actions{"getById"}; | |||||||||||||||||||||||||||
| 411 | 0 | $type = "User"; | |||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::IdentityGroup") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | 0 | { $action = $Net::Cisco::ACS::IdentityGroup::actions{"getById"}; | |||||||||||||||||||||||||||
| 416 | 0 | $type = "IdentityGroup"; | |||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::Device") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 420 | 0 | { $action = $Net::Cisco::ACS::Device::actions{"getById"}; | |||||||||||||||||||||||||||
| 421 | 0 | $type = "Device"; | |||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::DeviceGroup") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 425 | 0 | { $action = $Net::Cisco::ACS::DeviceGroup::actions{"getById"}; | |||||||||||||||||||||||||||
| 426 | 0 | $type = "DeviceGroup"; | |||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if (ref($record) eq "Net::Cisco::ACS::Host") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 430 | 0 | { $action = $Net::Cisco::ACS::Host::actions{"getById"}; | |||||||||||||||||||||||||||
| 431 | 0 | $type = "Host"; | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 0 | my $data = $record->header($record->toXML); | |||||||||||||||||||||||||||
| 435 | 0 | $hostname = $hostname . $action.$record->id; | |||||||||||||||||||||||||||
| 436 | 0 | my $useragent = LWP::UserAgent->new (ssl_opts => $self->ssl_options); | |||||||||||||||||||||||||||
| 437 | 0 | my $request = HTTP::Request->new(DELETE => $hostname ); | |||||||||||||||||||||||||||
| 438 | 0 | $request->content_type("application/xml"); | |||||||||||||||||||||||||||
| 439 | 0 | $request->header("Authorization" => "Basic $credentials"); | |||||||||||||||||||||||||||
| 440 | 0 | $request->content($data); | |||||||||||||||||||||||||||
| 441 | 0 | my $result = $useragent->request($request); | |||||||||||||||||||||||||||
| 442 | 0 | my $result_ref = undef; | |||||||||||||||||||||||||||
| 443 | 0 | ▶ | $result_ref = $self->parse_xml("result", $result->content) if $result_ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 444 | 0 | ▶ | $result_ref = {} unless $result_ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 445 | 0 | my $id = ""; | |||||||||||||||||||||||||||
| 446 | 0 | ▶ | if ($result->code ne "200" && $result_ref->{"errorCode"}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$result->code ne 200 and $result_ref->{"errorCode"}
MC/DC0%0/2
$result->code ne 200 and $result_ref->{"errorCode"}
$result->code ne 200
$result_ref->{"errorCode"}
Truth table0%0/3
A and B
A= $result->code ne 200B= $result_ref->{"errorCode"}
| |||||||||||||||||||||||||||||
| 447 | 0 | { $ERROR = $result_ref->{"errorCode"}." ".$result_ref->{"moreErrInfo"}." - HTTP Status: ".$result_ref->{"httpCode"}; | |||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | sub parse_xml | ||||||||||||||||||||||||||||
| 452 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
parse_xml: not called CC=20 SCAR=60.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 453 | 0 | my $type = shift; | |||||||||||||||||||||||||||
| 454 | 0 | my $xml_ref = shift; | |||||||||||||||||||||||||||
| 455 | 0 | my $xmlsimple = XML::Simple->new(SuppressEmpty => 1); | |||||||||||||||||||||||||||
| 456 | 0 | my $xmlout = $xmlsimple->XMLin($xml_ref); | |||||||||||||||||||||||||||
| 457 | 0 | ▶ | if ($type eq "Users") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 458 | 0 | { my $users_ref = $xmlout->{"User"}; | |||||||||||||||||||||||||||
| 459 | 0 | my %users = (); | |||||||||||||||||||||||||||
| 460 | 0 | for my $key (keys % {$users_ref}) | |||||||||||||||||||||||||||
| 461 | 0 | { my $user = Net::Cisco::ACS::User->new( name => $key, %{ $users_ref->{$key} } ); | |||||||||||||||||||||||||||
| 462 | 0 | $users{$key} = $user; | |||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||
| 464 | 0 | $self->{"Users"} = \%users; | |||||||||||||||||||||||||||
| 465 | 0 | return $self->{"Users"}; | |||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if ($type eq "User") # userByName and userById DO NOT return hash but a single instance of Net::Cisco::ACS::User | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 468 | 0 | { my %user_hash = %{ $xmlout }; | |||||||||||||||||||||||||||
| 469 | 0 | my $user = Net::Cisco::ACS::User->new( %user_hash ); | |||||||||||||||||||||||||||
| 470 | 0 | $self->{"Users"} = $user ; | |||||||||||||||||||||||||||
| 471 | 0 | return $self->{"Users"}; | |||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | 0 | ▶ | if ($type eq "IdentityGroups") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 475 | 0 | { my $identitygroups_ref = $xmlout->{"IdentityGroup"}; | |||||||||||||||||||||||||||
| 476 | 0 | my %identitygroups = (); | |||||||||||||||||||||||||||
| 477 | 0 | for my $key (keys % {$identitygroups_ref}) | |||||||||||||||||||||||||||
| 478 | 0 | { my $identitygroup = Net::Cisco::ACS::IdentityGroup->new( name => $key, %{ $identitygroups_ref->{$key} } ); | |||||||||||||||||||||||||||
| 479 | 0 | $identitygroups{$key} = $identitygroup; | |||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||
| 481 | 0 | $self->{"IdentityGroups"} = \%identitygroups; | |||||||||||||||||||||||||||
| 482 | 0 | return $self->{"IdentityGroups"}; | |||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||
| 484 | 0 | ▶ | if ($type eq "IdentityGroup") # ByName and ById DO NOT return hash but a single instance of Net::Cisco::ACS::IdentityGroup | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 485 | 0 | { my %identitygroup_hash = %{ $xmlout }; | |||||||||||||||||||||||||||
| 486 | 0 | my $identitygroup = Net::Cisco::ACS::IdentityGroup->new( %identitygroup_hash ); | |||||||||||||||||||||||||||
| 487 | 0 | $self->{"IdentityGroups"} = $identitygroup; | |||||||||||||||||||||||||||
| 488 | 0 | return $self->{"IdentityGroups"}; | |||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if ($type eq "Devices") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 492 | 0 | { my $device_ref = $xmlout->{"Device"}; | |||||||||||||||||||||||||||
| 493 | 0 | my %devices = (); | |||||||||||||||||||||||||||
| 494 | 0 | for my $key (keys % {$device_ref}) | |||||||||||||||||||||||||||
| 495 | 0 | { my $device = Net::Cisco::ACS::Device->new( name => $key, %{ $device_ref->{$key} } ); | |||||||||||||||||||||||||||
| 496 | 0 | $devices{$key} = $device; | |||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||
| 498 | 0 | $self->{"Devices"} = \%devices; | |||||||||||||||||||||||||||
| 499 | 0 | return $self->{"Devices"}; | |||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||
| 501 | 0 | ▶ | if ($type eq "Device") # deviceByName and deviceById DO NOT return hash but a single instance of Net::Cisco::ACS::Device | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 502 | 0 | { my %device_hash = %{ $xmlout }; | |||||||||||||||||||||||||||
| 503 | 0 | my $device = Net::Cisco::ACS::Device->new( %device_hash ); | |||||||||||||||||||||||||||
| 504 | 0 | $self->{"Devices"} = $device; | |||||||||||||||||||||||||||
| 505 | 0 | return $self->{"Devices"}; | |||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 0 | ▶ | if ($type eq "DeviceGroups") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 509 | 0 | { my $devicegroup_ref = $xmlout->{"DeviceGroup"}; | |||||||||||||||||||||||||||
| 510 | 0 | my %devicegroups = (); | |||||||||||||||||||||||||||
| 511 | 0 | for my $key (keys % {$devicegroup_ref}) | |||||||||||||||||||||||||||
| 512 | 0 | { my $devicegroup = Net::Cisco::ACS::DeviceGroup->new( name => $key, %{ $devicegroup_ref->{$key} } ); | |||||||||||||||||||||||||||
| 513 | 0 | $devicegroups{$key} = $devicegroup; | |||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||
| 515 | 0 | $self->{"DeviceGroups"} = \%devicegroups; | |||||||||||||||||||||||||||
| 516 | 0 | return $self->{"DeviceGroups"}; | |||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||
| 518 | 0 | ▶ | if ($type eq "DeviceGroup") # deviceGroupByName and deviceGroupById DO NOT return hash but a single instance of Net::Cisco::ACS::DeviceGroup | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 519 | 0 | { my %devicegroup_hash = %{ $xmlout }; | |||||||||||||||||||||||||||
| 520 | 0 | my $devicegroup = Net::Cisco::ACS::DeviceGroup->new( %devicegroup_hash ); | |||||||||||||||||||||||||||
| 521 | 0 | $self->{"DeviceGroups"} = $devicegroup; | |||||||||||||||||||||||||||
| 522 | 0 | return $self->{"DeviceGroups"}; | |||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | 0 | ▶ | if ($type eq "Hosts") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 526 | 0 | { my $host_ref = $xmlout->{"Host"}; | |||||||||||||||||||||||||||
| 527 | 0 | my %hosts = (); | |||||||||||||||||||||||||||
| 528 | 0 | for my $key (keys % {$host_ref}) | |||||||||||||||||||||||||||
| 529 | 0 | { my $host = Net::Cisco::ACS::Host->new( macAddress => $key, %{ $host_ref->{$key} } ); | |||||||||||||||||||||||||||
| 530 | 0 | $hosts{$key} = $host; | |||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||
| 532 | 0 | $self->{"Hosts"} = \%hosts; | |||||||||||||||||||||||||||
| 533 | 0 | return $self->{"Hosts"}; | |||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||
| 535 | 0 | ▶ | if ($type eq "Host") # ByName and ById DO NOT return hash but a single instance of Net::Cisco::ACS::Host | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 536 | 0 | { my %host_hash = %{ $xmlout }; | |||||||||||||||||||||||||||
| 537 | 0 | my $host = Net::Cisco::ACS::Host->new( %host_hash ); | |||||||||||||||||||||||||||
| 538 | 0 | $self->{"Hosts"} = $host; | |||||||||||||||||||||||||||
| 539 | 0 | return $self->{"Hosts"}; | |||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | 0 | ▶ | if ($type eq "result") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 543 | 0 | { my %result_hash = %{ $xmlout }; | |||||||||||||||||||||||||||
| 544 | 0 | return \%result_hash; | |||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||
| 546 | 0 | ▶ | if ($type eq "Version") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 547 | 0 | { my %version_hash = %{ $xmlout }; | |||||||||||||||||||||||||||
| 548 | 0 | return \%version_hash; | |||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||
| 550 | 0 | ▶ | if ($type eq "ServiceLocation") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 551 | 0 | { my %servicelocation_hash = %{ $xmlout }; | |||||||||||||||||||||||||||
| 552 | 0 | return \%servicelocation_hash; | |||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||
| 554 | 0 | ▶ | if ($type eq "ErrorMessage") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 555 | 0 | { my %errormessage_hash = %{ $xmlout }; | |||||||||||||||||||||||||||
| 556 | 0 | return \%errormessage_hash; | |||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | =head1 NAME | ||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | Net::Cisco::ACS - Access Cisco ACS functionality through REST API | ||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||
| 565 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | use Net::Cisco::ACS; | ||||||||||||||||||||||||||||
| 568 | my $acs = Net::Cisco::ACS->new(hostname => '10.0.0.1', username => 'acsadmin', password => 'testPassword'); | ||||||||||||||||||||||||||||
| 569 | # Options: | ||||||||||||||||||||||||||||
| 570 | # hostname - IP or hostname of Cisco ACS 5.x server | ||||||||||||||||||||||||||||
| 571 | # username - Username of Administrator user | ||||||||||||||||||||||||||||
| 572 | # password - Password of user | ||||||||||||||||||||||||||||
| 573 | # ssl - SSL enabled (1 - default) or disabled (0) | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | my %users = $acs->users; | ||||||||||||||||||||||||||||
| 576 | # Retrieve all users from ACS | ||||||||||||||||||||||||||||
| 577 | # Returns hash with username / Net::Cisco::ACS::User pairs | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | print $acs->users->{"acsadmin"}->toXML; | ||||||||||||||||||||||||||||
| 580 | # Dump in XML format (used by ACS for API calls) | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | my $user = $acs->users("name","acsadmin"); | ||||||||||||||||||||||||||||
| 583 | # Faster call to request specific user information by name | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | my $user = $acs->users("id","150"); | ||||||||||||||||||||||||||||
| 586 | # Faster call to request specific user information by ID (assigned by ACS, present in Net::Cisco::ACS::User) | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | my %identitygroups = $acs->identitygroups; | ||||||||||||||||||||||||||||
| 589 | # Retrieve all identitygroups from ACS | ||||||||||||||||||||||||||||
| 590 | # Returns hash with name / Net::Cisco::ACS::IdentityGroup pairs | ||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||
| 592 | print $acs->identitygroups->{"All Groups"}->toXML; | ||||||||||||||||||||||||||||
| 593 | # Dump in XML format (used by ACS for API calls) | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | my $identitygroup = $acs->identitygroups("name","All Groups"); | ||||||||||||||||||||||||||||
| 596 | # Faster call to request specific identity group information by name | ||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||
| 598 | my $identitygroup = $acs->identitygroups("id","150"); | ||||||||||||||||||||||||||||
| 599 | # Faster call to request specific identity group information by ID (assigned by ACS, present in Net::Cisco::ACS::IdentityGroup) | ||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | my %devices = $acs->devices; | ||||||||||||||||||||||||||||
| 602 | # Retrieve all devices from ACS | ||||||||||||||||||||||||||||
| 603 | # Returns hash with device name / Net::Cisco::ACS::Device pairs | ||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | print $acs->devices->{"MAIN_Router"}->toXML; | ||||||||||||||||||||||||||||
| 606 | # Dump in XML format (used by ACS for API calls) | ||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||
| 608 | my $device = $acs->devices("name","MAIN_Router"); | ||||||||||||||||||||||||||||
| 609 | # Faster call to request specific device information by name | ||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | my $device = $acs->devices("id","250"); | ||||||||||||||||||||||||||||
| 612 | # Faster call to request specific device information by ID (assigned by ACS, present in Net::Cisco::ACS::Device) | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | my %devicegroups = $acs->devicegroups; | ||||||||||||||||||||||||||||
| 615 | # Retrieve all device groups from ACS | ||||||||||||||||||||||||||||
| 616 | # Returns hash with device name / Net::Cisco::ACS::DeviceGroup pairs | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | print $acs->devicegroups->{"All Locations"}->toXML; | ||||||||||||||||||||||||||||
| 619 | # Dump in XML format (used by ACS for API calls) | ||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||
| 621 | my $device = $acs->devicegroups("name","All Locations"); | ||||||||||||||||||||||||||||
| 622 | # Faster call to request specific device group information by name | ||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | my $devicegroup = $acs->devicegroups("id","250"); | ||||||||||||||||||||||||||||
| 625 | # Faster call to request specific device group information by ID (assigned by ACS, present in Net::Cisco::ACS::DeviceGroup) | ||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||
| 627 | my %hosts = $acs->hosts; | ||||||||||||||||||||||||||||
| 628 | # Retrieve all hosts from ACS | ||||||||||||||||||||||||||||
| 629 | # Returns hash with host name / Net::Cisco::ACS::Host pairs | ||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||
| 631 | print $acs->hosts->{"1234"}->toXML; | ||||||||||||||||||||||||||||
| 632 | # Dump in XML format (used by ACS for API calls) | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | my $host = $acs->hosts("name","1234"); | ||||||||||||||||||||||||||||
| 635 | # Faster call to request specific host information by name | ||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | my $host = $acs->hosts("id","250"); | ||||||||||||||||||||||||||||
| 638 | # Faster call to request specific hosts information by ID (assigned by ACS, present in Net::Cisco::ACS::Host) | ||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||
| 640 | $user->id(0); # Required for new user! | ||||||||||||||||||||||||||||
| 641 | my $id = $acs->create($user); | ||||||||||||||||||||||||||||
| 642 | # Create new user based on Net::Cisco::ACS::User instance | ||||||||||||||||||||||||||||
| 643 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 644 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 645 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 646 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | my $id = $acs->create(@users); # Still requires nullified ID! | ||||||||||||||||||||||||||||
| 649 | # Create new users based on Net::Cisco::ACS::User instances in arguments | ||||||||||||||||||||||||||||
| 650 | # Return value is not guaranteed in this case! | ||||||||||||||||||||||||||||
| 651 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 652 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 653 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | $identitygroup->id(0); # Required for new record! | ||||||||||||||||||||||||||||
| 656 | my $id = $acs->create($identitygroup); | ||||||||||||||||||||||||||||
| 657 | # Create new identity group based on Net::Cisco::ACS::IdentityGroup instance | ||||||||||||||||||||||||||||
| 658 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 659 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 660 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 661 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||
| 663 | my $id = $acs->create(@identitygroups); # Still requires nullified ID! | ||||||||||||||||||||||||||||
| 664 | # Create new identitygroups based on Net::Cisco::ACS::IdentityGroup instances in arguments | ||||||||||||||||||||||||||||
| 665 | # Return value is not guaranteed in this case! | ||||||||||||||||||||||||||||
| 666 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 667 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 668 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||
| 670 | $device->id(0); # Required for new device! | ||||||||||||||||||||||||||||
| 671 | my $id = $acs->create($device); | ||||||||||||||||||||||||||||
| 672 | # Create new device based on Net::Cisco::ACS::Device instance | ||||||||||||||||||||||||||||
| 673 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 674 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 675 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 676 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||
| 678 | my $id = $acs->create(@devices); # Still requires nullified ID! | ||||||||||||||||||||||||||||
| 679 | # Create new devices based on Net::Cisco::ACS::Device instances in arguments | ||||||||||||||||||||||||||||
| 680 | # Return value is not guaranteed in this case! | ||||||||||||||||||||||||||||
| 681 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 682 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 683 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||
| 685 | $devicegroup->id(0); # Required for new device group! | ||||||||||||||||||||||||||||
| 686 | my $id = $acs->create($devicegroup); | ||||||||||||||||||||||||||||
| 687 | # Create new device group based on Net::Cisco::ACS::DeviceGroup instance | ||||||||||||||||||||||||||||
| 688 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 689 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 690 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 691 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | my $id = $acs->create(@devicegroups); # Still requires nullified ID! | ||||||||||||||||||||||||||||
| 694 | # Create new devicegroups based on Net::Cisco::ACS::DeviceGroup instances in arguments | ||||||||||||||||||||||||||||
| 695 | # Return value is not guaranteed in this case! | ||||||||||||||||||||||||||||
| 696 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 697 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 698 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | $host->id(0); # Required for new host! | ||||||||||||||||||||||||||||
| 701 | my $id = $acs->create($host); | ||||||||||||||||||||||||||||
| 702 | # Create new host based on Net::Cisco::ACS::Host instance | ||||||||||||||||||||||||||||
| 703 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 704 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 705 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 706 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | my $id = $acs->create(@hosts); # Still requires nullified ID! | ||||||||||||||||||||||||||||
| 709 | # Create new hosts based on Net::Cisco::ACS::Host instances in arguments | ||||||||||||||||||||||||||||
| 710 | # Return value is not guaranteed in this case! | ||||||||||||||||||||||||||||
| 711 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 712 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 713 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||
| 715 | my $id = $acs->update($user); | ||||||||||||||||||||||||||||
| 716 | # Update existing user based on Net::Cisco::ACS::User instance | ||||||||||||||||||||||||||||
| 717 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 718 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 719 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 720 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | my $id = $acs->update(@users); | ||||||||||||||||||||||||||||
| 723 | # Update existing users based on Net::Cisco::ACS::User instances in arguments | ||||||||||||||||||||||||||||
| 724 | # Return value is not guaranteed in this case! | ||||||||||||||||||||||||||||
| 725 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 726 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 727 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||
| 729 | my $id = $acs->update($identitygroup); | ||||||||||||||||||||||||||||
| 730 | # Update existing identitygroup based on Net::Cisco::ACS::IdentityGroup instance | ||||||||||||||||||||||||||||
| 731 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 732 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 733 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 734 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||
| 736 | my $id = $acs->update(@identitygroups); | ||||||||||||||||||||||||||||
| 737 | # Update existing identitygroups based on Net::Cisco::ACS::IdentityGroups instances in arguments | ||||||||||||||||||||||||||||
| 738 | # Return value is not guaranteed in this case! | ||||||||||||||||||||||||||||
| 739 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 740 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 741 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||
| 743 | my $id = $acs->update($device); | ||||||||||||||||||||||||||||
| 744 | # Update existing device based on Net::Cisco::ACS::Device instance | ||||||||||||||||||||||||||||
| 745 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 746 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 747 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 748 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||
| 750 | my $id = $acs->update(@devices); | ||||||||||||||||||||||||||||
| 751 | # Update existing devices based on Net::Cisco::ACS::Device instances in arguments | ||||||||||||||||||||||||||||
| 752 | # Return value is not guaranteed in this case! | ||||||||||||||||||||||||||||
| 753 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 754 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 755 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | my $id = $acs->update($devicegroup); | ||||||||||||||||||||||||||||
| 758 | # Update existing device based on Net::Cisco::ACS::DeviceGroup instance | ||||||||||||||||||||||||||||
| 759 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 760 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 761 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 762 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||
| 764 | my $id = $acs->update(@devicegroups); | ||||||||||||||||||||||||||||
| 765 | # Update existing devicegroups based on Net::Cisco::ACS::DeviceGroup instances in arguments | ||||||||||||||||||||||||||||
| 766 | # Return value is not guaranteed in this case! | ||||||||||||||||||||||||||||
| 767 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 768 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 769 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||
| 771 | my $id = $acs->update($host); | ||||||||||||||||||||||||||||
| 772 | # Update existing device based on Net::Cisco::ACS::Host instance | ||||||||||||||||||||||||||||
| 773 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 774 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 775 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 776 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||
| 778 | my $id = $acs->update(@hosts); | ||||||||||||||||||||||||||||
| 779 | # Update existing hosts based on Net::Cisco::ACS::Host instances in arguments | ||||||||||||||||||||||||||||
| 780 | # Return value is not guaranteed in this case! | ||||||||||||||||||||||||||||
| 781 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 782 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 783 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||
| 785 | $acs->delete($user); | ||||||||||||||||||||||||||||
| 786 | # Delete existing user based on Net::Cisco::ACS::User instance | ||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||
| 788 | $acs->delete($identitygroup); | ||||||||||||||||||||||||||||
| 789 | # Delete existing identity group based on Net::Cisco::ACS::IdentityGroup instance | ||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||
| 791 | $acs->delete($device); | ||||||||||||||||||||||||||||
| 792 | # Delete existing device based on Net::Cisco::ACS::Device instance | ||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||
| 794 | $acs->delete($devicegroup); | ||||||||||||||||||||||||||||
| 795 | # Delete existing device based on Net::Cisco::ACS::DeviceGroup instance | ||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||
| 797 | $acs->delete($host); | ||||||||||||||||||||||||||||
| 798 | # Delete existing host based on Net::Cisco::ACS::Host instance | ||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||
| 800 | $acs->version | ||||||||||||||||||||||||||||
| 801 | # Return version information for the connected server *HASHREF* | ||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||
| 803 | $acs->serviceLocation | ||||||||||||||||||||||||||||
| 804 | # Return ACS instance that serves as primary and the ACS instance that provide Monitoring and Troubleshooting Viewer. *HASHREF* | ||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||
| 806 | $acs->errorMessage | ||||||||||||||||||||||||||||
| 807 | # Return all ACS message codes and message texts that are used on the REST Interface. *HASHREF* | ||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||
| 810 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||
| 812 | Net::Cisco::ACS is an implementation of the Cisco Secure Access Control System (ACS) REST API. Cisco ACS is a application / appliance that can be used for network access policy control. In short, it allows configuration of access policies for specific users onto specific devices and applications (either using RADIUS or TACACS+ authentication). Net::Cisco::ACS currently supports Device, Device Group, Host, User, Identity Group and generic information. | ||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||
| 814 | =head1 USAGE | ||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||
| 816 | All calls are handled through an instance of the L<Net::Cisco::ACS> class. | ||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||
| 818 | use Net::Cisco::ACS; | ||||||||||||||||||||||||||||
| 819 | my $acs = Net::Cisco::ACS->new(hostname => '10.0.0.1', username => 'acsadmin', password => 'testPassword'); | ||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||
| 821 | =over 3 | ||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||
| 823 | =item new | ||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||
| 825 | Class constructor. Returns object of Net::Cisco::ACS on succes. Required fields are: | ||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||
| 827 | =over 5 | ||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||
| 829 | =item hostname | ||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||
| 831 | =item username | ||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||
| 833 | =item password | ||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||
| 835 | =back | ||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | Optional fields are | ||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||
| 839 | =over 5 | ||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||
| 841 | =item ssl | ||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||
| 843 | =item ssl_options | ||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||
| 845 | =back | ||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||
| 847 | =item hostname | ||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||
| 849 | IP or hostname of Cisco ACS 5.x server. This is a required value in the constructor but can be redefined afterwards. | ||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||
| 851 | =item username | ||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||
| 853 | Username of Administrator user. This is a required value in the constructor but can be redefined afterwards. | ||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||
| 855 | =item password | ||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||
| 857 | Password of user. This is a required value in the constructor but can be redefined afterwards. | ||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||
| 859 | =item ssl | ||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||
| 861 | SSL enabled (1 - default) or disabled (0). | ||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||
| 863 | =item ssl_options | ||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||
| 865 | Value is passed directly to LWP::UserAGent as ssl_opt. Default value (hash-ref) is | ||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||
| 867 | { 'SSL_verify_mode' => SSL_VERIFY_NONE, 'verify_hostname' => '0' } | ||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||
| 869 | =back | ||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||
| 871 | From the class instance, call the different methods for retrieving values. | ||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||
| 873 | =over 3 | ||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||
| 875 | =item users | ||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||
| 877 | Returns hash or single instance, depending on context. | ||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||
| 879 | my %users = $acs->users(); # Slow | ||||||||||||||||||||||||||||
| 880 | my $user = $acs->users()->{"acsadmin"}; | ||||||||||||||||||||||||||||
| 881 | print $user->name; | ||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||
| 883 | The returned hash contains instances of L<Net::Cisco::ACS::User>, using name (typically the username) as the hash key. Using a call to C<users> with no arguments will retrieve all users and can take quite a few seconds (depending on the size of your database). When you know the username or ID, use the L<users> call with arguments as listed below. | ||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||
| 885 | my $user = $acs->users("name","acsadmin"); # Faster | ||||||||||||||||||||||||||||
| 886 | # or | ||||||||||||||||||||||||||||
| 887 | my $user = $acs->users("id","123"); # Faster | ||||||||||||||||||||||||||||
| 888 | print $user->name; | ||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||
| 890 | The ID is typically generated by Cisco ACS when the entry is created. It can be retrieved by calling the C<id> method on the object. | ||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||
| 892 | print $user->id; | ||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||
| 894 | =item identitygroups | ||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||
| 896 | Returns hash or single instance, depending on context. | ||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||
| 898 | my %identitygroups = $acs->identitygroups(); # Slow | ||||||||||||||||||||||||||||
| 899 | my $identitygroup = $acs->identitygroups()->{"All Groups"}; | ||||||||||||||||||||||||||||
| 900 | print $identitgroup->name; | ||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||
| 902 | The returned hash contains instances of L<Net::Cisco::ACS::IdentityGroup>, using name (typically the username) as the hash key. Using a call to C<identitygroup> with no arguments will retrieve all identitygroups and can take quite a few seconds (depending on the size of your database). When you know the group name or ID, use the L<identitygroups> call with arguments as listed below. | ||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||
| 904 | my $identitygroup = $acs->identitygroups("name","All Groups"); # Faster | ||||||||||||||||||||||||||||
| 905 | # or | ||||||||||||||||||||||||||||
| 906 | my $identitygroup = $acs->identitygroups("id","123"); # Faster | ||||||||||||||||||||||||||||
| 907 | print $identitygroup->name; | ||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||
| 909 | The ID is typically generated by Cisco ACS when the entry is created. It can be retrieved by calling the C<id> method on the object. | ||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||
| 911 | print $identitygroup->id; | ||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||
| 913 | =item devices | ||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||
| 915 | Returns hash or single instance, depending on context. | ||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||
| 917 | my %devices = $acs->devices(); # Slow | ||||||||||||||||||||||||||||
| 918 | my $device = $acs->devices()->{"Main_Router"}; | ||||||||||||||||||||||||||||
| 919 | print $device->name; | ||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||
| 921 | The returned hash contains instances of L<Net::Cisco::ACS::Device>, using name (typically the sysname) as the hash key. Using a call to C<device> with no arguments will retrieve all devices and can take quite a few seconds (depending on the size of your database). When you know the hostname or ID, use the L<devices> call with arguments as listed below. | ||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||
| 923 | my $device = $acs->device("name","Main_Router"); # Faster | ||||||||||||||||||||||||||||
| 924 | # or | ||||||||||||||||||||||||||||
| 925 | my $device = $acs->device("id","123"); # Faster | ||||||||||||||||||||||||||||
| 926 | print $device->name; | ||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||
| 928 | The ID is typically generated by Cisco ACS when the entry is created. It can be retrieved by calling the C<id> method on the object. | ||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||
| 930 | print $device->id; | ||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||
| 932 | =item devicegroups | ||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||
| 934 | Returns hash or single instance, depending on context. | ||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||
| 936 | my %devicegroups = $acs->devicegroups(); # Slow | ||||||||||||||||||||||||||||
| 937 | my $devicegroup = $acs->devicegroups()->{"All Locations:Main Site"}; | ||||||||||||||||||||||||||||
| 938 | print $devicegroup->name; | ||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||
| 940 | The returned hash contains instances of L<Net::Cisco::ACS::DeviceGroup>, using name (typically the device group name) as the hash key. Using a call to C<devicegroups> with no arguments will retrieve all device groups and can take quite a few seconds (depending on the size of your database). When you know the device group or ID, use the L<devicegroups> call with arguments as listed below. | ||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||
| 942 | my $devicegroup = $acs->devicegroups("name","All Locations::Main Site"); # Faster | ||||||||||||||||||||||||||||
| 943 | # or | ||||||||||||||||||||||||||||
| 944 | my $devicegroup = $acs->devicegroups("id","123"); # Faster | ||||||||||||||||||||||||||||
| 945 | print $devicegroup->name; | ||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||
| 947 | The ID is typically generated by Cisco ACS when the entry is created. It can be retrieved by calling the C<id> method on the object. | ||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||
| 949 | print $devicegroup->id; | ||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||
| 951 | =item hosts | ||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||
| 953 | Returns hash or single instance, depending on context. | ||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||
| 955 | my %hosts = $acs->hosts(); # Slow | ||||||||||||||||||||||||||||
| 956 | my $host = $acs->hosts()->{"12345"}; | ||||||||||||||||||||||||||||
| 957 | print $host->name; | ||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||
| 959 | The returned hash contains instances of L<Net::Cisco::ACS::Host>, using name as the hash key. Using a call to C<hosts> with no arguments will retrieve all hosts and can take quite a few seconds (depending on the size of your database). When you know the name or ID, use the L<hosts> call with arguments as listed below. | ||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||
| 961 | my $host = $acs->host("name","12345"); # Faster | ||||||||||||||||||||||||||||
| 962 | # or | ||||||||||||||||||||||||||||
| 963 | my $host = $acs->device("id","123"); # Faster | ||||||||||||||||||||||||||||
| 964 | print $host->name; | ||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||
| 966 | The ID is typically generated by Cisco ACS when the entry is created. It can be retrieved by calling the C<id> method on the object. | ||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||
| 968 | print $host->id; | ||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||
| 970 | =item version | ||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||
| 972 | This method returns version specific information about the Cisco ACS instance you're connected to. Values are returned in a hash reference. | ||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||
| 974 | use Data::Dumper; | ||||||||||||||||||||||||||||
| 975 | # ... | ||||||||||||||||||||||||||||
| 976 | print Dumper $acs->version; | ||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||
| 978 | =item servicelocation | ||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||
| 980 | This method returns information about the ACS instance that serves as primary and the ACS instance that provide Monitoring and Troubleshooting Viewer. Values are returned in a hash reference. | ||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||
| 982 | use Data::Dumper; | ||||||||||||||||||||||||||||
| 983 | # ... | ||||||||||||||||||||||||||||
| 984 | print Dumper $acs->servicelocation; | ||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||
| 986 | =item errormessage | ||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||
| 988 | This method returns all ACS message codes and message texts that are used on the REST Interface. Values are returned in a hash reference. See also C<$Net::Cisco::ACS::ERROR>. | ||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||
| 990 | use Data::Dumper; | ||||||||||||||||||||||||||||
| 991 | # ... | ||||||||||||||||||||||||||||
| 992 | print Dumper $acs->errormessage; | ||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||
| 994 | =item create | ||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||
| 996 | This method created a new entry in Cisco ACS, depending on the argument passed. Record type is detected automatically. For all record types, the ID value must be set to 0. | ||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||
| 998 | my $user = $acs->users("name","acsadmin"); | ||||||||||||||||||||||||||||
| 999 | $user->id(0); # Required for new user! | ||||||||||||||||||||||||||||
| 1000 | $user->name("altadmin"); # Required field | ||||||||||||||||||||||||||||
| 1001 | $user->password("TopSecret"); # Password policies will be enforced! | ||||||||||||||||||||||||||||
| 1002 | $user->description("Alternate Admin"); | ||||||||||||||||||||||||||||
| 1003 | my $id = $acs->create($user); | ||||||||||||||||||||||||||||
| 1004 | # Create new user based on Net::Cisco::ACS::User instance | ||||||||||||||||||||||||||||
| 1005 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 1006 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 1007 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 1008 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||
| 1010 | my $device = $acs->devices("name","Main_Router"); | ||||||||||||||||||||||||||||
| 1011 | $device->name("AltRouter"); # Required field | ||||||||||||||||||||||||||||
| 1012 | $device->description("Standby Router"); | ||||||||||||||||||||||||||||
| 1013 | $device->ips([{netMask => "32", ipAddress=>"10.0.0.2"}]); # Change IP address! Overlap check is enforced! | ||||||||||||||||||||||||||||
| 1014 | $device->id(0); # Required for new device! | ||||||||||||||||||||||||||||
| 1015 | my $id = $acs->create($device); | ||||||||||||||||||||||||||||
| 1016 | # Create new device based on Net::Cisco::ACS::Device instance | ||||||||||||||||||||||||||||
| 1017 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 1018 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 1019 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 1020 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||
| 1022 | Multiple instances can be passed as an argument. Objects will be created in bulk (one transaction). The returned ID is not guaranteed to be the IDs of the created objects. | ||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||
| 1024 | my $user = $acs->users("name","acsadmin"); | ||||||||||||||||||||||||||||
| 1025 | $user->id(0); # Required for new user! | ||||||||||||||||||||||||||||
| 1026 | $user->name("altadmin"); # Required field | ||||||||||||||||||||||||||||
| 1027 | $user->password("TopSecret"); # Password policies will be enforced! | ||||||||||||||||||||||||||||
| 1028 | $user->description("Alternate Admin"); | ||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||
| 1030 | my $user2 = $acs->users("name","acsadmin"); | ||||||||||||||||||||||||||||
| 1031 | $user2->id(0); # Required for new user! | ||||||||||||||||||||||||||||
| 1032 | $user2->name("altadmin"); # Required field | ||||||||||||||||||||||||||||
| 1033 | $user2->password("TopSecret"); # Password policies will be enforced! | ||||||||||||||||||||||||||||
| 1034 | $user2->description("Alternate Admin"); | ||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||
| 1036 | my $id = $acs->create($user,$user2); | ||||||||||||||||||||||||||||
| 1037 | # Create new users based on Net::Cisco::ACS::User instances in argument. | ||||||||||||||||||||||||||||
| 1038 | # Return value is ID generated by ACS but not guaranteed. | ||||||||||||||||||||||||||||
| 1039 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 1040 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 1041 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||
| 1043 | my $device = $acs->devices("name","Main_Router"); | ||||||||||||||||||||||||||||
| 1044 | $device->name("MainRouter"); # Required field | ||||||||||||||||||||||||||||
| 1045 | $device->description("Main Router"); | ||||||||||||||||||||||||||||
| 1046 | $device->ips([{netMask => "32", ipAddress=>"10.0.0.1"}]); # Change IP address! Overlap check is enforced! | ||||||||||||||||||||||||||||
| 1047 | $device->id(0); # Required for new device! | ||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||
| 1049 | my $device2 = $acs->devices("name","Alt_Router"); | ||||||||||||||||||||||||||||
| 1050 | $device2->name("AltRouter"); # Required field | ||||||||||||||||||||||||||||
| 1051 | $device2->description("Standby Router"); | ||||||||||||||||||||||||||||
| 1052 | $device2->ips([{netMask => "32", ipAddress=>"10.0.0.2"}]); # Change IP address! Overlap check is enforced! | ||||||||||||||||||||||||||||
| 1053 | $device2->id(0); # Required for new device! | ||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||
| 1055 | my $id = $acs->create($device,$device2); | ||||||||||||||||||||||||||||
| 1056 | # Create new device based on Net::Cisco::ACS::Device instance | ||||||||||||||||||||||||||||
| 1057 | # Return value is ID generated by ACS but not guaranteed. | ||||||||||||||||||||||||||||
| 1058 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 1059 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 1060 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||
| 1062 | =item update | ||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||
| 1064 | This method updates an existing entry in Cisco ACS, depending on the argument passed. Record type is detected automatically. | ||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||
| 1066 | my $user = $acs->users("name","acsadmin"); | ||||||||||||||||||||||||||||
| 1067 | $user->password("TopSecret"); # Change password. Password policies will be enforced! | ||||||||||||||||||||||||||||
| 1068 | my $id = $acs->update($user); | ||||||||||||||||||||||||||||
| 1069 | # Update user based on Net::Cisco::ACS::User instance | ||||||||||||||||||||||||||||
| 1070 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 1071 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 1072 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 1073 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||
| 1075 | my $device = $acs->devices("name","Main_Router"); | ||||||||||||||||||||||||||||
| 1076 | $user->description("To be ceased"); # Change description | ||||||||||||||||||||||||||||
| 1077 | $device->ips([{netMask => "32", ipAddress=>"10.0.0.2"}]); # or Change IP address. Overlap check is enforced! | ||||||||||||||||||||||||||||
| 1078 | my $id = $acs->update($device); | ||||||||||||||||||||||||||||
| 1079 | # Create new device based on Net::Cisco::ACS::Device instance | ||||||||||||||||||||||||||||
| 1080 | # Return value is ID generated by ACS | ||||||||||||||||||||||||||||
| 1081 | print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 1082 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 1083 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||
| 1085 | Multiple instances can be passed as an argument. Objects will be updated in bulk (one transaction). The returned ID is not guaranteed to be the IDs of the created objects. | ||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||
| 1087 | my $user = $acs->users("name","acsadmin"); | ||||||||||||||||||||||||||||
| 1088 | $user->id(0); # Required for new user! | ||||||||||||||||||||||||||||
| 1089 | $user->password("TopSecret"); # Password policies will be enforced! | ||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||
| 1091 | my $user2 = $acs->users("name","acsadmin2"); | ||||||||||||||||||||||||||||
| 1092 | $user2->password("TopSecret"); # Password policies will be enforced! | ||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||
| 1094 | my $id = $acs->update($user,$user2); | ||||||||||||||||||||||||||||
| 1095 | # Update users based on Net::Cisco::ACS::User instances in arguments | ||||||||||||||||||||||||||||
| 1096 | # Return value is ID generated by ACS but not guaranteed. | ||||||||||||||||||||||||||||
| 1097 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 1098 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 1099 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||
| 1101 | my $device = $acs->devices("name","Main_Router"); | ||||||||||||||||||||||||||||
| 1102 | $device->description("Main Router"); | ||||||||||||||||||||||||||||
| 1103 | $device->ips([{netMask => "32", ipAddress=>"10.0.0.1"}]); # Change IP address! Overlap check is enforced! | ||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||
| 1105 | my $device2 = $acs->devices("name","Alt_Router"); | ||||||||||||||||||||||||||||
| 1106 | $device2->description("Standby Router"); | ||||||||||||||||||||||||||||
| 1107 | $device2->ips([{netMask => "32", ipAddress=>"10.0.0.2"}]); # Change IP address! Overlap check is enforced! | ||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||
| 1109 | my $id = $acs->create($device,$device2); | ||||||||||||||||||||||||||||
| 1110 | # Update devices based on Net::Cisco::ACS::Device instances in arguments | ||||||||||||||||||||||||||||
| 1111 | # Return value is ID generated by ACS but not guaranteed. | ||||||||||||||||||||||||||||
| 1112 | # print "Record ID is $id" if $id; | ||||||||||||||||||||||||||||
| 1113 | # print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||||||||||||||||||
| 1114 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||
| 1116 | =item delete | ||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||
| 1118 | This method deletes an existing entry in Cisco ACS, depending on the argument passed. Record type is detected automatically. | ||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||
| 1120 | my $user = $acs->users("name","acsadmin"); | ||||||||||||||||||||||||||||
| 1121 | $acs->delete($user); | ||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||
| 1123 | my $device = $acs->users("name","Main_Router"); | ||||||||||||||||||||||||||||
| 1124 | $acs->delete($device); | ||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||
| 1126 | =item $ERROR | ||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||
| 1128 | This variable will contain detailed error information, based on the REST API answer. This value is reset during every call to C<users>, C<devices> and C<devicegroups>. | ||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||
| 1130 | =back | ||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||
| 1132 | =head1 REQUIREMENTS | ||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||
| 1134 | For this library to work, you need an instance with Cisco ACS (obviously) or a simulator like L<Net::Cisco::ACS::Mock>. | ||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||
| 1136 | To enable the Cisco ACS REST API, you will need to run the command below from the Cisco ACS console: | ||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||
| 1138 | acs config-web-interface rest enable | ||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||
| 1140 | You will also need an administrator-role account, typically NOT associated with a device-access account. Configure the account through the GUI. | ||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||
| 1142 | System Administration > Administrators > Accounts | ||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||
| 1144 | You will need more than generic privileges (SuperAdmin is ideal, suspected that UserAdmin and NetworkDeviceAdmin are sufficient). | ||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||
| 1146 | You will also need | ||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||
| 1148 | =over 3 | ||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||
| 1150 | =item L<Moose> | ||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||
| 1152 | =item L<IO::Socket::SSL> | ||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||
| 1154 | =item L<LWP::UserAgent> | ||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||
| 1156 | =item L<XML::Simple> | ||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||
| 1158 | =item L<MIME::Base64> | ||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||
| 1160 | =item L<URI::Escape> | ||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||
| 1162 | =back | ||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||
| 1164 | =head1 BUGS | ||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||
| 1166 | None so far | ||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||
| 1168 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||
| 1170 | None so far :) | ||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||
| 1172 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||
| 1174 | Hendrik Van Belleghem | ||||||||||||||||||||||||||||
| 1175 | CPAN ID: BEATNIK | ||||||||||||||||||||||||||||
| 1176 | hendrik.vanbelleghem@gmail.com | ||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||
| 1178 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||
| 1180 | This program is free software licensed under the... | ||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||
| 1182 | The General Public License (GPL) | ||||||||||||||||||||||||||||
| 1183 | Version 2, June 1991 | ||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||
| 1185 | The full text of the license can be found in the | ||||||||||||||||||||||||||||
| 1186 | LICENSE file included with this module. | ||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||
| 1188 | =head1 COMPATIBILITY | ||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||
| 1190 | Certain API calls are not support from Cisco ACS 5.0 onwards. The current supported versions of Cisco ACS (by Cisco) are 5.6, 5.7 and 5.8 (Active). | ||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||
| 1192 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||
| 1194 | =over 3 | ||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||
| 1196 | See L<Net::Cisco::ACS::User> for more information on User management. | ||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||
| 1198 | See L<Net::Cisco::ACS::IdentityGroup> for more information on User Group management. | ||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||
| 1200 | See L<Net::Cisco::ACS::Device> for more information on Device management. | ||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||
| 1202 | See L<Net::Cisco::ACS::DeviceGroup> for more information on Device Group management. | ||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||
| 1204 | See L<Net::Cisco::ACS::Host> for more information on Host management. | ||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||
| 1206 | See the L<Cisco ACS product page|http://www.cisco.com/c/en/us/products/security/secure-access-control-system/index.html> for more information. | ||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||
| 1208 | L<Net::Cisco::ACS> relies on L<Moose>. | ||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||
| 1210 | =back | ||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||
| 1212 | =cut | ||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||
| 1214 | #################### main pod documentation end ################### | ||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||
| 1216 | 1 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||
| 1218 | 1 | 1; | |||||||||||||||||||||||||||
| 1219 | # The preceding line will help the module return a true value | ||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||