chi.magic

The chi.magic module provides utility methods to magically orchestrate resources as a very high level interface.

chi.magic.cleanup_resources(lease_name: str)[source]

Cleans up resources associated with the given lease name.

Parameters:

lease_name (str) – The name of the lease to be cleaned up.

chi.magic.create_container(container_name: str, device_type: str, container_image: str, device_name: str | None = None, reserve_fip: bool = True, exposed_ports: List[str] | None = None, runtime: str | None = None, duration: timedelta = datetime.timedelta(days=1), show: str = 'widget') Container[source]

Creates a lease for a device and then creates a container on it.

Parameters:
  • container_name (str) – The name of the container.

  • device_type (str) – The type of device (e.g., compute, storage).

  • container_image (str) – The image to use for the container.

  • device_name (str, optional) – The name of the device. Defaults to None.

  • reserve_fip (bool, optional) – Whether to reserve a floating IP for the container. Defaults to True.

  • duration (timedelta, optional) – Duration for the lease. Defaults to 6 hours.

  • show (str, optional) – Determines whether to display information as a widget. Defaults to “widget”.

  • exposed_ports (List[str], optional) – List of ports to expose on the container. Defaults to None.

  • runtime (str, optional) – can be set to nvidia to enable GPU support on supported devices. Defaults to None.

Returns:

The created container object.

Return type:

Container

chi.magic.create_server(server_name: str, network_name: str | None = 'sharednet1', node_type: str | None = None, image_name: str | None = None, reserve_fip: bool = True, duration: timedelta = datetime.timedelta(days=1), show: str = 'widget') Server[source]

Creates a server with the given parameters. Will automatically create a reservation.

Parameters:
  • server_name (str) – The name of the server.

  • node_type (str, optional) – The type of the server node. If not provided, the user will be prompted to choose from available options.

  • image_name (str, optional) – The name of the server image. If not provided, the user will be prompted to choose from available options.

  • reserve_fip (bool, optional) – Whether to reserve a floating IP for the server. Defaults to True.

  • duration (timedelta, optional) – The duration of the server lease. Defaults to 24 hours.

  • show (str, optional) – The type of output to show. Defaults to “widget”.

Returns:

The created server object.

Return type:

Server

chi.magic.visualize_resources(leases: List[Lease])[source]

Displays a visualization of the resources associated with the leases in a graph.

Parameters: leases (List[Lease]): A list of Lease objects.

Returns: None