@@ -12,6 +12,15 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool):
1212 __handles__ = [('Service' , 'rc-update' )]
1313 __req__ = {'Service' : ['name' , 'status' ]}
1414
15+ def get_enabled_svcs (self ):
16+ """
17+ Return a list of all enabled services.
18+ """
19+ return [line .split ()[0 ]
20+ for line in self .cmd .run (['/bin/rc-status' ,
21+ '-s' ]).stdout .splitlines ()
22+ if 'started' in line ]
23+
1524 def VerifyService (self , entry , _ ):
1625 """
1726 Verify Service status for entry.
@@ -21,9 +30,12 @@ def VerifyService(self, entry, _):
2130 if entry .get ('status' ) == 'ignore' :
2231 return True
2332
33+ # get a list of all started services
34+ allsrv = self .get_enabled_svcs ()
35+
2436 # check if service is enabled
25- result = self .cmd .run (["/sbin/rc-update" , "show" , "default" ])
26- is_enabled = entry .get ("name" ) in result . stdout
37+ result = self .cmd .run (["/sbin/rc-update" , "show" , "default" ]). stdout
38+ is_enabled = entry .get ("name" ) in result
2739
2840 # check if init script exists
2941 try :
@@ -34,8 +46,7 @@ def VerifyService(self, entry, _):
3446 return False
3547
3648 # check if service is enabled
37- result = self .cmd .run (self .get_svc_command (entry , "status" ))
38- is_running = "started" in result .stdout
49+ is_running = entry .get ('name' ) in allsrv
3950
4051 if entry .get ('status' ) == 'on' and not (is_enabled and is_running ):
4152 entry .set ('current_status' , 'off' )
@@ -70,10 +81,7 @@ def InstallService(self, entry):
7081
7182 def FindExtra (self ):
7283 """Locate extra rc-update services."""
73- allsrv = [line .split ()[0 ]
74- for line in self .cmd .run (['/bin/rc-status' ,
75- '-s' ]).stdout .splitlines ()
76- if 'started' in line ]
84+ allsrv = self .get_enabled_svcs ()
7785 self .logger .debug ('Found active services:' )
7886 self .logger .debug (allsrv )
7987 specified = [srv .get ('name' ) for srv in self .getSupportedEntries ()]
0 commit comments