create_instance#
- Client.create_instance(product_name: str, product_version: str | None = None, requests_timeout: float | None = None, security_settings: InsecureSettings | MtlsSettings | WnuaSettings | UdsSettings | None = None) Instance#
Create a remote instance of a product based on its name and optionally its version.
This effectively starts the product in the backend, according to the backend configuration.
The created instance will not yet be ready to use. You must call
wait_for_ready()to wait for the instance to be ready.- Parameters:
- product_name
str Name of the product to start. For example,
mapdl.- product_version
str,optional Version of the product. For example,
"222". The default isNone.- requests_timeout
float,optional Maximum time for each request in seconds. The default is
None.- security_settings
SecuritySettings,optional Transport security settings for the instance. One of
InsecureSettings,MtlsSettings,WnuaSettings, orUdsSettings. The default isNone(server default). This is a request: the transport the instance actually uses is reported back through each of itsservices. See Security.
- product_name
- Returns:
InstanceInstance of the product.
- Raises:
UnsupportedProductErrorThe product or the selected version is not available remotely.
Examples
Create an instance with default security settings:
>>> import ansys.platform.instancemanagement as pypim >>> client = pypim.connect() >>> instance = client.create_instance(product_name="mapdl") >>> instance.wait_for_ready() >>> print(instance.services) >>> instance.delete() {'grpc': Service(uri='dns:10.240.4.231:50052', headers={}, security=None)}
Create an instance using UDS (Unix Domain Socket) security settings:
>>> import ansys.platform.instancemanagement as pypim >>> from ansys.platform.instancemanagement import UdsSettings >>> client = pypim.connect() >>> instance = client.create_instance( ... product_name="mapdl", ... security_settings=UdsSettings(), ... ) >>> instance.wait_for_ready() >>> print(instance.services) >>> instance.delete() { 'grpc': Service( uri='unix:/home/jdoe/.conn/mapdl.sock', headers={}, security=ServiceSecurity(transport='uds', cert_files=None), ) }
Create an instance using mTLS security settings:
>>> import ansys.platform.instancemanagement as pypim >>> from ansys.platform.instancemanagement import MtlsSettings >>> client = pypim.connect() >>> mtls = MtlsSettings( ... certificates_directory="/path/to/certs", ... ) >>> instance = client.create_instance( ... product_name="mapdl", ... security_settings=mtls, ... ) >>> instance.wait_for_ready() >>> print(instance.services) >>> instance.delete() { 'grpc': Service( uri='dns:127.0.0.1:63006', headers={}, security=ServiceSecurity(transport='mtls', cert_files=CertificateFiles( cert_file='/path/to/certs/client.crt', key_file='/path/to/certs/client.key', ca_file='path/to/certs/ca.crt') ) ) }