def SearchIndex(app): searchNames = {} for k in ["--index:", "--sourcetype:" ]: searchNames[k] = None if k in app.options: searchNames[k] = app.options[k] searchAttrs = _GetAttrOptions("Indexes", app.options, prefix="") with GetInventoryEngine().begin() as conn: inv = IndexInventory(conn) h = ConsoleHandler(inv, app.logger) h.display(inv.search(indexName=searchNames["--index:"], sourcetypeName=searchNames["--sourcetype:"], **searchAttrs))
def SearchApp(app): searchNames = {} for k in ["--app:"]: searchNames[k] = None if k in app.options: searchNames[k] = app.options[k] searchAttrs = _GetAttrOptions("Apps", app.options, prefix="") with GetInventoryEngine().begin() as conn: inv = AppInventory(conn) h = ConsoleHandler(inv, app.logger) h.display(inv.search(appName=searchNames["--app:"], **searchAttrs))
def DeleteApp(app): searchNames = {} for k in ["--app:"]: searchNames[k] = None if k in app.options: searchNames[k] = app.options[k] with GetInventoryEngine().begin() as conn: inv = AppInventory(conn) h = ConsoleHandler(inv, app.logger) if not inv.search(appName=searchNames["--app:"]): raise AppNotFoundException("App \"" + searchNames["--app:"] + "\" does not exist.") else: h.delete(None, searchNames["--app:"], None)
def DeleteIndex(app): searchNames = {} for k in ["--index:", "--sourcetype:" ]: searchNames[k] = None if k in app.options: searchNames[k] = app.options[k] with GetInventoryEngine().begin() as conn: inv = IndexInventory(conn) h = ConsoleHandler(inv, app.logger) if not inv.search(index=searchNames["--index:"], sourceType=searchNames["--sourcetype:"]): raise IndexNotFoundException("Index \"" + searchNames["--index:"] + "\", Sourctype \"" + searchNames["--sourcetype:"] + "\" does not exist.") else: h.delete(None, searchNames["--index:"], searchNames["--sourcetype:"])
def CreateIndex(app): searchNames = {} for k in ["--index:", "--sourcetype:" ]: searchNames[k] = None if k in app.options: searchNames[k] = app.options[k] searchAttrs = _GetAttrOptions("Indexes", app.options, prefix="") with GetInventoryEngine().begin() as conn: inv = IndexInventory(conn) h = ConsoleHandler(inv, app.logger) if not inv.search(index=searchNames["--index:"], sourceType=searchNames["--sourcetype:"]): h.update(None, searchNames["--index:"], searchNames["--sourcetype:"], **searchAttrs) else: raise IndexAlreadyExistsException("Index \"" + searchNames["--index:"] + "\", Sourctype \"" + searchNames["--sourcetype:"] + "\" already exists.")
def UpdateApp(app): searchNames = {} for k in ["--app:"]: searchNames[k] = None if k in app.options: searchNames[k] = app.options[k] searchAttrs = _GetAttrOptions("Apps", app.options, prefix="") with GetInventoryEngine().begin() as conn: inv = AppInventory(conn) h = ConsoleHandler(inv, app.logger) if not inv.search(appName=searchNames["--app:"]): raise AppNotFoundException("App \"" + searchNames["--app:"] + "\" does not exist.") else: h.update(None, searchNames["--app:"], None, **searchAttrs)