def configure(config_files): group = cfg.OptGroup(name='test', title='group for test') args = None CONF(args=args, project=group.name, default_config_files=config_files) CONF.register_group(group) logging.setup(CONF, group.name) defalut_logging.captureWarnings(True)
def configure(version=None, config_files=None): base_config.configure() CONF(project=fmclient_group.name, version=version, default_config_files=config_files) CONF.register_group(fmclient_group) logging.setup(CONF, fmclient_group.name) default_logging.captureWarnings(True) CONF.register_opts(filemanager_opts, group=fmclient_group)
def configure(name, config_files, config_dirs=None): group = cfg.OptGroup(name=name, title='group of goperation %s' % name) args = None if config_dirs is not None: args = [] if isinstance(config_dirs, basestring): config_dirs = [ config_dirs, ] for _dir in config_dirs: args.extend(['--config-dir', _dir]) if isinstance(config_files, basestring): config_files = [ config_files, ] # set default of goperation set_all_default() service_config.set_default_for_default_log_levels([]) # call cli opts before CONF init service_config.cliopts() CONF(args=args, project=group.name, default_config_files=config_files) CONF.register_group(group) # set base config service_config.configure() # reg base opts CONF.register_opts(service_base_opts) # set log config logging.setup(CONF, group.name) default_logging.captureWarnings(True) if systemutils.LINUX: if not CONF.repo: raise RuntimeError('rpm repo is not set') repofile = '/etc/yum.repos.d/goputil.repo' cf = ConfigParser.ConfigParser() if not os.path.exists(repofile): cf.add_section('goputil') cf.set('goputil', 'name', 'Goperation util rpm source') cf.set('goputil', 'baseurl', CONF.repo) cf.set('goputil', 'enabled', '1') cf.set('goputil', 'gpgcheck', '0') with open(repofile, 'wb') as f: cf.write(f) else: cf.read(repofile) if cf.get('goputil', 'baseurl') != CONF.repo: cf.set('goputil', 'baseurl', CONF.repo) with open(repofile, 'wb') as f: cf.write(f) return group
def configure(version=None, config_files=None): base_config.configure() base_config.set_default_for_default_log_levels([ 'routes=INFO', ]) CONF(project=center_group.name, version=version, default_config_files=config_files) CONF.register_group(center_group) logging.setup(CONF, center_group.name) default_logging.captureWarnings(True) CONF.register_opts(wsgi_options, group=center_group) # 确认paste_deploy配置文件 if not CONF[center_group.name].paste_config: LOG.critical('Paste config file not exist') if not os.path.isabs(CONF[center_group.name].paste_config): paste_config = CONF.find_file(CONF[center_group.name].paste_config) else: paste_config = CONF[center_group.name].paste_config return paste_config
from simpleservice.rpc.service import LauncheRpcServiceBase from simpleservice.server import ServerWrapper from simpleservice.server import launch from simpleutil.config import cfg from simpleutil.log import log as logging from simpleservice.rpc.target import Target CONF = cfg.CONF LOG = logging.getLogger(__name__) config_file = 'C:\\Users\\loliz_000\\Desktop\\etc\\agent.conf' config_files = [ config_file, ] # config.set_default_for_default_log_levels(['routes=INFO', ]) CONF(project='agent', default_config_files=config_files) config.configure() agent_group = cfg.OptGroup(name='agent', title='agent options') CONF.register_group(agent_group) logging.setup(CONF, 'agent') default_logging.captureWarnings(True) servers = [] manager = base.ManagerBase(Target(topic='agent', namespace='manager')) rpc_server = LauncheRpcServiceBase(manager) wsgi_wrapper = ServerWrapper(rpc_server, workers=1) servers.append(wsgi_wrapper) launch(servers)
from simpleutil.config import cfg from simpleutil.log import log as logging CONF = cfg.CONF LOG = logging.getLogger(__name__) config_file = 'C:\\Users\\loliz_000\\Desktop\\etc\\agent.conf' config_files=[config_file, ] # config.set_default_for_default_log_levels(['routes=INFO', ]) CONF(project='rpclient', default_config_files=config_files) config.configure() # agent_group = cfg.OptGroup(name='agent', title='agent options') # CONF.register_group(agent_group) logging.setup(CONF, 'rpclient') default_logging.captureWarnings(True) client = RPCClientBase(CONF['rabbit']) target = Target(namespace='manager', topic='agent') # ret = client.cast(target, {'request_id':'f**k'}, {'method':'show', 'args':{'data':[1,2,3,4,56]}}) ret = client.call(target, {'request_id':'f**k'}, {'method':'show', 'args':{'data':[1,2,3,4,56]}}, timeout=0.5) print ret