Handle hostnames with upper-case letters
[webmin.git] / heartbeat / edit_node.cgi
1 #!/usr/local/bin/perl
2 # edit_node.cgi
3 # Edit a node in the haresources file
4
5 require './heartbeat-lib.pl';
6 &ReadParse();
7 &foreign_require("init", "init-lib.pl");
8
9 if ($in{'new'}) {
10         &ui_print_header(undef, $text{'node_create'}, "");
11         }
12 else {
13         &ui_print_header(undef, $text{'node_edit'}, "");
14         @res = &list_resources();
15         $res = $res[$in{'idx'}];
16         }
17
18 print "<form action=save_node.cgi>\n";
19 print "<input type=hidden name=new value='$in{'new'}'>\n";
20 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
21 print "<table border width=100%>\n";
22 print "<tr $tb> <td><b>$text{'node_header'}</b></td> </tr>\n";
23 print "<tr $cb> <td><table width=100%>\n";
24
25 print "<tr> <td><b>$text{'node_node'}</b></td>\n";
26 printf "<td><input name=node size=40 value='%s'></td> </tr>\n",
27         $res->{'node'};
28
29 print "<tr> <td valign=top><b>$text{'node_ips'}</b></td>\n";
30 print "<td><table border width=100%>\n";
31 print "<tr $tb> <td><b>$text{'node_ip'}</b></td> ",
32       "<td><b>$text{'node_cidr'}</b></td> ",
33       "<td><b>$text{'node_broad'}</b></td> </tr>\n";
34 $i = 0;
35 foreach $a (@{$res->{'ips'}}, "") {
36         local @a = split(/\//, $a);
37         print "<tr $cb> <td><input name=ip_$i size=15 value='$a[0]'></td>\n";
38         printf "<td><input type=radio name=cidr_def_$i value=1 %s> %s\n",
39                 $a[1] ? "" : "checked", $text{'default'};
40         printf "<input type=radio name=cidr_def_$i value=0 %s>\n",
41                 $a[1] ? "checked" : "";
42         print "<input name=cidr_$i size=4 value='$a[1]'></td>\n";
43         printf "<td><input type=radio name=broad_def_$i value=1 %s> %s\n",
44                 $a[2] ? "" : "checked", $text{'default'};
45         printf "<input type=radio name=broad_def_$i value=0 %s>\n",
46                 $a[2] ? "checked" : "";
47         print "<input name=broad_$i size=15 value='$a[2]'></td> </tr>\n";
48         $i++;
49         }
50 print "</table></td> </tr>\n";
51
52 @acts = map { /^(\S+)/; $1 } &foreign_call("init", "list_actions");
53 opendir(DIR, $resource_d);
54 while($f = readdir(DIR)) {
55         push(@acts, $f) if ($f !~ /^\./);
56         }
57 closedir(DIR);
58 print "<tr> <td valign=top><b>$text{'node_servs'}</b></td>\n";
59 print "<td><table border width=100%>\n";
60 print "<tr $tb> <td><b>$text{'node_serv'}</b></td> ",
61       "<td><b>$text{'node_args'}</b></td> </tr>\n";
62 $i = 0;
63 foreach $a (@{$res->{'servs'}}, "") {
64         local @a = split(/::/, $a);
65         print "<tr $cb> <td><select name=serv_$i>\n";
66         printf "<option value='' %s>&nbsp;\n",
67                 $a[0] ? "" : "selected";
68         local $found;
69         foreach $s (@acts) {
70                 printf "<option %s>%s\n",
71                         $a[0] eq $s ? "selected" : "", $s;
72                 $found++ if ($a[0] eq $s);
73                 }
74         if (!$found && $a[0]) {
75                 print "<option selected>$a[0]\n";
76                 }
77         print "</select></td>\n";
78         printf "<td><input name=args_$i size=40 value='%s'></td> </tr>\n",
79                 join(" ", @a[1..$#a]);
80         $i++;
81         }
82 print "</table></td> </tr>\n";
83
84 print "</table></td></tr></table>\n";
85 print "<table width=100%><tr>\n";
86 print "<td><input type=submit value='$text{'save'}'></td>\n";
87 print "<td align=right><input type=submit name=delete ",
88       "value='$text{'delete'}'></td> </tr>\n";
89 print "</table>\n";
90
91 print "</form>\n";
92 &ui_print_footer("edit_res.cgi", $text{'res_return'});
93