Forum Discussion

Hyder_141209's avatar
Hyder_141209
Icon for Altostratus rankAltostratus
9 years ago

Curl command for import and overwrite policy

Can anybody please help to correct the curl command for importing the policy and overwrite the existing one?

 

curl -sk -u admin:XXXX -H 'Content-Type: application/json' -X POST -d '{"isBase64":"true", "name": “test.com_policy”, "file": "base64 /shared/tmp/test.com_policy”}’ https://192.168.6.245/mgmt/tm/asm/tasks/import-policy

I am getting error in the /var/log/asm:

 

Apr 8 21:13:47 f5 crit g_server_rpc_handler_async.pl[45797]: 01310027:2: ASM subsystem error (asm_config_server.pl,F5::ImportExportPolicy::Base::fatal_error): failed to fd_retrieve from gzip pipe (Magic number checking on storable file failed at /usr/lib/perl5/vendor_perl/Storable.pm line 401, at /usr/local/share/perl5/F5/ImportExportPolicy/Binary.pm line 1802 )

 

Apr 8 21:13:47 f5 crit g_server_rpc_handler_async.pl[45797]: 01310027:2: ASM subsystem error (asm_config_server.pl,F5::ImportExportPolicy::Base::fatal_error): Cannot read from input file.

 

Apr 8 21:13:50 f5 info perl[22621]: 01310053:6: ASMConfig change: Import Policy Task Import Policy Task (1491711226.921315) [update]: Status was set to FAILURE. End Time was set to 1491711231. Message was set to Cannot read exported security policy file. Cannot read from input file.. { audit: username = admin, client IP = 192.168.6.1 }

 

Thanks in advance.

 

Best regards

 

Hyder

 

2 Replies

  • I have the policy file already uploaded under the folder of /shared/tmp/ at F5.

     

  • In the JSON body, specify a property that identifies the source of the import data. You must supply one property from the list:

     

    • file
    • filename
    • policyReferenceTemplate

    "file" specifies inline content in XML format to import.

     

    "filename" specifies the name of a local system file that contains the policy to import.

     

    "policyReferenceTemplate" (or "policyTemplateReference" -- the REST manual is contradictory) specifies the template for a policy.

     

    So, delete '"isBase64":"true"', remove 'base64' from the file name, and change 'file' to 'filename'.