def testParsingSystemdOutputFromCentOS7(): output = [ 'UNIT FILE STATE ', 'proc-sys-fs-binfmt_misc.automount static ', 'tmp.mount disabled', 'brandbot.path disabled', 'systemd-ask-password-console.path static ', 'session-1.scope static ', 'session-c2.scope static ', 'dhcpd.service disabled', 'dhcpd6.service disabled', '[email protected] enabled ', 'initrd-cleanup.service static ', 'smb.service enabled ', '[email protected] static ', '-.slice static ', 'machine.slice static ', 'syslog.socket static ', 'systemd-udevd-kernel.socket static ', 'basic.target static ', 'systemd-tmpfiles-clean.timer static ', '', '219 unit files listed.' ] expectedServices = set([ "dhcpd", "dhcpd6", "getty@", "initrd-cleanup", "smb", "systemd-backlight@" ]) assert expectedServices == Posix.getServiceNames( _serviceStatusOutput=output)
def testGetServiceNameParsingFromSystemd(): output = [ 'iprdump.service - LSB: Start the ipr dump daemon', ' Loaded: loaded (/etc/rc.d/init.d/iprdump)', ' Active: active (running) since Di 2014-10-07 15:53:35 CEST; 4min 14s ago', ' Process: 572 ExecStart=/etc/rc.d/init.d/iprdump start (code=exited, status=0/SUCCESS)', ' Main PID: 581 (iprdump)', ' CGroup: /system.slice/iprdump.service', ' └─581 /sbin/iprdump --daemon', '', 'Okt 07 15:53:35 stb-40-srv-106.test.invalid iprdump[572]: Starting iprdump: [ OK ]', 'Okt 07 15:53:35 stb-40-srv-106.test.invalid systemd[1]: Started LSB: Start the ipr dump daemon.', 'iprinit.service - LSB: Start the ipr init daemon', ' Loaded: loaded (/etc/rc.d/init.d/iprinit)', ' Active: active (running) since Di 2014-10-07 15:53:35 CEST; 4min 15s ago', ' Process: 537 ExecStart=/etc/rc.d/init.d/iprinit start (code=exited, status=0/SUCCESS)', ' Main PID: 566 (iprinit)', ' CGroup: /system.slice/iprinit.service', ' └─566 /sbin/iprinit --daemon', '', 'Okt 07 15:53:35 stb-40-srv-106.test.invalid iprinit[537]: Starting iprinit: [ OK ]', 'Okt 07 15:53:35 stb-40-srv-106.test.invalid systemd[1]: Started LSB: Start the ipr init daemon.', 'iprupdate.service - LSB: Start the iprupdate utility', ' Loaded: loaded (/etc/rc.d/init.d/iprupdate)', ' Active: active (running) since Di 2014-10-07 15:53:35 CEST; 4min 15s ago', ' Process: 525 ExecStart=/etc/rc.d/init.d/iprupdate start (code=exited, status=0/SUCCESS)', ' Main PID: 567 (iprupdate)', ' CGroup: /system.slice/iprupdate.service', ' └─567 /sbin/iprupdate --daemon', '', 'Okt 07 15:53:34 stb-40-srv-106.test.invalid systemd[1]: Starting LSB: Start the iprupdate utility...', 'Okt 07 15:53:35 stb-40-srv-106.test.invalid iprupdate[525]: Starting iprupdate: [ OK ]', 'Okt 07 15:53:35 stb-40-srv-106.test.invalid systemd[1]: Started LSB: Start the iprupdate utility.', 'Netconsole-Modul nicht geladen', 'Konfigurierte Geräte:', 'lo ens18', 'Derzeit aktive Geräte:', 'lo ens18', ] assert set(["iprdump", "iprinit", "iprupdate" ]) == Posix.getServiceNames(_serviceStatusOutput=output)