<s> """<STR_LIT>""" <EOL> import glob <EOL> import os <EOL> import Bcfg2 . Client . Tools <EOL> class SMF ( Bcfg2 . Client . Tools . SvcTool ) : <EOL> """<STR_LIT>""" <EOL> __handles__ = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> __execs__ = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> __req__ = { '<STR_LIT>' : [ '<STR_LIT:name>' , '<STR_LIT:status>' , '<STR_LIT>' ] } <EOL> def get_svc_command ( self , service , action ) : <EOL> if service . get ( '<STR_LIT:type>' ) == '<STR_LIT>' : <EOL> return Bcfg2 . Client . Tools . SvcTool . get_svc_command ( self , <EOL> service , action ) <EOL> if action == '<STR_LIT>' : <EOL> return "<STR_LIT>" % ( service . get ( '<STR_LIT>' ) ) <EOL> elif action == '<STR_LIT>' : <EOL> return "<STR_LIT>" % ( service . get ( '<STR_LIT>' ) ) <EOL> elif action == '<STR_LIT:start>' : <EOL> return "<STR_LIT>" % ( service . get ( '<STR_LIT>' ) ) <EOL> def GetFMRI ( self , entry ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' not in entry . attrib : <EOL> rv = self . cmd . run ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> entry . get ( '<STR_LIT:name>' ) ] ) <EOL> if rv . success : <EOL> entry . set ( '<STR_LIT>' , rv . stdout . splitlines ( ) [ <NUM_LIT:0> ] ) <EOL> else : <EOL> self . logger . info ( '<STR_LIT>' % <EOL> entry . get ( '<STR_LIT:name>' ) ) <EOL> return rv . success <EOL> return True <EOL> def VerifyService ( self , entry , _ ) : <EOL> """<STR_LIT>""" <EOL> if not self . GetFMRI ( entry ) : <EOL> self . logger . error ( "<STR_LIT>" % <EOL> entry . get ( '<STR_LIT:name>' ) ) <EOL> return False <EOL> if entry . get ( '<STR_LIT>' ) . startswith ( '<STR_LIT>' ) : <EOL> filename = entry . get ( '<STR_LIT>' ) . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> gname = "<STR_LIT>" % filename <EOL> files = glob . glob ( gname . replace ( '<STR_LIT:_>' , '<STR_LIT:.>' ) ) <EOL> if files : <EOL> self . logger . debug ( "<STR_LIT>" % <EOL> ( entry . get ( "<STR_LIT>" ) , "<STR_LIT::>" . join ( files ) ) ) <EOL> return entry . get ( '<STR_LIT:status>' ) == '<STR_LIT>' <EOL> else : <EOL> self . logger . debug ( "<STR_LIT>" % <EOL> entry . get ( "<STR_LIT>" ) ) <EOL> return entry . get ( '<STR_LIT:status>' ) == '<STR_LIT>' <EOL> try : <EOL> srvdata = self . cmd . run ( "<STR_LIT>" % <EOL> entry . get ( '<STR_LIT>' ) ) . stdout . splitlines ( ) [ <NUM_LIT:0> ] . split ( ) <EOL> except IndexError : <EOL> return False <EOL> entry . set ( '<STR_LIT>' , srvdata [ <NUM_LIT:0> ] ) <EOL> if entry . get ( '<STR_LIT:status>' ) == '<STR_LIT>' : <EOL> return srvdata [ <NUM_LIT:0> ] == '<STR_LIT>' <EOL> else : <EOL> return srvdata [ <NUM_LIT:0> ] in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def InstallService ( self , entry ) : <EOL> """<STR_LIT>""" <EOL> self . logger . info ( "<STR_LIT>" % ( entry . get ( '<STR_LIT:name>' ) ) ) <EOL> if entry . get ( '<STR_LIT:status>' ) == '<STR_LIT>' : <EOL> if entry . get ( "<STR_LIT>" ) . startswith ( '<STR_LIT>' ) : <EOL> try : <EOL> loc = entry . get ( "<STR_LIT>" ) [ <NUM_LIT:4> : ] . replace ( '<STR_LIT:_>' , '<STR_LIT:.>' ) <EOL> self . logger . debug ( "<STR_LIT>" % <EOL> ( loc , loc . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) ) <EOL> os . rename ( loc , loc . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return True <EOL> except OSError : <EOL> self . logger . error ( "<STR_LIT>" % loc ) <EOL> return False <EOL> else : <EOL> return self . cmd . run ( "<STR_LIT>" % <EOL> entry . get ( '<STR_LIT>' ) ) . success <EOL> elif entry . get ( '<STR_LIT>' ) . startswith ( '<STR_LIT>' ) : <EOL> loc = entry . get ( "<STR_LIT>" ) [ <NUM_LIT:4> : ] . replace ( '<STR_LIT:_>' , '<STR_LIT:.>' ) <EOL> try : <EOL> os . stat ( loc . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . logger . debug ( "<STR_LIT>" % <EOL> ( loc . replace ( '<STR_LIT>' , '<STR_LIT>' ) , loc ) ) <EOL> os . rename ( loc . replace ( '<STR_LIT>' , '<STR_LIT>' ) , loc ) <EOL> return True <EOL> except OSError : <EOL> self . logger . debug ( "<STR_LIT>" % <EOL> ( loc . replace ( '<STR_LIT>' , '<STR_LIT>' ) , loc ) ) <EOL> return False <EOL> else : <EOL> srvdata = self . cmd . run ( "<STR_LIT>" % <EOL> entry . get ( '<STR_LIT>' ) ) [ <NUM_LIT:1> ] . splitlines ( ) [ <NUM_LIT:0> ] . split ( ) <EOL> if srvdata [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> cmdarg = '<STR_LIT>' <EOL> else : <EOL> cmdarg = '<STR_LIT>' <EOL> return self . cmd . run ( "<STR_LIT>" % <EOL> ( cmdarg , entry . get ( '<STR_LIT>' ) ) ) . success <EOL> def Remove ( self , svcs ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def FindExtra ( self ) : <EOL> """<STR_LIT>""" <EOL> allsrv = [ ] <EOL> for srvc in self . cmd . run ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] ) . stdout . splitlines ( ) : <EOL> name , version = srvc . split ( ) <EOL> if version != '<STR_LIT>' : <EOL> allsrv . append ( name ) <EOL> for svc in self . getSupportedEntries ( ) : <EOL> if svc . get ( "<STR_LIT>" ) in allsrv : <EOL> allsrv . remove ( svc . get ( '<STR_LIT>' ) ) <EOL> return [ Bcfg2 . Client . XML . Element ( "<STR_LIT>" , type = '<STR_LIT>' , name = name ) <EOL> for name in allsrv ] </s>
