2 # dependency/dependent tree viewer
3 # Display a form for displaying/editing SMF service states in dependency
6 require './smf-lib.pl';
10 if (defined($in{'fmri'})) {
13 $fmri =~ /\'([^\']*)\'/;
16 &error("No fmri supplied to dep viewer!");
19 # deal with application of state changes first. this way
20 # dep lists will show new states...
21 if (defined($in{'change_state'})) {
22 $cmd = "$in{'change_state'}";
23 # get update fmri list
24 @update_fmris = split(/\0/, $in{'applyto'});
25 &svc_state_cmd("$cmd", \@update_fmris);
28 @depy_expand_list = ();
29 # which dependency fmris do we expand?
30 if (defined($in{'dependency_expandlist'})) {
31 # get required expansions. each is fmri
32 @depy_expand_list = split(/\0/, $in{'dependency_expandlist'});
34 # Expand list - list of fmris to expand. By default, expand top fmri.
35 push(@depy_expand_list, $fmri);
37 @dept_expand_list = ();
38 # which dependent fmris do we expand?
39 if (defined($in{'dependent_expandlist'})) {
40 # get required expansions. each is fmri
41 @dept_expand_list = split(/\0/, $in{'dependent_expandlist'});
43 # Expand list - list of fmris to expand. By default, expand top fmri.
44 push(@dept_expand_list, $fmri);
46 # get new expansion/contractions submitted...
48 foreach $inkey (@inkeys) {
49 if ($inkey =~ /dependency_expand_(.*)$/) {
51 push(@depy_expand_list, $expand_fmri);
53 if ($inkey =~ /dependency_contract_(.*)$/) {
55 foreach $e (@depy_expand_list) {
56 $old = shift(@depy_expand_list);
57 if ($old eq $contract_fmri) {
60 push(@depy_expand_list, $old);
63 if ($inkey =~ /dependent_expand_(.*)$/) {
65 push(@dept_expand_list, $expand_fmri);
67 if ($inkey =~ /dependent_contract_(.*)$/) {
69 foreach $e (@dept_expand_list) {
70 $old = shift(@dept_expand_list);
71 if ($old eq $contract_fmri) {
74 push(@dept_expand_list, $old);
79 # Gather service description, and state info
80 $description = &run_smf_cmds("/usr/bin/svcs -H -oDESC $fmri", 0);
84 $depy_treeref = \%depy_tree;
85 $dept_treeref= \%dept_tree;
86 $instance_state = &svc_get_state_cmd($fmri);
87 &build_dep_tree("dependent", $dept_treeref, $fmri, 0, \@dept_expand_list,
89 &build_dep_tree("dependency", $depy_treeref, $fmri, 0, \@depy_expand_list,
92 &ui_print_header(undef, $text{'dep_viewer_title'}, "", undef);
94 print "<form method=\"POST\" action=\"dep_viewer.cgi?fmri='$fmri'\">\n";
96 print "<h2>$description</h2>\n";
98 &text_and_whats_this("dep_viewer_detail");
101 print "<h2>$text{'dep_viewer_depy_info'}</h2>\n";
102 print "<p>$text{'dep_viewer_apply'}: \n";
103 &print_state_buttons();
105 &print_dep_tree("dependency", $depy_treeref, $fmri, 0, \@depy_expand_list);
107 print "<h2>$text{'dep_viewer_dept_info'}</h2>\n";
108 print "<p>$text{'dep_viewer_apply'}: \n";
109 &print_state_buttons();
111 &print_dep_tree("dependent", $dept_treeref, $fmri, 0, \@dept_expand_list);
117 &ui_print_footer("instance_viewer.cgi?fmri='$fmri'",
118 $text{'dep_viewer_back'});