#!/usr/local/bin/perl # property_editor.cgi # Display a list of properties for property group for fmri require './smf-lib.pl'; &ReadParse(); &ui_print_header(undef, $text{'property_editor_title'}, ""); # get instance fmri if (defined($in{'fmri'})) { $fmri = $in{'fmri'}; # remove quotes... $fmri =~ /\'([^\']*)\'/; $fmri = $1; if ($fmri =~ /(svc:\/[^:]*):(.*)/) { $svc = $1; $inst = $2; } else { &error("Invalid fmri: instance must be specified!"); } } else { &error("No fmri supplied to property editor!"); } if (defined($in{'sinst'})) { $sinst = "$in{'sinst'}"; $entity = ($sinst eq "service") ? "$svc" : "$svc:$inst"; } else { &error("Service/Instance level not specified for property editor!"); } if (defined($in{'pgroup'})) { $pgroup = $in{'pgroup'}; } else { &error("No property group supplied to property editor!"); } # deal with add/deletion/update of properties first. this way # prop list will show changes... if ((defined($in{'add'})) && (defined($in{'addname'})) && (defined($in{'addtype'})) && (defined($in{'addvalue'}))) { $addname = "$in{'addname'}"; $addtype = "$in{'addtype'}"; $addvalue = "$in{'addvalue'}"; if (($addname =~ /.+/) && ($addtype =~ /.+/) && ($addvalue =~ /.+/)) { &svc_setprop("$svc", "$sinst", "$pgroup", "$addname", "$addtype", "$addvalue"); } } if (defined($in{'remove'})) { # get remove prop list @remove_props = split(/\0/, $in{'applyto'}); foreach $rp (@remove_props) { &svc_delprop("$svc", "$sinst", "$pgroup", "$rp"); } } @prop_listing = &svc_listprop("$svc", "$sinst", $pgroup); # need prop listing to match against values for update. if we change # anything, we`ll regenerate the listing... $regenerate_listing = 0; if (defined($in{'update'})) { # update each prop in listing with new value foreach $prop (@prop_listing) { $prop_name = $prop->{'prop_name'}; $prop_type = $prop->{'prop_type'}; if (defined($in{"$prop_name/$prop_type"})) { $prop_value = $in{"$prop_name/$prop_type"}; &svc_setprop("$svc", "$sinst", "$pgroup", "$prop_name", "$prop_type", "$prop_value"); $regenerate_listing = 1; } } } if ($regenerate_listing == 1) { @prop_listing = &svc_listprop("$svc", "$sinst", $pgroup); } print "