class Splunkd(object): def __init__(self, host_path=None, sessionKey=None): self.runner = PaladinQueryRunner(host_path, sessionKey) self.host_path = host_path self.sessionKey = sessionKey info = ServerInfo.build (self.runner) # there is only one entry anyway for f in info.all(): self.platform = f.platform.value self.version = f.version.value self.server_name = f.server_name.value self.m_localapps = LocalApps.build (self) self.m_templates = AppTemplates.build (self.runner) self.m_installer = AppInstall.build (self.runner) def get_templates(self): return self.m_templates.all() def create_app_from_template(self, appname, template='barebones', **kwargs): return self.m_apps.create(appname, template, **kwargs) def local_apps(self): return self.m_localapps.all() ''' Allows for restarting Splunk. POST server/control/restart Restarts the Splunk server. no return if ok. ''' def restart(self): self.runner.set_entity('services/server/control/restart') def remove_app(self, app): m_app = self.m_localapps.get(app) if m_app: m_app.delete() # after deletion, the splunkd should restart to respond the change. # here it is left to the application to do/control that. def install_app(self, fileName, update=False): return self.m_installer.create(name=fileName, update=update) def archive_app(self, app): m_app = self.m_localapps.get(app) return m_app.archive() if m_app else None ''' The restoration of an app is based on the app file or a link from package_app that can be downloaded. it actually calls install_app with update=True flag. ''' def restore_app(self, archive): return self.install_app(archive.path.value, True)
def __init__(self, host_path=None, sessionKey=None): self.runner = PaladinQueryRunner(host_path, sessionKey) self.host_path = host_path self.sessionKey = sessionKey info = ServerInfo.build (self.runner) # there is only one entry anyway for f in info.all(): self.platform = f.platform.value self.version = f.version.value self.server_name = f.server_name.value self.m_localapps = LocalApps.build (self) self.m_templates = AppTemplates.build (self.runner) self.m_installer = AppInstall.build (self.runner)
def __init__(self, host_path, username, password, login_url): super(Splunkbase, self).__init__() self.host_path = host_path self.login_url = login_url self.sessionKey = self.login(username, password) self.runner = PaladinQueryRunner(self.host_path, self.sessionKey)