| 1 | package Net::Cisco::ACS::DeviceGroup; | ||||||||||||
| 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 | 1 | ▶ | use Data::Dumper; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 1 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use Exporter (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS %actions); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | $VERSION = '0.03'; | |||||||||||
| 10 | 1 | @ISA = qw(Exporter); | |||||||||||
| 11 | 1 | @EXPORT = qw(); | |||||||||||
| 12 | 1 | @EXPORT_OK = qw(); | |||||||||||
| 13 | 1 | %EXPORT_TAGS = (); | |||||||||||
| 14 | }; | ||||||||||||
| 15 | |||||||||||||
| 16 | 1 | %actions = ( "query" => "/Rest/NetworkDevice/DeviceGroup", | |||||||||||
| 17 | "create" => "/Rest/NetworkDevice/DeviceGroup", | ||||||||||||
| 18 | "update" => "/Rest/NetworkDevice/DeviceGroup", | ||||||||||||
| 19 | "getByName" => "/Rest/NetworkDevice/DeviceGroup/name/", | ||||||||||||
| 20 | "getById" => "/Rest/NetworkDevice/DeviceGroup/id/", | ||||||||||||
| 21 | ); | ||||||||||||
| 22 | |||||||||||||
| 23 | # MOOSE! | ||||||||||||
| 24 | |||||||||||||
| 25 | 1 | has 'description' => ( | |||||||||||
| 26 | is => 'rw', | ||||||||||||
| 27 | isa => 'Any', | ||||||||||||
| 28 | ); | ||||||||||||
| 29 | |||||||||||||
| 30 | 1 | has 'id' => ( | |||||||||||
| 31 | is => 'rw', | ||||||||||||
| 32 | isa => 'Str', | ||||||||||||
| 33 | ); | ||||||||||||
| 34 | |||||||||||||
| 35 | 1 | has 'name' => ( | |||||||||||
| 36 | is => 'rw', | ||||||||||||
| 37 | isa => 'Str', | ||||||||||||
| 38 | ); | ||||||||||||
| 39 | |||||||||||||
| 40 | 1 | has 'groupType' => ( | |||||||||||
| 41 | is => 'rw', | ||||||||||||
| 42 | isa => 'Str', | ||||||||||||
| 43 | ); | ||||||||||||
| 44 | |||||||||||||
| 45 | # No Moose | ||||||||||||
| 46 | |||||||||||||
| 47 | sub toXML | ||||||||||||
| 48 | 0 | ▶ | { my $self = shift; | ||||||||||
|
Subroutine
toXML: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||
| 49 | 0 | my $result = ""; | |||||||||||
| 50 | 0 | my $id = $self->id; | |||||||||||
| 51 | 0 | ▶ | my $description = $self->description || ""; | ||||||||||
|
Condition0%0/2
$self->description || ''
MC/DC0%0/1
$self->description || ''
$self->description
Truth table0%0/2
A
A= $self->description
| |||||||||||||
| 52 | 0 | ▶ | my $name = $self->name || ""; | ||||||||||
|
Condition0%0/2
$self->name || ''
MC/DC0%0/1
$self->name || ''
$self->name
Truth table0%0/2
A
A= $self->name
| |||||||||||||
| 53 | 0 | ▶ | my $grouptype = $self->groupType || "Location"; | ||||||||||
|
Condition0%0/2
$self->groupType || 'Location'
MC/DC0%0/1
$self->groupType || 'Location'
$self->groupType
Truth table0%0/2
A
A= $self->groupType
| |||||||||||||
| 54 | 0 | ▶ | if ($id) { $result = " <id>$id</id>\n"; } | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 55 | |||||||||||||
| 56 | 0 | $result = <<XML; | |||||||||||
| 57 | <description>$description</description> | ||||||||||||
| 58 | <name>$name</name> | ||||||||||||
| 59 | <groupType>$grouptype</groupType> | ||||||||||||
| 60 | XML | ||||||||||||
| 61 | |||||||||||||
| 62 | 0 | return $result; | |||||||||||
| 63 | } | ||||||||||||
| 64 | |||||||||||||
| 65 | sub header | ||||||||||||
| 66 | 0 | ▶ | { my $self = shift; | ||||||||||
|
Subroutine
header: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 67 | 0 | my $devices = shift; | |||||||||||
| 68 | 0 | return qq(<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns1:deviceGroup xmlns:ns1="networkdevice.rest.mgmt.acs.nm.cisco.com">$devices</ns1:deviceGroup>); | |||||||||||
| 69 | } | ||||||||||||
| 70 | |||||||||||||
| 71 | =head1 NAME | ||||||||||||
| 72 | |||||||||||||
| 73 | Net::Cisco::ACS::DeviceGroup - Access Cisco ACS functionality through REST API - DeviceGroup fields | ||||||||||||
| 74 | |||||||||||||
| 75 | =head1 SYNOPSIS | ||||||||||||
| 76 | |||||||||||||
| 77 | use Net::Cisco::ACS; | ||||||||||||
| 78 | use Net::Cisco::ACS::DeviceGroup; | ||||||||||||
| 79 | |||||||||||||
| 80 | my $acs = Net::Cisco::ACS->new(hostname => '10.0.0.1', username => 'acsadmin', password => 'testPassword'); | ||||||||||||
| 81 | |||||||||||||
| 82 | my %devicegroups = $acs->devicegroups; | ||||||||||||
| 83 | # Retrieve all device groups from ACS | ||||||||||||
| 84 | # Returns hash with device name / Net::Cisco::ACS::DeviceGroup pairs | ||||||||||||
| 85 | |||||||||||||
| 86 | print $acs->devicegroups->{"All Locations"}->toXML; | ||||||||||||
| 87 | # Dump in XML format (used by ACS for API calls) | ||||||||||||
| 88 | |||||||||||||
| 89 | my $device = $acs->devicegroups("name","All Locations"); | ||||||||||||
| 90 | # Faster call to request specific device group information by name | ||||||||||||
| 91 | |||||||||||||
| 92 | my $devicegroup = $acs->devicegroups("id","250"); | ||||||||||||
| 93 | # Faster call to request specific device group information by ID (assigned by ACS, present in Net::Cisco::ACS::DeviceGroup) | ||||||||||||
| 94 | |||||||||||||
| 95 | $devicegroup->id(0); # Required for new device group! | ||||||||||||
| 96 | my $id = $acs->create($devicegroup); | ||||||||||||
| 97 | # Create new device group based on Net::Cisco::ACS::DeviceGroup instance | ||||||||||||
| 98 | # Return value is ID generated by ACS | ||||||||||||
| 99 | print "Record ID is $id" if $id; | ||||||||||||
| 100 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||
| 101 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||
| 102 | |||||||||||||
| 103 | my $id = $acs->update($devicegroup); | ||||||||||||
| 104 | # Update existing device based on Net::Cisco::ACS::DeviceGroup instance | ||||||||||||
| 105 | # Return value is ID generated by ACS | ||||||||||||
| 106 | print "Record ID is $id" if $id; | ||||||||||||
| 107 | print $Net::Cisco::ACS::ERROR unless $id; | ||||||||||||
| 108 | # $Net::Cisco::ACS::ERROR contains details about failure | ||||||||||||
| 109 | |||||||||||||
| 110 | $acs->delete($devicegroup); | ||||||||||||
| 111 | # Delete existing device based on Net::Cisco::ACS::DeviceGroup instance | ||||||||||||
| 112 | |||||||||||||
| 113 | =head1 DESCRIPTION | ||||||||||||
| 114 | |||||||||||||
| 115 | The Net::Cisco::ACS::DeviceGroup class holds all the device group relevant information from Cisco ACS 5.x | ||||||||||||
| 116 | |||||||||||||
| 117 | =head1 USAGE | ||||||||||||
| 118 | |||||||||||||
| 119 | All calls are typically handled through an instance of the L<Net::Cisco::ACS> class. L<Net::Cisco::ACS::DeviceGroup> acts as a container for device group related information. | ||||||||||||
| 120 | |||||||||||||
| 121 | =over 3 | ||||||||||||
| 122 | |||||||||||||
| 123 | =item new | ||||||||||||
| 124 | |||||||||||||
| 125 | Class constructor. Returns object of Net::Cisco::ACS::DeviceGroup on succes. The following fields can be set / retrieved: | ||||||||||||
| 126 | |||||||||||||
| 127 | =over 5 | ||||||||||||
| 128 | |||||||||||||
| 129 | =item description | ||||||||||||
| 130 | |||||||||||||
| 131 | =item name | ||||||||||||
| 132 | |||||||||||||
| 133 | =item id | ||||||||||||
| 134 | |||||||||||||
| 135 | =item groupType | ||||||||||||
| 136 | |||||||||||||
| 137 | Formatting rules may be in place & enforced by Cisco ACS. | ||||||||||||
| 138 | |||||||||||||
| 139 | =back | ||||||||||||
| 140 | |||||||||||||
| 141 | =over 3 | ||||||||||||
| 142 | |||||||||||||
| 143 | =item description | ||||||||||||
| 144 | |||||||||||||
| 145 | The device group account description, typically used for full device group name. | ||||||||||||
| 146 | |||||||||||||
| 147 | =item name | ||||||||||||
| 148 | |||||||||||||
| 149 | The device group name. This is a required value in the constructor but can be redefined afterwards. | ||||||||||||
| 150 | |||||||||||||
| 151 | =item groupType | ||||||||||||
| 152 | |||||||||||||
| 153 | This points to the type of Device Group, typically Location or Device Type but can be customized. See also L<Net::Cisco::ACS::Device> C<deviceType>. | ||||||||||||
| 154 | |||||||||||||
| 155 | =item id | ||||||||||||
| 156 | |||||||||||||
| 157 | Cisco ACS generates a unique ID for each Device Group record. This field cannot be updated within ACS but is used for reference. Set to 0 when creating a new record or when duplicating an existing device group. | ||||||||||||
| 158 | |||||||||||||
| 159 | =item toXML | ||||||||||||
| 160 | |||||||||||||
| 161 | Dump the record in ACS accept XML formatting (without header). | ||||||||||||
| 162 | |||||||||||||
| 163 | =item header | ||||||||||||
| 164 | |||||||||||||
| 165 | Generate the correct XML header. Takes output of C<toXML> as argument. | ||||||||||||
| 166 | |||||||||||||
| 167 | =back | ||||||||||||
| 168 | |||||||||||||
| 169 | =back | ||||||||||||
| 170 | |||||||||||||
| 171 | =head1 BUGS | ||||||||||||
| 172 | |||||||||||||
| 173 | None yet | ||||||||||||
| 174 | |||||||||||||
| 175 | =head1 SUPPORT | ||||||||||||
| 176 | |||||||||||||
| 177 | None yet :) | ||||||||||||
| 178 | |||||||||||||
| 179 | =head1 AUTHOR | ||||||||||||
| 180 | |||||||||||||
| 181 | Hendrik Van Belleghem | ||||||||||||
| 182 | CPAN ID: BEATNIK | ||||||||||||
| 183 | hendrik.vanbelleghem@gmail.com | ||||||||||||
| 184 | |||||||||||||
| 185 | =head1 COPYRIGHT | ||||||||||||
| 186 | |||||||||||||
| 187 | This program is free software licensed under the... | ||||||||||||
| 188 | |||||||||||||
| 189 | The General Public License (GPL) | ||||||||||||
| 190 | Version 2, June 1991 | ||||||||||||
| 191 | |||||||||||||
| 192 | The full text of the license can be found in the | ||||||||||||
| 193 | LICENSE file included with this module. | ||||||||||||
| 194 | |||||||||||||
| 195 | |||||||||||||
| 196 | =head1 SEE ALSO | ||||||||||||
| 197 | |||||||||||||
| 198 | perl(1). | ||||||||||||
| 199 | |||||||||||||
| 200 | =cut | ||||||||||||
| 201 | |||||||||||||
| 202 | #################### main pod documentation end ################### | ||||||||||||
| 203 | 1 | __PACKAGE__->meta->make_immutable(); | |||||||||||
| 204 | |||||||||||||
| 205 | 1 | 1; | |||||||||||
| 206 | # The preceding line will help the module return a true value | ||||||||||||
| 207 | |||||||||||||