def main(): # Setup flags config.parse_args(sys.argv) if CONF.ssl_only and not os.path.exists(CONF.cert): print("SSL only and %s not found." % CONF.cert) return(-1) # Check to see if spice html/js/css files are present if not os.path.exists(CONF.web): print("Can not find spice html/js/css files at %s." % CONF.web) return(-1) gmr.TextGuruMeditation.setup_autorun(version) # Create and start the NovaWebSockets proxy server = websocketproxy.NovaWebSocketProxy( listen_host=CONF.spice.html5proxy_host, listen_port=CONF.spice.html5proxy_port, source_is_ipv6=CONF.source_is_ipv6, verbose=CONF.verbose, cert=CONF.cert, key=CONF.key, ssl_only=CONF.ssl_only, daemon=CONF.daemon, record=CONF.record, web=CONF.web, target_host='ignore', target_port='ignore', wrap_mode='exit', wrap_cmd=None) server.start_server()
def setUp(self): super(ConfFixture, self).setUp() self.conf.set_default('api_paste_config', paths.state_path_def('etc/nova/api-paste.ini')) self.conf.set_default('host', 'fake-mini') self.conf.set_default('compute_driver', 'nova.virt.fake.FakeDriver') self.conf.set_default('fake_network', True) self.conf.set_default('flat_network_bridge', 'br100') self.conf.set_default('floating_ip_dns_manager', 'nova.tests.utils.dns_manager') self.conf.set_default('instance_dns_manager', 'nova.tests.utils.dns_manager') self.conf.set_default('network_size', 8) self.conf.set_default('num_networks', 2) self.conf.set_default('rpc_backend', 'nova.openstack.common.rpc.impl_fake') self.conf.set_default('rpc_cast_timeout', 5) self.conf.set_default('rpc_response_timeout', 5) self.conf.set_default('connection', "sqlite://", group='database') self.conf.set_default('sqlite_synchronous', False) self.conf.set_default('use_ipv6', True) self.conf.set_default('verbose', True) self.conf.set_default('vlan_interface', 'eth0') config.parse_args([], default_config_files=[]) self.addCleanup(utils.cleanup_dns_managers) self.addCleanup(ipv6.api.reset_backend)
def main(): # Setup flags CONF = cfg.CONF CONF.register_cli_opts(opts) CONF.import_opt('debug', 'nova.openstack.common.log') config.parse_args(sys.argv) if CONF.ssl_only and not os.path.exists(CONF.cert): print "SSL only and %s not found." % CONF.cert return(-1) # Check to see if spice html/js/css files are present if not os.path.exists(CONF.web): print "Can not find spice html/js/css files at %s." % CONF.web return(-1) # Create and start the NovaWebSockets proxy server = websocketproxy.NovaWebSocketProxy( listen_host=CONF.spicehtml5proxy_host, listen_port=CONF.spicehtml5proxy_port, source_is_ipv6=CONF.source_is_ipv6, verbose=CONF.verbose, cert=CONF.cert, key=CONF.key, ssl_only=CONF.ssl_only, daemon=CONF.daemon, record=CONF.record, web=CONF.web, target_host='ignore', target_port='ignore', wrap_mode='exit', wrap_cmd=None) server.start_server()
def main(): config.parse_args(sys.argv,['novadbtest.conf']) logging.setup("novadbtest") procs = parepare_process() # start subprocess length = len(procs) for i in range(length): if i *100.0 % length == 0: sys.stdout.write(" %d%% subprocess have been started\r" % (i * 100.0 / length)) sys.stdout.flush() procs[i].start() print 'All %d subprocesses have been started' % length dummy = DummyService() dummy.start() signal.signal(signal.SIGTERM, _handle_signal) signal.signal(signal.SIGINT, _handle_signal) try: status = None dummy.wait() except SignalExit as exc: signame = {signal.SIGTERM: 'SIGTERM', signal.SIGINT: 'SIGINT'}[exc.signo] LOG.info('Caught %s, exiting', signame) status = exc.code for p in procs: p.terminate() except SystemExit as exc: status = exc.code finally: if rpc: rpc.cleanup() dummy.stop() return status
def start_fixture(self): # Set up stderr and stdout captures by directly driving the # existing nova fixtures that do that. This captures the # output that happens outside individual tests (for # example database migrations). self.standard_logging_fixture = fixtures.StandardLogging() self.standard_logging_fixture.setUp() self.output_stream_fixture = fixtures.OutputStreamCapture() self.output_stream_fixture.setUp() self.conf = CONF self.conf.set_override('auth_strategy', 'noauth2') # Be explicit about all three database connections to avoid # potential conflicts with config on disk. self.conf.set_override('connection', "sqlite://", group='database') self.conf.set_override('connection', "sqlite://", group='api_database') self.conf.set_override('connection', "sqlite://", group='placement_database') config.parse_args([], default_config_files=None, configure_db=False, init_rpc=False) # NOTE(cdent): api and main database are not used but we still need # to manage them to make the fixtures work correctly and not cause # conflicts with other tests in the same process. self.api_db_fixture = fixtures.Database('api') self.main_db_fixture = fixtures.Database('main') self.api_db_fixture.reset() self.main_db_fixture.reset() os.environ['RP_UUID'] = uuidutils.generate_uuid() os.environ['RP_NAME'] = uuidutils.generate_uuid()
def setUp(self): super(ConfFixture, self).setUp() # default group self.conf.set_default('compute_driver', 'fake.SmallFakeDriver') self.conf.set_default('fake_network', True) self.conf.set_default('flat_network_bridge', 'br100') self.conf.set_default('floating_ip_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('force_dhcp_release', False) self.conf.set_default('host', 'fake-mini') self.conf.set_default('instance_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('network_size', 8) self.conf.set_default('num_networks', 2) self.conf.set_default('periodic_enable', False) # TODO(sdague): this makes our project_id match 'fake' as well. # We should fix the tests to use real # UUIDs then drop this work around. self.conf.set_default('project_id_regex', '[0-9a-fk\-]+', 'osapi_v21') self.conf.set_default('use_ipv6', True) self.conf.set_default('vlan_interface', 'eth0') # api group self.conf.set_default('auth_strategy', 'noauth2', group='api') # api_database group self.conf.set_default('connection', "sqlite://", group='api_database') self.conf.set_default('sqlite_synchronous', False, group='api_database') # database group self.conf.set_default('connection', "sqlite://", group='database') self.conf.set_default('sqlite_synchronous', False, group='database') # key_manager group self.conf.set_default('api_class', 'nova.keymgr.conf_key_mgr.ConfKeyManager', group='key_manager') # wsgi group self.conf.set_default('api_paste_config', paths.state_path_def('etc/nova/api-paste.ini'), group='wsgi') # The functional tests run wsgi API services using fixtures and # eventlet and we want one connection per request so things don't # leak between requests from separate services in concurrently running # tests. self.conf.set_default('keep_alive', False, group="wsgi") # placement group self.conf.set_default('os_region_name', 'RegionOne', group='placement') config.parse_args([], default_config_files=[], configure_db=False, init_rpc=False) policy_opts.set_defaults(self.conf) self.addCleanup(utils.cleanup_dns_managers) self.addCleanup(ipv6.api.reset_backend)
def main(): # Setup flags CONF.set_default('web', '/usr/share/novnc') config.parse_args(sys.argv) if CONF.ssl_only and not os.path.exists(CONF.cert): print("SSL only and %s not found" % CONF.cert) return(-1) # Check to see if novnc html/js/css files are present if not os.path.exists(CONF.web): print("Can not find novnc html/js/css files at %s." % CONF.web) return(-1) # Create and start the NovaWebSockets proxy server = websocketproxy.NovaWebSocketProxy( listen_host=CONF.novncproxy_host, listen_port=CONF.novncproxy_port, source_is_ipv6=CONF.source_is_ipv6, verbose=CONF.verbose, cert=CONF.cert, key=CONF.key, ssl_only=CONF.ssl_only, daemon=CONF.daemon, record=CONF.record, web=CONF.web, target_host='ignore', target_port='ignore', wrap_mode='exit', wrap_cmd=None) server.start_server()
def setUp(self): super(ConfFixture, self).setUp() self.conf.set_default('api_paste_config', paths.state_path_def('etc/nova/api-paste.ini')) self.conf.set_default('host', 'fake-mini') self.conf.set_default('compute_driver', 'nova.virt.fake.SmallFakeDriver') self.conf.set_default('fake_network', True) self.conf.set_default('flat_network_bridge', 'br100') self.conf.set_default('floating_ip_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('instance_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('network_size', 8) self.conf.set_default('num_networks', 2) self.conf.set_default('use_ipv6', True) self.conf.set_default('vlan_interface', 'eth0') self.conf.set_default('auth_strategy', 'noauth2') config.parse_args([], default_config_files=[], configure_db=False) self.conf.set_default('connection', "sqlite://", group='database') self.conf.set_default('connection', "sqlite://", group='api_database') self.conf.set_default('sqlite_synchronous', False, group='database') self.conf.set_default('sqlite_synchronous', False, group='api_database') self.conf.set_default('fatal_exception_format_errors', True) self.conf.set_default('enabled', True, 'osapi_v21') self.conf.set_default('force_dhcp_release', False) self.conf.set_default('periodic_enable', False) policy_opts.set_defaults(self.conf) self.addCleanup(utils.cleanup_dns_managers) self.addCleanup(ipv6.api.reset_backend)
def main(): config.parse_args(sys.argv) logging.setup("nova") wsgi_server = xvp_proxy.get_wsgi_server() service.serve(wsgi_server) service.wait()
def main(): # Setup flags config.parse_args(sys.argv) if CONF.ssl_only and not os.path.exists(CONF.cert): print("SSL only and %s not found" % CONF.cert) return(-1) # Check to see if tty html/js/css files are present if not os.path.exists(CONF.web): print("Can not find serial terminal html/js/css files at %s." \ % CONF.web) sys.exit(-1) # Create and start the NovaWebSockets proxy server = websocketproxy.NovaWebSocketProxy( listen_host=CONF.serialproxy_host, listen_port=CONF.serialproxy_port, source_is_ipv6=CONF.source_is_ipv6, verbose=CONF.verbose, cert=CONF.cert, key=CONF.key, ssl_only=CONF.ssl_only, daemon=CONF.daemon, record=CONF.record, web=CONF.web, target_host='ignore', target_port='ignore', wrap_mode='exit', wrap_cmd=None, connect_info_validator=validate_connection) server.start_server()
def start_fixture(self): self.conf = CONF self.conf.set_override('auth_strategy', 'noauth2') # Be explicit about all three database connections to avoid # potential conflicts with config on disk. self.conf.set_override('connection', "sqlite://", group='database') self.conf.set_override('connection', "sqlite://", group='api_database') self.conf.set_override('connection', "sqlite://", group='placement_database') config.parse_args([], default_config_files=None, configure_db=False, init_rpc=False) self.placement_db_fixture = fixtures.Database('placement') # NOTE(cdent): api and main database are not used but we still need # to manage them to make the fixtures work correctly and not cause # conflicts with other tests in the same process. self.api_db_fixture = fixtures.Database('api') self.main_db_fixture = fixtures.Database('main') self.placement_db_fixture.reset() self.api_db_fixture.reset() self.main_db_fixture.reset() os.environ['RP_UUID'] = uuidutils.generate_uuid() os.environ['RP_NAME'] = uuidutils.generate_uuid()
def main(): config.parse_args(sys.argv) logging.setup(CONF, "nova") utils.monkey_patch() objects.register_all() if 'osapi_compute' in CONF.enabled_apis: # NOTE(mriedem): This is needed for caching the nova-compute service # version. objects.Service.enable_min_version_cache() log = logging.getLogger(__name__) gmr.TextGuruMeditation.setup_autorun(version) launcher = service.process_launcher() started = 0 for api in CONF.enabled_apis: should_use_ssl = api in CONF.enabled_ssl_apis try: server = service.WSGIService(api, use_ssl=should_use_ssl) launcher.launch_service(server, workers=server.workers or 1) started += 1 except exception.PasteAppNotFound as ex: log.warning("%s. ``enabled_apis`` includes bad values. " "Fix to remove this warning.", ex) if started == 0: log.error('No APIs were started. ' 'Check the enabled_apis config option.') sys.exit(1) launcher.wait()
def init_application(name): conf_files = _get_config_files() config.parse_args([], default_config_files=conf_files) logging.setup(CONF, "nova") try: _setup_service(CONF.host, name) except exception.ServiceTooOld as exc: return error_application(exc, name) service.setup_profiler(name, CONF.host) # dump conf at debug (log_options option comes from oslo.service) # FIXME(mriedem): This is gross but we don't have a public hook into # oslo.service to register these options, so we are doing it manually for # now; remove this when we have a hook method into oslo.service. CONF.register_opts(service_opts.service_opts) if CONF.log_options: CONF.log_opt_values( logging.getLogger(__name__), logging.DEBUG) conf = conf_files[0] return deploy.loadapp('config:%s' % conf, name=name)
def main(hosts): # not entirely sure what happens here, but once this is # run we have access to all the CONF keys/values config.parse_args([]) conductor_api = api.API() #ctxt = context.RequestContext(user_id="admin", project_id="admin", # is_admin=True) ctxt = context.get_admin_context() # can't filter by {'host': None} for whatever reason :-/ filters = {'vm_state': 'error'} if hosts == 'one': filters['host'] = api.CONF.host try: instances = conductor_api.instance_get_all_by_filters(ctxt, filters) except common.Timeout: print "status timeout" sys.exit(1) count = 0 for i in instances: # we skip these instances as they'll be accounted for when run from # the compute node if hosts == "all" and i['host'] is not None: continue count += 1 print "status success" print "metric error int32 %d" % count
def proxy(host, port): # Setup flags config.parse_args(sys.argv) if CONF.ssl_only and not os.path.exists(CONF.cert): exit_with_error("SSL only and %s not found" % CONF.cert) # Check to see if tty html/js/css files are present if CONF.web and not os.path.exists(CONF.web): exit_with_error("Can not find html/js files at %s." % CONF.web) logging.setup("nova") gmr.TextGuruMeditation.setup_autorun(version) # Create and start the NovaWebSockets proxy websocketproxy.NovaWebSocketProxy( listen_host=host, listen_port=port, source_is_ipv6=CONF.source_is_ipv6, verbose=CONF.verbose, cert=CONF.cert, key=CONF.key, ssl_only=CONF.ssl_only, daemon=CONF.daemon, record=CONF.record, traffic=CONF.verbose and not CONF.daemon, web=CONF.web, file_only=True, RequestHandlerClass=websocketproxy.NovaProxyRequestHandler ).start_server()
def main(): config.parse_args(sys.argv) logging.setup("nova") LOG = logging.getLogger('nova.virt.baremetal.deploy_helper') app = BareMetalDeploy() srv = simple_server.make_server('', 10000, app) srv.serve_forever()
def main(): """Parse environment and arguments and call the appropriate action.""" config.parse_args(sys.argv, default_config_files=jsonutils.loads(os.environ["CONFIG_FILE"])) logging.setup(CONF, "nova") global LOG LOG = logging.getLogger("nova.dhcpbridge") objects.register_all() if not CONF.conductor.use_local: block_db_access() objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI() else: LOG.warning(_LW("Conductor local mode is deprecated and will " "be removed in a subsequent release")) if CONF.action.name in ["add", "del", "old"]: LOG.debug( "Called '%(action)s' for mac '%(mac)s' with ip '%(ip)s'", {"action": CONF.action.name, "mac": CONF.action.mac, "ip": CONF.action.ip}, ) CONF.action.func(CONF.action.mac, CONF.action.ip) else: try: network_id = int(os.environ.get("NETWORK_ID")) except TypeError: LOG.error(_LE("Environment variable 'NETWORK_ID' must be set.")) return 1 print(init_leases(network_id)) rpc.cleanup()
def start_fixture(self): # Set up stderr and stdout captures by directly driving the # existing nova fixtures that do that. This captures the # output that happens outside individual tests (for # example database migrations). self.standard_logging_fixture = fixtures.StandardLogging() self.standard_logging_fixture.setUp() self.output_stream_fixture = fixtures.OutputStreamCapture() self.output_stream_fixture.setUp() # Filter ignorable warnings during test runs. self.warnings_fixture = fixtures.WarningsFixture() self.warnings_fixture.setUp() self.conf = CONF self.conf.set_override('auth_strategy', 'noauth2', group='api') # Be explicit about all three database connections to avoid # potential conflicts with config on disk. self.conf.set_override('connection', "sqlite://", group='database') self.conf.set_override('connection', "sqlite://", group='api_database') self.conf.set_override('connection', "sqlite://", group='placement_database') # Register CORS opts, but do not set config. This has the # effect of exercising the "don't use cors" path in # deploy.py. Without setting some config the group will not # be present. self.conf.register_opts(cors.CORS_OPTS, 'cors') # Make sure default_config_files is an empty list, not None. # If None /etc/nova/nova.conf is read and confuses results. config.parse_args([], default_config_files=[], configure_db=False, init_rpc=False) # NOTE(cdent): All three database fixtures need to be # managed for database handling to work and not cause # conflicts with other tests in the same process. self._reset_db_flags() self.placement_db_fixture = fixtures.Database('placement') self.api_db_fixture = fixtures.Database('api') self.main_db_fixture = fixtures.Database('main') self.placement_db_fixture.reset() self.api_db_fixture.reset() self.main_db_fixture.reset() # Do this now instead of waiting for the WSGI app to start so that # fixtures can have traits. deploy.update_database() os.environ['RP_UUID'] = uuidutils.generate_uuid() os.environ['RP_NAME'] = uuidutils.generate_uuid() os.environ['CUSTOM_RES_CLASS'] = 'CUSTOM_IRON_NFV' os.environ['PROJECT_ID'] = uuidutils.generate_uuid() os.environ['USER_ID'] = uuidutils.generate_uuid() os.environ['PROJECT_ID_ALT'] = uuidutils.generate_uuid() os.environ['USER_ID_ALT'] = uuidutils.generate_uuid() os.environ['INSTANCE_UUID'] = uuidutils.generate_uuid() os.environ['MIGRATION_UUID'] = uuidutils.generate_uuid() os.environ['CONSUMER_UUID'] = uuidutils.generate_uuid() os.environ['PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid() os.environ['ALT_PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid()
def main(): """Parse environment and arguments and call the appropriate action.""" try: config_file = os.environ['CONFIG_FILE'] except KeyError: config_file = os.environ['FLAGFILE'] config.parse_args(sys.argv, default_config_files=jsonutils.loads(config_file)) logging.setup("nova") global LOG LOG = logging.getLogger('nova.dhcpbridge') if CONF.action.name in ['add', 'del', 'old']: msg = (_("Called '%(action)s' for mac '%(mac)s' with ip '%(ip)s'") % {"action": CONF.action.name, "mac": CONF.action.mac, "ip": CONF.action.ip}) LOG.debug(msg) CONF.action.func(CONF.action.mac, CONF.action.ip) else: try: network_id = int(os.environ.get('NETWORK_ID')) except TypeError: LOG.error(_("Environment variable 'NETWORK_ID' must be set.")) return(1) print init_leases(network_id) rpc.cleanup()
def main(): config.parse_args(sys.argv) logging.setup("nova") utils.monkey_patch() server = service.WSGIService('osapi_compute') service.serve(server, workers=server.workers) service.wait()
def main(): config.parse_args(sys.argv) logging.setup("nova") utils.monkey_patch() server = s3server.get_wsgi_server() service.serve(server) service.wait()
def main(): config.parse_args(sys.argv) logging.setup("nova") utils.monkey_patch() server = service.WSGIService("ec2", max_url_len=16384) service.serve(server, workers=server.workers) service.wait()
def main(): # Setup flags config.parse_args(sys.argv) if CONF.ssl_only and not os.path.exists(CONF.cert): exit_with_error("SSL only and %s not found" % CONF.cert) logging.setup("nova") gmr.TextGuruMeditation.setup_autorun(version) # Create and start the NovaWebSockets proxy server = websocketproxy.NovaWebSocketProxy( listen_host=CONF.serial_console.serialproxy_host, listen_port=CONF.serial_console.serialproxy_port, source_is_ipv6=CONF.source_is_ipv6, verbose=CONF.verbose, cert=CONF.cert, key=CONF.key, ssl_only=CONF.ssl_only, daemon=CONF.daemon, record=CONF.record, traffic=CONF.verbose and not CONF.daemon, file_only=True, RequestHandlerClass=websocketproxy.NovaProxyRequestHandler) server.start_server()
def main(): config.parse_args(sys.argv) logging.setup("nova") server = service.Service.create(binary='nova-consoleauth', topic=CONF.consoleauth_topic) service.serve(server) service.wait()
def main(): config.parse_args(sys.argv) logging.setup("nova") utils.monkey_patch() server = service.Service.create(binary='nova-cert', topic=CONF.cert_topic) service.serve(server) service.wait()
def main(): # set default web flag option web = '/usr/share/nova-serial' #web = os.path.join(os.path.dirname(__file__), 'serialproxy_web') CONF.set_default('web', web) config.parse_args(sys.argv) proxyclient_address = CONF.serial_console.proxyclient_address if proxyclient_address == '0.0.0.0': # determine the correct host to connect to as the local address # of the interface with the best default route import subprocess, re command = "route -n | awk '/^0.0.0.0/{print $5 \" \" $8}'" prc = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) out, _ = prc.communicate() routes = [line.split(None, 1) for line in out.splitlines()] if routes: routes.sort(key=lambda metr_iface: int(metr_iface[0])) selected_iface = routes[0][1] command = "ifconfig %s" % selected_iface prc = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) out, _ = prc.communicate() outside_ip = re.search(r'inet (?:addr:)?([^\s]+)', out) if outside_ip: proxyclient_address = outside_ip.group(1) baseproxy.proxy( target_host=proxyclient_address, host=CONF.serial_console.serialproxy_host, port=CONF.serial_console.serialproxy_port)
def setUp(self): super(ConfFixture, self).setUp() self.conf.set_default("api_paste_config", paths.state_path_def("etc/nova/api-paste.ini")) self.conf.set_default("host", "fake-mini") self.conf.set_default("compute_driver", "nova.virt.fake.SmallFakeDriver") self.conf.set_default("fake_network", True) self.conf.set_default("flat_network_bridge", "br100") self.conf.set_default("floating_ip_dns_manager", "nova.tests.unit.utils.dns_manager") self.conf.set_default("instance_dns_manager", "nova.tests.unit.utils.dns_manager") self.conf.set_default("network_size", 8) self.conf.set_default("num_networks", 2) self.conf.set_default("use_ipv6", True) self.conf.set_default("vlan_interface", "eth0") self.conf.set_default("auth_strategy", "noauth2") config.parse_args([], default_config_files=[], configure_db=False) self.conf.set_default("connection", "sqlite://", group="database") self.conf.set_default("connection", "sqlite://", group="api_database") self.conf.set_default("sqlite_synchronous", False, group="database") self.conf.set_default("sqlite_synchronous", False, group="api_database") self.conf.set_default("fatal_exception_format_errors", True) self.conf.set_default("enabled", True, "osapi_v21") self.conf.set_default("force_dhcp_release", False) self.conf.set_default("periodic_enable", False) policy_opts.set_defaults(self.conf) self.addCleanup(utils.cleanup_dns_managers) self.addCleanup(ipv6.api.reset_backend)
def main(): """Parse options and call the appropriate class/method.""" CONF.register_cli_opt(category_opt) try: config.parse_args(sys.argv) logging.setup("nova") except cfg.ConfigFilesNotFoundError: cfgfile = CONF.config_file[-1] if CONF.config_file else None if cfgfile and not os.access(cfgfile, os.R_OK): st = os.stat(cfgfile) print(_("Could not read %s. Re-running with sudo") % cfgfile) try: os.execvp("sudo", ["sudo", "-u", "#%s" % st.st_uid] + sys.argv) except Exception: print(_("sudo failed, continuing as if nothing happened")) print(_("Please re-run nova-manage as root.")) return 2 objects.register_all() if CONF.category.name == "version": print(version.version_string_with_package()) return 0 if CONF.category.name == "bash-completion": if not CONF.category.query_category: print(" ".join(CATEGORIES.keys())) elif CONF.category.query_category in CATEGORIES: fn = CATEGORIES[CONF.category.query_category] command_object = fn() actions = methods_of(command_object) print(" ".join([k for (k, v) in actions])) return 0 fn = CONF.category.action_fn fn_args = [arg.decode("utf-8") for arg in CONF.category.action_args] fn_kwargs = {} for k in CONF.category.action_kwargs: v = getattr(CONF.category, "action_kwarg_" + k) if v is None: continue if isinstance(v, six.string_types): v = v.decode("utf-8") fn_kwargs[k] = v # call the action with the remaining arguments # check arguments try: cliutils.validate_args(fn, *fn_args, **fn_kwargs) except cliutils.MissingArgs as e: print(fn.__doc__) print(e) return 1 try: fn(*fn_args, **fn_kwargs) return 0 except Exception: print(_("Command failed, please check log for more info")) raise
def main(): # Setup flags CONF.set_default('web', '/usr/share/novnc') config.parse_args(sys.argv) logging.setup("nova") if CONF.ssl_only and not os.path.exists(CONF.cert): print("SSL only and %s not found" % CONF.cert) return(-1) # Check to see if novnc html/js/css files are present if not os.path.exists(CONF.web): print("Can not find novnc html/js/css files at %s." % CONF.web) return(-1) logging.setup("nova") gmr.TextGuruMeditation.setup_autorun(version) # Create and start the NovaWebSockets proxy server = websocketproxy.NovaWebSocketProxy( listen_host=CONF.novncproxy_host, listen_port=CONF.novncproxy_port, source_is_ipv6=CONF.source_is_ipv6, verbose=CONF.verbose, cert=CONF.cert, key=CONF.key, ssl_only=CONF.ssl_only, daemon=CONF.daemon, record=CONF.record, traffic=CONF.verbose and not CONF.daemon, web=CONF.web, file_only=True, RequestHandlerClass=websocketproxy.NovaProxyRequestHandler) server.start_server()
def main(): """Parse environment and arguments and call the appropriate action.""" config.parse_args(sys.argv, default_config_files=jsonutils.loads(os.environ['CONFIG_FILE'])) logging.setup("nova") global LOG LOG = logging.getLogger('nova.dhcpbridge') objects.register_all() if not CONF.conductor.use_local: block_db_access() objects_base.NovaObject.indirection_api = \ conductor_rpcapi.ConductorAPI() if CONF.action.name in ['add', 'del', 'old']: msg = (_("Called '%(action)s' for mac '%(mac)s' with ip '%(ip)s'") % {"action": CONF.action.name, "mac": CONF.action.mac, "ip": CONF.action.ip}) LOG.debug(msg) CONF.action.func(CONF.action.mac, CONF.action.ip) else: try: network_id = int(os.environ.get('NETWORK_ID')) except TypeError: LOG.error(_("Environment variable 'NETWORK_ID' must be set.")) return(1) print(init_leases(network_id)) rpc.cleanup()
def test_parse_args_glance_debug_true(self, register_options): self.flags(debug=True, group='glance') config.parse_args([], configure_db=True, init_rpc=False) self.assertIn('glanceclient=DEBUG', config.CONF.default_log_levels) self.nova_db_config_mock.assert_called_once_with(config.CONF)
def __init__(self): super(NovaProject, self).__init__() self.conf = nova.conf.CONF config.parse_args([]) objects.register_all()
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """WSGI script for Placement API WSGI handler for running Placement API under Apache2, nginx, gunicorn etc. """ from nova.api.openstack.placement import deploy from nova import conf from nova import config CONFIG_FILE = '/etc/nova/nova.conf' config.parse_args([], default_config_files=[CONFIG_FILE]) application = deploy.loadapp(conf.CONF)
from oslo_log import log as logging import hastack.has.conf as ha_conf from nova import config from nova import objects import hastack.openstack.openstack_utils as openstack_utils from hastack.openstack.openstack_api.api import ComputeAPI from nova.objects import instance as instance_obj LOG = logging.getLogger(__name__) CONF = ha_conf.CONF argv = [] default_config_files = ['/etc/nova/nova.conf'] config.parse_args(argv, default_config_files=default_config_files) objects.register_all() ctxt = openstack_utils.create_context() INSTANCE_DEFAULT_FIELDS = instance_obj.INSTANCE_DEFAULT_FIELDS inst_id = '8c9f2873-cf42-4df0-99c0-c7ac41fa3313' host = 'test-compute2' compute_api = ComputeAPI() inst = compute_api.get_instance_by_uuid(ctxt, inst_id, expected_attrs=INSTANCE_DEFAULT_FIELDS) compute_api.evacuate(ctxt.elevated(), inst, host, True) from nova import compute compute_api = compute.API() compute_api.evacuate(ctxt.elevated(), inst, host, True,force=False)
def test_parse_args_glance_debug_false(self, register_options): self.flags(debug=False, group='glance') config.parse_args([], configure_db=False, init_rpc=False) self.assertIn('glanceclient=WARN', config.CONF.default_log_levels) self.nova_db_config_mock.assert_not_called()
(b) Heck no (c) Definitely not (d) All of the above """ from oslo_config import cfg from oslo_log import log as logging from paste import deploy from nova import config from nova import objects from nova import service # noqa from nova import utils CONF = cfg.CONF config_files = ['/etc/nova/api-paste.ini', '/etc/nova/nova.conf'] config.parse_args([], default_config_files=config_files) logging.setup(CONF, "nova") utils.monkey_patch() objects.register_all() conf = config_files[0] name = "osapi_compute" options = deploy.appconfig('config:%s' % conf, name=name) application = deploy.loadapp('config:%s' % conf, name=name)
def setUp(self): super(ConfFixture, self).setUp() # default group self.conf.set_default('compute_driver', 'fake.SmallFakeDriver') self.conf.set_default('fake_network', True) self.conf.set_default('flat_network_bridge', 'br100') self.conf.set_default('floating_ip_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('force_dhcp_release', False) self.conf.set_default('host', 'fake-mini') self.conf.set_default('instance_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('network_size', 8) self.conf.set_default('num_networks', 2) self.conf.set_default('periodic_enable', False) # TODO(sdague): this makes our project_id match 'fake' as well. # We should fix the tests to use real # UUIDs then drop this work around. self.conf.set_default('project_id_regex', '[0-9a-fk-]+', 'osapi_v21') self.conf.set_default('use_ipv6', True) self.conf.set_default('vlan_interface', 'eth0') # api group self.conf.set_default('auth_strategy', 'noauth2', group='api') # api_database group self.conf.set_default('connection', "sqlite://", group='api_database') self.conf.set_default('sqlite_synchronous', False, group='api_database') # database group self.conf.set_default('connection', "sqlite://", group='database') self.conf.set_default('sqlite_synchronous', False, group='database') # key_manager group self.conf.set_default('backend', 'nova.keymgr.conf_key_mgr.ConfKeyManager', group='key_manager') # wsgi group self.conf.set_default('api_paste_config', paths.state_path_def('etc/nova/api-paste.ini'), group='wsgi') # The functional tests run wsgi API services using fixtures and # eventlet and we want one connection per request so things don't # leak between requests from separate services in concurrently running # tests. self.conf.set_default('keep_alive', False, group="wsgi") # many tests synchronizes on the reception of versioned notifications self.conf.set_default('notification_format', "both", group="notifications") config.parse_args([], default_config_files=[], configure_db=False, init_rpc=False) policy_opts.set_defaults(self.conf) neutron.register_dynamic_opts(self.conf) self.addCleanup(utils.cleanup_dns_managers) self.addCleanup(ipv6.api.reset_backend)
def main(): """Parse options and call the appropriate class/method.""" CONF.register_cli_opt(category_opt) try: config.parse_args(sys.argv) logging.setup("nova") except cfg.ConfigFilesNotFoundError: cfgfile = CONF.config_file[-1] if CONF.config_file else None if cfgfile and not os.access(cfgfile, os.R_OK): st = os.stat(cfgfile) print(_("Could not read %s. Re-running with sudo") % cfgfile) try: os.execvp('sudo', ['sudo', '-u', '#%s' % st.st_uid] + sys.argv) except Exception: print(_('sudo failed, continuing as if nothing happened')) print(_('Please re-run nova-manage as root.')) return (2) objects.register_all() if CONF.category.name == "version": print(version.version_string_with_package()) return (0) if CONF.category.name == "bash-completion": if not CONF.category.query_category: print(" ".join(CATEGORIES.keys())) elif CONF.category.query_category in CATEGORIES: fn = CATEGORIES[CONF.category.query_category] command_object = fn() actions = methods_of(command_object) print(" ".join([k for (k, v) in actions])) return (0) fn = CONF.category.action_fn fn_args = [arg.decode('utf-8') for arg in CONF.category.action_args] fn_kwargs = {} for k in CONF.category.action_kwargs: v = getattr(CONF.category, 'action_kwarg_' + k) if v is None: continue if isinstance(v, six.string_types): v = v.decode('utf-8') fn_kwargs[k] = v # call the action with the remaining arguments # check arguments try: cliutils.validate_args(fn, *fn_args, **fn_kwargs) except cliutils.MissingArgs as e: # NOTE(mikal): this isn't the most helpful error message ever. It is # long, and tells you a lot of things you probably don't want to know # if you just got a single arg wrong. print(fn.__doc__) CONF.print_help() print(e) return (1) try: ret = fn(*fn_args, **fn_kwargs) rpc.cleanup() return (ret) except Exception: print(_("Command failed, please check log for more info")) raise
from oslo_config import cfg from nova import config CONF = cfg.CONF config.parse_args(["/usr/bin/nova-compute"]) config_files = " --config-file=".join([""] + CONF['config_file']).strip() print config_files