### Install KubeVirt Client Python Package via Setuptools Source: https://github.com/kubevirt/client-python/blob/master/README.md Installs the KubeVirt Python client using Setuptools. This method involves downloading or cloning the source code and running the setup script. It allows for user-specific or system-wide installation. ```sh python setup.py install --user ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1alpha3/start-cluster-profiler Source: https://github.com/kubevirt/client-python/blob/master/README.md Starts the cluster profiler. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1alpha3/start-cluster-profiler ### Description Starts the cluster profiler. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/start-cluster-profiler ### Response #### Success Response (200) - **status** (string) - The status of the profiler start operation. ``` -------------------------------- ### PUT /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachines/{name}/start Source: https://github.com/kubevirt/client-python/blob/master/README.md Starts a virtual machine. ```APIDOC ## PUT /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachines/{name}/start ### Description Starts a virtual machine. ### Method PUT ### Endpoint /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachines/{name}/start ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the virtual machine. - **name** (string) - Required - The name of the virtual machine. ### Response #### Success Response (200) - **status** (string) - The status of the start operation. #### Response Example { "status": "started" } ``` -------------------------------- ### PUT /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachines/{name}/start Source: https://github.com/kubevirt/client-python/blob/master/README.md Starts a Virtual Machine. ```APIDOC ## PUT /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachines/{name}/start ### Description Starts a Virtual Machine. ### Method PUT ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachines/{name}/start ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the VirtualMachine. - **name** (string) - Required - The name of the VirtualMachine. ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/guestosinfo Source: https://github.com/kubevirt/client-python/blob/master/README.md Retrieves guest operating system information for a VirtualMachineInstance. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/guestosinfo ### Description Fetches operating system information from within a specific VirtualMachineInstance. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/guestosinfo ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the VirtualMachineInstance. - **name** (string) - Required - The name of the VirtualMachineInstance. ### Response #### Success Response (200) - **Guest OS Information** (object) - Information about the guest operating system (e.g., name, version, distribution). ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/sev/querylaunchmeasurement Source: https://github.com/kubevirt/client-python/blob/master/README.md Queries the launch measurement for a given virtual machine instance with SEV enabled. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/sev/querylaunchmeasurement ### Description Queries the launch measurement for a given virtual machine instance with SEV enabled. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/sev/querylaunchmeasurement ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the virtual machine instance. - **name** (string) - Required - The name of the virtual machine instance. ### Response #### Success Response (200) - **launchMeasurement** (string) - The launch measurement of the VMI. #### Response Example { "launchMeasurement": "example-measurement-string" } ``` -------------------------------- ### GET Start Profiler Source: https://github.com/kubevirt/client-python/blob/master/README.md Starts the profiling mechanism on the API server. This endpoint enables performance monitoring. ```APIDOC ## GET /start-profiler ### Description Starts the profiling mechanism on the API server. ### Method GET ### Endpoint /start-profiler ``` -------------------------------- ### Install KubeVirt Client Python Package via Pip Source: https://github.com/kubevirt/client-python/blob/master/README.md Installs the KubeVirt Python client directly from its GitHub repository using pip. This is a common method for installing packages not yet available on PyPI or for development versions. It may require root privileges depending on the system setup. ```sh pip install git+https://github.com/kubevirt/client-python.git ``` -------------------------------- ### PUT /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/sev/setupsession Source: https://github.com/kubevirt/client-python/blob/master/README.md Sets up an SEV session for a virtual machine instance. ```APIDOC ## PUT /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/sev/setupsession ### Description Sets up an SEV session for a virtual machine instance. ### Method PUT ### Endpoint /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/sev/setupsession ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the virtual machine instance. - **name** (string) - Required - The name of the virtual machine instance. ### Request Body - **sessionData** (string) - Required - The session data for setting up the SEV session. ### Request Example { "sessionData": "example-session-data" } ### Response #### Success Response (200) - **status** (string) - The status of the SEV session setup. #### Response Example { "status": "success" } ``` -------------------------------- ### V1beta1VirtualMachineSnapshot Model Source: https://github.com/kubevirt/client-python/blob/master/docs/V1beta1VirtualMachineSnapshot.md Documentation for the V1beta1VirtualMachineSnapshot model, detailing its properties, types, and descriptions. ```APIDOC ## V1beta1VirtualMachineSnapshot ### Description Represents a Virtual Machine Snapshot resource in KubeVirt. ### Properties #### `api_version` (str) APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources * **Type**: string * **Required**: [optional] #### `kind` (str) Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds * **Type**: string * **Required**: [optional] #### `metadata` (K8sIoApimachineryPkgApisMetaV1ObjectMeta) Represents metadata for the Virtual Machine Snapshot. * **Type**: object (K8sIoApimachineryPkgApisMetaV1ObjectMeta) * **Required**: [optional] #### `spec` (V1beta1VirtualMachineSnapshotSpec) Specification for the Virtual Machine Snapshot. * **Type**: object (V1beta1VirtualMachineSnapshotSpec) * **Required**: yes #### `status` (V1beta1VirtualMachineSnapshotStatus) Current status of the Virtual Machine Snapshot. * **Type**: object (V1beta1VirtualMachineSnapshotStatus) * **Required**: [optional] ### Request Example ```json { "api_version": "kubevirt.io/v1beta1", "kind": "VirtualMachineSnapshot", "metadata": {}, "spec": {}, "status": {} } ``` ### Response Example ```json { "api_version": "kubevirt.io/v1beta1", "kind": "VirtualMachineSnapshot", "metadata": {}, "spec": {}, "status": {} } ``` ``` -------------------------------- ### GET /apis/subresources.kubevirt.io Source: https://github.com/kubevirt/client-python/blob/master/README.md Gets the API group for subresources. ```APIDOC ## GET /apis/subresources.kubevirt.io ### Description Retrieves information about the Kubevirt subresources API group. ### Method GET ### Endpoint /apis/subresources.kubevirt.io ### Response #### Success Response (200) - **API Group Information** (object) - Details about the API group, including versions and resources. ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1alpha3/stop-cluster-profiler Source: https://github.com/kubevirt/client-python/blob/master/README.md Stops the cluster profiler. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1alpha3/stop-cluster-profiler ### Description Stops the cluster profiler. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/stop-cluster-profiler ### Response #### Success Response (200) - **status** (string) - The status of the profiler stop operation. ``` -------------------------------- ### POST /apis/kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstancepresets Source: https://github.com/kubevirt/client-python/blob/master/README.md Creates a virtual machine instance preset in a specified namespace. Presets define common configurations for VMIs. ```APIDOC ## POST /apis/kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstancepresets ### Description Creates a virtual machine instance preset in a specified namespace. ### Method POST ### Endpoint /apis/kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstancepresets ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace where the virtual machine instance preset will be created. #### Query Parameters (None) #### Request Body - **body** (object) - Required - The virtual machine instance preset object to create. ### Request Example { "example": "{... VirtualMachineInstancePreset object ...}" } ### Response #### Success Response (200 or 201) - **status** (string) - The status of the operation. - **metadata** (object) - Metadata about the created virtual machine instance preset. #### Response Example { "example": "{\"apiVersion\": \"kubevirt.io/v1\", \"kind\": \"VirtualMachineInstancePreset\", \"metadata\": {\"namespace\": \"default\"}, ...}" } ``` -------------------------------- ### V1MigrateOptions Model Source: https://github.com/kubevirt/client-python/blob/master/docs/V1MigrateOptions.md Documentation for the V1MigrateOptions model, including its properties, types, and descriptions. ```APIDOC ## V1MigrateOptions ### Description Represents options for migrating a virtual machine. ### Properties #### added_node_selector (dict(str, str)) - Type: dict(str, str) - Description: AddedNodeSelector is an additional selector that can be used to complement a NodeSelector or NodeAffinity as set on the VM to restrict the set of allowed target nodes for a migration. In case of key collisions, values set on the VM objects are going to be preserved to ensure that addedNodeSelector can only restrict but not bypass constraints already set on the VM object. - Notes: [optional] #### api_version (str) - Type: str - Description: APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - Notes: [optional] #### dry_run (list[str]) - Type: list[str] - Description: When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed - Notes: [optional] #### kind (str) - Type: str - Description: Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - Notes: [optional] ### Links [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1alpha3/dump-cluster-profiler Source: https://github.com/kubevirt/client-python/blob/master/README.md Dumps the cluster profiler data. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1alpha3/dump-cluster-profiler ### Description Dumps the cluster profiler data. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/dump-cluster-profiler ### Response #### Success Response (200) - **profiler_data** (string) - The cluster profiler data. ``` -------------------------------- ### Create Migration Policy with Python Source: https://context7.com/kubevirt/client-python/llms.txt Defines policies for virtual machine migrations across the cluster using the kubevirt Python client. This example sets up a policy for production environments targeting critical VMs. Requires the kubevirt library. ```python import kubevirt api = kubevirt.DefaultApi() policy_spec = { "apiVersion": "migrations.kubevirt.io/v1alpha1", "kind": "MigrationPolicy", "metadata": { "name": "production-migration-policy" }, "spec": { "selectors": { "namespaceSelector": { "matchLabels": {"env": "production"} }, "virtualMachineInstanceSelector": { "matchLabels": {"tier": "critical"} } }, "allowAutoConverge": True, "bandwidthPerMigration": "64Mi", "completionTimeoutPerGiB": 800 } } try: policy = api.create_migration_policy(body=policy_spec) print(f"Migration policy created: {policy.metadata.name}") except kubevirt.rest.ApiException as e: print(f"Error creating migration policy: {e}") ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1alpha3/version Source: https://github.com/kubevirt/client-python/blob/master/README.md Retrieves the API version information. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1alpha3/version ### Description Retrieves the API version information. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/version ### Response #### Success Response (200) - **version** (string) - The API version. ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1alpha3/guestfs Source: https://github.com/kubevirt/client-python/blob/master/README.md Retrieves guest filesystem information. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1alpha3/guestfs ### Description Retrieves guest filesystem information. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/guestfs ### Response #### Success Response (200) - **guestfsInfo** (object) - Information about guest filesystems. #### Response Example { "guestfsInfo": { "details": "Example guest filesystem details" } } ``` -------------------------------- ### V1HostDisk Model Documentation Source: https://github.com/kubevirt/client-python/blob/master/docs/V1HostDisk.md This section details the V1HostDisk model, outlining its properties, data types, and optionality. ```APIDOC ## V1HostDisk ### Description Represents a host disk for VM storage. It allows specifying capacity, path, sharing status, and disk image type. ### Properties #### capacity - **K8sIoApimachineryPkgApiResourceQuantity** - Optional - Capacity of the sparse disk. #### path - **str** - Default: '' - The path to HostDisk image located on the cluster. #### shared - **bool** - Optional - Indicates whether the path is shared between nodes. #### type - **str** - Default: '' - Contains information if disk.img exists or should be created. Allowed options are 'Disk' and 'DiskOrCreate'. ### Model Navigation [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ``` -------------------------------- ### V1VirtualMachineInstance Resource Source: https://github.com/kubevirt/client-python/blob/master/docs/V1VirtualMachineInstance.md Documentation for the V1VirtualMachineInstance resource model, outlining its properties and their specifications. ```APIDOC ## V1VirtualMachineInstance Resource ### Description Represents a VirtualMachineInstance resource in the Kubevirt API. ### Method N/A (This describes a resource model, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) This model defines the structure of the VirtualMachineInstance resource. - **api_version** (str) - APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. - **kind** (str) - Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. - **metadata** (K8sIoApimachineryPkgApisMetaV1ObjectMeta) - Kubernetes object metadata. - **spec** (V1VirtualMachineInstanceSpec) - VirtualMachineInstance Spec contains the VirtualMachineInstance specification. - **status** (V1VirtualMachineInstanceStatus) - Status is the high level overview of how the VirtualMachineInstance is doing. It contains information available to controllers and users. #### Response Example ```json { "apiVersion": "kubevirt.io/v1", "kind": "VirtualMachineInstance", "metadata": {}, "spec": {}, "status": {} } ``` ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1/guestfs Source: https://github.com/kubevirt/client-python/blob/master/README.md Retrieves guest filesystem information. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1/guestfs ### Description Fetches information related to guest filesystems. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1/guestfs ### Response #### Success Response (200) - **Guest Filesystem Information** (object) - Information about guest filesystems. ``` -------------------------------- ### V1VirtualMachineInstanceList API Source: https://github.com/kubevirt/client-python/blob/master/docs/V1VirtualMachineInstanceList.md Provides details about the V1VirtualMachineInstanceList model, including its properties like apiVersion, items, kind, and metadata. ```APIDOC ## V1VirtualMachineInstanceList ### Description Represents a list of V1VirtualMachineInstance objects. ### Properties - **api_version** (str) - APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | [optional] - **items** (list[V1VirtualMachineInstance]) - List of V1VirtualMachineInstance objects. | - **kind** (str) - Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [optional] - **metadata** (K8sIoApimachineryPkgApisMetaV1ListMeta) - | [optional] ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1alpha3/ Source: https://github.com/kubevirt/client-python/blob/master/README.md Retrieves a list of available API subresources. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1alpha3/ ### Description Retrieves a list of available API subresources. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/ ### Response #### Success Response (200) - **subresources** (array) - A list of available subresources. ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1alpha3/healthz Source: https://github.com/kubevirt/client-python/blob/master/README.md Checks the health status of the Kubevirt API. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1alpha3/healthz ### Description Checks the health status of the Kubevirt API. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/healthz ### Response #### Success Response (200) - **status** (string) - The health status of the API (e.g., "ok"). #### Response Example { "status": "ok" } ``` -------------------------------- ### Create Virtual Machine Snapshot with Python Source: https://context7.com/kubevirt/client-python/llms.txt Creates a snapshot of a Virtual Machine's current state using the kubevirt Python client. It defines the snapshot specification and includes logic to wait for the snapshot to become ready. Requires the kubevirt library. ```python import kubevirt import time api = kubevirt.DefaultApi() namespace = "default" vm_name = "my-persistent-vm" snapshot_spec = { "apiVersion": "snapshot.kubevirt.io/v1beta1", "kind": "VirtualMachineSnapshot", "metadata": { "name": f"{vm_name}-snapshot-{int(time.time())}", "namespace": namespace }, "spec": { "source": { "apiGroup": "kubevirt.io", "kind": "VirtualMachine", "name": vm_name } } } try: snapshot = api.create_namespaced_virtual_machine_snapshot( body=snapshot_spec, namespace=namespace ) print(f"Snapshot created: {snapshot.metadata.name}") # Wait for snapshot to be ready for _ in range(60): snap_status = api.read_namespaced_virtual_machine_snapshot( name=snapshot.metadata.name, namespace=namespace ) if snap_status.status and hasattr(snap_status.status, 'ready_to_use'): if snap_status.status.ready_to_use: print(f"Snapshot ready!") break time.sleep(5) except kubevirt.rest.ApiException as e: print(f"Error creating snapshot: {e}") ``` -------------------------------- ### Create KubeVirt Migration Policy using Python Client Source: https://github.com/kubevirt/client-python/blob/master/README.md Demonstrates how to create an instance of the KubeVirt API client and use it to create a migration policy. It includes importing necessary modules, handling potential API exceptions, and printing the response. Requires the kubevirt package to be installed. ```python from __future__ import print_function import time import kubevirt from kubevirt.rest import ApiException from pprint import pprint # create an instance of the API class api_instance = kubevirt.DefaultApi() body = kubevirt.V1alpha1MigrationPolicy() # V1alpha1MigrationPolicy | try: api_response = api_instance.create_migration_policy(body) pprint(api_response) except ApiException as e: print("Exception when calling DefaultApi->create_migration_policy: %s\n" % e) ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1/version Source: https://github.com/kubevirt/client-python/blob/master/README.md Retrieves the version information for the Kubevirt API. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1/version ### Description Retrieves the version information for the Kubevirt API. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1/version ### Response #### Success Response (200) - **version** (string) - The version string of the Kubevirt API. #### Response Example { "version": "v1.0.0" } ``` -------------------------------- ### V1StopOptions Model Documentation Source: https://github.com/kubevirt/client-python/blob/master/docs/V1StopOptions.md This section details the V1StopOptions model, outlining its properties, their types, descriptions, and optionality. ```APIDOC ## V1StopOptions Model ### Description Represents options for stopping a virtual machine instance. ### Properties #### api_version - **api_version** (str) - APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | [optional] #### dry_run - **dry_run** (list[str]) - When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed | [optional] #### grace_period - **grace_period** (int) - This updates the VMIs terminationGracePeriodSeconds during shutdown | [optional] #### kind - **kind** (str) - Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [optional] ### Links - [Back to Model list](../README.md#documentation-for-models) - [Back to API list](../README.md#documentation-for-api-endpoints) - [Back to README](../README.md) ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1/healthz Source: https://github.com/kubevirt/client-python/blob/master/README.md Checks the health status of the Kubevirt API. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1/healthz ### Description Retrieves the health status of the Kubevirt API server. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1/healthz ### Response #### Success Response (200) - **Health Status** (string) - A string indicating the health status (e.g., "ok"). ``` -------------------------------- ### V1VirtualMachineInstanceGuestOSInfo Source: https://github.com/kubevirt/client-python/blob/master/docs/V1VirtualMachineInstanceGuestOSInfo.md Represents the Guest OS information for a Virtual Machine Instance. ```APIDOC ## V1VirtualMachineInstanceGuestOSInfo ### Description Represents the Guest OS information for a Virtual Machine Instance. ### Properties - **id** (str) - Guest OS Id [optional] - **kernel_release** (str) - Guest OS Kernel Release [optional] - **kernel_version** (str) - Kernel version of the Guest OS [optional] - **machine** (str) - Machine type of the Guest OS [optional] - **name** (str) - Name of the Guest OS [optional] - **pretty_name** (str) - Guest OS Pretty Name [optional] - **version** (str) - Guest OS Version [optional] - **version_id** (str) - Version ID of the Guest OS [optional] ### Request Example ```json { "id": "string", "kernel_release": "string", "kernel_version": "string", "machine": "string", "name": "string", "pretty_name": "string", "version": "string", "version_id": "string" } ``` ### Response Example ```json { "id": "string", "kernel_release": "string", "kernel_version": "string", "machine": "string", "name": "string", "pretty_name": "string", "version": "string", "version_id": "string" } ``` ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/filesystemlist Source: https://github.com/kubevirt/client-python/blob/master/README.md Lists the filesystems of a VirtualMachineInstance. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/filesystemlist ### Description Retrieves a list of filesystems present within a specific VirtualMachineInstance. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/filesystemlist ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the VirtualMachineInstance. - **name** (string) - Required - The name of the VirtualMachineInstance. ### Response #### Success Response (200) - **Filesystem List** (array) - An array of filesystem objects. ``` -------------------------------- ### GET /kubevirt/status Source: https://github.com/kubevirt/client-python/blob/master/docs/V1KubeVirtStatus.md Retrieves the current status of the KubeVirt deployment. This includes information about conditions, versions, and deployment configurations. ```APIDOC ## GET /kubevirt/status ### Description Retrieves the current status of the KubeVirt deployment. This includes information about conditions, versions, and deployment configurations. ### Method GET ### Endpoint /kubevirt/status ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **conditions** (list[V1KubeVirtCondition]) - Current conditions of the KubeVirt deployment. - **default_architecture** (str) - The default architecture for KubeVirt components. - **generations** (list[V1GenerationStatus]) - Status of various generation processes within KubeVirt. - **observed_deployment_config** (str) - The observed deployment configuration. - **observed_deployment_id** (str) - The observed deployment identifier. - **observed_generation** (int) - The observed generation number. - **observed_kube_virt_registry** (str) - The observed KubeVirt registry. - **observed_kube_virt_version** (str) - The observed KubeVirt version. - **operator_version** (str) - The version of the KubeVirt operator. - **outdated_virtual_machine_instance_workloads** (int) - The number of outdated VM instance workloads. - **phase** (str) - The current operational phase of KubeVirt. - **synchronization_addresses** (list[str]) - Addresses used for synchronization. - **target_deployment_config** (str) - The target deployment configuration. - **target_deployment_id** (str) - The target deployment identifier. - **target_kube_virt_registry** (str) - The target KubeVirt registry. - **target_kube_virt_version** (str) - The target KubeVirt version. #### Response Example ```json { "conditions": [ { "last_heartbeat_time": "2023-10-27T10:00:00Z", "last_transition_time": "2023-10-27T10:00:00Z", "message": "KubeVirt is running", "reason": "Running", "status": "True", "type": "Available" } ], "default_architecture": "amd64", "generations": [], "observed_deployment_config": "config-123", "observed_deployment_id": "deploy-abc", "observed_generation": 1, "observed_kube_virt_registry": "docker.io/kubevirt", "observed_kube_virt_version": "v1.0.0", "operator_version": "v1.0.0", "outdated_virtual_machine_instance_workloads": 0, "phase": "Running", "synchronization_addresses": [], "target_deployment_config": "config-123", "target_deployment_id": "deploy-abc", "target_kube_virt_registry": "docker.io/kubevirt", "target_kube_virt_version": "v1.0.0" } ``` ``` -------------------------------- ### Create Virtual Machine Restore with Python Source: https://context7.com/kubevirt/client-python/llms.txt Restores a Virtual Machine to a previous state from a snapshot using the kubevirt Python client. It defines the restore specification and includes a loop to monitor the restore progress. Requires the kubevirt library. ```python import kubevirt import time api = kubevirt.DefaultApi() namespace = "default" vm_name = "my-persistent-vm" snapshot_name = "my-persistent-vm-snapshot-1234567890" restore_spec = { "apiVersion": "snapshot.kubevirt.io/v1beta1", "kind": "VirtualMachineRestore", "metadata": { "name": f"{vm_name}-restore", "namespace": namespace }, "spec": { "target": { "apiGroup": "kubevirt.io", "kind": "VirtualMachine", "name": vm_name }, "virtualMachineSnapshotName": snapshot_name } } try: restore = api.create_namespaced_virtual_machine_restore( body=restore_spec, namespace=namespace ) print(f"Restore operation initiated: {restore.metadata.name}") # Monitor restore progress for _ in range(120): restore_status = api.read_namespaced_virtual_machine_restore( name=restore.metadata.name, namespace=namespace ) if restore_status.status: complete = getattr(restore_status.status, 'complete', False) if complete: print(f"Restore completed successfully!") break print(f"Restore in progress...") time.sleep(5) except kubevirt.rest.ApiException as e: print(f"Error creating restore: {e}") ``` -------------------------------- ### Initialize KubeVirt API Client with Kubernetes Configuration Source: https://context7.com/kubevirt/client-python/llms.txt This snippet demonstrates how to initialize the KubeVirt API client using Kubernetes configuration. It shows loading credentials from a kubeconfig file (default or environment variable) and creating a default API instance. An alternative method for initializing with a custom API client, including specifying the host and SSL verification details, is also provided. ```python import os from kubernetes import config import kubevirt # Load kubeconfig from default location or environment variable kubeconfig_path = os.environ.get("KUBECONFIG", os.path.expanduser("~/.kube/config")) config_loader = config.kube_config._get_kube_config_loader_for_yaml_file(kubeconfig_path) config_loader.load_and_set(kubevirt.configuration) # Create API client instance api = kubevirt.DefaultApi() # Alternative: Initialize with custom API client from kubevirt import ApiClient, Configuration custom_config = Configuration() custom_config.host = "https://my-cluster.example.com" custom_config.verify_ssl = True custom_config.ssl_ca_cert = "/path/to/ca.crt" api_client = ApiClient(configuration=custom_config) api = kubevirt.DefaultApi(api_client=api_client) ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachines/{name}/expand-spec Source: https://github.com/kubevirt/client-python/blob/master/README.md Expands the specification of a Virtual Machine. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachines/{name}/expand-spec ### Description Expands the specification of a Virtual Machine. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachines/{name}/expand-spec ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the VirtualMachine. - **name** (string) - Required - The name of the VirtualMachine. ### Response #### Success Response (200) - **expanded_spec** (object) - The expanded Virtual Machine specification. ``` -------------------------------- ### V1VirtualMachine Model Source: https://github.com/kubevirt/client-python/blob/master/docs/V1VirtualMachine.md This section details the properties of the V1VirtualMachine model, including their types, descriptions, and optionality. ```APIDOC ## V1VirtualMachine ### Description Represents a Virtual Machine resource in Kubevirt. ### Properties #### apiVersion (str) - [optional] APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources #### kind (str) - [optional] Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds #### metadata (K8sIoApimachineryPkgApisMetaV1ObjectMeta) - [optional] Standard Kubernetes object metadata. #### spec (V1VirtualMachineSpec) - Spec contains the specification of VirtualMachineInstance created. #### status (V1VirtualMachineStatus) - [optional] Status holds the current state of the controller and brief information about its associated VirtualMachineInstance. ### Request Example ```json { "apiVersion": "kubevirt.io/v1", "kind": "VirtualMachine", "metadata": { "name": "example-vm" }, "spec": { "template": { "spec": { "domain": { "resources": { "requests": { "memory": "64Mi" } } }, "terminationGracePeriodSeconds": 0, "containers": [ { "name": "containerdisk", "image": "kubevirt/cirros-container-disk:latest", "volumeMounts": [ { "name": "virt-disk", "mountPath": "/var/run/libvirt/virt-launcher/" } ] } ] } } } } ``` ### Response Example ```json { "apiVersion": "kubevirt.io/v1", "kind": "VirtualMachine", "metadata": { "creationTimestamp": "2023-10-27T10:00:00Z", "name": "example-vm", "namespace": "default" }, "spec": { "dataVolumeTemplates": [], "instantiateVolumeCloneStrategy": "copy", "runStrategy": "Serial", "template": { "metadata": {}, "spec": { "architecture": "amd64", "domain": { "cpu": { "cores": 1, "model": "host-model", "sockets": 1, "threads": 1 }, "devices": { "disks": [ { "name": "virt-disk", "volumeMode": "Block", "lun": 0 } ], "interfaces": [ { "name": "default", "masquerade": {}, "model": "virtio" } ] }, "machine": { "type": "q35" }, "resources": { "limits": { "memory": "64Mi" }, "requests": { "memory": "64Mi" } } }, "hostname": "example-vm", "nodeSelector": {}, "priority": 0, "serviceAccountName": "" } } }, "status": { "conditions": [ { "lastProbeTime": null, "lastTransitionTimestamp": "2023-10-27T10:00:00Z", "reason": "VMPending", "status": "False", "type": "Scheduled" } ], "printableStatus": "Pending", "phase": "Pending" } } ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachines/{name}/objectgraph Source: https://github.com/kubevirt/client-python/blob/master/README.md Retrieves the object graph for a Virtual Machine. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachines/{name}/objectgraph ### Description Retrieves the object graph for a Virtual Machine. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachines/{name}/objectgraph ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the VirtualMachine. - **name** (string) - Required - The name of the VirtualMachine. ### Response #### Success Response (200) - **object_graph** (object) - The object graph representation of the VirtualMachine. ``` -------------------------------- ### V1beta1DataVolumeSourceS3 Model Source: https://github.com/kubevirt/client-python/blob/master/docs/V1beta1DataVolumeSourceS3.md Documentation for the V1beta1DataVolumeSourceS3 model, outlining its properties, types, and descriptions. ```APIDOC ## V1beta1DataVolumeSourceS3 Model ### Description Represents the S3 source configuration for a DataVolume in Kubevirt. ### Properties #### Request Body - **cert_config_map** (str) - Optional - CertConfigMap is a configmap reference, containing a Certificate Authority(CA) public key, and a base64 encoded pem certificate. - **secret_ref** (str) - Optional - SecretRef provides the secret reference needed to access the S3 source. - **url** (str) - Optional - URL is the url of the S3 source (default to ''). ### Request Example ```json { "cert_config_map": "my-ca-configmap", "secret_ref": "my-s3-secret", "url": "s3://my-bucket/path/to/image.qcow2" } ``` ### Response #### Success Response (200) - **cert_config_map** (str) - CertConfigMap is a configmap reference, containing a Certificate Authority(CA) public key, and a base64 encoded pem certificate. - **secret_ref** (str) - SecretRef provides the secret reference needed to access the S3 source. - **url** (str) - URL is the url of the S3 source. #### Response Example ```json { "cert_config_map": "my-ca-configmap", "secret_ref": "my-s3-secret", "url": "s3://my-bucket/path/to/image.qcow2" } ``` ``` -------------------------------- ### V1VirtualMachineInstanceNetworkInterface Model Source: https://github.com/kubevirt/client-python/blob/master/docs/V1VirtualMachineInstanceNetworkInterface.md Details the properties of the V1VirtualMachineInstanceNetworkInterface model. ```APIDOC ## V1VirtualMachineInstanceNetworkInterface ### Description Represents a network interface within a Virtual Machine Instance. ### Properties - **info_source** (str) - Specifies the origin of the interface data collected. values: domain, guest-agent, multus-status. | [optional] - **interface_name** (str) - The interface name inside the Virtual Machine | [optional] - **ip_address** (str) - IP address of a Virtual Machine interface. It is always the first item of IPs | [optional] - **ip_addresses** (list[str]) - List of all IP addresses of a Virtual Machine interface | [optional] - **link_state** (str) - LinkState Reports the current operational link state. values: up, down. | [optional] - **mac** (str) - Hardware address of a Virtual Machine interface | [optional] - **name** (str) - Name of the interface, corresponds to name of the network assigned to the interface | [optional] - **pod_interface_name** (str) - PodInterfaceName represents the name of the pod network interface | [optional] - **queue_count** (int) - Specifies how many queues are allocated by MultiQueue | [optional] ### Request Example ```json { "info_source": "domain", "interface_name": "eth0", "ip_address": "192.168.1.100", "ip_addresses": ["192.168.1.100", "2001:db8::1"], "link_state": "up", "mac": "0a:00:35:02:00:01", "name": "default", "pod_interface_name": "vmi-net-abcd", "queue_count": 4 } ``` ### Response Example ```json { "info_source": "domain", "interface_name": "eth0", "ip_address": "192.168.1.100", "ip_addresses": ["192.168.1.100", "2001:db8::1"], "link_state": "up", "mac": "0a:00:35:02:00:01", "name": "default", "pod_interface_name": "vmi-net-abcd", "queue_count": 4 } ``` ``` -------------------------------- ### GET /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/sev/fetchcertchain Source: https://github.com/kubevirt/client-python/blob/master/README.md Fetches the certificate chain for SEV-enabled VirtualMachineInstances. ```APIDOC ## GET /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/sev/fetchcertchain ### Description Retrieves the certificate chain required for Secure Encrypted Virtualization (SEV) operations on a VirtualMachineInstance. ### Method GET ### Endpoint /apis/subresources.kubevirt.io/v1/namespaces/{namespace}/virtualmachineinstances/{name}/sev/fetchcertchain ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the VirtualMachineInstance. - **name** (string) - Required - The name of the VirtualMachineInstance. ### Response #### Success Response (200) - **Certificate Chain** (string) - The SEV certificate chain. ``` -------------------------------- ### PUT /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachineinstances/{name}/sev/setupsession Source: https://github.com/kubevirt/client-python/blob/master/README.md Sets up a Secure Encrypted Virtualization (SEV) session for a Virtual Machine Instance. ```APIDOC ## PUT /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachineinstances/{name}/sev/setupsession ### Description Sets up a Secure Encrypted Virtualization (SEV) session for a Virtual Machine Instance. ### Method PUT ### Endpoint /apis/subresources.kubevirt.io/v1alpha3/namespaces/{namespace}/virtualmachineinstances/{name}/sev/setupsession ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the VirtualMachineInstance. - **name** (string) - Required - The name of the VirtualMachineInstance. ### Request Body - **session_setup** (object) - Required - The session setup configuration. - **payload** (string) - Required - The session payload. ### Request Example ```json { "session_setup": { "payload": "base64_encoded_payload" } } ``` ### Response #### Success Response (200) - **session_result** (string) - The result of the session setup. ```