Handle hostnames with upper-case letters
[webmin.git] / cfengine / list_hosts.cgi
1 #!/usr/local/bin/perl
2 # list_hosts.cgi
3 # Display other webmin servers to which the configuration should be copied
4 # and run.
5
6 require './cfengine-lib.pl';
7 &foreign_require("servers", "servers-lib.pl");
8 &ui_print_header(undef, $text{'hosts_title'}, "", "hosts");
9
10 # Show existing servers
11 print &ui_subheading($text{'hosts_hosts'});
12 @servers = &list_servers();
13 @hosts = &list_cfengine_hosts();
14 foreach $h (@hosts) {
15         local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
16         next if (!$s);
17         push(@titles, &server_name($s));
18         push(@links, "edit_host.cgi?id=$h->{'id'}");
19         push(@icons, "$gconfig{'webprefix'}/servers/images/$s->{'type'}.gif");
20         $gothost{$h->{'id'}}++;
21         }
22 if (@links) {
23         &icons_table(\@links, \@titles, \@icons);
24         }
25 else {
26         print "<b>$text{'hosts_nohosts'}</b><p>\n";
27         }
28
29 # Display adding form
30 print "<form action=add.cgi>\n";
31 print "<table width=100%><tr>\n";
32 @addservers = grep { !$gothost{$_->{'id'}} } @servers;
33 if (@addservers) {
34         print "<td><input type=submit name=add value='$text{'hosts_add'}'>\n";
35         print "<select name=server>\n";
36         foreach $s (@addservers) {
37                 print "<option value=$s->{'id'}>",&server_name($s),"\n";
38                 }
39         print "</select></td>\n";
40         }
41 @groups = &servers::list_all_groups(\@servers);
42 if (@groups) {
43         print "<td align=right><input type=submit name=gadd ",
44               "value='$text{'hosts_gadd'}'>\n";
45         print "<select name=group>\n";
46         foreach $g (@groups) {
47                 print "<option>$g->{'name'}\n";
48                 }
49         print "</select></td>\n";
50         }
51 print "</tr></table></form>\n";
52
53 # Display run form
54 if (@hosts) {
55         print &ui_hr();
56         print "<form action=cluster.cgi>\n";
57         print "<table width=100%>\n";
58         print "<tr> <td><input type=submit value='$text{'hosts_run'}'></td>\n";
59         print "<td>$text{'hosts_rundesc'}</td> </tr>\n";
60         print "<tr> <td><input type=submit name=copy ",
61               "value='$text{'hosts_copy'}'></td>\n";
62         print "<td>$text{'hosts_copydesc'}</td> </tr>\n";
63         print "</table>\n";
64
65         print "<table border width=100%>\n";
66         print "<tr $tb> <td><b>$text{'hosts_opts'}</b></td> </tr>\n";
67         print "<tr $cb> <td><table width=100%>\n";
68         &show_run_form();
69         print "</table></td></tr></table>\n";
70         print "</form>\n";
71         }
72
73 &ui_print_footer("", $text{'index_return'});
74