air_sdk.endpoints.simulations
air_sdk.endpoints.simulations
Stub file for simulations endpoint type hints.
Classes
Module Contents
Bases: air_sdk.air_model.AirModel
Simulation model representing a network simulation.
The string representation shows: id, name, state, creator
Unique identifier for the simulation
Human-readable name of the simulation
Timestamp when the simulation was created
Timestamp when the simulation was last modified
Current state of the simulation (see Literal values for all states)
Email of the user who created the simulation
Whether automatic out-of-band management is enabled
Whether DHCP is enabled on the OOB server (when OOB is enabled)
When the simulation should be automatically put to sleep (stored)
When the simulation should be automatically deleted
Documentation markdown or URL to documentation markdown
Number of complete checkpoints in the simulation
Custom metadata as a JSON string
Update the simulation’s properties.
Note: For OOB and DHCP configuration, use dedicated methods like enable_auto_oob(), disable_auto_oob(), etc.
Parameters:
name– New name for the simulationsleep_at– When the simulation should be automatically put to sleepexpires_at– When the simulation should be automatically deleteddocumentation– Documentation markdown or URL to documentation markdownmetadata– Custom metadata as a JSON string
Example:
Enable automatic Out-of-band management for this simulation.
Parameters:
enable_dhcp– If True, enable DHCP on the OOB management network (default behavior). If False, disable DHCP on the OOB network.
Example:
Disable automatic Out-of-band management for this simulation.
Example:
Start the simulation.
Parameters:
checkpoint– Optional checkpoint ID to start from. If not specified, the API will use its default behavior (typically uses the most recent checkpoint if available). If explicitly set to None, starts from clean state (rebuild). If a string, starts from the specified checkpoint.
Example:
Shut down the simulation.
Parameters:
create_checkpoint– Whether to create a checkpoint before shutting down. If not specified, the API will use its default behavior.
Example:
Rebuild the simulation from a given checkpoint.
Tears down the simulation and starts it from the given checkpoint. If no checkpoint is provided, the simulation will be rebuilt from the clean state.
Parameters:
checkpoint– Optional checkpoint ID to rebuild from. If not specified, the API will use its default behavior (the current checkpoint the simulation is running off of). If explicitly set to None, starts from clean state (rebuild). If a string, starts from the specified checkpoint.
Example:
Wait for simulation to reach one of the target states.
Parameters:
target_states– Single state or list of states to wait fortimeout– Maximum time to wait (default: 120 seconds)poll_interval– Time between status checks (default: 2 seconds)error_states– Single state or list of states that should raise an error
Raises:
ValueError– If the simulation enters one of the error statesTimeoutError– If timeout is reached before target state
Example:
Set when the simulation should be automatically put to sleep (stored).
Accepts any timezone-aware datetime, which will be automatically converted to UTC. Naive datetimes (without timezone) will trigger a warning and assume local timezone.
Parameters:
sleep_at– Timezone-aware datetime when simulation should sleep, or None to clear. Naive datetimes will assume local timezone and emit a warning.
Example:
Set when the simulation should be automatically deleted.
Accepts any timezone-aware datetime, which will be automatically converted to UTC. Naive datetimes (without timezone) will trigger a warning and assume local timezone.
Parameters:
expires_at– Timezone-aware datetime when simulation should expire, or None to clear. Naive datetimes will assume local timezone and emit a warning.
Example:
Create a ZTP (Zero Touch Provisioning) script for the simulation.
Parameters:
content– The content of the ZTP script
Returns:
The created ZTPScript instance
Example:
Update the ZTP script for this simulation.
Parameters:
content– The new script content
Returns:
The updated ZTPScript instance
Example:
Delete the ZTP script for this simulation.
After deletion, simulation.ztp_script will return None.
Example:
Export the simulation.
Parameters:
image_ids– Whether to include image IDs in the export. If not specified, the API will use its default behavior.topology_format– Format for the topology in the export. If not specified, the API will use its default behavior.
Returns:
Dictionary containing the exported simulation data
Example:
Clone/duplicate the simulation.
Parameters:
checkpoint– Optional checkpoint ID to clone from. If not specified, Air will find the most recent COMPLETE checkpoint if it exists.attempt_start– If the simulation should start immediately after cloning
Returns:
The cloned Simulation instance
Example:
Get the simulation’s ZTP script if it exists.
Returns:
The ZTPScript instance or None if no script exists
Example:
Get the historical entries for the simulation.
Parameters:
category– Filter by category of the history entriesactor– Filter by actor who performed the actionssearch– Search term to filter the history entriesordering– Order the response by the specified field
Returns:
Iterator of History objects for the simulation
Example:
Query for the related nodes of the simulation.
Returns:
NodeEndpointAPI instance filtered for this simulation’s nodes
Example:
Query for the related interfaces of the simulation.
Returns:
InterfaceEndpointAPI instance filtered for this simulation’s interfaces
Example:
Query for the related links of the simulation.
Returns:
LinkEndpointAPI instance filtered for this simulation’s links
Example:
Query for the related node instructions of the simulation.
Returns:
NodeInstructionEndpointAPI filtered for this simulation’s instructions
Example:
Query for the related services of the simulation.
Returns:
ServiceEndpointAPI instance filtered for this simulation’s services
Example:
Query for the related checkpoints of the simulation.
Returns:
CheckpointEndpointAPI instance filtered for this simulation’s checkpoints
Example:
Create service using node and interface names.
Parameters:
node_name– Node name in this simulationinterface_name– Interface name on the node (e.g., ‘eth0’, ‘swp1’)node_port– Port number on the nodename– Service name (optional)service_type– Service type - ‘SSH’, ‘HTTPS’, ‘HTTP’, or ‘OTHER’
Returns:
Service object
Raises:
ValueError– If node or interface not found in simulation
Example:
Bulk assign configurations to nodes in this simulation.
Parameters:
nodes– List of node assignment data containing node, user_data, and meta_data
Example:
Reset specific nodes within this simulation.
Resetting the node emulates the hardware reset button on physical machines where the machine is immediately restarted without a clean shutdown of the operating system. For nodes that are not currently running, this means simply booting them back up.
Parameters:
nodes– List of node reset payloads, each containing a node object or ID
Example:
Rebuild specific nodes within this simulation.
Rebuilding a node means returning the node to either the state of the current checkpoint of its simulation or its initial, first boot state. When rebuilding from the initial state, all repeatable instructions for selected nodes will be applied. All existing instructions created for the selected nodes which have not yet been completed will be failed. All existing instructions created for the selected nodes which have not yet been delivered will be cancelled.
Parameters:
nodes– List of node rebuild payloads, each containing a node object or IDcheckpoint– Optional checkpoint ID to rebuild from
Example:
Bases: air_sdk.air_model.BaseEndpointAPI[air_sdk.endpoints.simulations.Simulation]
API client for simulation endpoints.
Create a blank simulation.
Parameters:
name– Name for the new simulationsleep_at– When the simulation should be automatically put to sleepexpires_at– When the simulation should be automatically deleteddocumentation– Documentation/description for the simulationmetadata– Custom metadata as a JSON string
Returns:
The created Simulation instance
Example:
Import a simulation from raw data.
Parameters:
format– Format of the content (‘JSON’ or ‘DOT’)content– The topology content (dict for JSON, str for DOT)name– Name for the new simulationztp– Optional ZTP script contentattempt_start– When enabled, waits for the simulation creation to complete and then starts it automaticallystart_timeout– Maximum time to wait for simulation creation (default: 120 seconds)
Returns:
The imported Simulation instance
Example:
Import simulation from a full JSON manifest file.
The manifest should contain all import parameters including:
- format: ‘JSON’
- name: Simulation name
- content: Topology data (for JSON format: dict with ‘nodes’, ‘links’, ‘oob’)
- ztp: Optional ZTP script content
Parameters:
simulation_manifest– Full simulation manifest (dict, JSON string, file path, or file handle)attempt_start– When enabled, waits for the simulation creation to complete and then starts it automaticallystart_timeout– Maximum time to wait for simulation creation (default: 120 seconds)
Returns:
The created Simulation instance
Raises:
ValueError– If manifest is missing required fieldsFileNotFoundError– If file path doesn’t existJSONDecodeError– If JSON content is malformed
Example:
Import simulation from DOT topology file/content.
Parameters:
topology_data– DOT topology content (string, file path, Path object, or file handle)name– Simulation name. If not provided, defaults to the graph name declared in the DOT contentztp– Optional ZTP script contentattempt_start– When enabled, waits for the simulation creation to complete and then starts it automaticallystart_timeout– Maximum time to wait for simulation creation (default: 120 seconds)
Returns:
The created Simulation instance
Raises:
ValueError– If content is invalidFileNotFoundError– If file path doesn’t exist
Example:
List all simulations with optional filtering.
Args:
auto_oob_enabled: Filter by auto OOB enabled status enable_dhcp: Filter by DHCP enabled status on OOB network id: Filter by simulation ID limit: Number of results to return per page name: Filter by simulation name offset: The initial index from which to return the results ordering: Order objects by field. Prefix with ”-” for desc order search: Search by name state: Filter by simulation state (e.g., ‘ACTIVE’, ‘INACTIVE’, ‘CREATING’, ‘CLONING’, etc.)
Returns:
Iterator of Simulation instances
Example:
Get a specific simulation by ID.
Parameters:
pk– The simulation ID (string or UUID)
Returns:
The Simulation instance
Example:
Update a simulation’s properties.
Parameters:
simulation– The simulation to update (Simulation object or ID)name– New name for the simulationsleep_at– When the simulation should be automatically put to sleepexpires_at– When the simulation should be automatically deleteddocumentation– Documentation/description for the simulationmetadata– Custom metadata as a JSON string
Returns:
The updated Simulation instance
Example:
Export a simulation.
Parameters:
simulation– The simulation to export (Simulation object or simulation ID)image_ids– Whether to include image IDs in the exporttopology_format– Format for the topology in the export
Returns:
Dictionary containing the exported simulation data
Example:
Clone/duplicate a simulation.
Parameters:
simulation– The simulation to clone (Simulation object or simulation ID)checkpoint– Optional checkpoint ID to clone from. If not specified, Air will find the most recent COMPLETE checkpoint if it exists.attempt_start– If the simulation should start immediately after cloning
Returns:
The cloned Simulation instance
Example:
Enable automatic Out-of-band management for a simulation.
Parameters:
simulation– The simulation object or simulation IDenable_dhcp– If True, enable DHCP on the OOB management network. If False, disable DHCP on the OOB network.
Example:
Disable automatic Out-of-band management for a simulation.
Parameters:
simulation– The simulation object or simulation ID
Example:
Start a simulation.
Parameters:
simulation– The simulation object or simulation ID to startcheckpoint– Optional checkpoint ID to start from. If not specified, the API will use its default behavior (typically uses the most recent checkpoint if available). If explicitly set to None, starts from clean state (rebuild). If a string, starts from the specified checkpoint.
Example:
Rebuild a simulation from a given checkpoint.
Tears down the simulation and starts it from the given checkpoint. If no checkpoint is provided, the simulation will be rebuilt from the clean state.
Parameters:
simulation– The simulation object or simulation ID to rebuildcheckpoint– Optional checkpoint ID to rebuild from. If not specified, the API will use its default behavior (the current checkpoint the simulation is running off of). If explicitly set to None, starts from clean state (rebuild). If a string, starts from the specified checkpoint.
Example:
Shut down a simulation.
Parameters:
simulation– The simulation object or simulation ID to shut downcreate_checkpoint– Whether to create a checkpoint before shutting down. If not specified, the API will use its default behavior.
Example:
Create service for a simulation by resolving node and interface names.
Parameters:
simulation– Simulation ID or objectnode_name– Node name in the simulationinterface_name– Interface name on the node (e.g., ‘eth0’, ‘swp1’)node_port– Port number on the nodename– Service name (optional)service_type– Service type - ‘SSH’, ‘HTTPS’, ‘HTTP’, or ‘OTHER’
Returns:
Service object
Raises:
ValueError– If node or interface not found in simulation
Example:
Parse topology content between different formats.
Convert topology data between different formats (e.g., DOT to JSON).
Parameters:
topology_data– The topology content to parsesource_format– The format to parse the topology from (e.g., ‘DOT’).destination_format– The format to parse the topology to (e.g., ‘JSON’).
Returns:
Parsed topology data as a dictionary
Example:
Bulk assign configurations to nodes in given simulation.
Parameters:
simulation– The simulation to bulk assign tonodes– List of node assignment data containing node, user_data, and meta_data
Example:
Reset specific nodes within a simulation.
Resetting the node emulates the hardware reset button on physical machines where the machine is immediately restarted without a clean shutdown of the operating system. For nodes that are not currently running, this means simply booting them back up.
Parameters:
simulation– The simulation object or simulation ID containing the nodesnodes– List of node reset payloads, each containing a node object or ID
Example:
Rebuild specific nodes within a simulation.
Rebuilding a node means returning the node to either the state of the current checkpoint of its simulation or its initial, first boot state. When rebuilding from the initial state, all repeatable instructions for selected nodes will be applied. All existing instruction created for the selected nodes which have not yet been completed will be failed. All existing instructions created for the selected nodes which have not yet been delivered will be cancelled.
Parameters:
simulation– The simulation object or simulation ID containing the nodesnodes– List of node rebuild payloads, each containing a node object or IDcheckpoint– Optional checkpoint ID to rebuild from
Example: