本文整理汇总了Python中vnc_api.vnc_api.VncApi.loadbalancer_healthmonitor_read方法的典型用法代码示例。如果您正苦于以下问题:Python VncApi.loadbalancer_healthmonitor_read方法的具体用法?Python VncApi.loadbalancer_healthmonitor_read怎么用?Python VncApi.loadbalancer_healthmonitor_read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnc_api.vnc_api.VncApi
的用法示例。
在下文中一共展示了VncApi.loadbalancer_healthmonitor_read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LoadBalancerPluginDb
# 需要导入模块: from vnc_api.vnc_api import VncApi [as 别名]
# 或者: from vnc_api.vnc_api.VncApi import loadbalancer_healthmonitor_read [as 别名]
class LoadBalancerPluginDb(LoadBalancerPluginBase):
def __init__(self):
# TODO: parse configuration for api-server:port and auth
self._api = VncApi()
self._pool_manager = \
loadbalancer_pool.LoadbalancerPoolManager(self._api)
self._vip_manager = virtual_ip.VirtualIpManager(self._api)
self._member_manager = \
loadbalancer_member.LoadbalancerMemberManager(self._api)
self._monitor_manager = \
loadbalancer_healthmonitor.LoadbalancerHealthmonitorManager(
self._api)
def get_api_client(self):
return self._api
def get_vips(self, context, filters=None, fields=None):
return self._vip_manager.get_collection(context, filters, fields)
def get_vip(self, context, id, fields=None):
return self._vip_manager.get_resource(context, id, fields)
def create_vip(self, context, vip):
return self._vip_manager.create(context, vip)
def update_vip(self, context, id, vip):
return self._vip_manager.update(context, id, vip)
def delete_vip(self, context, id):
return self._vip_manager.delete(context, id)
def get_pools(self, context, filters=None, fields=None):
return self._pool_manager.get_collection(context, filters, fields)
def get_pool(self, context, id, fields=None):
return self._pool_manager.get_resource(context, id, fields)
def create_pool(self, context, pool):
return self._pool_manager.create(context, pool)
def update_pool(self, context, id, pool):
return self._pool_manager.update(context, id, pool)
def delete_pool(self, context, id):
return self._pool_manager.delete(context, id)
def stats(self, context, pool_id):
pass
def create_pool_health_monitor(self, context, health_monitor, pool_id):
""" Associate an health monitor with a pool.
"""
m = health_monitor['health_monitor']
try:
pool = self._api.loadbalancer_pool_read(id=pool_id)
except NoIdError:
raise loadbalancer.PoolNotFound(pool_id=pool_id)
try:
monitor = self._api.loadbalancer_healthmonitor_read(id=m['id'])
except NoIdError:
raise loadbalancer.HealthMonitorNotFound(monitor_id=m['id'])
if not context.is_admin:
tenant_id = context.tenant_id
if tenant_id != pool.parent_uuid or \
tenant_id != monitor.parent_uuid:
raise n_exc.NotAuthorized()
pool_refs = monitor.get_loadbalancer_pool_back_refs()
if pool_refs is not None:
for ref in pool_refs:
if ref['uuid'] == pool_id:
raise loadbalancer.PoolMonitorAssociationExists(
monitor_id=m['id'], pool_id=pool_id)
pool.add_loadbalancer_healthmonitor(monitor)
self._api.loadbalancer_pool_update(pool)
res = {
'id': monitor.uuid,
'tenant_id': monitor.parent_uuid
}
return res
def get_pool_health_monitor(self, context, id, pool_id, fields=None):
""" Query a specific pool, health_monitor association.
"""
try:
pool = self._api.loadbalancer_pool_read(id=pool_id)
except NoIdError:
raise loadbalancer.PoolNotFound(pool_id=id)
if not context.is_admin and context.tenant_id != pool.parent_uuid:
raise loadbalancer.PoolNotFound(pool_id=id)
in_list = False
for mref in pool.get_loadbalancer_healthmonitor_refs():
if mref['uuid'] == id:
in_list = True
#.........这里部分代码省略.........
示例2: LoadBalancerPluginDb
# 需要导入模块: from vnc_api.vnc_api import VncApi [as 别名]
# 或者: from vnc_api.vnc_api.VncApi import loadbalancer_healthmonitor_read [as 别名]
#.........这里部分代码省略.........
'bytes_out': '0',
'active_connections': '0',
'total_connections': '0',
}
endpoint = "http://%s:%s" % (cfg.CONF.COLLECTOR.analytics_api_ip,
cfg.CONF.COLLECTOR.analytics_api_port)
analytics = analytics_client.Client(endpoint)
path = "/analytics/uves/service-instance/"
fqdn_uuid = "%s?cfilt=UveLoadbalancer" % pool_id
try:
lb_stats = analytics.request(path, fqdn_uuid)
pool_stats = lb_stats['UveLoadbalancer']['pool_stats']
except Exception:
pool_stats = []
for pool_stat in pool_stats:
stats['bytes_in'] = str(int(stats['bytes_in']) + int(pool_stat['bytes_in']))
stats['bytes_out'] = str(int(stats['bytes_out']) + int(pool_stat['bytes_out']))
stats['active_connections'] = str(int(stats['active_connections']) + int(pool_stat['current_sessions']))
stats['total_connections'] = str(int(stats['total_connections']) + int(pool_stat['total_sessions']))
return {'stats': stats}
def create_pool_health_monitor(self, context, health_monitor, pool_id):
""" Associate an health monitor with a pool.
"""
m = health_monitor['health_monitor']
try:
pool = self._api.loadbalancer_pool_read(id=pool_id)
except vnc_exc.NoIdError:
raise loadbalancer.PoolNotFound(pool_id=pool_id)
try:
monitor = self._api.loadbalancer_healthmonitor_read(id=m['id'])
except vnc_exc.NoIdError:
raise loadbalancer.HealthMonitorNotFound(monitor_id=m['id'])
if not context.is_admin:
tenant_id = str(uuid.UUID(context.tenant_id))
if tenant_id != pool.parent_uuid or \
tenant_id != monitor.parent_uuid:
raise n_exc.NotAuthorized()
pool_refs = monitor.get_loadbalancer_pool_back_refs()
if pool_refs is not None:
for ref in pool_refs:
if ref['uuid'] == pool_id:
raise loadbalancer.PoolMonitorAssociationExists(
monitor_id=m['id'], pool_id=pool_id)
pool.add_loadbalancer_healthmonitor(monitor)
self._api.loadbalancer_pool_update(pool)
res = {
'id': monitor.uuid,
'tenant_id': monitor.parent_uuid.replace('-', '')
}
return res
def get_pool_health_monitor(self, context, id, pool_id, fields=None):
""" Query a specific pool, health_monitor association.
"""
try:
pool = self._api.loadbalancer_pool_read(id=pool_id)
except vnc_exc.NoIdError:
raise loadbalancer.PoolNotFound(pool_id=id)
示例3: LoadBalancerPluginDb
# 需要导入模块: from vnc_api.vnc_api import VncApi [as 别名]
# 或者: from vnc_api.vnc_api.VncApi import loadbalancer_healthmonitor_read [as 别名]
#.........这里部分代码省略.........
return self._vip_manager.update(context, id, vip)
def delete_vip(self, context, id):
return self._vip_manager.delete(context, id)
def get_pools(self, context, filters=None, fields=None):
return self._pool_manager.get_collection(context, filters, fields)
def get_pool(self, context, id, fields=None):
return self._pool_manager.get_resource(context, id, fields)
def create_pool(self, context, pool):
return self._pool_manager.create(context, pool)
def update_pool(self, context, id, pool):
return self._pool_manager.update(context, id, pool)
def delete_pool(self, context, id):
return self._pool_manager.delete(context, id)
def stats(self, context, pool_id):
pass
def create_pool_health_monitor(self, context, health_monitor, pool_id):
""" Associate an health monitor with a pool.
"""
m = health_monitor['health_monitor']
try:
pool = self._api.loadbalancer_pool_read(id=pool_id)
except NoIdError:
raise loadbalancer.PoolNotFound(pool_id=pool_id)
try:
monitor = self._api.loadbalancer_healthmonitor_read(id=m['id'])
except NoIdError:
raise loadbalancer.HealthMonitorNotFound(monitor_id=m['id'])
if not context.is_admin:
tenant_id = str(uuid.UUID(context.tenant_id))
if tenant_id != pool.parent_uuid or \
tenant_id != monitor.parent_uuid:
raise n_exc.NotAuthorized()
pool_refs = monitor.get_loadbalancer_pool_back_refs()
if pool_refs is not None:
for ref in pool_refs:
if ref['uuid'] == pool_id:
raise loadbalancer.PoolMonitorAssociationExists(
monitor_id=m['id'], pool_id=pool_id)
pool.add_loadbalancer_healthmonitor(monitor)
self._api.loadbalancer_pool_update(pool)
res = {
'id': monitor.uuid,
'tenant_id': monitor.parent_uuid.replace('-', '')
}
return res
def get_pool_health_monitor(self, context, id, pool_id, fields=None):
""" Query a specific pool, health_monitor association.
"""
try:
pool = self._api.loadbalancer_pool_read(id=pool_id)
except NoIdError:
raise loadbalancer.PoolNotFound(pool_id=id)
开发者ID:alfredcs,项目名称:Integrating-Docker-with-OpenStack-With-OpenContrail-For-SDN,代码行数:70,代码来源:loadbalancer_db.py