I recently spent some time creating custom dashboards in Aria Operations and realised very quickly that I would not want to lose them! So I looked at exporting the content using the API and then automating this.
Firstly I used my go to language, PowerShell (this requires PowerShell 7) to make my life easier, specifically the Invoke-RestMethod cmdlet.
I thought it would be worth while sharing for anyone else out there creating custom content in Aria Operations and is looking for a way to back it up.
Acquire Token
Firstly, we need to acquire an authorisation token to be able to authenticate when using the export API’s. We achieve this using the token API.
Below are the details you will need, obviously updating the FQDN to your own and the credentials. There a a few options when it comes to credentials.
Parameter | Value |
---|---|
URL | https://vrops01.my-sddc.vcd/suite-api/api/auth/token/acquire |
Headers | Content-Type = application/json Accept = application/json |
Body | username ="samaccount@domain" authSource = “vIDMAuthSource” password = “ Or username =“admin” authSource = “LOCAL” password = “ |
You could use the local admin credentials, not ideal, or in my case, an authentication source within Aria Operations, specifically my vIDM (VMware Identity Manager) instance. You will need to grab the ‘Source Display Name’ configured in Aria Operations, Administration > Authentication Sources
to use for the ‘authSource’ value.
We are also placing the authentication token value with the $token
variable to then use within the remaining steps.
In the real world, you would ideally want to feed in these credentials securely via variables.
1$Splat = @{
2 "URI" = "https://vrops01.my-sddc.vcd/suite-api/api/auth/token/acquire"
3 "Headers" = @{
4 'Content-Type' = "application/json"
5 'Accept' = "application/json"
6 }
7 "Method" = "POST"
8 "body" = @{
9 username = "[email protected]"
10 authSource = "vIDMAuthSource"
11 password = "VMware123!"
12 } | ConvertTo-JSON -Depth 6
13}
14$token = Invoke-RestMethod @Splat -SkipCertificateCheck | Select-Object -expandproperty token
The output of the above Invoke-RestMethod command is the authorisation token that we will need in the proceeding steps below.
10bd65cc3-2561-xxxx-9c2c-xxxxxxxxxxxx::xxxxxxxx-c9cf-4e57-xxxx-5660c988f298
Export Content
Now we want to export the configuration using the Export API
Parameter | Value |
---|---|
URL | https://vrops01.my-sddc.vcd/suite-api/api/content/operations/export |
Headers | Content-Type = application/json Accept = application/json Authorization = vRealizeOpsToken 0bd65cc3-2561-xxxx-9c2c-xxxxxxxxxxxx::xxxxxxxx-c9cf-4e57-xxxx-5660c988f298 |
Body | scope = “ALL” contentTypes = [“DASHBOARDS”,“CUSTOM_GROUPS”,“SUPER_METRICS”] |
Note: There is a prefix of ‘vRealizeOpsToken’ followed by a ‘space’ before the authorisation token for the Authorisation header value!
I have listed a subset of the possible content types in the example above, here is the full list of options:
"VIEW_DEFINITIONS, REPORT_DEFINITIONS, DASHBOARDS, REPORT_SCHEDULES, POLICIES, ALERT_DEFINITIONS, SYMPTOM_DEFINITIONS, RECOMMENDATION_DEFINITIONS, CUSTOM_GROUPS, SUPER_METRICS, CONFIG_FILES, COMPLIANCE_SCORECARDS, NOTIFICATION_RULES, OUTBOUND_SETTINGS, PAYLOAD_TEMPLATES, INTEGRATIONS, COST_DRIVERS, USERS, USER_GROUPS, ROLES, AUTH_SOURCES, HTTP_PROXIES, SDMP_CUSTOM_SERVICES, SDMP_CUSTOM_APPLICATIONS, CUSTOM_PROFILES, DISCOVERY_RULES, APP_DEF_ASSIGNMENTS, GLOBAL_SETTINGS, UNKNOWN"
1$Splat = @{
2 "URI" = "https://vrops01.my-sddc.vcd/suite-api/api/content/operations/export"
3 "Headers" = @{
4 'Content-Type' = "application/json"
5 'Accept' = "application/json"
6 Authorization = "vRealizeOpsToken $($token)"
7 }
8 "Method" = "POST"
9 "body" = @{
10 scope = "ALL"
11 contentTypes = "DASHBOARDS","CUSTOM_GROUPS","SUPER_METRICS"
12 } | ConvertTo-JSON -Depth 6
13}
14Invoke-RestMethod @Splat -SkipCertificateCheck | Select-Object -expandproperty contentTypes
On running successfully, you will see something that look like this:
Download Content
Now we need to download the content we just exported. This comes down in the form of a zip file. We use the Download API for this.
Parameter | Value |
---|---|
URL | https://vrops01.my-sddc.vcd/suite-api/api/content/operations/export/zip |
Headers | Content-Type = application/json Accept = application/json Authorization = vRealizeOpsToken 0bd65cc3-2561-xxxx-9c2c-xxxxxxxxxxxx::xxxxxxxx-c9cf-4e57-xxxx-5660c988f298 |
The main difference in this one is that we are providing the -OutFile parameter to the Invoke-Rest Method command to download the content as a Zip file.
1$Splat = @{
2 "URI" = "https://vrops01.my-sddc.vcd/suite-api/api/content/operations/export/zip"
3 "Headers" = @{
4 'Content-Type' = "application/json"
5 'Accept' = "application/json"
6 Authorization = "vRealizeOpsToken $($token)"
7 }
8 "Method" = "GET"
9}
10Invoke-RestMethod @Splat -SkipCertificateCheck -OutFile "content.zip"
In your working directory, you will see a content.zip file which should look something like this:
1Mode LastWriteTime Length Name
2---- ------------- ------ ----
3d---- 10/25/2023 7:25 PM dashboards
4d---- 10/25/2023 7:25 PM dashboardsharings
5----- 10/25/2023 6:15 PM 36 6844548499441080431L.v1
6----- 10/25/2023 6:15 PM 195 configuration.json
7----- 10/25/2023 6:15 PM 11404 customgroups.json
8----- 10/25/2023 6:15 PM 12333 supermetrics.json
9----- 10/25/2023 6:15 PM 124 usermappings.json
Here is a quick video demo of the export process:
Import Content
Now to complete the loop, lets look at importing a content back into Aria Operations using the Import Content API.
Parameter | Value |
---|---|
URL | https://vrops01.my-sddc.vcd/suite-api/api/content/operations/import |
Headers | Content-Type = multipart/form-data Accept = */* Authorization = vRealizeOpsToken 0bd65cc3-2561-xxxx-9c2c-xxxxxxxxxxxx::xxxxxxxx-c9cf-4e57-xxxx-5660c988f298 |
We have an additional variable in this one to be able to get the zip file we which to import and pass it into the -Form parameter of the Invoke-RestMethod cmdlet.
1$File = @{
2 contentFile = Get-Item -Path "C:\Users\Administrator\content.zip"
3}
4$Splat = @{
5 "URI" = "https://vrops01.my-sddc.vcd/suite-api/api/content/operations/import"
6 "Headers" = @{
7 'Content-Type' = "multipart/form-data"
8 'Accept' = "*/*"
9 Authorization = "vRealizeOpsToken $($token)"
10 }
11 "Method" = "POST"
12}
13Invoke-RestMethod @Splat -SkipCertificateCheck -Form $File
The output should look something like this:
Hope this has been helpful and make sure you test appropriately!
As always, thanks for reading!
If you like my content, consider following me on Twitter so you don’t miss out!