• python disable node


    AFAT1:~/sbin/diable # cat disable_node.py 
    #NodeAddress
    # -*- coding: utf-8 -*-
    import sys
    import time
    import csv
    import ssl
    reload(sys)
    sys.path.append('./pycontrol')
    import pycontrol.pycontrol as pc
    #ssl._create_default_https_context = ssl._create_unverified_context
    if len(sys.argv) != 5:
        print sys.argv[0] + ' ' + 'f5managedip' + ' ' + 'username' + ' ' + 'passwd' + ' ' + 'nodeip'
    else :
    f5ip= sys.argv[1]
    username= sys.argv[2]
    passwd= sys.argv[3]
    nodeip= sys.argv[4]
    b = pc.BIGIP(
    hostname = f5ip,
    username = username,
    password = passwd,
    fromurl = True,
        wsdls=['LocalLB.NodeAddress'])
    node = b.LocalLB.NodeAddress
    ipaddress=nodeip
    #print node.set_monitor_state(node_addresses=[ipaddress],states=['STATE_FORCED_DISABLED'])
    #print node.set_monitor_state(node_addresses=['10.4.161.149'],states=['STATE_ENABLED'])
    a=node.get_object_status(node_addresses=[ipaddress])
    print a[0].availability_status
    #node.set_monitor_state(node_addresses=[ipaddress],states=['STATE_DISABLED'])
    node.set_session_enabled_state(node_addresses=[ipaddress],states=['STATE_DISABLED'])
    b= node.get_object_status(node_addresses=[ipaddress])
    print b[0].availability_status
    if b[0].availability_status == 'AVAILABILITY_STATUS_RED':
       print "%s Node Status: %s" %(ipaddress,b[0].availability_status)
    else :
      print "请检查是否正常关闭 %s" %(ipaddress)
    print node.get_monitor_status(node_addresses=[ipaddress])
    AFAT1:~/sbin/diable #
    
    
    
    AFAT1:~/sbin/diable # cat enable_node.py 
    #NodeAddress
    # -*- coding: utf-8 -*-
    import sys
    import time
    import csv
    import ssl
    reload(sys)
    sys.path.append('./pycontrol')
    import pycontrol.pycontrol as pc
    #ssl._create_default_https_context = ssl._create_unverified_context
    if len(sys.argv) != 5:
        print sys.argv[0] + ' ' + 'f5managedip' + ' ' + 'username' + ' ' + 'passwd' + ' ' + 'nodeip'
    else :
    f5ip= sys.argv[1]
    username= sys.argv[2]
    passwd= sys.argv[3]
    nodeip= sys.argv[4]
    b = pc.BIGIP(
    hostname = f5ip,
    username = username,
    password = passwd,
    fromurl = True,
        wsdls=['LocalLB.NodeAddress'])
    node = b.LocalLB.NodeAddress
    ipaddress=nodeip
    #print node.set_monitor_state(node_addresses=[ipaddress],states=['STATE_FORCED_DISABLED'])
    #print node.set_monitor_state(node_addresses=['10.4.161.149'],states=['STATE_ENABLED'])
    a=node.get_object_status(node_addresses=[ipaddress])
    print a[0].availability_status
    #node.set_monitor_state(node_addresses=[ipaddress],states=['STATE_DISABLED'])
    node.set_session_enabled_state(node_addresses=[ipaddress],states=['STATE_ENABLED'])
    b= node.get_object_status(node_addresses=[ipaddress])
    print b[0].availability_status
    if b[0].availability_status == 'AVAILABILITY_STATUS_RED':
       print "%s Node Status: %s" %(ipaddress,b[0].availability_status)
    else :
      print "请检查是否正常关闭 %s" %(ipaddress)
    print node.get_monitor_status(node_addresses=[ipaddress])
  • 相关阅读:
    字典序算法
    C语言中strcpy,strcmp,strlen,strcat函数原型
    堆和栈概念整理
    distribution counting—a sorting method from aocp
    矩阵访问测试
    一个很大的数组,如何高效的把零都移到前面
    poj1083
    AXD+HJTAG环境搭建总结
    软件断点和硬件断点的区别和数量限制
    Ubuntu下用as汇编器编写hello.S文件
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348656.html
Copyright © 2020-2023  润新知