def issu_prepare(self): self._logger( "Issu contrail cassandra prepare...", level=SandeshLevel.SYS_INFO, ) for issu_func, ks, cflist in self._issu_info: if issu_func is None: issu_func = self._issu_basic_function ks_issu_func_info = {ks: issu_func} nks = {ks: cflist} oks = {ks: cflist} self._nkeyspaces.update(nks) self._okeyspaces.update(oks) self._ks_issu_func_info.update(ks_issu_func_info) self._oldversion_handle = VncCassandraClient( self._oldversion_server_list, self._odb_prefix, None, self._okeyspaces, self._logger, credential=self._old_creds) self._newversion_handle = VncCassandraClient( self._newversion_server_list, self._ndb_prefix, self._nkeyspaces, None, self._logger, credential=self._new_creds)
def init_cassandra(self, ks_cf_info=None): ssl_enabled = (self._api_args.cassandra_use_ssl if 'cassandra_use_ssl' in self._api_args else False) try: self._cassandra = VncCassandraClient( self._api_args.cassandra_server_list, self._api_args.cluster_id, rw_keyspaces=ks_cf_info, ro_keyspaces=None, logger=self.log, reset_config=False, ssl_enabled=self._api_args.cassandra_use_ssl, ca_certs=self._api_args.cassandra_ca_certs) except NotFoundException: # in certain multi-node setup, keyspace/CF are not ready yet when # we connect to them, retry later gevent.sleep(20) self._cassandra = VncCassandraClient( self._api_args.cassandra_server_list, self._api_args.cluster_id, rw_keyspaces=ks_cf_info, ro_keyspaces=None, logger=self.log, reset_config=False, ssl_enabled=self._api_args.cassandra_use_ssl, ca_certs=self._api_args.cassandra_ca_certs) try: self._get_cf = self._cassandra._cassandra_driver.get_cf except AttributeError: # backward conpat before R2002 self._get_cf = self._cassandra.get_cf
def __init__(self, force, resources_file, cassandra_servers, cassandra_username, cassandra_password, db_prefix, cassandra_batch_size, zookeeper_servers, rules_per_security_group, keystone_client): self._force = force self._resource_distribution = yaml.load(resources_file) self._cassandra_batch_size = cassandra_batch_size self._rules_per_security_group = rules_per_security_group self._keystone_client = keystone_client # Connect to cassandra database logger.debug("Initilizing the cassandra connection on %s", cassandra_servers) cassandra_credentials = {} if (cassandra_username is not None and cassandra_password is not None): cassandra_credentials = { 'username': cassandra_username, 'password': cassandra_password, } def vnc_cassandra_client_logger(msg, level=logging.INFO): logger.log(msg=msg, level=level) self._cassandra_db = VncCassandraClient( cassandra_servers, db_prefix, self._UUID_KEYSPACE, None, vnc_cassandra_client_logger, credential=cassandra_credentials) self._uuid_cf = self._cassandra_db.get_cf('obj_uuid_table') self._fqname_cf = self._cassandra_db.get_cf('obj_fq_name_table') # Initilize zookeeper client self._zk_client = ZookeeperClient(zookeeper_servers)
def init_cassandra(self, ks_cf_info=None): self._cassandra = VncCassandraClient( self._api_args.cassandra_server_list, self._api_args.cluster_id, rw_keyspaces=ks_cf_info, ro_keyspaces=None, logger=self.log, reset_config=False, ssl_enabled=self._api_args.cassandra_use_ssl, ca_certs=self._api_args.cassandra_ca_certs)
def __init__(self, args_str): self._parse_args(args_str) self._cassandra = VncCassandraClient( self._api_args.cassandra_server_list, False, self._api_args.cluster_id, None, logger=self.log) self._zookeeper = kazoo.client.KazooClient(self._api_args.zk_server_ip) self._zookeeper.start()
def issu_prepare(self): self._logger( "Issu contrail cassandra prepare...", level=SandeshLevel.SYS_INFO, ) for issu_func, ks, cflist in self._issu_info: if issu_func is None: issu_func = self._issu_basic_function ks_issu_func_info = {ks: issu_func} nks = {ks: cflist} oks = {ks: cflist} self._nkeyspaces.update(nks) self._okeyspaces.update(oks) self._ks_issu_func_info.update(ks_issu_func_info) self._oldversion_handle = VncCassandraClient( self._oldversion_server_list, cassandra_driver='thrift', db_prefix=self._odb_prefix, ro_keyspaces=self._okeyspaces, logger=self._logger, credential=self._old_creds, ssl_enabled=self._odb_use_ssl, ca_certs=self._odb_ca_certs) self._newversion_handle = VncCassandraClient( self._newversion_server_list, cassandra_driver='thrift', db_prefix=self._ndb_prefix, rw_keyspaces=self._nkeyspaces, logger=self._logger, credential=self._new_creds, ssl_enabled=self._ndb_use_ssl, ca_certs=self._ndb_ca_certs)
def _connect_rabbit(self): rabbit_server = 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 = 'svc_mon.%s' % (socket.gethostname()) self._vnc_kombu = VncKombuClient(rabbit_server, rabbit_port, rabbit_user, rabbit_password, rabbit_vhost, rabbit_ha_mode, q_name, self._vnc_subscribe_callback, self.config_log) cass_server_list = self._args.cassandra_server_list reset_config = self._args.reset_config self._cassandra = VncCassandraClient(cass_server_list, reset_config, self._args.cluster_id, None, self.config_log) DBBase.init(self, self.logger, self._cassandra)
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]) self._sandesh = Sandesh() 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) 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) 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) cass_server_list = self._args.cassandra_server_list reset_config = self._args.reset_config self._cassandra = VncCassandraClient(cass_server_list, reset_config, self._args.cluster_id, None, self.config_log) DBBase.init(self, self._sandesh.logger(), self._cassandra) ok, global_system_config_list = self._cassandra._cassandra_global_system_config_list( ) if not ok: self.config_log('global system config list returned error: %s' % global_system_config_list) else: for fq_name, uuid in global_system_config_list: GlobalSystemConfigDM.locate(uuid) ok, vn_list = self._cassandra._cassandra_virtual_network_list() if not ok: self.config_log('virtual network list returned error: %s' % vn_list) else: for fq_name, uuid in vn_list: vn = VirtualNetworkDM.locate(uuid) 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) ok, bgp_list = self._cassandra._cassandra_bgp_router_list() if not ok: self.config_log('bgp router list returned error: %s' % bgp_list) else: for fq_name, uuid in bgp_list: BgpRouterDM.locate(uuid) ok, pr_list = self._cassandra._cassandra_physical_router_list() if not ok: self.config_log('physical router list returned error: %s' % pr_list) else: for fq_name, uuid in pr_list: pr = PhysicalRouterDM.locate(uuid) if pr.bgp_router: BgpRouterDM.locate(pr.bgp_router) li_set = pr.logical_interfaces for pi_id in pr.physical_interfaces: pi = PhysicalInterfaceDM.locate(pi_id) if pi: li_set |= pi.logical_interfaces vmi_set = set() for li_id in li_set: li = LogicalInterfaceDM.locate(li_id) if li and li.virtual_machine_interface: vmi_set |= set([li.virtual_machine_interface]) for vmi_id in vmi_set: vmi = VirtualMachineInterfaceDM.locate(vmi_id) for pr in PhysicalRouterDM.values(): pr.push_config() self._db_resync_done.set() while 1: # Just wait indefinitely time.sleep(5)