sl.snippet_api.automation package
- sl.snippet_api.automation.align_app(did, app_guid, cred_id, session, dbc=None)
Aligns the Dynamic Application with the specified app_guid to the device with the specified ID using the credential with the specified cred_id through the provided SL1 API session.
- Parameters:
did (
int
) – The ID of the device to align the Dynamic Application to.app_guid (
str
) – The GUID for the Dynamic Application to align with the device.cred_id (
int
) – The ID of the credential to align the device and Dynamic Application with.session (
Session
) – An SL1 API session.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
Response
- Returns:
The result of the session API request.
- sl.snippet_api.automation.align_app_with_cred(did, app_guid, cred_id, dbc=None)
Aligns the Dynamic Application with the specified app_guid to the device with the specified ID using the credential with the specified cred_id through direct db queries.
- Parameters:
did (
int
) – The ID of the device to align the Dynamic Application to.app_guid (
str
) – The GUID for the Dynamic Application to align with the device.cred_id (
int
) – The ID of the credential to align the device and Dynamic Application with.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
None
- sl.snippet_api.automation.align_class(class_type, did, session)
Align the device with the specified ID to the class with the specified type.
- Parameters:
class_type (
int
) – The class type (not class ID) for the class to align to the device.did (
int
) – The ID of the device to align with the specified class type.session (
Session
) – An SL1 API session.
- Return type:
Response
- Returns:
The result of the session API request.
- sl.snippet_api.automation.aligned_credential(did, app_guid, dbc=None)
Gets the ID of the credential aligned to the device with the specified ID and the Dynamic Application with the specified app_guid.
- Parameters:
did (
int
) – The ID of the device to check credential alignment for.app_guid (
str
) – The GUID for the Dynamic Application to check credential alignment for.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
Optional
[int
]- Returns:
The ID of the credential if both the device and Dynamic Application were found and aligned with each other, otherwise
None
.
- sl.snippet_api.automation.app_aligned(dids, app_guid, dbc=None)
Checks if the Dynamic Application with the specified app_guid is aligned to the devices with the specified dids.
- Parameters:
dids (
List
[int
]) – List of Device IDs to check Dynamic Application alignment for.app_guid (
str
) – The GUID for the Dynamic Application to check device alignment for.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
List
[int
]- Returns:
The subset of device IDs from the specified list that have the Dynamic Application with the specified app_guid aligned.
- sl.snippet_api.automation.app_type(app_guid, dbc=None)
Gets the Dynamic Application type (i.e. bulk_snippet_performance) for the Dynamic Application with the specified app_guid.
- Parameters:
app_guid (
str
) – The GUID for the Dynamic Application to get the type for.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
Optional
[str
]- Returns:
The Dynamic Application type if Dynamic Application was found, otherwise
None
.
- sl.snippet_api.automation.children_of(parent_did, columns=None, dbc=None)
Gets the desired device information of the direct children of the specified parent device.
With no columns specified, it retrieves the IDs of the child devices. Ex:
columns=None
(default) ->[2, 3]
With only one column specified, it creates a list of values of the specified column. Ex:
columns=["name"]
->['Dev2', 'Dev3']
With multiple columns specified, it creates a dict of key-value pairs for each column. Ex:
columns=["did", "name"]
->[{'did': 2, 'name': 'Dev2'}, {'did': 3, 'name': 'Dev3'}]
- Parameters:
parent_did (
int
) – The device of which to get the children information.columns (
Optional
[List
[str
]]) – The list of columns to retrieve for each device. The available columns can be found by runningdesc collector_state.V_device
within a MariaDB shell. Default is a list of only the device identifier:['did']
dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
List
[Any
]- Returns:
List of requested information for each of the child devices.
- sl.snippet_api.automation.descendants_of(root_did, columns=None, dbc=None)
Gets the desired device information of the descendants of the specified device. A device is a descendant if it’s root_did is the same as the specified root_did.
With no columns specified, it retrieves the IDs of the descendant devices. Ex:
columns=None
(default) ->[2, 3]
With only one column specified, it creates a list of values of the specified column. Ex:
columns=["name"]
->['Dev2', 'Dev3']
With multiple columns specified, it creates a dict of key-value pairs for each column. Ex:
columns=["did", "name"]
->[{'did': 2, 'name': 'Dev2'}, {'did': 3, 'name': 'Dev3'}]
- Parameters:
root_did (
int
) – The device of which to get the descendant’s information.columns (
Optional
[List
[str
]]) – The list of columns to retrieve for each device. The available columns can be found by runningdesc collector_state.V_device
within a MariaDB shell. Default is a list of only the device identifier:['did']
dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
List
[Any
]- Returns:
List of requested information for each of the descendant devices.
- sl.snippet_api.automation.device_attr_by_did(did, attr, dbc=None)
Gets the specified device attribute of the device with the specified ID.
The available fields can be found by running a describe collector_state.V_device command on an SL1 database instance.
- Parameters:
did (
int
) – The ID of the device to retrieve the attribute for.attr (
str
) – The name of the attribute, i.e. the column in collector_state.V_device.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
Optional
[Any
]- Returns:
The specified attribute if the device and column was found, otherwise
None
.
- sl.snippet_api.automation.device_class_id(class_guid, dbc=None)
Gets the ID of the device class associated with the specified GUID.
- Parameters:
class_guid (
str
) – GUID for the device class to retrieve the ID for.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
Optional
[int
]- Returns:
The device class ID if device class was found, otherwise
None
.
- sl.snippet_api.automation.device_class_type(class_guid, dbc=None)
Gets the type of the device class associated with the specified GUID.
- Parameters:
class_guid (
str
) – GUID for the device class to retrieve the type for.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
Optional
[int
]- Returns:
The device class type if device class was found, otherwise
None
.
- sl.snippet_api.automation.devices_by_class(class_guid, dids, columns=None, dbc=None)
Gets all the devices of the specified device class. The queried devices can be restricted to those included in the specified dids list.
With no columns specified, it retrieves the IDs of the devices with the specified class. Ex:
columns=None
(default) ->[2, 3]
With only one column specified, it creates a list of values of the specified column. Ex:
columns=["name"]
->['Dev2', 'Dev3']
With multiple columns specified, it creates a dict of key-value pairs for each column. Ex:
columns=["did", "name"]
->[{'did': 2, 'name': 'Dev2'}, {'did': 3, 'name': 'Dev3'}]
- Parameters:
class_guid (
str
) – GUID for the device class to retrieve devices for.dids (
List
[int
]) – The list of DIDs to check the database for. If an empty list is provided, all devices will be checked.columns (
Optional
[List
[str
]]) – The list of columns to retrieve for each device. The available columns can be found by runningdesc collector_state.V_device
within a MariaDB shell. Default is a list of only the device identifier:['did']
dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
List
[Any
]- Returns:
List of requested information for each device of the specified device class.
- sl.snippet_api.automation.generate_alert(message, xid, xtype, yid=0, ytype=0, yname='', value='', threshold='', dbc=None)
Generates an alert for a specific entity. An alert does not become an event unless there is an event policy that matches using the Event Source API. Refer to sl.snippet_api.platform_definitions for SiloXType and SiloYType.
- enum sl.snippet_api.platform_definitions.SiloXType(value)
XTypes used by ScienceLogic
These values can be used when something is requesting Xtype. Typically, there will be a
Xid
that is the ID for theXType
. For example, If you wanted to specify device id 12, you would useXType=SiloXType.SILO_DEVICE
andXid=12
.- Member Type:
int
Valid values are as follows:
- SILO_ORGANIZATION = <SiloXType.SILO_ORGANIZATION: 0>
- SILO_DEVICE = <SiloXType.SILO_DEVICE: 1>
- SILO_ASSET = <SiloXType.SILO_ASSET: 2>
- SILO_DOMAIN_NAME = <SiloXType.SILO_DOMAIN_NAME: 3>
- SILO_NETWORK = <SiloXType.SILO_NETWORK: 4>
- SILO_IF = <SiloXType.SILO_IF: 5>
- SILO_VENDOR = <SiloXType.SILO_VENDOR: 6>
- SILO_USER = <SiloXType.SILO_USER: 7>
- SILO_VIF = <SiloXType.SILO_VIF: 8>
- SILO_DEVICE_GROUP = <SiloXType.SILO_DEVICE_GROUP: 9>
- SILO_SERVICE_POLICY = <SiloXType.SILO_SERVICE_POLICY: 10>
- SILO_TICKET = <SiloXType.SILO_TICKET: 11>
- SILO_BUSINESS_SERVICE = <SiloXType.SILO_BUSINESS_SERVICE: 14>
- SILO_BUSINESS_IT_SERVICE = <SiloXType.SILO_BUSINESS_IT_SERVICE: 15>
- SILO_DEVICE_SERVICE = <SiloXType.SILO_DEVICE_SERVICE: 16>
- SILO_APPLICATION = <SiloXType.SILO_APPLICATION: 17>
- SILO_APPLICATION_COMPONENT = <SiloXType.SILO_APPLICATION_COMPONENT: 18>
- SILO_UNDEFINED_SERVICE = <SiloXType.SILO_UNDEFINED_SERVICE: 19>
- enum sl.snippet_api.platform_definitions.SiloYType(value)
YTypes used by ScienceLogic
These values can be used when something is requesting Ytype. Typically, there will be a Yid that is the ID for the YType.
- Member Type:
int
Valid values are as follows:
- SILO_CPU = <SiloYType.SILO_CPU: 1>
- SILO_DISK = <SiloYType.SILO_DISK: 2>
- SILO_FILESYSTEM = <SiloYType.SILO_FILESYSTEM: 3>
- SILO_MEMORY = <SiloYType.SILO_MEMORY: 4>
- SILO_VIRTUAL_MEMORY = <SiloYType.SILO_VIRTUAL_MEMORY: 5>
- SILO_COMPONENT = <SiloYType.SILO_COMPONENT: 6>
- SILO_INTERFACE = <SiloYType.SILO_INTERFACE: 7>
- SILO_SOFTWARE = <SiloYType.SILO_SOFTWARE: 8>
- SILO_PROCESS = <SiloYType.SILO_PROCESS: 9>
- SILO_PORT = <SiloYType.SILO_PORT: 10>
- SILO_SERVICE = <SiloYType.SILO_SERVICE: 11>
- SILO_CONTENT = <SiloYType.SILO_CONTENT: 12>
- SILO_MAIL = <SiloYType.SILO_MAIL: 13>
- SILO_DNS = <SiloYType.SILO_DNS: 14>
- SILO_RSS = <SiloYType.SILO_RSS: 15>
- SILO_CBQOS = <SiloYType.SILO_CBQOS: 16>
- Parameters:
message (
str
) – The message for the alert.xid (
int
) – The id of the xtype entity.xtype (
int
) – The entity xtype. The primary object to a ytype.yid (
Optional
[int
]) – The id of the ytype entity. Defaults to 0.ytype (
Optional
[int
]) – The entity ytype. The secondary object to a xtype. Defaults to 0.yname (
Optional
[str
]) – The name for the given ytype. Defaults to ‘’.value (
Optional
[str
]) – The value to use for the alert. Defaults to ‘’.threshold (
Optional
[str
]) – The threshold to use for the alert. Defaults to ‘’.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
int
- Returns:
The ID of the last row in the database after insertion.
- sl.snippet_api.automation.get_device_class_dict(did, dbc=None)
Gets the device class record of the device with the specified ID.
- Parameters:
did (
int
) – The ID of the device to retrieve the class information for.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
Dict
[str
,Any
]- Returns:
The device class record for the device with the specified ID.
- sl.snippet_api.automation.get_device_id_by_unique_id(unique_id, root_did=None, dbc=None)
Gets the device ID of a single device associated with the specified unique identifier. The device can be restricted to one with the specified root_did, if provided.
- Parameters:
unique_id (
str
) – The unique identifier of the device to retrieve the ID for.root_did (
Optional
[int
]) – The ID of the root device. No additional filtering will take place if none is provided. Defaults toNone
.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
Optional
[int
]- Returns:
The device ID if a single device was found, otherwise
None
.
- sl.snippet_api.automation.unalign_app(did, app_guid, session)
Un-aligns the Dynamic Application with the specified app_guid from the device with the specified ID through the provided SL1 API session.
- Parameters:
did (
int
) – The ID of the device to un-align the Dynamic Application from.app_guid (
str
) – The GUID for the Dynamic Application to un-align from the device.session (
Session
) – An SL1 API session.
- Return type:
Response
- Returns:
The result of the session API request.
- sl.snippet_api.automation.update_ip(ip_address, did, dbc=None)
Updates the IP Address field (registry tab) of the device with the specified ID.
- Parameters:
ip_address (
str
) – The ip address to set for the device with the specified ID.did (
int
) – The ID of the device to update the IP address for.dbc (
Union
[silo_cursor
,SiloCursor
,None
]) – The database cursor. If none is provided, a local database cursor will be used.
- Return type:
None