[yast-commit] r58389 - /trunk/yast2/library/runlevel/src/YaPI/SERVICES.pm
Author: jsuchome Date: Wed Aug 19 16:00:44 2009 New Revision: 58389 URL: http://svn.opensuse.org/viewcvs/yast?rev=58389&view=rev Log: simplified version, only dealing with Service.ycp Modified: trunk/yast2/library/runlevel/src/YaPI/SERVICES.pm Modified: trunk/yast2/library/runlevel/src/YaPI/SERVICES.pm URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/runlevel/src/YaPI/SERVICES.pm?rev=58389&r1=58388&r2=58389&view=diff ============================================================================== --- trunk/yast2/library/runlevel/src/YaPI/SERVICES.pm (original) +++ trunk/yast2/library/runlevel/src/YaPI/SERVICES.pm Wed Aug 19 16:00:44 2009 @@ -3,7 +3,6 @@ use strict; use YaST::YCP qw(:LOGGING); use YaPI; -use YAML; use Data::Dumper; # ------------------- imported modules @@ -15,50 +14,6 @@ our @CAPABILITIES = ('SLES11'); our %TYPEINFO; -# path to file with list of services -my $service_list_file = "/etc/YaST2/custom_services.yml"; - -# read the services from config file and return list of maps -sub get_services { - - if (! -r $service_list_file) { - y2error ("file $service_list_file does not exists or is not readable"); - returna {}; - } - - my $services = YAML::LoadFile ($service_list_file); - - if (!defined $services || ref ($services) ne "HASH") { - y2error ("service list cannot be read"); - return {}; - } - return $services; -} - -# call the status script, argument is service hash -sub get_service_status { - - my $service = shift; - my $status = -1; - my $name = $service->{"name"}; - - if (defined $service->{"status"}) { - # call the custom status script - my $out = SCR->Execute (".target.bash_output", $service->{"status"}); - if (!defined ($out->{"exit"})) { - y2error ("error calling status script: ", Dumper ($out)); - } - else { - $status = $out->{"exit"}; - } - } - else { - # call the init script - $status = Service->Status ($name); - } - return $status; -} - BEGIN{$TYPEINFO{Read} = ["function", ["list", [ "map", "string", "any"]]]; @@ -68,13 +23,14 @@ my $self = shift; my @ret = (); - my $services = get_services (); - while (my ($name, $service) = each %$services) { + my $current_runlevel = 3; #FIXME which runlevel? - y2milestone ("service: ", Dumper ($service)); + my $services = Service->EnabledServices ($current_runlevel); + foreach my $name (@$services) { my $s = { - "name" => $name, - "status" => get_service_status ($service) + "name" => $name +#read the status on demand, this is costly +# "status" => Service->Status ($name) }; push @ret, $s; } @@ -90,19 +46,10 @@ my $self = shift; my $name = shift; - my $found = 0; - my $service = { "name" => $name, - "status" => -1 # not found + "status" => Service->Status ($name) }; - - my $services = get_services (); - if (! defined ($services->{$name}) || ref ($services->{$name} ne "HASH")) { - y2error ("service $name not found in the list"); - return $service; - } - $service->{"status"} = get_service_status ($services->{$name}); return $service; } @@ -115,20 +62,6 @@ my $self = shift; my $name = shift; my $action = shift; - my $ret = {}; - - my $services = get_services (); - if (! defined ($services->{$name}) || ref ($services->{$name} ne "HASH")) { - y2error ("service $name not found in the list"); - return $ret; - } - my $service = $services->{$name}; - if (defined $service->{$action}) { - $ret = SCR->Execute (".target.bash_output", $service->{$action}); - } - else { - $ret = Service->RunInitScriptOutput ($name, $action); - } - return $ret; + return Service->RunInitScriptOutput ($name, $action); } 1; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
jsuchome@svn.opensuse.org