示例#1
0
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))
示例#2
0
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))
示例#3
0
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)
示例#4
0
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:"])
示例#5
0
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.")
示例#6
0
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)