def __test_foo(): add_config_file('/etc/e3net/e3vswitch.ini') load_configs() logger = get_e3loger('e3vswitch') logger.info('hello world') logger.debug('hello debugging foo') logger1 = get_e3loger('e3vswitch1') logger1.info('hello world1')
def main(): import sys assert (len(sys.argv) == 2) add_config_file(sys.argv[1]) load_configs() e3neta_config_init() e3neta_db_init() from e3net.e3neta.e3neta_agent_ops import e3neta_agent_connect e3neta_agent_connect() grpc_server_init()
def main(): #initialize config as the 1st step add_config_file('/etc/e3net/e3vswitch-standalone.ini') load_configs() #initilize database options DB_NAME = 'E3NET_VSWITCH' init_database( DB_NAME, 'mysql+pymysql://e3net:e3credientials@localhost/E3NET_VSWITCH', False) load_database() #initialize inventory e3inventory_base_init() #initialize taskflow taskflow_init() #initialize event notification event_init() #initialize grpc grpc_server_init()
finally: self.guard.read_unlock() def get_stub(address, port, service_name, auto_create = True): channel = get_channel(address, port, auto_create) assert (channel) write_locked = False try: stub = _get_stub(channel, service_name) if not stub and auto_create: channel.guard.write_lock() write_locked = True assert (service_name in stub_inventory) stub = stub_inventory[service_name](channel.channel) channel.stubs[service_name] = stub channel.guard.write_unlock() write_locked = False stub = _get_stub(channel, service_name) if not stub: raise e3_exception(E3_EXCEPTION_NOT_FOUND) return stub finally: if write_locked: channel.guard.write_unlock() if __name__ == '__main__': from e3net.common.e3config import add_config_file from e3net.common.e3config import load_configs add_config_file('/etc/e3net/e3vswitch.ini') load_configs() print(get_stub('130.140.150.2',9418,'vswitch_host')) print(get_channel('130.140.150.2',9418))