line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cisco::UCS; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21882
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
557
|
use Cisco::UCS::Chassis; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
7
|
1
|
|
|
1
|
|
610
|
use Cisco::UCS::Interconnect; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
8
|
1
|
|
|
1
|
|
8
|
use Cisco::UCS::FEX; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
9
|
1
|
|
|
1
|
|
624
|
use Cisco::UCS::Blade; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
43
|
|
10
|
1
|
|
|
1
|
|
699
|
use Cisco::UCS::Fault; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
11
|
1
|
|
|
1
|
|
664
|
use Cisco::UCS::MgmtEntity; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
55
|
|
12
|
1
|
|
|
1
|
|
684
|
use Cisco::UCS::ServiceProfile; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
46
|
|
13
|
1
|
|
|
1
|
|
1007
|
use LWP; |
|
1
|
|
|
|
|
53645
|
|
|
1
|
|
|
|
|
38
|
|
14
|
1
|
|
|
1
|
|
1284
|
use XML::Simple; |
|
1
|
|
|
|
|
10056
|
|
|
1
|
|
|
|
|
8
|
|
15
|
1
|
|
|
1
|
|
87
|
use Carp qw(croak carp cluck); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
244
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.50'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @ATTRIBUTES = qw(dn cluster cookie); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our %ATTRIBUTES = (); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
0
|
|
|
0
|
1
|
|
my ( $class, %args ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $self = {}; |
29
|
0
|
|
|
|
|
|
bless $self, $class; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
defined $args{cluster} |
32
|
|
|
|
|
|
|
? $self->{cluster} = $args{cluster} |
33
|
0
|
0
|
|
|
|
|
: croak 'cluster not defined'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
defined $args{username} |
36
|
|
|
|
|
|
|
? $self->{username} = $args{username} |
37
|
0
|
0
|
|
|
|
|
: croak 'username not defined'; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
defined $args{passwd} |
40
|
|
|
|
|
|
|
? $self->{passwd} = $args{passwd} |
41
|
0
|
0
|
|
|
|
|
: croak 'passwd not defined'; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
defined $args{verify_hostname} |
44
|
|
|
|
|
|
|
? $self->{verify_hostname} = $args{verify_hostname} |
45
|
0
|
0
|
|
|
|
|
: 0; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
0
|
|
|
|
$self->{port} = ( $args{port} or 443 ); |
48
|
0
|
|
0
|
|
|
|
$self->{proto} = ( $args{proto} or 'https' ); |
49
|
0
|
|
0
|
|
|
|
$self->{dn} = ( $args{dn} or 'sys' ); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return $self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
{ |
55
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3617
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
while ( my ($pseudo, $attribute) = each %ATTRIBUTES ) { |
58
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $pseudo } = sub { |
59
|
|
|
|
|
|
|
my $self = shift; |
60
|
|
|
|
|
|
|
return $self->{$attribute} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
foreach my $attribute (@ATTRIBUTES) { |
65
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $attribute } = sub { |
66
|
0
|
|
|
0
|
|
|
my $self = shift; |
67
|
0
|
|
|
|
|
|
return $self->{$attribute} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub login { |
73
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
undef $self->{error}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$self->{ua} = LWP::UserAgent->new( |
78
|
|
|
|
|
|
|
ssl_opts => { |
79
|
|
|
|
|
|
|
verify_hostname => $self->{verify_hostname} |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$self->{uri} = $self->{proto}. '://' .$self->{cluster} |
84
|
0
|
|
|
|
|
|
. ':' .$self->{port}. '/nuova'; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$self->{req} = HTTP::Request->new( |
87
|
|
|
|
|
|
|
POST => $self->{uri} |
88
|
0
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
$self->{req}->content_type( 'application/x-www-form-urlencoded' ); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$self->{req}->content( '
93
|
0
|
|
|
|
|
|
.'" inPassword="'. $self->{passwd} .'"/>' ); |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
my $res = $self->{ua}->request( $self->{req} ); |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
unless ( $res->is_success ) { |
98
|
0
|
|
|
|
|
|
$self->{error} = 'Login failure: '.$res->status_line; |
99
|
0
|
|
|
|
|
|
return 0 |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$self->{parser} = XML::Simple->new; |
103
|
0
|
|
|
|
|
|
my $xml = $self->{parser}->XMLin( $res->content ); |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
if ( defined $xml->{'errorCode'} ) { |
106
|
|
|
|
|
|
|
$self->{error} = 'Login failure: ' |
107
|
|
|
|
|
|
|
. ( defined $xml->{'errorDescr'} |
108
|
0
|
0
|
|
|
|
|
? $xml->{'errorDescr'} |
109
|
|
|
|
|
|
|
: 'Unspecified error' |
110
|
|
|
|
|
|
|
); |
111
|
0
|
|
|
|
|
|
return 0 |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$self->{cookie} = $xml->{'outCookie'}; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return 1 |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub refresh { |
120
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
undef $self->{error}; |
123
|
|
|
|
|
|
|
$self->{req}->content( '
124
|
|
|
|
|
|
|
.'" inPassword="'. $self->{passwd} |
125
|
0
|
|
|
|
|
|
.'" inCookie="' . $self->{cookie} . '"/>' |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $res = $self->{ua}->request( $self->{req} ); |
129
|
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
unless ( $res->is_success ) { |
131
|
0
|
|
|
|
|
|
$self->{error} = 'Refresh failed: '. $res->status_line; |
132
|
0
|
|
|
|
|
|
return 0 |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my $xml = $self->{parser}->XMLin( $res->content() ); |
136
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
if ( defined $xml->{'errorCode'} ) { |
138
|
|
|
|
|
|
|
$self->{error} = 'Refresh failure: ' |
139
|
|
|
|
|
|
|
. ( defined $xml->{'errorDescr'} |
140
|
0
|
0
|
|
|
|
|
? $xml->{'errorDescr'} |
141
|
|
|
|
|
|
|
: 'Unspecified error' |
142
|
|
|
|
|
|
|
); |
143
|
0
|
|
|
|
|
|
return 0 |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
$self->{cookie} = $xml->{'outCookie'}; |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
return 1 |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub logout { |
152
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
153
|
|
|
|
|
|
|
|
154
|
0
|
0
|
|
|
|
|
return unless $self->{cookie}; |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
undef $self->{error}; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
return ( $self->_ucsm_request( '
159
|
0
|
0
|
|
|
|
|
. $self->{cookie} .'" />' ) ? 1 : 0 |
160
|
|
|
|
|
|
|
) |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub _ucsm_request { |
164
|
0
|
|
|
0
|
|
|
my ( $self, $content, $class_id ) = @_; |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
undef $self->{error}; |
167
|
0
|
|
|
|
|
|
$self->{req}->content( $content ); |
168
|
0
|
|
|
|
|
|
my $res = $self->{ua}->request( $self->{req} ); |
169
|
|
|
|
|
|
|
|
170
|
0
|
0
|
|
|
|
|
$self->error( $res->status_line ) unless $res->is_success; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
my $xml = ( $class_id |
173
|
|
|
|
|
|
|
? $self->{parser}->XMLin( |
174
|
|
|
|
|
|
|
$res->content, |
175
|
|
|
|
|
|
|
KeyAttr => $class_id |
176
|
|
|
|
|
|
|
) |
177
|
|
|
|
|
|
|
: $self->{parser}->XMLin( |
178
|
0
|
0
|
|
|
|
|
$res->content, |
179
|
|
|
|
|
|
|
KeyAttr => [ 'name', 'key', 'id', 'intId' ] |
180
|
|
|
|
|
|
|
) |
181
|
|
|
|
|
|
|
); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
return ( $xml->{errorCode} |
184
|
0
|
0
|
|
|
|
|
? do { |
185
|
|
|
|
|
|
|
$self->{error} = ( $xml->{'errorDescr'} |
186
|
0
|
0
|
|
|
|
|
? $xml->{'errorDescr'} |
187
|
|
|
|
|
|
|
: 'Unspecified error' |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
undef |
190
|
0
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
: $xml |
192
|
|
|
|
|
|
|
); |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# This private method provides an abstract factory-type constructor for resolved child |
196
|
|
|
|
|
|
|
# objects of the specified dn. To maintain compatibility with existing methods and to |
197
|
|
|
|
|
|
|
# provide a single method for all child objects, there are a few important design |
198
|
|
|
|
|
|
|
# considerations that have been made. |
199
|
|
|
|
|
|
|
# |
200
|
|
|
|
|
|
|
# Importantly we check for a 'class_filter' argument to the method which if present is |
201
|
|
|
|
|
|
|
# used to call the 'resolve_class_filter' method rather than the 'resolve_children' method. |
202
|
|
|
|
|
|
|
# This is necessary due to limitations and difficulties present in resolving child objects |
203
|
|
|
|
|
|
|
# for some objects can lead to incorrect results. For example, resolving the child objects |
204
|
|
|
|
|
|
|
# for a chassis to retrieve the blades in the chassis is difficult, instead we can use a much |
205
|
|
|
|
|
|
|
# more efficient and simpler method of retrieving the blades in a specified chassis by |
206
|
|
|
|
|
|
|
# resolving all objects in the specified class (i.e. computeBlade) and restricting the |
207
|
|
|
|
|
|
|
# results returned using a filter method. |
208
|
|
|
|
|
|
|
# |
209
|
|
|
|
|
|
|
# The implication of doing this is that the call to 'resolve_class_filter' returns an array |
210
|
|
|
|
|
|
|
# which cannot be processed using the same logic as for a hash returned by the 'resolve_children' |
211
|
|
|
|
|
|
|
# method. Therefore we perform extra processing to convert the returned array results to a |
212
|
|
|
|
|
|
|
# hash using a nominated attribute in the object as the hash index for the objects. |
213
|
|
|
|
|
|
|
# |
214
|
|
|
|
|
|
|
# SYNOPSIS |
215
|
|
|
|
|
|
|
# get_child_object ( %ARGS ) |
216
|
|
|
|
|
|
|
# |
217
|
|
|
|
|
|
|
# PARAMETERS |
218
|
|
|
|
|
|
|
# id The optional identifier of a specific child object. This identifier is context |
219
|
|
|
|
|
|
|
# dependent and may be either numerical (as in the case of a chassis) or alphanumeric |
220
|
|
|
|
|
|
|
# (as is the case with a fabric interconnect - A or B). |
221
|
|
|
|
|
|
|
# |
222
|
|
|
|
|
|
|
# type The desired child object type to be resolved as according to the UCSM information |
223
|
|
|
|
|
|
|
# management hierarchy name. e.g. etherPIo is the ethernet port child object type for line cards. |
224
|
|
|
|
|
|
|
# |
225
|
|
|
|
|
|
|
# class The class into which the child object will be blessed. |
226
|
|
|
|
|
|
|
# |
227
|
|
|
|
|
|
|
# attr The pseudo-namespace in the Cisco::UCS object in which the retrieved child onjects will be cached. |
228
|
|
|
|
|
|
|
# For example; attr => 'interconnect' will mean that Cisco::UCS::Interconnect objects retrieved in |
229
|
|
|
|
|
|
|
# a $ucs->get_interconnects method call will be stored in $ucs->{interconnects}->{$OBJ}. |
230
|
|
|
|
|
|
|
# |
231
|
|
|
|
|
|
|
# self A reference to a Cisco::UCS object. If not present $self is assumed to be a Cisco::UCS object. |
232
|
|
|
|
|
|
|
# |
233
|
|
|
|
|
|
|
# uid Where results are returned and parsed into an array and the array index is not aligned to an identifying |
234
|
|
|
|
|
|
|
# attribute of the object (i.e. the array index has no relation to a unique identifier for the object) then |
235
|
|
|
|
|
|
|
# the uid may be used to refer to a unique identifying attribute of the object that should be used. |
236
|
|
|
|
|
|
|
# For example, in resolving all blades for a Cisco::UCS object, the uid value of bladeId is used to uniquely |
237
|
|
|
|
|
|
|
# identify all Cisco::UCS::Blade objects as the array index has no relation to a uniquely identifying feature |
238
|
|
|
|
|
|
|
# of the blade and is not guaranteed to be consistent. |
239
|
|
|
|
|
|
|
# |
240
|
|
|
|
|
|
|
# class_filter (%ARGS) |
241
|
|
|
|
|
|
|
# A class filter may be specified to filter the results to a particular subset. This is useful for |
242
|
|
|
|
|
|
|
# operations like retrieving all blades in a particular chassis rather than retrieving all blades and |
243
|
|
|
|
|
|
|
# manually filtering the results. |
244
|
|
|
|
|
|
|
# |
245
|
|
|
|
|
|
|
# Where %ARGS: |
246
|
|
|
|
|
|
|
# |
247
|
|
|
|
|
|
|
# classId The UCSM class which should be used for the UCSM query. For example: classId => etherPio. |
248
|
|
|
|
|
|
|
# |
249
|
|
|
|
|
|
|
# filter Where filter is composed of any number of valid attribute/value pairs. For example: slotId => 1, switchId => $self->{id}. |
250
|
|
|
|
|
|
|
# |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
sub _get_child_objects { |
253
|
0
|
|
|
0
|
|
|
my ( $self,%args ) = @_; |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
my $ucs = ( defined $self->{ucs} |
256
|
|
|
|
|
|
|
? $self->{ucs} |
257
|
0
|
0
|
|
|
|
|
: $self |
258
|
|
|
|
|
|
|
); |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
my $ref = ( defined $args{self} |
261
|
|
|
|
|
|
|
? $args{self} |
262
|
0
|
0
|
|
|
|
|
: $self |
263
|
|
|
|
|
|
|
); |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
my $xml = ( defined $args{class_filter} |
266
|
0
|
|
|
|
|
|
? $ucs->resolve_class_filter( %{ $args{class_filter} } ) |
267
|
|
|
|
|
|
|
: $ucs->resolve_children( dn => $ref->{dn} ) |
268
|
0
|
0
|
|
|
|
|
); |
269
|
|
|
|
|
|
|
|
270
|
0
|
0
|
0
|
|
|
|
if ( ref( $xml->{outConfigs}->{ $args{type} } ) eq 'ARRAY' ) { |
|
|
0
|
|
|
|
|
|
271
|
0
|
|
0
|
|
|
|
$args{uid} ||= 'id'; |
272
|
0
|
|
|
|
|
|
my $res; |
273
|
|
|
|
|
|
|
|
274
|
0
|
|
|
|
|
|
foreach my $obj ( @{ $xml->{outConfigs}->{ $args{type} } } ) { |
|
0
|
|
|
|
|
|
|
275
|
0
|
|
|
|
|
|
$res->{ $obj->{ $args{uid} } } = $obj |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
0
|
|
|
|
|
|
$xml->{outConfigs}->{ $args{type} } = $res |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
elsif ( ( ref( $xml->{outConfigs}->{ $args{type} } ) eq 'HASH' ) |
281
|
|
|
|
|
|
|
and ( exists $xml->{outConfigs}->{ $args{type} }->{dn} ) ) { |
282
|
0
|
|
0
|
|
|
|
$args{uid} ||= 'id'; |
283
|
0
|
|
|
|
|
|
my $res; |
284
|
|
|
|
|
|
|
$res->{ $xml->{outConfigs}->{ $args{type} }->{ $args{uid} } } |
285
|
0
|
|
|
|
|
|
= $xml->{outConfigs}->{ $args{type} }; |
286
|
|
|
|
|
|
|
|
287
|
0
|
|
|
|
|
|
$xml->{outConfigs}->{ $args{type} } = $res |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
return ( defined $xml->{outConfigs}->{ $args{type} } |
291
|
0
|
0
|
|
|
|
|
? do { my @res; |
|
0
|
|
|
|
|
|
|
292
|
0
|
|
|
|
|
|
foreach my $res ( keys %{ $xml->{outConfigs}->{ $args{type} } } ) { |
|
0
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
my $obj = $args{class}->new( |
294
|
|
|
|
|
|
|
ucs => $ucs, |
295
|
|
|
|
|
|
|
dn => $xml->{outConfigs}->{ $args{type} }->{$res}->{dn}, |
296
|
0
|
|
|
|
|
|
id => $res |
297
|
|
|
|
|
|
|
); |
298
|
|
|
|
|
|
|
|
299
|
0
|
|
|
|
|
|
$ref->{ $args{attr} }->{$res} = $obj; |
300
|
0
|
|
|
|
|
|
push @res, $obj; |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
|
303
|
0
|
0
|
|
|
|
|
return @res unless $args{id}; |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
return $ref->{ $args{attr} }->{ $args{id} } |
306
|
0
|
0
|
0
|
|
|
|
if $args{id} and $ref->{ $args{attr} }->{ $args{id} }; |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
return |
309
|
0
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
: () |
311
|
|
|
|
|
|
|
); |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
sub get_error_id { |
316
|
0
|
|
|
0
|
1
|
|
warn "get_error_id has been deprecated in future releases"; |
317
|
0
|
|
|
|
|
|
return get_error( @_ ) |
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
sub error { |
321
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
return ( |
324
|
|
|
|
|
|
|
defined $self->{fault}->{$id} |
325
|
0
|
0
|
|
|
|
|
? $self->{fault}->{$id} |
326
|
|
|
|
|
|
|
: $self->get_error($id) |
327
|
|
|
|
|
|
|
) |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub get_error { |
331
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
332
|
|
|
|
|
|
|
|
333
|
0
|
|
|
|
|
|
return $self->get_errors( $id ) |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
sub get_errors { |
337
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
338
|
|
|
|
|
|
|
|
339
|
0
|
|
|
|
|
|
return $self->_get_child_objects( |
340
|
|
|
|
|
|
|
id => $id, |
341
|
|
|
|
|
|
|
type => 'faultInst', |
342
|
|
|
|
|
|
|
class => 'Cisco::UCS::Fault', |
343
|
|
|
|
|
|
|
uid => 'id', |
344
|
|
|
|
|
|
|
attr => 'fault', |
345
|
|
|
|
|
|
|
class_filter => { |
346
|
|
|
|
|
|
|
classId => 'faultInst' |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
); |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
sub _isInHierarchical { |
352
|
0
|
|
|
0
|
|
|
my $inHierarchical = lc shift; |
353
|
|
|
|
|
|
|
|
354
|
0
|
0
|
|
|
|
|
return 'false' unless ( $inHierarchical =~ /true|false|0|1/ ); |
355
|
|
|
|
|
|
|
|
356
|
0
|
0
|
|
|
|
|
return $inHierarchical if ( $inHierarchical =~ /^true|false$/ ); |
357
|
|
|
|
|
|
|
|
358
|
0
|
0
|
|
|
|
|
return ( $inHierarchical == 0 ? 'false' : 'true' ); |
359
|
|
|
|
|
|
|
} |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
sub _createFilter { |
362
|
0
|
|
|
0
|
|
|
my ( $self, %args ) = @_; |
363
|
|
|
|
|
|
|
|
364
|
0
|
0
|
|
|
|
|
unless ( defined $args{classId} ) { |
365
|
0
|
|
|
|
|
|
$self->{error} = 'No classId specified'; |
366
|
|
|
|
|
|
|
return |
367
|
0
|
|
|
|
|
|
} |
368
|
|
|
|
|
|
|
|
369
|
0
|
|
|
|
|
|
my $filter = ''; |
370
|
|
|
|
|
|
|
|
371
|
0
|
|
|
|
|
|
while ( my( $property,$value ) = each %args ) { |
372
|
0
|
0
|
0
|
|
|
|
next if ( $property eq 'inHierarchical' or $property eq 'classId' ); |
373
|
0
|
|
|
|
|
|
$filter .= '
374
|
|
|
|
|
|
|
. $property . '" value="' . $value . '" />'; |
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
|
377
|
0
|
|
|
|
|
|
$filter .= ''; |
378
|
|
|
|
|
|
|
|
379
|
0
|
|
|
|
|
|
return $filter; |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
sub resolve_class { |
383
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
384
|
|
|
|
|
|
|
|
385
|
0
|
0
|
|
|
|
|
unless ( defined $args{classId} ) { |
386
|
0
|
|
|
|
|
|
$self->{error} = 'No classId specified'; |
387
|
|
|
|
|
|
|
return |
388
|
0
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
$args{inHierarchical} = ( |
391
|
|
|
|
|
|
|
defined $args{inHierarchical} |
392
|
|
|
|
|
|
|
? _isInHierarchical( $args{inHierarchical} ) |
393
|
0
|
0
|
|
|
|
|
: 'false' |
394
|
|
|
|
|
|
|
); |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
my $xml = $self->_ucsm_request( '
397
|
|
|
|
|
|
|
. $args{inHierarchical} .'" cookie="' |
398
|
|
|
|
|
|
|
. $self->{cookie} .'" classId="' |
399
|
0
|
0
|
|
|
|
|
. $args{classId} .'" />' ) or return; |
400
|
|
|
|
|
|
|
|
401
|
0
|
|
|
|
|
|
return $xml |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
sub resolve_classes { |
405
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
406
|
|
|
|
|
|
|
|
407
|
0
|
0
|
|
|
|
|
unless ( defined $args{classId} ) { |
408
|
0
|
|
|
|
|
|
$self->{error} = 'No classID specified'; |
409
|
|
|
|
|
|
|
return |
410
|
0
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
$args{inHierarchical} = ( |
413
|
|
|
|
|
|
|
defined $args{inHierarchical} |
414
|
|
|
|
|
|
|
? _isInHierarchical( $args{inHierarchical} ) |
415
|
0
|
0
|
|
|
|
|
: 'false' |
416
|
|
|
|
|
|
|
); |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
my $xml = $self->_ucsm_request( '
419
|
|
|
|
|
|
|
. $args{inHierarchical} |
420
|
|
|
|
|
|
|
. '" cookie="'. $self->{cookie} .'">' |
421
|
|
|
|
|
|
|
. '
422
|
0
|
0
|
|
|
|
|
. '" />', 'classId' |
423
|
|
|
|
|
|
|
) or return; |
424
|
|
|
|
|
|
|
|
425
|
0
|
|
|
|
|
|
return $xml |
426
|
|
|
|
|
|
|
} |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
sub resolve_dn { |
429
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
430
|
|
|
|
|
|
|
|
431
|
0
|
0
|
|
|
|
|
unless ( defined $args{dn} ) { |
432
|
0
|
|
|
|
|
|
$self->{error} = 'No dn specified'; |
433
|
|
|
|
|
|
|
return |
434
|
0
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
$args{inHierarchical} = ( |
437
|
|
|
|
|
|
|
defined $args{inHierarchical} |
438
|
|
|
|
|
|
|
? _isInHierarchical( $args{inHierarchical} ) |
439
|
0
|
0
|
|
|
|
|
: 'false' |
440
|
|
|
|
|
|
|
); |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
my $xml = $self->_ucsm_request( '
443
|
|
|
|
|
|
|
. '" inHierarchical="'. $args{inHierarchical} |
444
|
0
|
0
|
|
|
|
|
. '" cookie="'. $self->{cookie} .'" />' |
445
|
|
|
|
|
|
|
) or return; |
446
|
|
|
|
|
|
|
|
447
|
0
|
|
|
|
|
|
return $xml; |
448
|
|
|
|
|
|
|
} |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
sub resolve_children { |
451
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
452
|
|
|
|
|
|
|
|
453
|
0
|
0
|
|
|
|
|
unless ( defined $args{dn} ) { |
454
|
0
|
|
|
|
|
|
$self->{error} = 'No dn specified'; |
455
|
|
|
|
|
|
|
return |
456
|
0
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
$args{inHierarchical} = ( |
459
|
|
|
|
|
|
|
defined $args{inHierarchical} |
460
|
|
|
|
|
|
|
? _isInHierarchical( $args{inHierarchical} ) |
461
|
0
|
0
|
|
|
|
|
: 'false' |
462
|
|
|
|
|
|
|
); |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
my $xml = $self->_ucsm_request( '
465
|
|
|
|
|
|
|
. $args{inHierarchical} .'" cookie="' |
466
|
|
|
|
|
|
|
. $self->{cookie} .'" inDn="' |
467
|
0
|
0
|
|
|
|
|
. $args{dn} .'">' |
468
|
|
|
|
|
|
|
) or return; |
469
|
|
|
|
|
|
|
|
470
|
0
|
|
|
|
|
|
return $xml |
471
|
|
|
|
|
|
|
} |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
sub resolve_class_filter { |
474
|
0
|
|
|
0
|
1
|
|
my( $self, %args ) = @_; |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
$args{inHierarchical} = ( |
477
|
|
|
|
|
|
|
defined $args{inHierarchical} |
478
|
|
|
|
|
|
|
? _isInHierarchical( $args{inHierarchical} ) |
479
|
0
|
0
|
|
|
|
|
: 'false' |
480
|
|
|
|
|
|
|
); |
481
|
|
|
|
|
|
|
|
482
|
0
|
0
|
|
|
|
|
my $filter = $self->_createFilter( %args ) or return; |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
my $xml = $self->_ucsm_request( '
485
|
|
|
|
|
|
|
. $args{classId} .'" inHierarchical="' |
486
|
|
|
|
|
|
|
. $args{inHierarchical} .'" cookie="' |
487
|
|
|
|
|
|
|
. $self->{cookie} .'">' . $filter |
488
|
|
|
|
|
|
|
. '', $args{classId} |
489
|
0
|
0
|
|
|
|
|
) or return; |
490
|
|
|
|
|
|
|
|
491
|
0
|
|
|
|
|
|
return $xml |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
sub get_cluster_status { |
495
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
496
|
|
|
|
|
|
|
|
497
|
0
|
0
|
|
|
|
|
my $xml = $self->resolve_dn( dn => 'sys' ) or return; |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
return ( |
500
|
|
|
|
|
|
|
defined $xml->{outConfig}->{topSystem} |
501
|
|
|
|
|
|
|
? $xml->{outConfig}->{topSystem} |
502
|
|
|
|
|
|
|
: undef |
503
|
|
|
|
|
|
|
) |
504
|
0
|
0
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
sub version { |
507
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
508
|
|
|
|
|
|
|
|
509
|
0
|
0
|
|
|
|
|
my $xml = $self->resolve_dn( dn => 'sys/mgmt/fw-system' ) or return; |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
return ( |
512
|
|
|
|
|
|
|
defined $xml->{outConfig}->{firmwareRunning}->{version} |
513
|
|
|
|
|
|
|
? $xml->{outConfig}->{firmwareRunning}->{version} |
514
|
|
|
|
|
|
|
: undef |
515
|
|
|
|
|
|
|
) |
516
|
0
|
0
|
|
|
|
|
} |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
sub mgmt_entity { |
519
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
return ( |
522
|
|
|
|
|
|
|
defined $self->{mgmt_entity}->{$id} |
523
|
0
|
0
|
|
|
|
|
? $self->{mgmt_entity}->{$id} |
524
|
|
|
|
|
|
|
: $self->mgmt_entity($id) |
525
|
|
|
|
|
|
|
) |
526
|
|
|
|
|
|
|
} |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
sub get_mgmt_entity { |
529
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
530
|
|
|
|
|
|
|
|
531
|
0
|
|
|
|
|
|
return $self->get_mgmt_entities( $id ) |
532
|
|
|
|
|
|
|
} |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
sub get_mgmt_entities { |
535
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
536
|
|
|
|
|
|
|
|
537
|
0
|
|
|
|
|
|
return $self->_get_child_objects( |
538
|
|
|
|
|
|
|
id => $id, |
539
|
|
|
|
|
|
|
type => 'mgmtEntity', |
540
|
|
|
|
|
|
|
class => 'Cisco::UCS::MgmtEntity', |
541
|
|
|
|
|
|
|
attr => 'mgmt_entity' |
542
|
|
|
|
|
|
|
); |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
sub get_primary_mgmt_entity { |
546
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
547
|
|
|
|
|
|
|
|
548
|
0
|
0
|
|
|
|
|
my $xml = $self->resolve_class_filter( |
549
|
|
|
|
|
|
|
classId => 'mgmtEntity', |
550
|
|
|
|
|
|
|
leadership => 'primary' |
551
|
|
|
|
|
|
|
) or return; |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
return ( |
554
|
|
|
|
|
|
|
defined $xml->{outConfigs}->{mgmtEntity} |
555
|
|
|
|
|
|
|
? $xml->{outConfigs}->{mgmtEntity} |
556
|
|
|
|
|
|
|
: undef |
557
|
|
|
|
|
|
|
) |
558
|
0
|
0
|
|
|
|
|
} |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
sub get_subordinate_mgmt_entity { |
561
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
562
|
|
|
|
|
|
|
|
563
|
0
|
0
|
|
|
|
|
my $xml = $self->resolve_class_filter( |
564
|
|
|
|
|
|
|
classId => 'mgmtEntity', |
565
|
|
|
|
|
|
|
leadership => 'subordinate' |
566
|
|
|
|
|
|
|
) or return; |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
return ( |
569
|
|
|
|
|
|
|
defined $xml->{outConfigs}->{mgmtEntity} |
570
|
|
|
|
|
|
|
? $xml->{outConfigs}->{mgmtEntity} |
571
|
|
|
|
|
|
|
: undef |
572
|
0
|
0
|
|
|
|
|
); |
573
|
|
|
|
|
|
|
} |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
sub service_profile { |
576
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
return ( |
579
|
|
|
|
|
|
|
defined $self->{service_profile}->{$id} |
580
|
0
|
0
|
|
|
|
|
? $self->{service_profile}->{$id} |
581
|
|
|
|
|
|
|
: $self->get_service_profile($id) |
582
|
|
|
|
|
|
|
) |
583
|
|
|
|
|
|
|
} |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
sub get_service_profile { |
586
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
587
|
|
|
|
|
|
|
|
588
|
0
|
|
|
|
|
|
return $self->get_service_profiles( $id ) |
589
|
|
|
|
|
|
|
} |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
sub get_service_profiles { |
592
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
593
|
|
|
|
|
|
|
|
594
|
0
|
|
|
|
|
|
return $self->_get_child_objects( |
595
|
|
|
|
|
|
|
id => $id, |
596
|
|
|
|
|
|
|
type => 'lsServer', |
597
|
|
|
|
|
|
|
class => 'Cisco::UCS::ServiceProfile', |
598
|
|
|
|
|
|
|
uid => 'name', |
599
|
|
|
|
|
|
|
attr => 'service_profile', |
600
|
|
|
|
|
|
|
class_filter => { |
601
|
|
|
|
|
|
|
classId => 'lsServer' |
602
|
|
|
|
|
|
|
} |
603
|
|
|
|
|
|
|
); |
604
|
|
|
|
|
|
|
} |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
sub interconnect { |
607
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
return ( |
610
|
|
|
|
|
|
|
defined $self->{interconnect}->{$id} |
611
|
0
|
0
|
|
|
|
|
? $self->{interconnect}->{$id} |
612
|
|
|
|
|
|
|
: $self->get_interconnect($id) |
613
|
|
|
|
|
|
|
) |
614
|
|
|
|
|
|
|
} |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
sub get_interconnect { |
617
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
618
|
|
|
|
|
|
|
|
619
|
0
|
|
|
|
|
|
return $self->get_interconnects( $id ) |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
sub get_interconnects { |
623
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
624
|
|
|
|
|
|
|
|
625
|
0
|
|
|
|
|
|
return $self->_get_child_objects( |
626
|
|
|
|
|
|
|
id => $id, |
627
|
|
|
|
|
|
|
type => 'networkElement', |
628
|
|
|
|
|
|
|
class => 'Cisco::UCS::Interconnect', |
629
|
|
|
|
|
|
|
attr => 'interconnect' |
630
|
|
|
|
|
|
|
); |
631
|
|
|
|
|
|
|
} |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
sub blade { |
634
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
return ( |
637
|
|
|
|
|
|
|
defined $self->{blade}->{$id} |
638
|
0
|
0
|
|
|
|
|
? $self->{blade}->{$id} |
639
|
|
|
|
|
|
|
: $self->get_blade($id) |
640
|
|
|
|
|
|
|
) |
641
|
|
|
|
|
|
|
} |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
sub get_blade { |
644
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
645
|
|
|
|
|
|
|
|
646
|
0
|
|
|
|
|
|
return $self->get_blades( $id ) |
647
|
|
|
|
|
|
|
} |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
sub get_blades { |
650
|
0
|
|
|
0
|
1
|
|
my ( $self, $id, %args ) = @_; |
651
|
|
|
|
|
|
|
|
652
|
0
|
|
|
|
|
|
return $self->_get_child_objects( |
653
|
|
|
|
|
|
|
id => $id, |
654
|
|
|
|
|
|
|
type => 'computeBlade', |
655
|
|
|
|
|
|
|
class => 'Cisco::UCS::Blade', |
656
|
|
|
|
|
|
|
attr => 'blade', |
657
|
|
|
|
|
|
|
uid => 'serverId', |
658
|
|
|
|
|
|
|
class_filter => { |
659
|
|
|
|
|
|
|
classId => 'computeBlade' |
660
|
|
|
|
|
|
|
} |
661
|
|
|
|
|
|
|
); |
662
|
|
|
|
|
|
|
} |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
sub chassis { |
665
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
return ( |
668
|
|
|
|
|
|
|
defined $self->{chassis}->{$id} |
669
|
0
|
0
|
|
|
|
|
? $self->{chassis}->{$id} |
670
|
|
|
|
|
|
|
: $self->get_chassis($id) |
671
|
|
|
|
|
|
|
) |
672
|
|
|
|
|
|
|
} |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
sub get_chassis { |
675
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
676
|
|
|
|
|
|
|
|
677
|
0
|
|
|
|
|
|
return $self->get_chassiss( $id ) |
678
|
|
|
|
|
|
|
} |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
sub get_chassiss { |
681
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
682
|
|
|
|
|
|
|
|
683
|
0
|
|
|
|
|
|
return $self->_get_child_objects( |
684
|
|
|
|
|
|
|
id => $id, |
685
|
|
|
|
|
|
|
type => 'equipmentChassis', |
686
|
|
|
|
|
|
|
class => 'Cisco::UCS::Chassis', |
687
|
|
|
|
|
|
|
attr => 'chassis' |
688
|
|
|
|
|
|
|
); |
689
|
|
|
|
|
|
|
} |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
sub full_state_backup { |
692
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
693
|
|
|
|
|
|
|
|
694
|
0
|
|
|
|
|
|
$args{backup_type} = 'full-state'; |
695
|
|
|
|
|
|
|
|
696
|
0
|
|
|
|
|
|
return ( $self->_backup( %args ) ); |
697
|
|
|
|
|
|
|
} |
698
|
|
|
|
|
|
|
sub all_config_backup { |
699
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
700
|
|
|
|
|
|
|
|
701
|
0
|
|
|
|
|
|
$args{backup_type} = 'config-all'; |
702
|
|
|
|
|
|
|
|
703
|
0
|
|
|
|
|
|
return ( $self->_backup( %args ) ); |
704
|
|
|
|
|
|
|
} |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
sub system_config_backup { |
707
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
708
|
|
|
|
|
|
|
|
709
|
0
|
|
|
|
|
|
$args{backup_type} = 'config-system'; |
710
|
|
|
|
|
|
|
|
711
|
0
|
|
|
|
|
|
return ( $self->_backup( %args ) ); |
712
|
|
|
|
|
|
|
} |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
sub logical_config_backup { |
715
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
716
|
|
|
|
|
|
|
|
717
|
0
|
|
|
|
|
|
$args{backup_type} = 'config-logical'; |
718
|
|
|
|
|
|
|
|
719
|
0
|
|
|
|
|
|
return ( $self->_backup( %args ) ); |
720
|
|
|
|
|
|
|
} |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
sub _backup { |
723
|
0
|
|
|
0
|
|
|
my ( $self, %args ) = @_; |
724
|
|
|
|
|
|
|
|
725
|
0
|
0
|
0
|
|
|
|
unless( defined $args{backup_type} and |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
726
|
|
|
|
|
|
|
defined $args{backup_proto} and |
727
|
|
|
|
|
|
|
defined $args{backup_host} and |
728
|
|
|
|
|
|
|
defined $args{backup_target} and |
729
|
|
|
|
|
|
|
defined $args{backup_passwd} and |
730
|
|
|
|
|
|
|
defined $args{backup_username} ) |
731
|
|
|
|
|
|
|
{ |
732
|
0
|
|
|
|
|
|
$self->{error} = 'Bad argument list'; |
733
|
|
|
|
|
|
|
return |
734
|
0
|
|
|
|
|
|
} |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
$args{admin_state} = ( |
737
|
|
|
|
|
|
|
defined $args{admin_state} |
738
|
|
|
|
|
|
|
? $args{admin_state} |
739
|
0
|
0
|
|
|
|
|
: 'enabled' |
740
|
|
|
|
|
|
|
); |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
$args{preserve_pooled_values} = ( |
743
|
|
|
|
|
|
|
defined $args{preserve_pooled_values} |
744
|
|
|
|
|
|
|
? $args{preserve_pooled_values} |
745
|
0
|
0
|
|
|
|
|
: 'yes' |
746
|
|
|
|
|
|
|
); |
747
|
|
|
|
|
|
|
|
748
|
0
|
0
|
|
|
|
|
unless ( $args{backup_type} =~ /(config-all|full-state|config-system|config-logical)/i ) { |
749
|
0
|
|
|
|
|
|
$self->{error} = "Bad backup type ($args{backup_type})"; |
750
|
|
|
|
|
|
|
return |
751
|
0
|
|
|
|
|
|
} |
752
|
|
|
|
|
|
|
|
753
|
0
|
0
|
|
|
|
|
unless ( $args{backup_proto} =~ /^((t|s)?ftp)|(scp)$/i ) { |
754
|
0
|
|
|
|
|
|
$self->{error} = "Bad backup proto' ($args{backup_proto})"; |
755
|
|
|
|
|
|
|
return |
756
|
0
|
|
|
|
|
|
} |
757
|
|
|
|
|
|
|
|
758
|
0
|
|
|
|
|
|
my $address = $self->get_cluster_status->{address}; |
759
|
|
|
|
|
|
|
|
760
|
0
|
|
|
|
|
|
my $data = <<"XML"; |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
proto="$args{backup_proto}" pwd="$args{backup_passwd}" remoteFile="$args{backup_target}" |
767
|
|
|
|
|
|
|
rn="backup-$args{backup_host}" type="$args{backup_type}" |
768
|
|
|
|
|
|
|
user="$args{backup_username}" policyOwner="local"> |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
XML |
775
|
|
|
|
|
|
|
|
776
|
0
|
0
|
|
|
|
|
my $xml = $self->_ucsm_request( $data ) or return; |
777
|
|
|
|
|
|
|
|
778
|
0
|
0
|
|
|
|
|
if ( defined $xml->{'errorCode'} ) { |
779
|
|
|
|
|
|
|
my $self->{error} = ( defined $xml->{'errorDescr'} |
780
|
0
|
0
|
|
|
|
|
? $xml->{'errorDescr'} |
781
|
|
|
|
|
|
|
: "Unspecified error" |
782
|
|
|
|
|
|
|
); |
783
|
|
|
|
|
|
|
return |
784
|
0
|
|
|
|
|
|
} |
785
|
|
|
|
|
|
|
|
786
|
0
|
|
|
|
|
|
return 1; |
787
|
|
|
|
|
|
|
} |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
1; |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
__END__ |