Forum Discussion

david_wang_2073's avatar
david_wang_2073
Historic F5 Account
Jan 14, 2010

how to save gtm's configuration with iControl

Dear All,

 

 

Anybody ever used icontrol to save the configuration with iControl?

 

It seems that save_configuration(

 

"/config/gtm/topology.inc",

 

"SAVE_HIGH_LEVEL_CONFIG"

 

);

 

only save bigip.conf bigip_local.conf bigip_sys.conf.

 

Should I save the gtm configuraiton files one by one as below:

 

 

$(Get-F5.iControl).SystemConfigSync.save_configuration(

 

"/config/gtm/wipeip.conf",

 

"SAVE_HIGH_LEVEL_CONFIG"

 

);

 

 

$(Get-F5.iControl).SystemConfigSync.save_configuration(

 

"/config/gtm/topology.inc",

 

"SAVE_HIGH_LEVEL_CONFIG"

 

);

 

 

$(Get-F5.iControl).SystemConfigSync.save_configuration(

 

"/config/gtm/region.user",

 

"SAVE_HIGH_LEVEL_CONFIG"

 

);

 

 

or there are other command to save all the configruation of GTM?

 

 

Thanks,

 

  • david_wang_2073's avatar
    david_wang_2073
    Historic F5 Account
    Nobody gave me a reply. I have to test by myself, then I found GlobalLB has different behavior with LocalLB in saving configuration:

     

     

    http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=164 said

     

    "In iControl, we opted to go the route of the command line from an API perspective - this gives you the flexibility to roll back changes that your code has made, or commit them to the hardware so that they are active on the next reboot of your BIG-IP. This means that any changes you make via iControl are applied immediately and are active on the BIG-IP that your code is managing, but if you want them to be a permanent part of the configuration you will have to make an iControl API call to save them. "

     

     

    But it does not apply to GlobalLB. I did some test with pycontrol2, the code as below and found the change to topology can be updated to topology.inc imediately withouth save_configuration:

     

     

    !/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 virtual server from pycontrol v.2. This example passes in

     

    the 'fromurl' keyword as True (default is False), which tells pycontrol

     

    to fetch the WSDL from the remote BigIP. This script creates an http VS

     

    with oneconnect (see profile setup/sequence section).

     

     

     

    if pc.__version__ == '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 = ['GlobalLB.Topology'])

     

     

     

    Setup a shortcut

     

    t = b.GlobalLB.Topology

     

     

    create() takes four params:

     

    in TopologyRecord[] records, GlobalLB.Topology.TopologyRecord

     

    in long[] weights,

     

    in long[] orders

     

     

     

    Setup types.

     

    for i in range(4, 255):

     

    print i

     

     

     

    top_def = t.typefactory.create('GlobalLB.Topology.TopologyRecord')

     

    reg_type = t.typefactory.create('GlobalLB.RegionType')

     

    server = t.typefactory.create('GlobalLB.Topology.TopologyEndpoint')

     

    server.type = reg_type.REGION_TYPE_CIDR

     

    server.content = "125.64.6.%u" % i

     

    server.negate = False

     

     

    ldns = t.typefactory.create('GlobalLB.Topology.TopologyEndpoint')

     

    ldns.type = reg_type.REGION_TYPE_CIDR

     

    ldns.content = "1.1.1.%u" % i

     

    ldns.negate = False

     

     

    top_def.server = [server]

     

    top_def.ldns = [ldns]

     

     

    try:

     

    t.create(

     

    records = [top_def],

     

    weights=[100],

     

    orders=[1]

     

    )

     

    except Exception, e:

     

    print "Error creating topology"

     

    print e

     

    else:

     

    print 'The i for loop is over'

     

    s = b.System.ConfigSync

     

    s.save_configuration(filename = "", save_flag = 0)

     

     

    Didn't know whether it is expected behavior for GlobalLB, but I think it might not be efficient if each topology create will trigger a file saving action.