Management::ResourceRecord::add_a

Introduced : BIG-IP_v9.0.3
Adds DNS “A” Records.

Prototype

 add_a(
    in Management__ViewZone [] view_zones,
    in Management__ARecord [] [] a_records,
    in boolean [] sync_ptrs
);

Parameters

Parameter Type Description
view_zones ViewZone [] The view/zone information.
a_records ARecord [] [] The list of A Records.
sync_ptrs boolean [] Boolean sequence to indicate if PTR records should be automatically generated from these A Records. This is one per VIEW_ZONE, not one per a_record

Return Type

Type Description
void  

Exceptions

Exception Description
Common::AccessDenied Raised if the client credentials are not valid.
Common::InvalidArgument Raised if one of the arguments is invalid.
Common::OperationFailed Raised if an operation error occurs.

See Also

Warning

The links to the sample code below are remnants of the old DevCentral wiki and will result in a 404 error. For best results, please copy the link text and search the codeshare directly on DevCentral.

Sample Code


#!/bin/env python

'''
----------------------------------------------------------------------------
The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5
Software Development Kit for iControl"; you may not use this file except in
compliance with the License. The License is included in the iControl
Software Development Kit.

Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.

The Original Code is iControl Code and related documentation
distributed by F5.

The Initial Developer of the Original Code is F5 Networks,
Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2004 F5 Networks,
Inc. All Rights Reserved.  iControl (TM) is a registered trademark of F5 Networks, Inc.

Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of GPL are applicable instead of those above.  If you wish
to allow use of your version of this file only under the terms of the
GPL and not to allow others to use your version of this file under the
License, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient may use your
version of this file under either the License or the GPL.
----------------------------------------------------------------------------
'''

import sys
import pycontrol.pycontrol as pc
import time

#######################################################################################
# Example of how to create a Resource Record in Zone Runner (ex. in this case an A record)
# This example passes in the  'fromurl' keyword as True (default is False), which tells pycontrol
# to fetch the WSDL from the remote BigIP.
#
# https://devcentral.f5.com/wiki/iControl.Management__ResourceRecord__add_a.ashx
#
# Majority of this code is borrowed from
#
# https://devcentral.f5.com/wiki/iControl.Management__ResourceRecord__add_cname.ashx
#
#######################################################################################

if pc.__version__.startswith('2.0'):
    pass
else:
    print "Requires pycontrol version 2.x!"
    sys.exit()

if len(sys.argv) < 4:
    print "Usage %s ip_address username password" % sys.argv[0]
    sys.exit()

a = sys.argv[1:]

b = pc.BIGIP(
        hostname = a[0],
        username = a[1],
        password = a[2],
        fromurl = True,
        wsdls = ['Management.ResourceRecord','Management.Zone', 'Management.View'])

# create short cut
r = b.Management.ResourceRecord

# Variables for USER to fill in
view = "external"
zone_name = "example.com."
domain_name = "test.example.com."
ip_address = "1.1.1.1"
ttl = 60

#Start creating required objects
viewzone_obj = r.typefactory.create('Management.ViewZone')
viewzone_obj.view_name = view
viewzone_obj.zone_name = zone_name

view_zone_seq = r.typefactory.create('Management.ViewZoneSequence')
view_zone_seq.item = viewzone_obj

# struct Management.ARecord
a_object = r.typefactory.create('Management.ARecord')
a_object.domain_name = domain_name
a_object.ip_address = ip_address
a_object.ttl = ttl

a_object_seq = r.typefactory.create('Management.ARecordSequence')
a_object_seq.item = a_object
a_object_seq_seq = r.typefactory.create('Management.ARecordSequenceSequence')
a_object_seq_seq.item = a_object_seq


print "Creating A RECORD: "
print "     \"" + domain_name + "     " + str(ttl) + "     IN      " + ip_address + "\"\n"

try:
    r.add_a(
                view_zones = view_zone_seq,
                a_records = a_object_seq_seq,
                sync_ptrs=['false']
                )
except Exception, e:
    print "Error adding Record %s" % a_object
    print e


print "Retrieving Resource Records for zone \"" + zone_name + "\":\n"
get_rrs_output = []

try:
    get_rrs_output = r.get_rrs(
                        view_zones = view_zone_seq
                        )

except Exception, e:
    print "Error retrieving resource records %s" % zone_name
    print e

for element in get_rrs_output:
    for resource_record in element:
        print resource_record

The BIG-IP API Reference documentation contains community-contributed content. F5 does not monitor or control community code contributions. We make no guarantees or warranties regarding the available code, and it may contain errors, defects, bugs, inaccuracies, or security vulnerabilities. Your access to and use of any code available in the BIG-IP API reference guides is solely at your own risk.