OpenFactoryManager#
- class openfactory.OpenFactoryManager(ksqlClient, bootstrap_servers=None)[source]#
Bases:
OpenFactoryOpenFactory Manager API.
Allows to deploy services on OpenFactory.
Important
User requires Docker access on the OpenFactory cluster.
- deployment_strategy#
The strategy used to deploy services.
- __init__(ksqlClient, bootstrap_servers=None)[source]#
Initializes the OpenFactoryManager.
- Parameters:
ksqlClient (KSQLDBClient) – The client for interacting with ksqlDB.
bootstrap_servers (str) – The Kafka bootstrap server address. Defaults to config.KAFKA_BROKER.
Note
The deployment strategy to use (e.g., swarm or docker) is selected based on config.DEPLOYMENT_PLATFORM
- create_device_ksqldb_tables(device_uuid, ksql_tables)[source]#
Create ksqlDB tables of an OpenFactory device.
- Return type:
- Parameters:
- Raises:
OFAException – If the ksqlDB tables cannot be created.
- deploy_apps_from_config_file(yaml_config_file)[source]#
Deploy OpenFactory applications from a YAML configuration file.
This method loads and validates the UNS schema, parses the application configurations from the specified YAML file, and deploys each application that is not already deployed.
- Return type:
- Parameters:
yaml_config_file (str) – Path to the YAML configuration file containing application definitions.
Note
If the UNS schema is invalid, a failure notification will be triggered, and deployment will abort early.
If application configurations fail to load or validate, deployment will abort early after notifying the user.
Deployment skips applications that are already deployed.
- deploy_device_supervisor(device_uuid, supervisor)[source]#
Deploy an OpenFactory device supervisor.
- Return type:
- Parameters:
- Raises:
OFAException – If the supervisor cannot be deployed.
- deploy_devices_from_config_file(yaml_config_file)[source]#
Deploy OpenFactory devices from a YAML configuration file.
This method loads and validates the UNS schema, parses the device configurations from the specified YAML file, and deploys each device that is not already deployed.
Deployment includes registering the device asset, deploying the MTConnect agent, Kafka producer, KSQLDB tables (if defined), and device supervisor (if defined).
- Return type:
- Parameters:
yaml_config_file (str) – Path to the YAML configuration file containing device definitions.
Note
If the UNS schema is invalid, a failure notification will be triggered, and deployment will abort early.
If device configurations fail to load or validate, deployment will abort early after notifying the user.
Deployment skips devices that are already deployed.
- deploy_kafka_producer(device)[source]#
Deploy a Kafka producer.
- Return type:
- Parameters:
device (dict) – The device configuration as a dictionary.
- Raises:
OFAException – If the producer cannot be deployed.
- deploy_mtconnect_adapter(device_uuid, adapter)[source]#
Deploy an MTConnect adapter.
- Return type:
- Parameters:
- Raises:
OFAException – If the adapter cannot be deployed.
- deploy_mtconnect_agent(device_uuid, device_xml_uri, agent)[source]#
Deploy an MTConnect agent.
- Return type:
- Parameters:
- Raises:
OFAException – If the agent cannot be deployed.
- deploy_openfactory_application(application)[source]#
Deploy an OpenFactory application.
- Return type:
- Parameters:
application (dict) – The application configuration as a dictionary.
- Raises:
OFAException – If the application cannot be deployed.
- get_asset_uuid_from_docker_service(docker_service_name)[source]#
Return ASSET_UUID of the asset running on the Docker service docker_service_name.
- shut_down_apps_from_config_file(yaml_config_file)[source]#
Shut down OpenFactory applications based on a config file.
- Return type:
- Parameters:
yaml_config_file (str) – Path to the yaml configuration file.
- Raises:
OFAException – If the application cannot be shut down.
- shut_down_devices_from_config_file(yaml_config_file)[source]#
Shut down devices based on a config file.
- Return type:
- Parameters:
yaml_config_file (str) – Path to the yaml configuration file.
- Raises:
OFAException – If the device cannot be shut down.
- tear_down_application(app_uuid)[source]#
Tear down a deployed OpenFactory application.
- Return type:
- Parameters:
app_uuid (str) – The UUID of the application to be torn down.
- Raises:
OFAException – If the application cannot be torn down.
- tear_down_device(device_uuid)[source]#
Tear down a device deployed on OpenFactory.
- Return type:
- Parameters:
device_uuid (str) – The UUID of the device to be torn down.
- Raises:
OFAException – If the device cannot be torn down.