OpenFactory Utils Module - Asset registration#
Asset registration and deregistration in OpenFactory.
- openfactory.utils.assets.deregister_asset(asset_uuid, ksqlClient, bootstrap_servers)[source]#
Deregister an asset from OpenFactory.
- openfactory.utils.assets.deregister_device_connector(device_uuid, bootstrap_servers, topic='device_connector_topic')[source]#
Deregister a device connector configuration.
- openfactory.utils.assets.now_iso_to_epoch_millis()[source]#
Get the current UTC time as epoch milliseconds, suitable for Kafka TIMESTAMP fields.
- Return type:
- Returns:
int – The current time in milliseconds since the Unix epoch.
- openfactory.utils.assets.register_asset(asset_uuid, uns, asset_type, ksqlClient, bootstrap_servers, docker_service='')[source]#
Register an asset in OpenFactory.
- Parameters:
asset_uuid (str) – UUID of the asset.
uns (dict) – UNS data with ‘levels’ (a dict of hierarchy levels) and ‘uns_id’ (UNS id as a string).
asset_type (str) – Type of the asset.
ksqlClient – (KSQLDBClient) KSQL client for executing queries.
bootstrap_servers (str) – Kafka bootstrap server address.
docker_service (str) – Docker service name associated with the asset.
- openfactory.utils.assets.register_device_connector(device, ksqlClient, table_name='DEVICE_CONNECTOR_SOURCE')[source]#
Register a device connector configuration in KSQLDB.
- Return type:
- Parameters:
device (Device) – OpenFactory device for which the connector is to register
ksqlClient (KSQLDBClient) – OpenFactory ksqlDB client.
table_name (str) – Name of the ksqlDB table to insert into. Defaults to ‘DEVICE_CONNECTOR_SOURCE’.
- Raises:
ValueError – If connector_config is invalid or cannot be serialized.
KSQLDBClientException – If the insert fails.