def manageService(self, service, action): """ Manage services running on this machine usage: service <action> <serviceName> """ client = ComponentMonitoringClient() result = client.getInstallations({'UninstallationTime': None}, { 'System': 'External', 'Module': service, 'Type': 'External' }, {'HostName': self.host}, False) if not result['OK']: self._errMsg(result['Message']) return elif len(result['Value']) < 1: self._errMsg('%s is not installed' % (service)) return client = SystemAdministratorClient(self.host, self.port) if action == 'start': result = client.startService(service) elif action == 'stop': result = client.stopService(service) elif action == 'restart': result = client.restartService(service) elif action == 'status': result = client.statusService(service) if not result['OK']: self._errMsg(result['Message']) return gLogger.notice(result['Value'])