我能够与 f5 框通信并使用一些基本配置文件创建称为(虚拟 = VIP = 虚拟服务器)的单个对象。
工作代码:
from f5.bigip import ManagementRoot
import urllib3
urllib3.disable_warnings()
mgmt = ManagementRoot('13.126.189.103','admin','admin')
ltm = mgmt.tm.ltm
virtuals = mgmt.tm.ltm.virtuals
virtual = mgmt.tm.ltm.virtuals.virtual
virtual1 = mgmt.tm.ltm.virtuals.virtual.create(name='virtual3', description = 'testnew' , destination= '172.31.5.8:80', partition='Common')
我的要求是,我将提供来自 CSV 文件的输入,可能是 100 个 VIP。上述语法必须在导入的 CSV 文件中逐行运行。
from f5.bigip import ManagementRoot
import urllib3
import csv
import sys
import os
urllib3.disable_warnings()
mgmt = ManagementRoot('13.126.189.103','admin','admin')
ltm = mgmt.tm.ltm
virtuals = mgmt.tm.ltm.virtuals
virtual = mgmt.tm.ltm.virtuals.virtual
def configureVirtuals(bigip, virtualFile):
# These are the fields in the file. The purpose of each field is obvious. See. Input from CSV file called 'virtualFile' and each row has config
details
# the BIG-IP iControl REST API for more information.
fieldNames = ["name", "description", "ip", "port"]
virtualReader = csv.DictReader(virtualFile, fieldnames=fieldNames,
delimiter=",")
# Create a virtual server, one per line. it will take input from CSV file by row one by one
try:
for row in virtualReader:
myvirtual = mgmt.tm.ltm.virtuals.virtual.create(name=row["name"],
description=row["description"],
destination="%s:%s" % (row["ip"], row["port"])
在解析我是 f5 工程师并且是 python 新手时,我收到了意外的 EOF 错误。为批量更改构建应用程序。
有人请帮帮我吗?