Skip to main content

Local Config

Provides access to local device configuration versions and file downloads in Strata Cloud Manager.

Class Overview​

The LocalConfig class inherits from ServiceBase and provides methods for listing configuration versions and downloading configuration files from devices.

Methods​

MethodDescriptionParametersReturn Type
list_versions()List config versions for a devicedeviceList[LocalConfigVersionModel]
download()Download a config filedevice, versionbytes

Model Attributes​

AttributeTypeDescription
idintUnique identifier for the configuration version entry
serialstrDevice serial number (14-15 digits)
local_versionstrLocal configuration version identifier
timestampdatetimeWhen the configuration version was created
xfmed_versionstrTransformed configuration version identifier
md5Optional[str]MD5 hash of the configuration

Exceptions​

ExceptionHTTP CodeDescription
InvalidQueryParameterError400Invalid query parameters
MissingQueryParameterError400Missing required parameters
AuthenticationError401Authentication failed
ObjectNotPresentError404Configuration not found
ServerError500Internal server error

Basic Configuration​

from scm.client import ScmClient

client = ScmClient(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)

Methods​

List Configuration Versions​

Retrieve the version history of local configurations for a specified device.

# List all configuration versions for a device
versions = client.local_config.list_versions(device="007951000123456")

for version in versions:
print(f"Version {version.local_version} at {version.timestamp}")

Download a Configuration File​

Download a specific local configuration file as raw XML bytes.

# Download a specific configuration version
config_bytes = client.local_config.download(
device="007951000123456",
version="1"
)

# Save to a file
with open("device-config.xml", "wb") as f:
f.write(config_bytes)

print(f"Downloaded {len(config_bytes)} bytes")

Use Cases​

Back Up Device Configuration​

# Get all versions, then download the latest
versions = client.local_config.list_versions(device="007951000123456")

if versions:
latest = versions[0]
config = client.local_config.download(
device="007951000123456",
version=str(latest.id)
)
filename = f"backup-{latest.serial}-{latest.local_version}.xml"
with open(filename, "wb") as f:
f.write(config)
print(f"Backed up to {filename}")
else:
print("No configuration versions found")

Track Configuration Changes​

# Monitor configuration version history
versions = client.local_config.list_versions(device="007951000123456")

for v in versions:
print(f"ID: {v.id} | Version: {v.local_version} | "
f"Transformed: {v.xfmed_version} | Time: {v.timestamp}")

Error Handling​

from scm.exceptions import (
AuthenticationError,
ObjectNotPresentError,
ServerError,
)

try:
versions = client.local_config.list_versions(device="007951000123456")
except AuthenticationError:
print("Authentication failed. Check your credentials.")
except ObjectNotPresentError:
print("Device not found.")
except ServerError as e:
print(f"Server error: {e.message}")