OpenFactory Utils Module - Asset registration#

Asset registration and deregistration in OpenFactory.

openfactory.utils.assets.deregister_asset(asset_uuid, ksqlClient, bootstrap_servers=None)[source]#

Deregister an asset from OpenFactory.

Parameters:
  • asset_uuid (str) – UUID of the asset.

  • ksqlClient – (KSQLDBClient) KSQL client for executing queries.

  • bootstrap_servers (str) – Kafka bootstrap server address.

openfactory.utils.assets.deregister_device_connector(device_uuid, bootstrap_servers=None, topic='device_connector_topic')[source]#

Deregister a device connector configuration.

Parameters:
  • device_uuid (str) – UUID of the device to deregister.

  • bootstrap_servers (str) – Kafka bootstrap servers. Defaults to config.KAFKA_BROKER.

  • topic (str) – Kafka topic backing the device connector table. Defaults to ‘device_connector_topic’.

Raises:

KafkaError – If sending the tombstone to the Kafka topic fails.

openfactory.utils.assets.now_iso_to_epoch_millis()[source]#

Get the current UTC time as epoch milliseconds, suitable for Kafka TIMESTAMP fields.

Return type:

int

Returns:

int – The current time in milliseconds since the Unix epoch.

openfactory.utils.assets.register_asset(asset_uuid, uns, asset_type, ksqlClient, bootstrap_servers=None, 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:

None

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: