You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when i exec this scripts ,
get this error ,but i got the VS INFO
Traceback (most recent call last): File "f5_vs_status.py", line 9, in from f5.bigip import ManagementRoot File "/usr/lib/python2.7/site-packages/f5_sdk-3.0.21-py2.7.egg/f5/bigip/init.py", line 20, in from icontrol.session import iControlRESTSession zlib.error: Error -2 while preparing to decompress data: inconsistent stream state
#!/usr/bin/env python
-- coding: utf-8 --
coding: UTF-8
import sys,os,commands
import collections,json
from utils.common import *
import utils.db_query as db_query
from f5.bigip import ManagementRoot
reload(sys)
sys.setdefaultencoding('utf8')
Connect to the BigIP and configure the basic objects
db = db_query.db_query()
class f5_api(object):
"""docstring for ClassName"""
def init(self, host,user,passwd,timeout=10):
self.host = host
self.user = user
self.passwd = passwd
self.timeout = timeout
def get_status(self):
mgmt = ManagementRoot(self.host, self.user, self.passwd,timeout=self.timeout)
virtuals = mgmt.tm.ltm.virtuals.get_collection()
# pools = mgmt.tm.ltm.pools.get_collection()
# for pool in pools:
# print json.dumps(pool.attrs)
# # for member in pool.members_s.get_collection():
# # print json.dumps(member.attrs)
# sys.exit(1)
for virtual in virtuals:
# print virtual.name,virtual.pool,virtual.enabled
name = virtual.pool.split("/")
vs_ip = virtual.destination.split("/")
if len(name) != 3:
continue
else:
pool_name = name[2]
pool = mgmt.tm.ltm.pools.pool.load(name=pool_name, partition='Common')
for m in pool.members_s.get_collection():
sql = '''replace into t_f5_vs_info
(device_ip,vs_name,vs_ip,vs_state,pool_name,server_name,server_address,server_state,c_time)
values ('{}','{}','{}','{}','{}','{}','{}','{}','{}') '''.format(
self.host,virtual.name,vs_ip[2],virtual.enabled,pool_name,m.name,m.address,m.state,c_time)
# print sql
try:
db.db_insert(sql)
except Exception as e:
print sql,e
if name == 'main':
device_list = db.get_f5()
cfg = get_config("f5")
for device in device_list:
import sys,os,commands
import collections,json
from utils.common import *
import utils.db_query as db_query
from f5.bigip import ManagementRoot
reload(sys)
sys.setdefaultencoding('utf8')
Connect to the BigIP and configure the basic objects
db = db_query.db_query()
class f5_api(object):
"""docstring for ClassName"""
def init(self, host,user,passwd,timeout=10):
self.host = host
self.user = user
self.passwd = passwd
self.timeout = timeout
def get_status(self):
mgmt = ManagementRoot(self.host, self.user, self.passwd,timeout=self.timeout)
virtuals = mgmt.tm.ltm.virtuals.get_collection()
# pools = mgmt.tm.ltm.pools.get_collection()
# for pool in pools:
# print json.dumps(pool.attrs)
# # for member in pool.members_s.get_collection():
# # print json.dumps(member.attrs)
# sys.exit(1)
for virtual in virtuals:
# print virtual.name,virtual.pool,virtual.enabled
name = virtual.pool.split("/")
vs_ip = virtual.destination.split("/")
if len(name) != 3:
continue
else:
pool_name = name[2]
pool = mgmt.tm.ltm.pools.pool.load(name=pool_name, partition='Common')
for m in pool.members_s.get_collection():
sql = '''replace into t_f5_vs_info
(device_ip,vs_name,vs_ip,vs_state,pool_name,server_name,server_address,server_state,c_time)
values ('{}','{}','{}','{}','{}','{}','{}','{}','{}') '''.format(
self.host,virtual.name,vs_ip[2],virtual.enabled,pool_name,m.name,m.address,m.state,c_time)
# print sql
try:
db.db_insert(sql)
except Exception as e:
print sql,e
if name == 'main':
device_list = db.get_f5()
cfg = get_config("f5")
for device in device_list:
f5 = f5_api(host=device_ip,user=cfg['username'],passwd=cfg['password'])
f5.get_status()
The text was updated successfully, but these errors were encountered:
benben17
changed the title
Traceback (most recent call last): File "f5_vs_status.py", line 9, in <module> from f5.bigip import ManagementRoot File "/usr/lib/python2.7/site-packages/f5_sdk-3.0.21-py2.7.egg/f5/bigip/__init__.py", line 20, in <module> from icontrol.session import iControlRESTSession zlib.error: Error -2 while preparing to decompress data: inconsistent stream state
zlib.error: Error -2 while preparing to decompress data: inconsistent stream state
Oct 15, 2019
when i exec this scripts ,
get this error ,but i got the VS INFO
Traceback (most recent call last): File "f5_vs_status.py", line 9, in from f5.bigip import ManagementRoot File "/usr/lib/python2.7/site-packages/f5_sdk-3.0.21-py2.7.egg/f5/bigip/init.py", line 20, in from icontrol.session import iControlRESTSession zlib.error: Error -2 while preparing to decompress data: inconsistent stream state
#!/usr/bin/env python
-- coding: utf-8 --
coding: UTF-8
import sys,os,commands
import collections,json
from utils.common import *
import utils.db_query as db_query
from f5.bigip import ManagementRoot
reload(sys)
sys.setdefaultencoding('utf8')
Connect to the BigIP and configure the basic objects
db = db_query.db_query()
class f5_api(object):
"""docstring for ClassName"""
def init(self, host,user,passwd,timeout=10):
self.host = host
self.user = user
self.passwd = passwd
self.timeout = timeout
if name == 'main':
device_list = db.get_f5()
cfg = get_config("f5")
for device in device_list:
import sys,os,commands
import collections,json
from utils.common import *
import utils.db_query as db_query
from f5.bigip import ManagementRoot
reload(sys)
sys.setdefaultencoding('utf8')
Connect to the BigIP and configure the basic objects
db = db_query.db_query()
class f5_api(object):
"""docstring for ClassName"""
def init(self, host,user,passwd,timeout=10):
self.host = host
self.user = user
self.passwd = passwd
self.timeout = timeout
if name == 'main':
device_list = db.get_f5()
cfg = get_config("f5")
for device in device_list:
f5 = f5_api(host=device_ip,user=cfg['username'],passwd=cfg['password'])
f5.get_status()
The text was updated successfully, but these errors were encountered: