Forum Discussion

Hyder_141209's avatar
Hyder_141209
Icon for Altostratus rankAltostratus
Feb 08, 2017

Code snippet for iControl API on upload_policy()

Hi,

 

I am writing a perl script to upload the modified ASM policies to F5. Is there any related perl snippet code available regarding using the following iControl SOAP API?

 

upload_policy( in String policy_name, in ASM__FileTransferContext file_context );

 

Appreciate your earliest response.

 

Best regards

 

Hyder

 

7 Replies

  • Thanks for your answer Jason. Unfortunately, my version is 11.6.0 and was looking for a SOAP call related snippet.

     

    Thanks.

     

    Best regards

     

    Hyder

     

  • ah yes, drove the train right through that SOAP intersection... :)

     

    I think the ASM file transfer contexts works similar to the standard context, but I'll reach out to see if I can get you a definitive answer. This might help get you started while I ask around.

     

  • Thanks for the link Jason. I can now upload the policy file to the /var/tmp/ directory. However, while trying to import_policy to the iApp its failing and showing the following error message:

    Exception: Common::OperationFailed
    primary_error_code   : 0 (0x00000000)
    secondary_error_code : 0
    error_string         : Import policy failed. Messages: [fatal] Cannot read exported security policy file. [fatal] Cannot read from input file.]
    

    BigIP version: 11.6.0 HF6

    Appreciate your further input on this.

    Best regards

    Hyder

  • usually there are two steps when uploading objects: upload to the system, then import to the configuration. I think that second step needs to happen before you can reference from the iApp, but I don't know the methods you are using so can't be sure.

     

  • Thanks Jason.

     

    Have done the upload correctly and actually can see the file uploaded there as well. The issue is only when running the SOAP import_policy().

     

    policy name is /TEST01/test.com.app/test.com_policy

     

    remote file name at F5 /var/tmp/ is test.com_policy

     

    The part of the code is:

     

        $check_resp->($f5_iface->import_policy(SOAP::Data->name(webapp_name => $policyname),
                                            SOAP::Data->name(filename =>                              
                                            $remote_file_location_name)));

    Have changed webapp_name to /TEST01/test.com.app. However, still the same error message. Any reference or sample code available on import_policy()?

     

    Cheers.

     

    Best regards Hyder

     

  • This is SOAP trace I can see at F5:

    
    
    
        
            /TEST01/test.com.app/test.com
            /shared/tmp/test.com_policy
        
    
    
    

    Anything missing?

    Best regards

    Hyder