コード例 #1
0
def lb(wsdls):
    wsdl_dir = os.path.abspath(os.path.dirname(__file__)) + '/wsdl'

    return pc.BIGIP(
        hostname = host,
        username = user,
        password = password,
        fromurl = False,
        directory = wsdl_dir,
        wsdls = wsdls
    )
コード例 #2
0
    def connect(self):
        """Connect to the F5"""
        # Set up config file
        config = ConfigParser.ConfigParser()
        config.read(self.config_file)

        # Connect to the F5 using the propery wsdls
        connection = pc.BIGIP(hostname=config.get('LoadBalancer', 'hostname'),
                              username=config.get('LoadBalancer', 'username'),
                              password=config.get('LoadBalancer', 'password'),
                              fromurl=True,
                              wsdls=['LocalLB.Rule'])
        return connection
コード例 #3
0
    def connect(self):
        """Connect to f5"""
        # Set up config file
        config = ConfigParser.ConfigParser()
        config.read(self.config_file)
        logging.getLogger('suds.client').setLevel(logging.CRITICAL)

        # Connect to the F5 using the propery wsdls
        connection = pc.BIGIP(hostname=config.get('LoadBalancer', 'hostname'),
                              username=config.get('LoadBalancer', 'username'),
                              password=config.get('LoadBalancer', 'password'),
                              fromurl=True,
                              wsdls=['System.ConfigSync'])

        return connection
コード例 #4
0
ファイル: f5.py プロジェクト: crimv42/saltstack
    def _connect(self):
        '''
        Connect to F5
        '''
        try:
            self.bigIP = f5.BIGIP(
                hostname=self.lb,
                username=self.username,
                password=self.password,
                fromurl=True,
                wsdls=['LocalLB.VirtualServer', 'LocalLB.Pool'])
        except Exception:  # pylint: disable=broad-except
            raise Exception('Unable to connect to {0}'.format(self.lb))

        return True
コード例 #5
0
    def _get_pc(self, username, password, host, fromurl=True):
        """
        Create and return an instance of the BigIP object.

        :param username: A string containing the username to use.
        :param password: A string containing the password to use.
        :param host: A string containing host to connect.
        :param fromurl: A boolean to determine if the WSDL should
                        be fetched from the `host`.
        :returns: BigIP
        """
        return pc.BIGIP(username=username,
                        password=password,
                        hostname=host,
                        fromurl=fromurl,
                        wsdls=self.WSDL_LIST)
コード例 #6
0
    def _connect(self):
        """
        Connect to F5
        """
        try:
            self.bigIP = f5.BIGIP(
                hostname=self.lb,
                username=self.username,
                password=self.password,
                fromurl=True,
                wsdls=["LocalLB.VirtualServer", "LocalLB.Pool"],
            )
        except Exception:  # pylint: disable=broad-except
            raise Exception("Unable to connect to {0}".format(self.lb))

        return True
コード例 #7
0
ファイル: F5.py プロジェクト: seryl/Nodetraq
    def __init__(self, ip, username=None, password=None):
        self.hostname = ip
        if not username:
            self.username = '******'
        else:
            self.username = username

        if not password:
            self.password = '******'
        else:
            self.password = password

        self.b = pc.BIGIP(hostname=self.hostname,
                          username=self.username,
                          password=self.password,
                          fromurl=True,
                          wsdls=['LocalLB.PoolMember', 'LocalLB.Pool'])
コード例 #8
0
ファイル: F5utils.py プロジェクト: trolldbois/BigIPTools
    def __init__(self,
                 lbhost="",
                 lbuser="",
                 lbpass="",
                 audit=False,
                 vip_filter=""):

        self.LoadBalancer=pc.BIGIP(self.lbhost,lbuser,lbpass,fromurl=True, \
                                   wsdls=['LocalLB.VirtualServer', 'LocalLB.Pool',  'LocalLB.ProfileOneConnect'])
        self.lbhost = lbip
        self.lbuser = lbuser
        self.lbpass = lbpass
        self.vip_filter = vip_filter
        self.audit = audit
        self.vips = self.load_vips()
        self.pools = self.load_pools()
        self.oneconnects = self.load_oneconnects()
コード例 #9
0
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 = ['LocalLB.VirtualServer'])


