Coverage for nova/cmd/scheduler.py: 100%

25 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-17 15:08 +0000

1# Copyright 2010 United States Government as represented by the 

2# Administrator of the National Aeronautics and Space Administration. 

3# All Rights Reserved. 

4# 

5# Licensed under the Apache License, Version 2.0 (the "License"); you may 

6# not use this file except in compliance with the License. You may obtain 

7# a copy of the License at 

8# 

9# http://www.apache.org/licenses/LICENSE-2.0 

10# 

11# Unless required by applicable law or agreed to in writing, software 

12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

14# License for the specific language governing permissions and limitations 

15# under the License. 

16 

17"""Starter script for Nova Scheduler.""" 

18 

19import sys 

20 

21from oslo_concurrency import processutils 

22from oslo_log import log as logging 

23from oslo_reports import guru_meditation_report as gmr 

24from oslo_reports import opts as gmr_opts 

25 

26import nova.conf 

27from nova.conf import remote_debug 

28from nova import config 

29from nova import objects 

30from nova.scheduler import rpcapi 

31from nova import service 

32from nova import version 

33 

34CONF = nova.conf.CONF 

35remote_debug.register_cli_opts(CONF) 

36 

37 

38def main(): 

39 config.parse_args(sys.argv) 

40 logging.setup(CONF, "nova") 

41 objects.register_all() 

42 gmr_opts.set_defaults(CONF) 

43 objects.Service.enable_min_version_cache() 

44 

45 gmr.TextGuruMeditation.setup_autorun(version, conf=CONF) 

46 

47 server = service.Service.create( 

48 binary='nova-scheduler', topic=rpcapi.RPC_TOPIC) 

49 

50 # Determine the number of workers; if not specified in config, default 

51 # to number of CPUs 

52 workers = CONF.scheduler.workers or processutils.get_worker_count() 

53 service.serve(server, workers=workers) 

54 service.wait()