Users may find it necessary to be able to export data from Aria Config in order to migrate to another environment or similar scenario
Aria Config 8.6+
SaltStack Config 6.3+
Tanzu Salt 8.18+
The following code sample will help export some resources. Please reference the attached API documentation for the remaining information on how to export other resources from Aria Config.
The code sample first gets a list of the file environments from Aria Config, lists the files, and then begins to save them to disk in the current working directory. Please keep in mind that this is just sample code and may require modification to match your environment and needs.
import os
from sseapiclient import APIClient
from pprint import pprint
# Please update this section to match your environment
# A local superuser account, preferably root, should be used to export data from RaaS since more information will be accessible
client = APIClient("http://my-aria-config-server:8080","<USERNAME>","<PASSWORD>",config_name="internal", ssl_validate_cert=False)
file_env = client.api.fs.get_envs().ret
print("Found {} environments: {}".format(len(file_env),file_env))
env_files = []
for fenv in file_env:
# The API usually returns an object with a "ret" attribute containing the actual response data
# In this case, the response contains a list, so we just extend (not append) an existing list
env_files.extend(client.api.fs.get_env(saltenv=fenv).ret)
pprint(env_files)
for fname in env_files:
try:
bname = os.path.basename(fname['path'])
except TypeError as e:
print(fname)
raise
with open(bname, "w") as fh:
print("Writing {}".format(bname))
data = client.api.fs.get_file(fname['uuid']).ret
try:
fh.write(data['contents'])
except TypeError as e:
pprint(data)
raise
This is just some quick boiler plate code for users looking to export files from their Aria Config instance.