count = count + 1
    poolname = l[0]
    Descrip = l[2]
    t = l[4]
    vip_addr = l[4]
    vip_port = l[5]
    if poolname != '':
        monic_name = 'TCP_' + str(vip_port)
        if device.exist(f"/mgmt/tm/ltm/monitor/tcp/{rest_format(monic_name)}"):
            print(f"monitor {monic_name} exists.")
        else:
            #raise Exception(f"monitor {member_name} in {pool_name}.")
            data = {}
            data["name"] = monic_name
            data["destination"] = '*.' + str(vip_port)
            monitor = device.create(
                f"/mgmt/tm/ltm/monitor/tcp", data)
            if monitor.properties["fullPath"] != '/Common/' + monic_name:
                raise Exception(monitor.properties["fullPath"])
            else:
                print(f"Health Monitor {monic_name} created.")
#
#        if vip_port == '80' or vip_port == '443':
#            moni_name = 'http'
#        else:
#            moni_name = 'TCP_' + str(vip_port)
#
        pool_names = 'pool_' + str(vip_port) + '_' + vip_addr
        if device.exist(f"/mgmt/tm/ltm/pool/{rest_format(pool_names)}"):
            print(f"Pool {pool_names} exists.")
        else:
            #raise Exception(f"Create {pool_names} and Check not exists.")
示例#2
0
buffer = []
while True:
    line = sys.stdin.readline().rstrip('\n')
    if line == '':
        break
    else:
        buffer.append(line)
#print (buffer)
node_list = buffer

# Create a device object with basic authentication
device = BIGIP(F5_Host, F5_username, F5_password)

# Create node
for node_ip_address in node_list:
    node_name = 'node_' + node_ip_address
    if device.exist(f"/mgmt/tm/ltm/node/{rest_format(node_name)}"):
        print(f"Node {node_name} exists.")
    else:
        raise Exception(f"Create {node_name} and Check not exists.")
        data = {}
        data["name"] = node_name
        data["address"] = node_ip_address
        data["description"] = 'webserver_NS2020-1026-001'
        node = device.create(f"/mgmt/tm/ltm/node/", data)
        if node.properties[
                "fullPath"] != '/Common/' + 'node_' + node_ip_address:
            raise Exception(node.properties["fullPath"])
        else:
            print(f"Node {node_ip_address} created.")
示例#3
0
        break
    else:
        port_buffer.append(line)
#print (buffer)
port_list = port_buffer

for port in port_list:
    moni_name = 'TCP-' + port
    if device.exist(f"/mgmt/tm/ltm/monitor/tcp/{rest_format(moni_name)}"):
        print(f"monitor {moni_name} exists.")
    else:
        #raise Exception(f"monitor {member_name} in {pool_name}.")
        data = {}
        data["name"] = moni_name
        data["destination"] = '*.' + port
        monitor = device.create(
            f"/mgmt/tm/ltm/monitor/tcp", data)
        if monitor.properties["fullPath"] != '/Common/' + moni_name:
            raise Exception(monitor.properties["fullPath"])
        else:
            print(f"Pool {moni_name} created.")
#Job_name = input('輸入單號或說明: ')
#print("Node_ip : ", end="")
#node_ip_address = input()

#VIP_address = input('VIP Address: ')

#print('請輸入資料 port list,如 \n80\n443\n8080\n...直接按下Enter 結束 : ')
#port_buffer = []
#while True:
#    line = sys.stdin.readline().rstrip('\n')
#    if line == '':
domain_name = input()

print(f"Domain Name is: {domain_name}")

# Connect to BigIP
b = BIGIP(ip, username, password)

# Load the Profiles on a virtual server
profiles = b.load(f"/mgmt/tm/ltm/virtual/{rest_format(domain_name)}/profiles")

print(f"List of Profiles attached to {domain_name}")
profile_context_list = []
for p in profiles:
    profile_context_list.append(p.properties["context"])
print(profile_context_list)

if "serverside" in profile_context_list:
    print("Serverside SSL applied")
    print("Deleting Serverside SSL profile")
    path = (
        f"/mgmt/tm/ltm/virtual/{rest_format(domain_name)}/profiles/{rest_format(profile_name)}"
    )
    b.delete(path)
else:
    print("Serverside SSL doesn't applied")
    print("Adding Serverside SSL Profile")
    data = {}
    data["name"] = profile_name
    data["context"] = "serverside"
    b.create(f"/mgmt/tm/ltm/virtual/{rest_format(domain_name)}/profiles", data)
示例#5
0
        port_buffer.append(line)
#print (buffer)
port_list = port_buffer

# Create pool
for pools in port_list:
    pool_names = 'pool_' + pools + '_' + VIP_address
    if device.exist(f"/mgmt/tm/ltm/pool/{rest_format(pool_names)}"):
        print(f"Pool {pool_names} exists.")
    else:
        #raise Exception(f"Create {pool_names} and Check not exists.")
        data = {}
        data["name"] = pool_names
        print(pool_names)
        data["description"] = Job_name
        pool = device.create("/mgmt/tm/ltm/pool", data)
        if pool.properties["fullPath"] != '/Common/' + pool_names:
            raise Exception(pool.properties["fullPath"])
        else:
            print(f"Pool {pool_names} created.")

## Add pool member
#for port in port_list:
#    pool_name = 'pool_' + port + '_' + VIP_address
#    for members in node_list:
#        member_name = 'node_' + members + ':' + port
#        # Test if poolmember not exists
#        if device.exist(f"/mgmt/tm/ltm/pool/{rest_format(pool_name)}/members/{rest_format(member_name)}"):
#            print(f"poolmember {member_name} in {pool_name} exists.")
#        else:
#            raise Exception(f"Creat poolmemeber {member_name} in {pool_name}.")