blib/lib/RackMan/Device.pm

filter: Statementstmt 22.8% 48 / 210 Branchbran 0.0% 0 / 54 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 35.7% 10 / 28 Podpod 85.7% 6 / 7 totaltotal 20.1% 64 / 318 CC 41 SCAR 38.4
CC
41
Cov
17%
BUILDARGS
132.0
_get_attributes
110.0
_get_tag_tree
30.0
CRAP 46.6
« bin/rack ↑ Summary blib/lib/RackMan/Template.pm »
1 package RackMan::Device;
2  
3 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Module::Runtime;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use RackMan;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use RackMan::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use RackMan::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14  
15 #
16 # constants
17 #
18 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 DEFAULT_VIRT_IFACES => "/(carp|lagg|vlan)\\d+/",
20 DEFAULT_MGMT_IFACES => "/(areca|ilo|ipmi)/",
21 1 };
22  
23  
24 #
25 # global vars
26 #
27 1 my %ImplementedType = map { $_ => 1 } RackMan::Types->implemented;
28  
29  
30 #
31 # custom types
32 #
33 1 enum RackObjectType => [ RackMan::Types->enum ];
34  
35  
36 #
37 # object attributes
38 #
39 1 has rackman => (
40 is => "ro",
41 isa => "RackMan",
42 );
43  
44 1 has racktables => (
45 is => "ro",
46 isa => "RackTables::Schema",
47 required => 1,
48 );
49  
50 1 has rackobject => (
51 is => "ro",
52 isa => "RackTables::Schema::Result::RackObject",
53 handles => {
54 object_id => "id",
55 object_name => "name",
56 object_asset_no => "asset_no",
57 object_has_problem => "has_problems",
58 object_comment => "comment",
59 },
60 );
61  
62 1 has object_type => (
63 is => "ro",
64 isa => "RackObjectType",
65 lazy => 1,
66 builder => "_get_type",
67 );
68  
69 1 has attributes => (
70 is => "ro",
71 isa => "HashRef",
72 lazy => 1,
73 builder => "_get_attributes",
74 );
75  
76 1 has explicit_tags => (
77 is => "ro",
78 isa => "ArrayRef",
79 lazy => 1,
80 builder => "_get_explicit_tags",
81 );
82  
83 1 has implicit_tags => (
84 is => "ro",
85 isa => "ArrayRef",
86 lazy => 1,
87 builder => "_get_implicit_tags",
88 );
89  
90 1 has tag_tree => (
91 is => "ro",
92 isa => "HashRef",
93 lazy => 1,
94 builder => "_get_tag_tree",
95 );
96  
97 1 has ports => (
98 is => "ro",
99 isa => "ArrayRef[HashRef]",
100 lazy => 1,
101 builder => "_get_ports",
102 );
103  
104 1 has ipv4addrs => (
105 is => "ro",
106 isa => "ArrayRef[HashRef]",
107 lazy => 1,
108 traits => ["Array"],
109 builder => "_get_ipv4addrs",
110 handles => {
111 has_ipv4addrs => "count",
112 },
113 );
114  
115 1 has ipv6addrs => (
116 is => "ro",
117 isa => "ArrayRef[HashRef]",
118 lazy => 1,
119 traits => ["Array"],
120 builder => "_get_ipv6addrs",
121 handles => {
122 has_ipv6addrs => "count",
123 },
124 );
125  
126 1 has default_ipv4_gateway => (
127 is => "ro",
128 isa => "HashRef",
129 lazy => 1,
130 builder => "_get_default_ipv4_gateway",
131 );
132  
133 1 has parents => (
134 is => "ro",
135 isa => "ArrayRef",
136 lazy => 1,
137 builder => "_get_parents",
138 );
139  
140 1 has rack => (
141 is => "ro",
142 isa => "HashRef",
143 lazy => 1,
144 builder => "_get_rack",
145 );
146  
147  
148 #
149 # BUILDARGS()
150 # ---------
151 0 ▶sub BUILDARGS {
Subroutine BUILDARGS: not called CC=11 SCAR=48.8
Pod documented
152 0 my $class = shift;
153 0 my %param;
154 my $rack_obj;
155  
156 0 ▶ if (@_ % 2 == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ % 2 == 0) { } 0 0 0
elsif (ref $_[0] eq 'HASH') { } 0 0 0
157 0 %param = @_;
158 }
159 elsif (ref $_[0] eq "HASH") {
160 0 %param = %{$_[0]};
161 }
162 else {
163 0 croak "invalid argument: ", lc ref $_[0], "ref instead of hashref";
164 }
165  
166 # check parameters
167 croak "error: one of 'id' or 'name' must be specified"
168 0 ▶ if not exists $param{id} and not exists $param{name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $param{"id"} or exists $param{"name"} 0 0 0
Condition0%0/3
exists $param{"id"} or exists $param{"name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $param{"id"} or exists $param{"name"}
exists $param{"id"} exists $param{"name"}
Truth table0%0/3
A or B
A= exists $param{"id"}B= exists $param{"name"}
ABresult
1X1
011
000
169  
170 croak "error: parameter 'racktables' isn't a RackTables::Schema object"
171 0 ▶ unless eval { $param{racktables}->isa("RackTables::Schema") };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { $param{"racktables"}->isa("RackTables::Schema") } } 0 0 0
172  
173 # try to find the RackObject
174 0 for my $src (qw< name id >) {
175 0 ▶ next unless exists $param{$src};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $param{$src} 0 0 0
176  
177 # try to fetch a RackObject using the given source
178 $rack_obj = $param{racktables}->resultset("RackObject")->search(
179 0 { "me.$src" => $param{$src} },
180 { prefetch => { attribute_values => { attr => "attr" } } },
181 )->first;
182  
183 # if none returned, it means it doesn't exist
184 0 ▶ RackMan->error("no RackObject with $src '$param{$src}'")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rack_obj 0 0 0
185 unless defined $rack_obj;
186  
187 0 ▶ last if $rack_obj;
Branch: 1 branch
BranchTrueFalseTotal
if $rack_obj 0 0 0
188 }
189  
190 # construct the object attributes
191 0 my %attrs = ( rackobject => $rack_obj, racktables => $param{racktables} );
192 0 ▶ $attrs{rackman} = $param{rackman} if defined $param{rackman};
Branch: 1 branch
BranchTrueFalseTotal
if defined $param{"rackman"} 0 0 0
193  
194 0 return \%attrs
195 }
196  
197  
198 #
199 # BUILD()
200 # -----
201 0 ▶sub BUILD {
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod undocumented
202 0 my ($self, $args) = @_;
203  
204 0 ▶ if ($ImplementedType{$self->object_type}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ImplementedType{$self->object_type}) 0 0 0
205 # determine the type of device and apply the corresponding
206 # role to the object
207 0 my $type_role = __PACKAGE__."::".$self->object_type;
208 0 ▶ eval { Module::Runtime::require_module($type_role) }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { &Module::Runtime::require_module($type_role) } } or "RackMan"->error("can't load ${type_role}: $@") 0 0 0
209 or RackMan->error("can't load $type_role: $@");
210 0 $type_role->meta->apply($self);
211  
212 # "specialise" the object (apply a specialised role) to the object
213 # so it knows how to speak with the actual hardware, if needed
214 0 $self->specialise;
215 }
216 }
217  
218  
219 #
220 # _get_type()
221 # ---------
222 0 ▶sub _get_type {
Subroutine _get_type: not called CC=1 SCAR=6.9
223 0 my $self = shift;
224  
225 # fetch the hardware type of the RackObject
226 0 my $type = $self->racktables->resultset("Dictionary")->search(
227 { chapter_id => 1, dict_key => $self->rackobject->objtype_id },
228 )->first->dict_value;
229  
230 0 $type = RackMan::Types->from_racktables($type);
231  
232 0 return $type
233 }
234  
235  
236 #
237 # _get_attributes()
238 # ---------------
239 0 ▶sub _get_attributes {
Subroutine _get_attributes: not called CC=10 SCAR=47.0
240 0 my $self = shift;
241  
242 0 my %attr;
243 0 my $dictionary = $self->racktables->resultset("Dictionary");
244  
245 # fetch object attributes
246 0 for my $attv ($self->rackobject->attribute_values) {
247 # $attv is an AttributeValue resultset
248 0 my $attm = $attv->attr; # $attm is an AttributeMap resultset
249 0 my $attr = $attm->attr; # $attr is an Attribute resultset
250 0 my $name = $attr->name;
251 0 my $type = $attr->type;
252  
253 0 ▶ if ($type eq "string") {
Branch: 4 branches
BranchTrueFalseTotal
if ($type eq 'string') { } 0 0 0
elsif ($type eq 'uint') { } 0 0 0
elsif ($type eq 'float') { } 0 0 0
elsif ($type eq 'dict') { } 0 0 0
254 0 $attr{$name} = $attv->string_value;
255 }
256 elsif ($type eq "uint") {
257 0 $attr{$name} = int $attv->uint_value;
258 }
259 elsif ($type eq "float") {
260 0 $attr{$name} = .0+ $attv->float_value;
261 }
262 elsif ($type eq "dict") {
263 0 my $dict_rs = $dictionary->search(
264 { "chapter.id" => $attm->chapter_id, dict_key => $attv->uint_value },
265 { join => "chapter" },
266 );
267  
268 0 ▶ while (my $item = $dict_rs->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $item = $dict_rs->next) 0 0 0
269 0 $attr{$name} = $item->dict_value;
270 }
271 }
272 }
273  
274 # interpret "GMarker" (that's a RackTables thing. don't ask.)
275 0 s/^.+%GSKIP%//, s/%GPASS%/ / for values %attr;
276  
277 # extract wiki-links and store them in additional attributes
278 0 for (keys %attr) {
279 ($attr{$_}, $attr{"$_ link"})
280 = $attr{$_} =~ /^\[\[([^|]+)\s*\|\s*(.+)\]\]$/
281 0 ▶ if $attr{$_} =~ /^\[\[/;
Branch: 1 branch
BranchTrueFalseTotal
if $attr{$_} =~ /^\[\[/ 0 0 0
282 0 $attr{$_} =~ s/ +$//;
283 }
284  
285 0 return \%attr
286 }
287  
288  
289 #
290 # _get_explicit_tags()
291 # ------------------
292 0 ▶sub _get_explicit_tags {
Subroutine _get_explicit_tags: not called CC=1 SCAR=6.9
293 0 my $self = shift;
294  
295 # fetch object tags
296 0 my $tags_rs = $self->racktables->resultset("TagTree")->search(
297 { entity_realm => "object", entity_id => $self->object_id },
298 { join => "tag_storages" },
299 );
300 0 my @explicit_tags = map { eval { $_->tag } } $tags_rs->all;
301  
302 return \@explicit_tags
303 0 }
304  
305  
306 #
307 # _get_implicit_tags()
308 # ------------------
309 0 ▶sub _get_implicit_tags {
Subroutine _get_implicit_tags: not called CC=3 SCAR=24.8
310 0 my $self = shift;
311  
312 # fetch object tags
313 0 my $tags_rs = $self->racktables->resultset("TagTree")->search(
314 { entity_realm => "object", entity_id => $self->object_id },
315 { join => "tag_storages" },
316 );
317  
318 # for each tag, find all its parent tags
319 0 my @implicit_tags;
320 0 for my $tag ($tags_rs->all) {
321 0 ▶ while ($tag = $tag->parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag = $tag->parent) 0 0 0
322 0 push @implicit_tags, $tag->tag;
323 }
324 }
325  
326 return \@implicit_tags
327 0 }
328  
329  
330 #
331 # _get_tag_tree()
332 # -------------
333 0 ▶sub _get_tag_tree {
Subroutine _get_tag_tree: not called CC=5 SCAR=34.0
334 0 my $self = shift;
335  
336 # fetch object tags
337 0 my $tags_rs = $self->racktables->resultset("TagTree")->search(
338 { entity_realm => "object", entity_id => $self->object_id },
339 { join => "tag_storages" },
340 );
341  
342 # reconstruct the tag tree as a hash of hashes
343 0 my %tag_tree;
344 0 for my $tag ($tags_rs->all) {
345 0 ▶ my $node = $tag_tree{$tag->tag} ||= {};
Condition0%0/2
$tag_tree{$tag->tag} ||= {}
l!l
00
MC/DC0%0/1
$tag_tree{$tag->tag} ||= {}
$tag_tree{$tag->tag}
Truth table0%0/2
A
A= $tag_tree{$tag->tag}
Aresult
11
00
346  
347 0 ▶ while ($tag = $tag->parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag = $tag->parent) 0 0 0
348 0 ▶ $node = $node->{$tag->tag} ||= {};
Condition0%0/2
$$node{$tag->tag} ||= {}
l!l
00
MC/DC0%0/1
$$node{$tag->tag} ||= {}
$$node{$tag->tag}
Truth table0%0/2
A
A= $$node{$tag->tag}
Aresult
11
00
349 }
350 }
351  
352 0 return \%tag_tree
353 }
354  
355  
356 #
357 # _get_ports()
358 # ----------
359 0 ▶sub _get_ports {
Subroutine _get_ports: not called CC=2 SCAR=17.9
360 0 my $self = shift;
361  
362 # find associated ports
363 0 my $ports = $self->racktables->resultset("viewAssociatedPorts")->search(
364 {}, { bind => [ $self->object_id ] },
365 );
366  
367 my @ports = map +{
368 name => $_->name,
369 l2address => $_->l2address,
370 0 l2address_text => eval {
371 0 ▶ my $s = $_->l2address || ""; $s =~ s/(\w\w)/$1:/g; $s =~ s/:$//; $s
Condition0%0/2
$_->l2address || ''
l!l
00
MC/DC0%0/1
$_->l2address || ''
$_->l2address
Truth table0%0/2
A
A= $_->l2address
Aresult
11
00
372 },
373 iif_id => $_->iif_id,
374 iif_name => $_->iif_name,
375 oif_id => $_->oif_id,
376 oif_name => $_->oif_name,
377 peer_port_id => $_->peer_port_id,
378 peer_port_name => $_->peer_port_name,
379 peer_object_id => $_->peer_object_id,
380 peer_object_name => $_->peer_object_name,
381 }, $ports->all;
382  
383 return \@ports
384 0 }
385  
386  
387 #
388 # regular_mac_addrs()
389 # -----------------
390 0 ▶sub regular_mac_addrs {
Subroutine regular_mac_addrs: not called CC=2 SCAR=17.9
Pod documented
391 0 my $self = shift;
392  
393 0 my ($re, $err) = parse_regexp($self->rackman->config->val(
394 "general", "management_interfaces", DEFAULT_MGMT_IFACES));
395  
396 return
397 0 grep { $_->{name} !~ /$re/ }
398 0 ▶ grep { defined $_->{l2address} and length $_->{l2address} }
Condition0%0/3
defined $_->{'l2address'} && length $_->{'l2address'}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_->{'l2address'} && length $_->{'l2address'}
defined $_->{'l2address'} length $_->{'l2address'}
Truth table0%0/3
A && B
A= defined $_->{'l2address'}B= length $_->{'l2address'}
ABresult
0X0
100
111
399 0 @{ $self->ports }
400 }
401  
402  
403 #
404 # _get_ipv4addrs()
405 # --------------
406 0 ▶sub _get_ipv4addrs {
Subroutine _get_ipv4addrs: not called CC=1 SCAR=6.9
407 0 my $self = shift;
408  
409 # find IPv4 addresses
410 0 my $ipv4_rs = $self->racktables->resultset("IPv4Allocation")->search(
411 { object_id => $self->object_id },
412 );
413  
414 0 my @addrs = sort { $a->{iface} cmp $b->{iface} } map +{
415 version => 4, type => $_->type, iface => $_->name,
416 addr => inet_ntoa(pack "N", $_->ip),
417 }, grep defined $_->ip, $ipv4_rs->all;
418  
419 return \@addrs
420 0 }
421  
422  
423 #
424 # _get_ipv6addrs()
425 # --------------
426 0 ▶sub _get_ipv6addrs {
Subroutine _get_ipv6addrs: not called CC=2 SCAR=17.9
427 0 my $self = shift;
428  
429 # Socket.pm only has IPv6 support since Perl 5.12; for older Perl,
430 # we need to use Socket6
431 0 ▶ if ($] < 5.012) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < 5.012) { } 0 0 0
432 0 require Socket6;
433 0 import Socket6;
434 }
435 else {
436 0 *inet_ntop = \&Socket::inet_ntop;
437 }
438  
439 # find IPv6 addresses
440 0 my $ipv6_rs = $self->racktables->resultset("IPv6Allocation")->search(
441 { object_id => $self->object_id },
442 );
443  
444 0 my @addrs = sort { $a->{iface} cmp $b->{iface} } map +{
445 version => 6, type => $_->type, iface => $_->name,
446 addr => inet_ntop(AF_INET6(), $_->ip),
447 }, grep defined $_->ip, $ipv6_rs->all;
448  
449 return \@addrs
450 0 }
451  
452  
453 #
454 # regular_ipv4addrs()
455 # -----------------
456 0 ▶sub regular_ipv4addrs {
Subroutine regular_ipv4addrs: not called CC=1 SCAR=6.9
Pod documented
457 0 my $self = shift;
458  
459 0 my ($re, $err) = parse_regexp($self->rackman->config->val(
460 "general", "management_interfaces", DEFAULT_MGMT_IFACES));
461  
462 return
463 0 grep { $_->{iface} !~ /$re/ }
464 0 grep { $_->{type} eq "regular" }
465 0 @{ $self->ipv4addrs }
466 }
467  
468  
469 #
470 # regular_ipv6addrs()
471 # -----------------
472 0 ▶sub regular_ipv6addrs {
Subroutine regular_ipv6addrs: not called CC=1 SCAR=6.9
Pod documented
473 0 my $self = shift;
474  
475 0 my ($re, $err) = parse_regexp($self->rackman->config->val(
476 "general", "management_interfaces", DEFAULT_MGMT_IFACES));
477  
478 return
479 0 grep { $_->{iface} !~ /$re/ }
480 0 grep { $_->{type} eq "regular" }
481 0 @{ $self->ipv6addrs }
482 }
483  
484  
485 #
486 # physical_interfaces()
487 # -------------------
488 0 ▶sub physical_interfaces {
Subroutine physical_interfaces: not called CC=1 SCAR=6.9
Pod documented
489 0 my $self = shift;
490  
491 0 my ($re, $err) = parse_regexp($self->rackman->config->val(
492 "general", "virtual_interfaces", DEFAULT_VIRT_IFACES));
493  
494 return
495 0 grep { $_->{iface} !~ /$re/ }
496 0 grep { $_->{type} eq "regular" }
497 0 @{ $self->ipv4addrs }, @{ $self->ipv6addrs }
498 }
499  
500  
501 #
502 # _get_default_ipv4_gateway()
503 # -------------------------
504 0 ▶sub _get_default_ipv4_gateway {
Subroutine _get_default_ipv4_gateway: not called CC=5 SCAR=34.0
505 0 my ($self, $addr) = @_;
506  
507 0 ▶ if (not defined $addr) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $addr) 0 0 0
508 # if no IP address is given, use the first regular one
509 0 my @addrs = $self->regular_ipv4addrs;
510 0 $addr = $addrs[0]{addr};
511 }
512  
513 # find the network of the given IPv4 address
514 0 my $networks = $self->racktables
515 ->resultset("viewIPv4AddressNetwork")->search(
516 {}, { bind => [ $addr ] },
517 );
518  
519 # determine the lower (network address) and upper (broadcast
520 # address) bounds of the range
521 0 my $network = $networks->first;
522 0 ▶ return {} unless $network;
Branch: 1 branch
BranchTrueFalseTotal
unless $network 0 0 0
523 0 my $lower = $network->ip;
524 0 my $upper = $lower | (0xffffffff >> $network->mask);
525  
526 0 my $range = $self->racktables
527 ->resultset("viewIPv4AddressRange")->search(
528 {}, { bind => [ $lower, $upper ] },
529 );
530  
531 # filter to only keep the routers, and keep only the first one
532 0 my ($gateway) = grep { $_->type eq "router" } $range->all;
533  
534 # construct the result
535 0 my @fields = qw< iface type addr object_id >;
536 0 my %result;
537 0 @result{@fields} = ();
538  
539 0 ▶ if (defined $gateway) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $gateway) 0 0 0
540 0 $result{$_} = $gateway->$_ for @fields;
541 0 $result{masklen} = $network->mask;
542 0 $result{network} = $network->addr;
543 0 $result{netname} = $network->name;
544 }
545  
546 0 return \%result
547 }
548  
549  
550 #
551 # get_network()
552 # -----------
553 0 ▶sub get_network {
Subroutine get_network: not called CC=5 SCAR=34.0
Pod documented
554 0 my ($self, $addr) = @_;
555  
556 0 my @fields = qw< id addr mask name comment >;
557 0 ▶ return { map { $_ => "" } @fields } unless defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 0 0
558  
559 0 ▶ $addr = { version => 4, addr => $addr } unless ref $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $addr 0 0 0
560  
561 # find the network of the given address
562 0 ▶ my $view = $addr->{version} eq "6" ? "viewIPv6AddressNetwork"
Branch: 1 branch
BranchTrueFalseTotal
$addr->{'version'} eq '6' ? : 0 0 0
563 : "viewIPv4AddressNetwork";
564 my $networks = $self->racktables->resultset($view)->search(
565 0 {}, { bind => [ $addr->{addr} ] },
566 );
567  
568 0 my $network = $networks->first;
569 return defined $network
570 0 ? { map { $_ => $network->$_ } @fields }
571 0 ▶ : { map { $_ => "" } @fields }
Branch: 1 branch
BranchTrueFalseTotal
defined $network ? : 0 0 0
572 }
573  
574  
575 #
576 # _get_parents()
577 # ------------
578 0 ▶sub _get_parents {
Subroutine _get_parents: not called CC=1 SCAR=6.9
579 0 my ($self) = @_;
580  
581 0 my $parents = $self->racktables->resultset("EntityLink")->search(
582 { child_entity_type => "object", child_entity_id => $self->object_id }
583 );
584  
585 0 my @parents = map $_->parent_entity_id, $parents->all;
586  
587 return \@parents
588 0 }
589  
590  
591 #
592 # _get_rack()
593 # ---------
594 0 ▶sub _get_rack {
Subroutine _get_rack: not called CC=3 SCAR=24.8
595 0 my $self = shift;
596  
597 0 my $object_id = $self->object_id;
598  
599 # check if this is a VM or a blade. in that case, we must find
600 # the ID of the parent
601 0 ▶ if (my @parents = @{ $self->parents }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@parents) = @{$self->parents;}) 0 0 0
602 0 ($object_id) = @parents;
603 }
604  
605 # find associated rack
606 0 my $rack = $self->racktables->resultset("viewRack")->search(
607 {}, { bind => [ $object_id ] },
608 )->first;
609  
610 0 my %rack = (
611 id => $rack->id,
612 name => $rack->name,
613 comment => $rack->comment,
614 row_id => $rack->row_id,
615 row_name => $rack->row_name,
616 );
617  
618 $_ = join " ", map ucfirst lc, split / /
619 0 for $rack{name}, $rack{row_name};
620  
621 0 return \%rack
622 }
623  
624  
625 1 __PACKAGE__->meta->make_immutable;
626  
627 __END__
« bin/rack ↑ Summary blib/lib/RackMan/Template.pm »