CloudLink: Cloudlink Rest API를 사용하여 Cloudlink 백업을 다운로드하는 Python 스크립트 예

Summary: 이 파일은 교육 및 정보 제공 목적으로만 사용됩니다. Python 언어로 Cloudlink 자동화 스크립트를 작성할 때 참조로 사용할 수 있습니다. Dell은 Dell 고객 환경에서 수행되는 이 파일에 대해 책임을 지지 않습니다. 이 스크립트는 Cloudlink RestAPI 호출을 사용하여 Python 스크립트로 Cloudlink 백업 파일을 다운로드하는 방법을 보여줍니다. 이 스크립트는 Cloudlink 8.x 라인에 적용할 수 있습니다. 스크립트는 /의 상태를 변경하지 않고 백업 파일만 다운로드합니다. Cloudlink secadmin 사용자의 자격 증명을 사용하여 Cloudlink 노드(IP 주소로 표시)에 대한 액세스 권한이 부여됩니다. ...

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Instructions

# Copyright Dell © 2025

# This file is for education / information purposes only.
# Can be used as a reference when writing Cloudlink automation scripts with Python language.
# Dell takes no responsibility for this file being executed in Dell Customer's environment

# The script shows a way to download Cloudlink backup file with a Python script using Cloudlink RestAPI calls.
# 이 스크립트는 Cloudlink 8.x 라인에 적용할 수 있습니다.
# The script doesn't alter state of any system, just downloads the backup file.
# Access to the Cloudlink node (indicated by IP address) is granted with credentials of a Cloudlink secadmin user.

import requests
import base64
import urllib3
import os

# Suppress only the single InsecureRequestWarning from urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

auth_url = "https://<cloudlink node ip>/cloudlink/oauth/token?grant_type=password&username=secadmin&password=<the password>&scope=all"

auth_response = requests.post(auth_url,timeout=1800, verify=False)

if auth_response.status_code == 200:
    # Parse the JSON response
    data = auth_response.json()
else:
    print(f"Error: {auth_response.status_code}")
    exit()

print("Auth token: "+data.get("access_token"))
access_token = data.get('access_token')

# Define the API endpoint
url = "https://<clc ip>:443/cloudlink/rest/backup"

# Define the headers (if needed)
headers = {
    "Authorization": "Bearer "+access_token,
    "Content-Type": "application/json"
}

# Make a GET request
response = requests.get(url, headers=headers, verify=False)

# Check the response status code
if response.status_code == 200:
    # Parse the JSON response
    data = response.json()
    print(data.get('file_name'))
else:
    print(f"Error: {response.status_code}")
    exit()

file_name = data.get('file_name')
file_content_base64 = data.get('file_content')

# Decode the base64 string to binary data
file_content_binary = base64.b64decode(file_content_base64)

# Save the binary data to a file
with open(str(file_name), "wb") as binary_file:
    binary_file.write(file_content_binary)

print("Backup has been saved to "+os.getcwd()+"\\"+str(file_name))

 

Article Properties
Article Number: 000330399
Article Type: How To
Last Modified: 10 Jun 2025
Version:  1
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.