blob: 46b90f747593d125794031b09038661f8911078c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# Copyright (c) 2006, 2007 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# AttributeRoster.pm
# - provides information about all available attributes
# -----------------------------------------------------------------------------
package OpenSLX::AttributeRoster;
use strict;
use warnings;
our (@ISA, @EXPORT, $VERSION);
use Exporter;
$VERSION = 0.2;
@ISA = qw(Exporter);
@EXPORT = qw(
$%AttributeInfo
);
use OpenSLX::Basics;
################################################################################
###
### Load the available AttrInfo-modules and build a hash containing info about
### all known attributes from the data contained in those modules.
###
################################################################################
my %AttributeInfo = ();
my $libPath = "$openslxConfig{'base-path'}/lib";
foreach my $module (glob("$libPath/OpenSLX/AttrInfo/*.pm")) {
next if $module !~ m{/([^/]+)\.pm$};
my $class = "OpenSLX::AttrInfo::$1";
vlog(2, "loading attr-info from module '$module'");
my $instance = instantiateClass($class);
my $attrInfo = $instance->AttrInfo();
foreach my $attr (keys %$attrInfo) {
$AttributeInfo{$attr} = $attrInfo->{$attr};
}
}
=item C<getAttrInfo()>
Returns info about all attributes.
=over
=item Return Value
An hash-ref with info about all known attributes.
=back
=cut
sub getAttrInfo
{
my $class = shift;
my $name = shift;
if (defined $name) {
my $attrInfo = $AttributeInfo{$name};
return if !defined $attrInfo;
return { $name => $AttributeInfo{$name} };
}
return \%AttributeInfo;
}
=item C<getSystemAttrs()>
Returns the attribute names that apply to systems.
=over
=item Return Value
An array of attribute names.
=back
=cut
sub getSystemAttrs
{
my $class = shift;
return
grep { $AttributeInfo{$_}->{"applies_to_systems"} }
keys %AttributeInfo
}
=item C<getClientAttrs()>
Returns the attribute names that apply to clients.
=over
=item Return Value
An array of attribute names.
=back
=cut
sub getClientAttrs
{
my $class = shift;
return
grep { $AttributeInfo{$_}->{"applies_to_clients"} }
keys %AttributeInfo
}
1;
|