Last change
on this file since 1341 was
457,
checked in by nanardon, 15 years ago
|
- add options to not load acls, command line tools are superuser command, then skip acls checks
|
-
Property svn:executable set to
*
|
File size:
1.5 KB
|
Line | |
---|
1 | #!/bin/env perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use LATMOS::Accounts; |
---|
6 | use Getopt::Long; |
---|
7 | use Pod::Usage; |
---|
8 | use LATMOS::Accounts::Utils; |
---|
9 | use LATMOS::Accounts::Log; |
---|
10 | use GraphViz; |
---|
11 | |
---|
12 | =head1 NAME |
---|
13 | |
---|
14 | la-group -- Graph user/cells-department |
---|
15 | |
---|
16 | =head1 SYNOPSIS |
---|
17 | |
---|
18 | la-group [options] |
---|
19 | |
---|
20 | =cut |
---|
21 | |
---|
22 | GetOptions( |
---|
23 | 'c|config=s' => \my $config, |
---|
24 | 'b|base=s' => \my $base, |
---|
25 | 'help' => sub { pod2usage(0) }, |
---|
26 | ) or pod2usage(); |
---|
27 | |
---|
28 | =head1 OPTIONS |
---|
29 | |
---|
30 | =over 4 |
---|
31 | |
---|
32 | =item -c|--config configfile |
---|
33 | |
---|
34 | Use this configuration file instead the default one |
---|
35 | |
---|
36 | =item -b|--base basename |
---|
37 | |
---|
38 | Query this specific base instead default. |
---|
39 | |
---|
40 | =back |
---|
41 | |
---|
42 | =cut |
---|
43 | |
---|
44 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
45 | my $labase = $base ? $LA->base($base) : $LA->default_base; |
---|
46 | $labase && $labase->load or die "Cannot load base"; |
---|
47 | |
---|
48 | my $g = GraphViz->new( |
---|
49 | layout => 'neato', |
---|
50 | concentrate => 1, |
---|
51 | overlap => 'compress', |
---|
52 | ratio => 'compress', |
---|
53 | ); |
---|
54 | |
---|
55 | open(my $h, '>', 'graph.png') or die 'cannot open graph'; |
---|
56 | |
---|
57 | #foreach ($labase->list_objects('user')) { |
---|
58 | # $g->add_node($_); |
---|
59 | #} |
---|
60 | |
---|
61 | my %users; |
---|
62 | |
---|
63 | foreach my $gr ($labase->list_objects('group')) { |
---|
64 | my $o = $labase->get_object('group', $gr); |
---|
65 | ($o->get_c_field('sutype') || '') =~ /^(dpmt|cell)$/ or next; |
---|
66 | $g->add_node($gr,fillcolor => 'red', style => 'filled'); |
---|
67 | foreach ($o->get_attributes('member')) { |
---|
68 | $users{$_} or do { |
---|
69 | $users{$_} = 1; |
---|
70 | $g->add_node($_); |
---|
71 | }; |
---|
72 | warn "$_ => $gr"; |
---|
73 | $g->add_edge($_ => $gr); |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | print $h $g->as_png; |
---|
78 | close($h); |
---|
Note: See
TracBrowser
for help on using the repository browser.