3 # Edit a node in the haresources file
5 require './heartbeat-lib.pl';
7 &foreign_require("init", "init-lib.pl");
10 &ui_print_header(undef, $text{'node_create'}, "");
13 &ui_print_header(undef, $text{'node_edit'}, "");
14 @res = &list_resources();
15 $res = $res[$in{'idx'}];
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";
25 print "<tr> <td><b>$text{'node_node'}</b></td>\n";
26 printf "<td><input name=node size=40 value='%s'></td> </tr>\n",
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";
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";
50 print "</table></td> </tr>\n";
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 !~ /^\./);
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";
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> \n",
67 $a[0] ? "" : "selected";
70 printf "<option %s>%s\n",
71 $a[0] eq $s ? "selected" : "", $s;
72 $found++ if ($a[0] eq $s);
74 if (!$found && $a[0]) {
75 print "<option selected>$a[0]\n";
77 print "</select></td>\n";
78 printf "<td><input name=args_$i size=40 value='%s'></td> </tr>\n",
79 join(" ", @a[1..$#a]);
82 print "</table></td> </tr>\n";
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";
92 &ui_print_footer("edit_res.cgi", $text{'res_return'});