Forum Discussion

Chandan_103558's avatar
Chandan_103558
Icon for Nimbostratus rankNimbostratus
May 01, 2012

Getting Error while using add_zone_file API for creating Management Zone

I am getting one error while creating zone using the function Create_Management_Zone( ) and Management.Zone.add_zone_file API.

 

 

Exception: Common::OperationFailed

 

primary_error_code : 18155542 (0x01150816)

 

secondary_error_code : 0

 

error_string : 01150816:3: File name specified for zone 'testf5.com' empty.. '

 

 

For the second parameter "src_file_names" in the API Management.Zone.add_zone_file, I am using the zone's resource record file name - 'rr_file' .

 

The file 'rr_file' is present in the same current path where the script is executing, but still getting the same above error.

 

Please find the file 'rr_file' contents as below.

 

 

testf5.com. IN NS apollo.testf5.com.

 

apollo.testf5.com. IN A 198.204.18.10

 

testf5.com IN NS hermes.testf5.com.

 

hermes.testf5.com IN A 198.204.18.11

 

 

Here is the code for creating management zone

 

 

def Create_Management_Zone():

 

zoneattr = b.Management.Zone.typefactory.create('Management.ZoneInfo')

 

zoneattr.view_name = 'external'

 

zoneattr.zone_name = 'testf5.com'

 

zoneattr.zone_type = 1

 

zoneattr_array = b.Management.Zone.typefactory.create('Management.ZoneInfoSequence')

 

zoneattr_array.item = zoneattr

 

 

str_array = b.Management.Zone.typefactory.create('Common.StringSequence')

 

str_array.item = ['SOA', 'NS', 'A', 'AAAA']

 

str_array.item = ['rr_file']

 

 

boolattr = ['true']

 

 

b.Management.Zone.add_zone_file(zone_records = zoneattr_array,

 

src_file_names = str_array,

 

sync_ptrs = boolattr)

 

 

I am assuming there is some problem while using second argument src_file_names but not able to find out the reason for failure . Please give some idea on this.

 

 

Thanks,

 

Chandan

1 Reply

  • George_Watkins_'s avatar
    George_Watkins_
    Historic F5 Account
    Hi Chandan,

     

     

    The issue you are running into is that the src_file_names parameter expects an array of zone file paths formatted as strings. The strings are the paths of zone files that are stored locally on the BIG-IP. You may want to add an upload method (likely SSH) to your code that pushes your zone file to /tmp on the BIG-IP. Here is a working example written in Java:

     

     

    package com.f5se.examples;
    
    import java.rmi.RemoteException;
    import javax.xml.rpc.ServiceException;
    
    
    public class CreateZone {
    public static void main(String[] args) {
    iControl.BigIP bigip = new iControl.BigIP("test-ltm-ve-03", "admin", "admin");
    bigip.setIgnoreInvalidCert(true);
    
    iControl.services.ManagementZoneInfo[] zone_info = new iControl.services.ManagementZoneInfo[1];
    zone_info[0] = new iControl.services.ManagementZoneInfo();
    zone_info[0].setView_name("external");
    zone_info[0].setZone_name("element.local.");
    zone_info[0].setZone_type(iControl.services.ManagementZoneType.MASTER);
    zone_info[0].setZone_file("db.element.local");
    zone_info[0].setOption_seq(new String[0]);
    
    String[] src_file_names = new String[] { "/tmp/db.element.local" };
    
    boolean[] sync_ptrs = new boolean[1];
    sync_ptrs[0] = true;
    
    try {
    bigip.ManagementZone().add_zone_file(zone_info, src_file_names, sync_ptrs);
    } catch (RemoteException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (ServiceException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }

     

     

    Hope that helps,

     

     

    George