本文整理匯總了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