Forum Discussion
icontrol - different exported policy via icontrol and GUI
- Aug 04, 2022
Tim Rupp helped me write a file upload/download function for the rest interface years ago. Here's the mixin for the python sdk that was refined a lot on how to manage the data with the range header.
https://github.com/F5Networks/f5-common-python/blob/development/f5/bigip/mixins.py#L303-L395
I don't know much about the ASM-specific iControl methods, but you might try changing:
minimal: true to minimal: false
and see if that helps.
- JustJozefJul 21, 2022
Cirrus
Nope. I tried this at the beggining but still different outputs were generated. Anyway seems that JSON is exported correctly. Same export is from GUI and API.
- JRahmJul 22, 2022
Admin
so GUI has a lot more metadata around the policy, but the actual policy objects are the same?
- Piotr_BadachAug 04, 2022
Employee
There is a limit of 1,048,576 bytes for exporting ASM policies through API. This is the max size returned in a single chunk and the remaining data is truncated.
There is a way to get the rest of the policy using a Content-Range header. I tested this in the lab.
Unfortunately you would need to merge the files manually then.Policy exported
# restcurl -u admin:admin -X POST https://localhost/mgmt/tm/asm/tasks/export-policy -d '{"filename":"sp_api-gw.xml","policyReference":{"link":"https://localhost/mgmt/tm/asm/policies/_zFj4JiaUN79SDubDLofpQ"}}'
{
"isBase64": false,
"inline": false,
"minimal": false,
"status": "NEW",
"lastUpdateMicros": 1.551281842e+15,
"includeVulnerabilityAssessmentConfigurationAndData": true,
"kind": "tm:asm:tasks:export-policy:export-policy-taskstate",
"selfLink": "https://localhost/mgmt/tm/asm/tasks/export-policy/o11Oq-hmzdWYemX_tBVPdw?ver\u003d13.1.1",
"format": "xml",
"filename": "sp_api-gw.xml",
"policyReference": {
"link": "https://localhost/mgmt/tm/asm/policies/_zFj4JiaUN79SDubDLofpQ?ver\u003d13.1.1"
},
"id": "o11Oq-hmzdWYemX_tBVPdw",
"startTime": "2019-02-27T15:37:22Z"
}Status checked
# restcurl -u admin:admin -X GET https://localhost/mgmt/tm/asm/tasks/export-policy/o11Oq-hmzdWYemX_tBVPdw?ver\u003d13.1.1
{
"isBase64": false,
"inline": false,
"minimal": false,
"status": "COMPLETED",
"lastUpdateMicros": 1.551281856e+15,
"includeVulnerabilityAssessmentConfigurationAndData": true,
"kind": "tm:asm:tasks:export-policy:export-policy-taskstate",
"selfLink": "https://localhost/mgmt/tm/asm/tasks/export-policy/o11Oq-hmzdWYemX_tBVPdw?ver\u003d13.1.1",
"format": "xml",
"filename": "sp_api-gw.xml",
"policyReference": {
"link": "https://localhost/mgmt/tm/asm/policies/_zFj4JiaUN79SDubDLofpQ?ver\u003d13.1.1"
},
"endTime": "2019-02-27T15:37:37Z",
"id": "o11Oq-hmzdWYemX_tBVPdw",
"startTime": "2019-02-27T15:37:22Z",
"result": {
"fileSize": 1124056 <========= total size
}
}File downloaded (truncated)
# restcurl -u admin:admin -X GET https://localhost/mgmt/tm/asm/file-transfer/downloads/sp_api-gw.xml > /var/tmp/sp_api-gw.xml
# ls -la /var/tmp/sp_api-gw.xml
-rw-r--r--. 1 root root 1048577 2019-02-27 07:42 /var/tmp/sp_api-gw.xml <=== actual sizeThe rest of the policy downloaded using Content-Range header.
# curl -sku admin:admin -H "Content-Range: 1048576-1124055/1124055" -X GET https://localhost/mgmt/tm/asm/file-transfer/downloads/sp_api-gw.xml >> /var/tmp/sp_api-gw.xml
But then the last part is added starting from new line.<signature signature_id="200101106">
<enabled>true</enabled>
<in_staging>false</in_staging>
</signature>
<signature signature_id="200 <======
101107">
<enabled>true</enabled>
<in_staging>false</in_staging>
</signature>I think the best option would be to save policy parts to separate files and then combine them manually.
You can try also exporting in json format by adding the "format":"json" to the task request.
It may give you some lower size output.
# curl -ksu admin:admin -X POST https://localhost/mgmt/tm/asm/tasks/export-policy -d '{"filename":"test_policy_export.json","format":"json","policyReference":{"link":"http://localhost/mgmt/tm/asm/policies/MrLpFzRHNarvj_zuAOD0fw"}}'
- JRahmAug 04, 2022
Admin
Tim Rupp helped me write a file upload/download function for the rest interface years ago. Here's the mixin for the python sdk that was refined a lot on how to manage the data with the range header.
https://github.com/F5Networks/f5-common-python/blob/development/f5/bigip/mixins.py#L303-L395
- JustJozefAug 05, 2022
Cirrus
Thank you for link. Will check the script and test it.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
