本文整理汇总了Python中cfgm_common.vnc_kombu.VncKombuClient类的典型用法代码示例。如果您正苦于以下问题:Python VncKombuClient类的具体用法?Python VncKombuClient怎么用?Python VncKombuClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VncKombuClient类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: establish
def establish(self):
q_name = '.'.join([self.q_name_prefix, socket.gethostname()])
self._vnc_kombu = VncKombuClient(
self._rabbitmq_cfg['servers'], self._rabbitmq_cfg['port'],
self._rabbitmq_cfg['user'], self._rabbitmq_cfg['password'],
self._rabbitmq_cfg['vhost'], self._rabbitmq_cfg['ha_mode'],
q_name, self._vnc_subscribe_callback,
self.logger.log, rabbit_use_ssl=self._rabbitmq_cfg['use_ssl'],
kombu_ssl_version=self._rabbitmq_cfg['ssl_version'],
kombu_ssl_keyfile=self._rabbitmq_cfg['ssl_keyfile'],
kombu_ssl_certfile=self._rabbitmq_cfg['ssl_certfile'],
kombu_ssl_ca_certs=self._rabbitmq_cfg['ssl_ca_certs'])
示例2: SchemaTransformer
#.........这里部分代码省略.........
node_type_name = NodeTypeNames[node_type]
instance_id = INSTANCE_ID_DEFAULT
hostname = socket.gethostname()
self._sandesh.init_generator(
module_name, hostname, node_type_name, instance_id,
self._args.collectors, 'to_bgp_context',
int(args.http_server_port),
['cfgm_common', 'schema_transformer.sandesh'], self._disc,
logger_class=args.logger_class,
logger_config_file=args.logging_conf)
self._sandesh.set_logging_params(enable_local_log=args.log_local,
category=args.log_category,
level=args.log_level,
file=args.log_file,
enable_syslog=args.use_syslog,
syslog_facility=args.syslog_facility)
ConnectionState.init(self._sandesh, hostname, module_name, instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
self._sandesh.trace_buffer_create(name="MessageBusNotifyTraceBuf",
size=1000)
rabbit_servers = self._args.rabbit_server
rabbit_port = self._args.rabbit_port
rabbit_user = self._args.rabbit_user
rabbit_password = self._args.rabbit_password
rabbit_vhost = self._args.rabbit_vhost
rabbit_ha_mode = self._args.rabbit_ha_mode
self._db_resync_done = gevent.event.Event()
q_name = 'schema_transformer.%s' % (socket.gethostname())
self._vnc_kombu = VncKombuClient(rabbit_servers, rabbit_port,
rabbit_user, rabbit_password,
rabbit_vhost, rabbit_ha_mode,
q_name, self._vnc_subscribe_callback,
self.config_log)
self._cassandra = SchemaTransformerDB(self, _zookeeper_client)
DBBaseST.init(self, self._sandesh.logger(), self._cassandra)
DBBaseST._sandesh = self._sandesh
DBBaseST._vnc_lib = _vnc_lib
ServiceChain.init()
self.reinit()
# create cpu_info object to send periodic updates
sysinfo_req = False
cpu_info = vnc_cpu_info.CpuInfo(
module_name, instance_id, sysinfo_req, self._sandesh, 60)
self._cpu_info = cpu_info
self._db_resync_done.set()
# end __init__
def config_log(self, msg, level):
self._sandesh.logger().log(SandeshLogger.get_py_logger_level(level),
msg)
def _vnc_subscribe_callback(self, oper_info):
self._db_resync_done.wait()
dependency_tracker = None
try:
msg = "Notification Message: %s" % (pformat(oper_info))
self.config_log(msg, level=SandeshLevel.SYS_DEBUG)
obj_type = oper_info['type'].replace('-', '_')
obj_class = DBBaseST.get_obj_type_map().get(obj_type)
if obj_class is None:
示例3: __init__
def __init__(self, args=None):
self._args = args
self._fabric_rt_inst_obj = None
# Initialize discovery client
self._disc = None
if self._args.disc_server_ip and self._args.disc_server_port:
self._disc = client.DiscoveryClient(
self._args.disc_server_ip,
self._args.disc_server_port,
ModuleNames[Module.SCHEMA_TRANSFORMER])
self._sandesh = Sandesh()
# Reset the sandesh send rate limit value
if args.sandesh_send_rate_limit is not None:
SandeshSystem.set_sandesh_send_rate_limit(
args.sandesh_send_rate_limit)
sandesh.VnList.handle_request = self.sandesh_vn_handle_request
sandesh.RoutintInstanceList.handle_request = \
self.sandesh_ri_handle_request
sandesh.ServiceChainList.handle_request = \
self.sandesh_sc_handle_request
sandesh.StObjectReq.handle_request = \
self.sandesh_st_object_handle_request
module = Module.SCHEMA_TRANSFORMER
module_name = ModuleNames[module]
node_type = Module2NodeType[module]
node_type_name = NodeTypeNames[node_type]
instance_id = INSTANCE_ID_DEFAULT
hostname = socket.gethostname()
self._sandesh.init_generator(
module_name, hostname, node_type_name, instance_id,
self._args.collectors, 'to_bgp_context',
int(args.http_server_port),
['cfgm_common', 'schema_transformer.sandesh'], self._disc,
logger_class=args.logger_class,
logger_config_file=args.logging_conf)
self._sandesh.set_logging_params(enable_local_log=args.log_local,
category=args.log_category,
level=args.log_level,
file=args.log_file,
enable_syslog=args.use_syslog,
syslog_facility=args.syslog_facility)
ConnectionState.init(self._sandesh, hostname, module_name, instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
self._sandesh.trace_buffer_create(name="MessageBusNotifyTraceBuf",
size=1000)
rabbit_servers = self._args.rabbit_server
rabbit_port = self._args.rabbit_port
rabbit_user = self._args.rabbit_user
rabbit_password = self._args.rabbit_password
rabbit_vhost = self._args.rabbit_vhost
rabbit_ha_mode = self._args.rabbit_ha_mode
self._db_resync_done = gevent.event.Event()
q_name = 'schema_transformer.%s' % (socket.gethostname())
self._vnc_kombu = VncKombuClient(rabbit_servers, rabbit_port,
rabbit_user, rabbit_password,
rabbit_vhost, rabbit_ha_mode,
q_name, self._vnc_subscribe_callback,
self.config_log)
self._cassandra = SchemaTransformerDB(self, _zookeeper_client)
DBBaseST.init(self, self._sandesh.logger(), self._cassandra)
DBBaseST._sandesh = self._sandesh
DBBaseST._vnc_lib = _vnc_lib
ServiceChain.init()
self.reinit()
# create cpu_info object to send periodic updates
sysinfo_req = False
cpu_info = vnc_cpu_info.CpuInfo(
module_name, instance_id, sysinfo_req, self._sandesh, 60)
self._cpu_info = cpu_info
self._db_resync_done.set()
示例4: DeviceManager
#.........这里部分代码省略.........
ConnectionState.init(
self._sandesh, hostname, module_name, instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
# Retry till API server is up
connected = False
self.connection_state_update(ConnectionStatus.INIT)
while not connected:
try:
self._vnc_lib = VncApi(
args.admin_user, args.admin_password,
args.admin_tenant_name, args.api_server_ip,
args.api_server_port, api_server_use_ssl=args.api_server_use_ssl)
connected = True
self.connection_state_update(ConnectionStatus.UP)
except requests.exceptions.ConnectionError as e:
# Update connection info
self.connection_state_update(ConnectionStatus.DOWN, str(e))
time.sleep(3)
except ResourceExhaustionError: # haproxy throws 503
time.sleep(3)
rabbit_servers = self._args.rabbit_server
rabbit_port = self._args.rabbit_port
rabbit_user = self._args.rabbit_user
rabbit_password = self._args.rabbit_password
rabbit_vhost = self._args.rabbit_vhost
rabbit_ha_mode = self._args.rabbit_ha_mode
self._db_resync_done = gevent.event.Event()
q_name = 'device_manager.%s' % (socket.gethostname())
self._vnc_kombu = VncKombuClient(rabbit_servers, rabbit_port,
rabbit_user, rabbit_password,
rabbit_vhost, rabbit_ha_mode,
q_name, self._vnc_subscribe_callback,
self.config_log)
self._cassandra = DMCassandraDB.getInstance(self)
DBBaseDM.init(self, self._sandesh.logger(), self._cassandra)
for obj in GlobalSystemConfigDM.list_obj():
GlobalSystemConfigDM.locate(obj['uuid'], obj)
for obj in GlobalVRouterConfigDM.list_obj():
GlobalVRouterConfigDM.locate(obj['uuid'], obj)
for obj in VirtualNetworkDM.list_obj():
vn = VirtualNetworkDM.locate(obj['uuid'], obj)
if vn is not None and vn.routing_instances is not None:
for ri_id in vn.routing_instances:
ri_obj = RoutingInstanceDM.locate(ri_id)
for obj in BgpRouterDM.list_obj():
BgpRouterDM.locate(obj['uuid'], obj)
pr_obj_list = PhysicalRouterDM.list_obj()
pr_uuid_set = set([pr_obj['uuid'] for pr_obj in pr_obj_list])
self._cassandra.handle_pr_deletes(pr_uuid_set)
for obj in pr_obj_list:
pr = PhysicalRouterDM.locate(obj['uuid'], obj)
li_set = pr.logical_interfaces
for pi_id in pr.physical_interfaces:
pi = PhysicalInterfaceDM.locate(pi_id)
示例5: __init__
def __init__(self, args=None):
self._args = args
# Initialize discovery client
self._disc = None
if self._args.disc_server_ip and self._args.disc_server_port:
self._disc = client.DiscoveryClient(
self._args.disc_server_ip,
self._args.disc_server_port,
ModuleNames[Module.DEVICE_MANAGER])
PushConfigState.set_repush_interval(int(self._args.repush_interval))
PushConfigState.set_repush_max_interval(int(self._args.repush_max_interval))
PushConfigState.set_push_delay_per_kb(float(self._args.push_delay_per_kb))
PushConfigState.set_push_delay_max(int(self._args.push_delay_max))
PushConfigState.set_push_delay_enable(bool(self._args.push_delay_enable))
self._sandesh = Sandesh()
# Reset the sandesh send rate limit value
if self._args.sandesh_send_rate_limit is not None:
SandeshSystem.set_sandesh_send_rate_limit( \
self._args.sandesh_send_rate_limit)
module = Module.DEVICE_MANAGER
module_name = ModuleNames[module]
node_type = Module2NodeType[module]
node_type_name = NodeTypeNames[node_type]
instance_id = INSTANCE_ID_DEFAULT
hostname = socket.gethostname()
self._sandesh.init_generator(
module_name, hostname, node_type_name, instance_id,
self._args.collectors, 'to_bgp_context',
int(args.http_server_port),
['cfgm_common', 'device_manager.sandesh'], self._disc)
self._sandesh.set_logging_params(enable_local_log=args.log_local,
category=args.log_category,
level=args.log_level,
file=args.log_file,
enable_syslog=args.use_syslog,
syslog_facility=args.syslog_facility)
PhysicalRouterDM._sandesh = self._sandesh
ConnectionState.init(
self._sandesh, hostname, module_name, instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
# Retry till API server is up
connected = False
self.connection_state_update(ConnectionStatus.INIT)
while not connected:
try:
self._vnc_lib = VncApi(
args.admin_user, args.admin_password,
args.admin_tenant_name, args.api_server_ip,
args.api_server_port, api_server_use_ssl=args.api_server_use_ssl)
connected = True
self.connection_state_update(ConnectionStatus.UP)
except requests.exceptions.ConnectionError as e:
# Update connection info
self.connection_state_update(ConnectionStatus.DOWN, str(e))
time.sleep(3)
except ResourceExhaustionError: # haproxy throws 503
time.sleep(3)
rabbit_servers = self._args.rabbit_server
rabbit_port = self._args.rabbit_port
rabbit_user = self._args.rabbit_user
rabbit_password = self._args.rabbit_password
rabbit_vhost = self._args.rabbit_vhost
rabbit_ha_mode = self._args.rabbit_ha_mode
self._db_resync_done = gevent.event.Event()
q_name = 'device_manager.%s' % (socket.gethostname())
self._vnc_kombu = VncKombuClient(rabbit_servers, rabbit_port,
rabbit_user, rabbit_password,
rabbit_vhost, rabbit_ha_mode,
q_name, self._vnc_subscribe_callback,
self.config_log)
self._cassandra = DMCassandraDB.getInstance(self)
DBBaseDM.init(self, self._sandesh.logger(), self._cassandra)
for obj in GlobalSystemConfigDM.list_obj():
GlobalSystemConfigDM.locate(obj['uuid'], obj)
for obj in GlobalVRouterConfigDM.list_obj():
GlobalVRouterConfigDM.locate(obj['uuid'], obj)
for obj in VirtualNetworkDM.list_obj():
vn = VirtualNetworkDM.locate(obj['uuid'], obj)
if vn is not None and vn.routing_instances is not None:
for ri_id in vn.routing_instances:
ri_obj = RoutingInstanceDM.locate(ri_id)
for obj in BgpRouterDM.list_obj():
BgpRouterDM.locate(obj['uuid'], obj)
pr_obj_list = PhysicalRouterDM.list_obj()
pr_uuid_set = set([pr_obj['uuid'] for pr_obj in pr_obj_list])
self._cassandra.handle_pr_deletes(pr_uuid_set)
#.........这里部分代码省略.........
示例6: VncAmqpHandle
class VncAmqpHandle(object):
def __init__(self, sandesh, logger, db_cls, reaction_map, q_name_prefix,
rabbitmq_cfg, trace_file=None):
self.sandesh = sandesh
self.logger = logger
self.db_cls = db_cls
self.reaction_map = reaction_map
self.q_name_prefix = q_name_prefix
self._db_resync_done = gevent.event.Event()
self._rabbitmq_cfg = rabbitmq_cfg
self._trace_file = trace_file
def establish(self):
q_name = '.'.join([self.q_name_prefix, socket.gethostname()])
self._vnc_kombu = VncKombuClient(
self._rabbitmq_cfg['servers'], self._rabbitmq_cfg['port'],
self._rabbitmq_cfg['user'], self._rabbitmq_cfg['password'],
self._rabbitmq_cfg['vhost'], self._rabbitmq_cfg['ha_mode'],
q_name, self._vnc_subscribe_callback,
self.logger.log, rabbit_use_ssl=self._rabbitmq_cfg['use_ssl'],
kombu_ssl_version=self._rabbitmq_cfg['ssl_version'],
kombu_ssl_keyfile=self._rabbitmq_cfg['ssl_keyfile'],
kombu_ssl_certfile=self._rabbitmq_cfg['ssl_certfile'],
kombu_ssl_ca_certs=self._rabbitmq_cfg['ssl_ca_certs'])
def msgbus_store_err_msg(self, msg):
self.msg_tracer.error = msg
def msgbus_trace_msg(self):
self.msg_tracer.trace_msg(name='MessageBusNotifyTraceBuf',
sandesh=self.sandesh)
def log_exception(self):
string_buf = cStringIO.StringIO()
cgitb_hook(file=string_buf, format="text")
self.logger.error(string_buf.getvalue())
self.msgbus_store_err_msg(string_buf.getvalue())
if not self._trace_file:
return
try:
with open(self._trace_file, 'a') as err_file:
err_file.write(string_buf.getvalue())
except IOError:
pass
def _vnc_subscribe_callback(self, oper_info):
self._db_resync_done.wait()
try:
self.oper_info = oper_info
self.vnc_subscribe_actions()
except ConnectionError:
try:
# retry write during api-server ConnectionError
self.vnc_subscribe_actions()
except ConnectionError:
# log the exception, and exit during api-server
# ConnectionError on retry to let standby to become active.
self.log_exception()
self.logger.error("Api-server connection lost. Exiting")
self.close()
raise SystemExit
except Exception:
self.log_exception()
except Exception:
self.log_exception()
finally:
try:
self.msgbus_trace_msg()
except Exception:
pass
del self.oper_info
del self.obj_type
del self.obj_class
del self.obj
del self.dependency_tracker
def create_msgbus_trace(self, request_id, oper, uuid):
self.msg_tracer = MessageBusNotifyTrace(request_id=request_id,
operation=oper, uuid=uuid)
def vnc_subscribe_actions(self):
msg = "Notification Message: %s" % (pformat(self.oper_info))
self.logger.debug(msg)
self.obj = None
self.dependency_tracker = None
self.obj_type = self.oper_info['type'].replace('-', '_')
self.obj_class = self.db_cls.get_obj_type_map().get(self.obj_type)
if self.obj_class is None:
return
oper = self.oper_info['oper']
obj_id = self.oper_info['uuid']
self.create_msgbus_trace(self.oper_info.get('request_id'),
oper, obj_id)
if oper == 'CREATE':
self.handle_create()
elif oper == 'UPDATE':
#.........这里部分代码省略.........