Office Address

Contact Mail

Contact Us

Scale Computing Rest API

Scale Computing’s REST API can be used to manage various aspects of your HC3 cluster, including backing up VMs. While direct “backup” operations in the sense of exporting a full VM image are possible, a common approach for data protection and recovery in Scale Computing environments involves creating snapshots and potentially replicating them to another cluster or exporting them for off-site storage.

Here’s a general outline of how you might interact with the Scale Computing REST API for VM backup-related tasks, using Python as an example:

1. Authentication:

You need to authenticate with the HC3 cluster to access the API. This typically involves sending a POST request to the /rest/v1/login endpoint with your username and password to obtain an authentication token.

import requests
import json

cluster_ip = "YOUR_CLUSTER_IP"
username = "YOUR_USERNAME"
password = "YOUR_PASSWORD"

login_url = f"https://{cluster_ip}/rest/v1/login"
headers = {"Content-Type": "application/json", "Accept": "application/json"}
payload = {"username": username, "password": password}

try:
    response = requests.post(login_url, headers=headers, data=json.dumps(payload), verify=False) # verify=False for self-signed certs
    response.raise_for_status()
    auth_token = response.json()["token"]
    print(f"Authentication successful. Token: {auth_token}")
except requests.exceptions.RequestException as e:
    print(f"Login failed: {e}")
    exit()

2. Creating a VM Snapshot:

Snapshots are a key component of backup and recovery on HC3. You can create a snapshot of a specific VM using the /rest/v1/VirDomain/{uuid}/snapshot endpoint.

vm_uuid = "YOUR_VM_UUID" # Get this from a VM listing or your environment
snapshot_url = f"https://{cluster_ip}/rest/v1/VirDomain/{vm_uuid}/snapshot"
headers["Authorization"] = f"Basic {auth_token}" # Assuming Basic auth with the token

try:
    response = requests.post(snapshot_url, headers=headers, verify=False)
    response.raise_for_status()
    print(f"Snapshot created successfully for VM {vm_uuid}.")
except requests.exceptions.RequestException as e:
    print(f"Failed to create snapshot: {e}")

3. Exporting a VM (for full backup):

If you need a full VM image for off-site storage or migration, you can export a VM or a specific snapshot. The VirDomain/export endpoint is used for this purpose. You’ll need to specify a target location (e.g., SMB share) and potentially a definition file.

export_url = f"https://{cluster_ip}/rest/v1/VirDomain/{vm_uuid}/export"
export_payload = {
    "source": {
        "pathURI": "smb://YOUR_SMB_USER:YOUR_SMB_PASSWORD@YOUR_SMB_SERVER/YOUR_EXPORT_SHARE/",
        "definitionFileName": "my_vm_backup.xml"
    }
}

try:
    response = requests.post(export_url, headers=headers, data=json.dumps(export_payload), verify=False)
    response.raise_for_status()
    print(f"VM {vm_uuid} export initiated.")
except requests.exceptions.RequestException as e:
    print(f"Failed to export VM: {e}")

Important Notes:

  • Error Handling:Implement robust error handling in your code to manage API responses and potential network issues.
  • Security:Handle authentication tokens securely. Avoid hardcoding credentials in production environments.
  • API Documentation:Refer to the official Scale Computing REST API documentation for detailed information on available endpoints, parameters, and response formats.
  • External Backup Solutions:For comprehensive backup and recovery, consider integrating with dedicated backup solutions like Veeam, which offer advanced features and support for Scale Computing platforms.

Leave a Reply

More Articles & Posts