3 # Show details of a managed host, and all the packages on it
5 require './cluster-software-lib.pl';
6 &foreign_require("servers", "servers-lib.pl");
8 &ui_print_header(undef, $text{'host_title'}, "", "edit_host");
10 @hosts = &list_software_hosts();
11 ($host) = grep { $_->{'id'} eq $in{'id'} } @hosts;
12 $server = &foreign_call("servers", "get_server", $in{'id'});
13 @packages = @{$host->{'packages'}};
16 print "<table border width=100%>\n";
17 print "<tr $tb> <td><b>$text{'host_header'}</b></td> </tr>\n";
18 print "<tr $cb> <td><table width=100%>\n";
20 print "<tr> <td><b>$text{'host_name'}</b></td>\n";
21 if ($server->{'id'}) {
22 $h = $server->{'realhost'} || $server->{'host'};
23 printf "<td><a href='/servers/link.cgi/%s/'>%s</a></td>\n",
24 $server->{'id'}, $server->{'desc'} ? "$server->{'desc'} ($h:$server->{'port'})" : "$h:$server->{'port'}";
27 print "<td><a href=/>$text{'this_server'}</a></td>\n";
30 if ($server->{'id'}) {
31 print "<td><b>$text{'host_type'}</b></td> <td>\n";
32 foreach $t (@servers::server_types) {
33 print $t->[1] if ($t->[0] eq $server->{'type'});
39 print "<tr> <td><b>$text{'host_count'}</b></td>\n";
40 printf "<td>%d</td>\n", scalar(@packages);
42 print "<td><b>$text{'host_os'}</b></td>\n";
43 print "<td>$host->{'real_os_type'} $host->{'real_os_version'}</td> </tr>\n";
45 print "<tr> <td><b>$text{'host_system'}</b></td>\n";
46 $system = $host->{'package_system'} || $software::config{'package_system'};
47 print "<td>",uc($system),"</td>\n";
51 print "</table></td></tr></table>\n";
53 # Show delete and refresh buttons
54 print "<table width=100%><tr>\n";
55 print "<form action=delete_host.cgi>\n";
56 print "<input type=hidden name=id value=$in{'id'}>\n";
57 print "<td><input type=submit value='$text{'host_delete'}'></td>\n";
60 print "<form action=refresh.cgi>\n";
61 print "<input type=hidden name=id value=$in{'id'}>\n";
62 print "<td align=right><input type=submit value='$text{'host_refresh'}'></td>\n";
64 print "</tr></table>\n";
66 # Show tree of packages
68 foreach $c (sort { $a cmp $b } &unique(map { $_->{'class'} } @packages)) {
71 $p = join('/', @w[0..$#w-1]);
72 if (!defined($heir{$p})) {
73 $pp = join('/', @w[0..$#w-2]);
80 # get the current open list
81 %heiropen = map { $_, 1 } &get_heiropen($in{'id'});
84 # traverse the heirarchy
87 print &ui_subheading($text{'host_installed'});
88 print "<table width=100%>\n";
92 print "<a href='closeall.cgi?id=$in{'id'}'>$text{'host_close'}</a>\n";
93 print "<a href='openall.cgi?id=$in{'id'}'>$text{'host_open'}</a><p>\n";
96 &ui_print_footer("", $text{'index_return'});
101 print "<tr> <td>", $spacer x $_[1];
103 print "<a name=\"$_[0]\"></a>\n";
104 $act = $heiropen{$_[0]} ? "close" : "open";
105 print "<a href=\"$act.cgi?id=$in{'id'}&what=",&urlize($_[0]),"\">";
106 $_[0] =~ /([^\/]+)$/;
107 print "<img border=0 src=images/$act.gif></a> $1</td>\n",
109 else { print "<img src=images/close.gif> <i>$text{'host_all'}</i></td>\n"; }
110 print "<td><br></td> </tr>\n";
111 if ($heiropen{$_[0]}) {
112 # print sub-folders followed by packages
113 foreach $i (@packages) {
114 if ($i->{'class'} eq $_[0]) {
115 print "<tr> <td>", $spacer x ($_[1]+1);
116 print "<img border=0 src=images/pack.gif></a> \n";
117 print "<a href=\"edit_pack.cgi?package=",
118 &urlize($i->{'name'}),"\">$i->{'name'}</a></td>\n";
119 print "<td>$i->{'desc'}</td>\n";
123 foreach $s (&unique(split(/\0+/, $heir{$_[0]}))) {
124 &traverse($s, $_[1]+1);