# Setup a shortcut
v = b.LocalLB.VirtualServer

# create() takes four params:
# definitions, a Common.VirtualServerSequence,
# wildmasks, a Common.IPAddressSequence,
# resources, a LocalLB.VirtualServer.VirtualServerResourceSequence,
# profiles, a LocalLB.VirtualServer.VirtualServerProfileSequenceSequence

name = 'PC2' + str(int(time.time())) # the name of our vs.ww
コード例 #10
0
ファイル: view_f5_node.py プロジェクト: tnt234tnt/netdevops
#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
    a = node.get_object_status(node_addresses=[ipaddress])
    print a[0].availability_status
コード例 #11
0
ファイル: make_pool.py プロジェクト: apackeer/pycontrol
    print "Usage %s ip_address username password" % sys.argv[0]
    sys.exit()

a = sys.argv[1:]

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

# The constructor is similar to the original pyControl.
# Note the change from wsdl_files to wsdls, which makes more sense.
b = pc.BIGIP(hostname=a[0],
             username=a[1],
             password=a[2],
             fromurl=True,
             wsdls=['LocalLB.Pool'])

# We'll call the create() method, which takes three params:
# pool_names, lb_methods, and members. Note how we create objects for the more
# complicated stuff.

# we'll create an LB Method object. Its attributes look like
# "lbmeth.LB_METHOD_ROUND_ROBIN", etc.
lbmeth = b.LocalLB.Pool.typefactory.create('LocalLB.LBMethod')

# This is basically a stub holder of member items that we need to wrap up.
mem_sequence = b.LocalLB.Pool.typefactory.create(
    'Common.IPPortDefinitionSequence')
コード例 #12
0
import ssl
if len(sys.argv) != 6:
    print sys.argv[
        0] + ' ' + 'f5managedip' + ' ' + 'username' + ' ' + 'passwd' + ' ' + 'poolname' + 'ip:port'
else:
    hostname = sys.argv[1]
    username = sys.argv[2]
    password = sys.argv[3]
    poolname = sys.argv[4]
    member = sys.argv[5]
    members = [member]
    pool = poolname
    #ssl._create_default_https_context = ssl._create_unverified_context
    b = pc.BIGIP(hostname=hostname,
                 username=username,
                 password=password,
                 fromurl=True,
                 wsdls=['LocalLB.PoolMember', 'LocalLB.Pool'])

    def member_factory(b, member):
        ip, port = member.split(':')
        pmem = b.LocalLB.PoolMember.typefactory.create(
            'Common.IPPortDefinition')
        pmem.address = ip
        pmem.port = int(port)
        return pmem

    def session_state_factory(b, members):
        session_states = []
        for x in members:
            print x
コード例 #13
0
if pc.__version__ == '2.0':
    pass
else:
    print "Requires pycontrol version 2.x!"
    sys.exit()


# The list of BigIP systems you want to query in parallel.
bigips = sys.argv[1:]

# Pick one and create a 'main' object. It's literally only a 
# Parent object that we'll clone multiple times for each system.
b = pc.BIGIP( hostname = bigips[0],
            username = '******', #change to match your env.
            password = '******', #change to match your env.
            directory = 'c:\\tmp\\', #Change this to a local dir on your system.
            wsdls = ['LocalLB.Pool'])
 
queue = Queue.Queue()

class ConcurrentCall(threading.Thread):
    """Threaded BigIP calls to multiple systems"""
    def __init__(self, queue, b):
        threading.Thread.__init__(self)
        self.queue = queue
        self.b = b

    def run(self):
        while True:
            #grab a BigIP host from queue
コード例 #14
0
# -*- 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' + ' ' + 'poolname'
else:
    poolname = sys.argv[4]
    a = pc.BIGIP(hostname=sys.argv[1],
                 username=sys.argv[2],
                 password=sys.argv[3],
                 fromurl=True,
                 wsdls=['LocalLB.PoolMember'])
    pool01 = a.LocalLB.PoolMember
    b = pool01.get_object_status(pool_names=[poolname])
    for x in b:
        for y in x:
            print poolname + '=>' + y.member.address + ':' + str(
                y.member.port
            ) + '=>' + y.object_status.availability_status + '=>' + y.object_status.enabled_status + '=>' + y.object_status.status_description