Forum Discussion

merlinet_60432's avatar
merlinet_60432
Icon for Nimbostratus rankNimbostratus
Aug 11, 2011

pycontrol, remove_wideip_pool() problem

Hello,

 

 

 

I'm using pycontrol v2 to control GTM WideIP. I'm trying to remove WIDEIP POOL with remove_wideip_pool()

 

When I run the python script, below error has been occured.

 

 

 

[merlinet@as-jw gslb]$ ./rmwp.py

 

No handlers could be found for logger "suds.client"

 

Server raised fault: 'Could not find element by name: pool_name'

 

 

 

 

 

here are part of the script:

 

 

 

new_set = glb.wip_obj.typefactory.create('GlobalLB.WideIP.WideIPPool')

 

new_set.pool_name = "real_www.domain.com"

 

new_set.order = 1

 

new_set.ratio = 0

 

 

 

try:

 

glb.wip_obj.remove_wideip_pool(wide_ips = [wideip], wideip_pools = [[new_set]])

 

except Exception, e:

 

print e

 

 

 

  • Remove the double brackets surrounding the new_set object and you should be good to go.

    
    >>> wip = b.GlobalLB.WideIP
    >>> pl = b.GlobalLB.Pool
    >>> wip.get_list()
    [/Common/test.wip.com]
    >>> wip.get_wideip_pool(wide_ips = ['/Common/test.wip.com'])
    [[(GlobalLB.WideIP.WideIPPool){
       pool_name = "/Common/gpool1"
       order = 0
       ratio = 1
     }, (GlobalLB.WideIP.WideIPPool){
       pool_name = "/Common/gpool2"
       order = 1
       ratio = 2
     }]]
    >>> pooldef = wip.typefactory.create('GlobalLB.WideIP.WideIPPool')
    >>> pooldef.pool_name = '/Common/gpool2'
    >>> pooldef.order = 1
    >>> pooldef.ratio = 2
    >>> wip.remove_wideip_pool(wide_ips = ['/Common/test.wip.com'], wideip_pools = pooldef)
    >>> wip.get_wideip_pool(wide_ips = ['/Common/test.wip.com'])
    [[(GlobalLB.WideIP.WideIPPool){
       pool_name = "/Common/gpool1"
       order = 0
       ratio = 1
     }, (GlobalLB.WideIP.WideIPPool){
       pool_name = "/Common/gpool2"
       order = 1
       ratio = 2
     }]]
    >>>
    
  • huh, doesn't appear after second glance that my pool was removed. Odd. Let me pick at it a little longer
  • Can you test on your version to see if this works. Even if I use the object as is returned from get_wideip_pool in the remove, it still isn't working on my v11 beta image:

    
    >>> a = wip.get_wideip_pool(wide_ips = ['/Common/test.wip.com'])
    >>> a[0][0]
    (GlobalLB.WideIP.WideIPPool){
       pool_name = "/Common/gpool1"
       order = 0
       ratio = 1
     }
    >>> wip.remove_wideip_pool(wide_ips = ['/Common/test.wip.com'], wideip_pools = a[0][0])
    >>> wip.get_wideip_pool(wide_ips = ['/Common/test.wip.com'])
    [[(GlobalLB.WideIP.WideIPPool){
       pool_name = "/Common/gpool1"
       order = 0
       ratio = 1
     }, (GlobalLB.WideIP.WideIPPool){
       pool_name = "/Common/gpool2"
       order = 1
       ratio = 2
     }]]
    >>>
    
  • backed off to 10.2.2 and still see the same behavior. Probably user error on my part. I'm going to test the method from another language and see if it's a pycontrol issue or a method issue.
  • so i have confirmed that the method works with a little ruby help from George. Now I have to figure out my pycontrol errors.
  • OK, idiot me...figured this out. Requires two creates, one to create the pool definition, then one to create the sequence. Gets me every time!

    
    >>> pooldef = wip.typefactory.create('GlobalLB.WideIP.WideIPPool')
    >>> pooldef.pool_name = 'gpool1'
    >>> pooldef.order = 0
    >>> pooldef.ratio = 1
    >>> pooldef_seq = wip.typefactory.create('GlobalLB.WideIP.WideIPPoolSequence')
    >>> pooldef_seq.item = [pooldef]
    >>> wip.add_wideip_pool(wide_ips = ['test.wip.com'], wideip_pools = [pooldef_seq])
    >>> wip.get_wideip_pool(wide_ips = ['test.wip.com'])
    [[(GlobalLB.WideIP.WideIPPool){
       pool_name = "gpool1"
       order = 0
       ratio = 1
     }, (GlobalLB.WideIP.WideIPPool){
       pool_name = "gpool2"
       order = 1
       ratio = 2
     }]]
    >>> wip.remove_wideip_pool(wide_ips = ['test.wip.com'], wideip_pools = [pooldef_seq])
    >>> wip.get_wideip_pool(wide_ips = ['test.wip.com'])
    [[(GlobalLB.WideIP.WideIPPool){
       pool_name = "gpool2"
       order = 1
       ratio = 2
     }]]
    

  • Point of the problem is how to assign GlobalLB.WideIP.WideIPPool to GlobalLB.WideIP.WideIPPoolSequence. right?

     

     

    I correct my script as your suggestion. like

     

     

    new_seq = glb.wip_obj.typefactory.create('GlobalLB.WideIP.WideIPPoolSequence')

     

    new_set = glb.wip_obj.typefactory.create('GlobalLB.WideIP.WideIPPool')

     

    new_set.pool_name = "real_www.domain.com"

     

    new_set.order = long(0)

     

    new_set.ratio = long(1)

     

    new_seq.item = [new_set]

     

     

    try:

     

    glb.wip_obj.remove_wideip_pool(wide_ips = [wideip], wideip_pools = [new_seq])

     

    except Exception, e:

     

    print e

     

     

    great! it works for me.

     

     

    Very thanks