List-Like object. ESM device tree interface.
__contains__
method returns: (bool
) True/None
the name or IP matches the provided search term.>>> from msiempy.device import DevTree >>> devtree = DevTree() >>> print("All Datasources") >>> print(devtree.get_text(fields=["parent_name", "name", "ds_id"]))
The script all_dev.py can help you list all your datasources.
>>> from msiempy import DevTree >>> devtree = DevTree() >>> devtree.add({ ... "name": "Test DS", ... "parent_id": "144116287587483648", ... "ds_ip": "10.2.2.2", ... "hostname": "testds.domain.ca", ... "type_id": "65" }) {'value': 1385420} # Wait a bit for the request >>> devtree.refresh() # Refresh the DevTree
DataSource
GRP_GETVIRTUALGROUPIPSLISTDATA
to assemble DevTree
object.Method | __init__ | Create a new list |
Instance Variable | data | Undocumented |
Method | __contains__ | Returns: (bool ) True/None the name or IP matches the provided search term. |
Method | search | Search a datasource in the DevTree. |
Method | search_ds_group | Search datasources in the DevTree. |
Method | refresh | Rebuilds the devtree |
Method | recs | Returns: list of Receiver dict |
Method | build_devtree | Coordinates assembly of the devtree object |
Method | duplicate_datasource | Check for duplicate dataname name or IP address. |
Method | add | Adds a datasource. |
Method | add_client | Add a datasource client |
Method | _get_devtree | Returns: ESM device tree; raw, but ordered, string. |
Method | _format_devtree | Parse key fields from raw device strings into datasource dicts. |
Method | _insert_rec_info | Adds parent_ids to datasources in the tree based upon the ordered list provided by the ESM. All the datasources below a Receiver row have it's id set as their parent ID. |
Method | _get_client_containers | Filters DevTree for datasources that have client datasources. |
Method | _merge_clients | Undocumented |
Method | _get_clients | Get list of raw client strings. |
Method | _format_clients | Parse key fields from _get_clients() output. Returns: list of dicts |
Method | _get_zonetree | Retrieve zone data. |
Method | _insert_zone_names | Arguments: - zonetree (str): Built by self._get_zonetree |
Method | _get_zone_map | Builds a table of zone names to zone ids. Returns: dict (str: str) zone name : zone ids |
Method | _insert_zone_ids | Undocumented |
Method | _get_last_times | Returns: string with datasource names and last event times. |
Method | _format_times | Formats the output of _get_last_times |
Method | _insert_ds_last_times | Parse event times str and insert it into the _devtree |
Method | _filter_bogus_ds | Filters objects that inaccurately show up as datasources sometimes. |
Method | _cast_datasources | Undocumented |
Method | _validate_ds_params | Validate parameters for new datasource. |
Method | _validate_ds_tz_id | Validates datasource time zone id. |
Static Method | _normalize_bool_vals | Recursively changes strings 'T', 'F' to bool |
Inherited from NitroList:
Method | __str__ | str(obj) -> return text string. |
Method | keys | List items keys. Every items should have the same set of keys. |
Method | get_text | Return a csv or table string representation of the list |
Method | text | Defaut table string, a shorcut to get_text() with no arguments. |
Method | json | JSON list of dicts representing the list. |
Method | perform | Wrapper to execute a function on the list of elements |
Static Method | _confirm_func | Ask user inut to confirm the calling of func on elements . |
Inherited from NitroObject (via NitroList):
Class | NitroJSONEncoder | Custom JSON encoder that will use the approprtiate propertie depending of the type of NitroObject. TODO support json json dumping of QueryFilers, may be by making them inherits from NitroDict. |
Instance Variable | nitro | msiempy.core.session.NitroSession object. Interface to the SIEM. |
Create a new list
alist
: list object to wrap.bool
) True/None
the name or IP matches the provided search term.Search datasources in the DevTree.
generator
(list
) containing any matching DataSource
objects or None
.ValueError
: if field or term are NoneDoes not include client datasources.
Parse key fields from raw device strings into datasource dicts.
Adds parent_ids to datasources in the tree based upon the ordered list provided by the ESM. All the datasources below a Receiver row have it's id set as their parent ID.
Filters DevTree for datasources that have client datasources.
Get list of raw client strings.
ds_id
(str): Parent ds_id(s) are collected on initftoken
(str): Set and used after requesting clients for ds_idRetrieve zone data.
str
device tree string sorted by zoneszonetree
(str): Built by self._get_zonetreeReturns: List of dicts (str: str) devices by zone
Formats the output of _get_last_times
last_times
(str): string output from _get_last_times()list[dict]
: [{'name', 'model', 'last_time'}]Parse event times str and insert it into the _devtree
Filters objects that inaccurately show up as datasources sometimes.
devtree
(list): the devtreeCheck for duplicate dataname name or IP address.
ds_params
(dict) : datasource paramsds_params
should contain following keys :name
(str): datasource nameds_ip
(str): datasource IPzone_id
(str): optional zone_idAdds a datasource.
attr
(dict
): datasource attributesattr
can contain following keys :client
(bool
): designate a client datasource (not child)name
(str
): name of datasource (required)parent_id
(str
): id of parent device (required)ds_ip
(str
): ip of datasource (ip or hostname required)hostname
(str
): hostname of datasourcetype_id
(str
): type of datasource (required)enabled
(bool
): enabled or not (default: True)tz_id
(str
): timezone of datasource (default UTC: 8)zone_id
(str
): numberic ESM id for zone (default: 0)
Examples (tz_id
only): PST: 27, MST: 12, CST: 11, EST: 32require_tls
(bool
): datasource uses syslog tlsstr
): id of the result. Not the ds_id as of 11.2.1 or None
on ErrorDevTree.add
do not ensure the Datasource is well added. There is place for improvment: #82.Add a datasource client
attr
(dict
) : datasource attributesattr
can contain following keys :parent_id
(str
): datasource id of the client group datasource (required)name
(str
): name of the client (required)enabled
(bool
): enabled or not (default: True
)ds_ip
(str
): IP address for client (ip or hostname required)hostname
(str
): hostname for clienttype_id
(str
): numeric ESM type-id (required)tz_id
(str
): numeric ESM timezone id or GMTdorder
(str
): Date ordermaskflag
(str
):port
(str
): IP port to userequire_tls
(bool
): use syslog-TLS (default: False
)str
) or None
on Error