From af556495d055e83a5d315d8018e6a8e91a65c68a Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Tue, 5 May 2015 12:17:11 +0800 Subject: [PATCH] Fix config items in project Fix some bug in config.py and remote some useless format transformation. Change-Id: Ice5a52523fe594436f299278b77ccfa8083ca034 --- ...eat.conf.sample => terracotta.conf.sample} | 159 +++++++++--------- terracotta/config.py | 20 +-- terracotta/globals/manager.py | 16 +- terracotta/locals/collector.py | 6 +- terracotta/locals/manager.py | 6 +- 5 files changed, 108 insertions(+), 99 deletions(-) rename etc/{neat.conf.sample => terracotta.conf.sample} (72%) diff --git a/etc/neat.conf.sample b/etc/terracotta.conf.sample similarity index 72% rename from etc/neat.conf.sample rename to etc/terracotta.conf.sample index 87ae641..e9eca4e 100644 --- a/etc/neat.conf.sample +++ b/etc/terracotta.conf.sample @@ -1,22 +1,55 @@ -[DEFAULT] +[default] +# The name of the host running the global manager +global_manager_host = controller -# The directory, where log files will be created by the Neat services -log_directory = /var/log/neat +# The port of the REST web service exposed by the global manager +global_manager_port = 60080 -# The level of emitted log messages: -# 0 -- no logging -# 1 -- errors and warnings -# 2 -- errors, warnings, and information messages -# 3 -- errors, warnings, information messages, and debug messages -log_level = 3 +# The time interval between subsequent invocations of the database +# cleaner in seconds +db_cleaner_interval = 7200 +# The directory used by the data collector to store the data on the +# resource usage by the VMs running on the host +local_data_directory = /var/lib/terracotta + +# The threshold on the overall (all cores) utilization of the physical +# CPU of a host that can be allocated to VMs. +host_cpu_usable_by_vms = 1.0 + +# The number of the latest data values stored locally by the data +# collector and passed to the underload / overload detection and VM +# placement algorithms +data_collector_data_length = 100 + +# The network bandwidth in MB/s available for VM migration +network_migration_bandwidth = 10 + +[api] +# Terracotta API server host +host = 0.0.0.0 + +# Terracotta API server port +port = 9090 + +[pecan] +# Pecan root controller +root = terracotta.api.controllers.root.RootController + +# A list of modules where pecan will search for applications. +modules = terracotta.api + +# Enables the ability to display tracebacks in the +# browser and interactively debug during development. +debug = False + +# Enables user authentication in pecan. +auth_enable = True + +[global_manager] # The directory, where the VM instance data are stored vm_instance_directory = /var/lib/nova/instances -# The host name and credentials for connecting to the MySQL database -# specified in the format supported by SQLAlchemy -sql_connection = mysql://neat:neatpassword@controller/neat - # The admin tenant name for authentication with Nova using Keystone os_admin_tenant_name = admin @@ -32,46 +65,16 @@ os_auth_url = http://controller:5000/v2.0/ # A coma-separated list of compute host names compute_hosts = compute1, compute2, compute3, compute4 -# The name of the host running the global manager -global_manager_host = controller - -# The port of the REST web service exposed by the global manager -global_manager_port = 60080 - -# The time interval between subsequent invocations of the database -# cleaner in seconds -db_cleaner_interval = 7200 - -# The directory used by the data collector to store the data on the -# resource usage by the VMs running on the host -local_data_directory = /var/lib/neat - -# The time interval between subsequent invocations of the local -# manager in seconds -local_manager_interval = 300 - -# The threshold on the overall (all cores) utilization of the physical -# CPU of a host, above which the host is considered to be overloaded. -# This is used for logging host overloads into the database. -host_cpu_overload_threshold = 0.8 - -# The threshold on the overall (all cores) utilization of the physical -# CPU of a host that can be allocated to VMs. -host_cpu_usable_by_vms = 1.0 - -# The user name for connecting to the compute hosts to switch them -# into the sleep mode -compute_user = neat - -# The password of the user account used for connecting to the compute -# hosts to switch them into the sleep mode -compute_password = neatpassword - # Whether to use block migration (includes disk migration) block_migration = True -# The network bandwidth in MB/s available for VM migration -network_migration_bandwidth = 10 +# The user name for connecting to the compute hosts to switch them +# into the sleep mode +compute_user = terracotta + +# The password of the user account used for connecting to the compute +# hosts to switch them into the sleep mode +compute_password = terracottapassword # A shell command used to switch a host into the sleep mode, the # compute_user must have permissions to execute this command @@ -80,10 +83,23 @@ sleep_command = pm-suspend # The network interface to send a magic packet from using ether-wake ether_wake_interface = eth0 +# The fully qualified name of a Python factory function that returns a +# function implementing a VM placement algorithm +algorithm_vm_placement_factory = terracotta.globals.vm_placement.bin_packing.best_fit_decreasing_factory + +# A JSON encoded parameters, which will be parsed and passed to the +# specified VM placement algorithm factory +algorithm_vm_placement_parameters = {"cpu_threshold": 0.8, "ram_threshold": 0.95, "last_n_vm_cpu": 2} + +[local_manager] +# The time interval between subsequent invocations of the local +# manager in seconds +local_manager_interval = 300 + # The fully qualified name of a Python factory function that returns a # function implementing an underload detection algorithm -#algorithm_underload_detection_factory = neat.locals.underload.trivial.threshold_factory -algorithm_underload_detection_factory = neat.locals.underload.trivial.last_n_average_threshold_factory +#algorithm_underload_detection_factory = terracotta.locals.underload.trivial.threshold_factory +algorithm_underload_detection_factory = terracotta.locals.underload.trivial.last_n_average_threshold_factory # A JSON encoded parameters, which will be parsed and passed to the # specified underload detection algorithm factory @@ -92,11 +108,11 @@ algorithm_underload_detection_parameters = {"threshold": 0.5, "n": 2} # The fully qualified name of a Python factory function that returns a # function implementing an overload detection algorithm -#algorithm_overload_detection_factory = neat.locals.overload.trivial.threshold_factory -algorithm_overload_detection_factory = neat.locals.overload.mhod.core.mhod_factory -#algorithm_overload_detection_factory = neat.locals.overload.trivial.last_n_average_threshold_factory -#algorithm_overload_detection_factory = neat.locals.overload.statistics.loess_factory -#algorithm_overload_detection_factory = neat.locals.overload.otf.otf_factory +#algorithm_overload_detection_factory = terracotta.locals.overload.trivial.threshold_factory +algorithm_overload_detection_factory = terracotta.locals.overload.mhod.core.mhod_factory +#algorithm_overload_detection_factory = terracotta.locals.overload.trivial.last_n_average_threshold_factory +#algorithm_overload_detection_factory = terracotta.locals.overload.statistics.loess_factory +#algorithm_overload_detection_factory = terracotta.locals.overload.otf.otf_factory # A JSON encoded parameters, which will be parsed and passed to the # specified overload detection algorithm factory @@ -108,32 +124,25 @@ algorithm_overload_detection_parameters = {"state_config": [0.8], "otf": 0.1, "h # The fully qualified name of a Python factory function that returns a # function implementing a VM selection algorithm -#algorithm_vm_selection_factory = neat.locals.vm_selection.algorithms.minimum_migration_time_factory -algorithm_vm_selection_factory = neat.locals.vm_selection.algorithms.minimum_migration_time_max_cpu_factory +#algorithm_vm_selection_factory = terracotta.locals.vm_selection.algorithms.minimum_migration_time_factory +algorithm_vm_selection_factory = terracotta.locals.vm_selection.algorithms.minimum_migration_time_max_cpu_factory # A JSON encoded parameters, which will be parsed and passed to the # specified VM selection algorithm factory #algorithm_vm_selection_parameters = {} algorithm_vm_selection_parameters = {"last_n": 2} -# The fully qualified name of a Python factory function that returns a -# function implementing a VM placement algorithm -algorithm_vm_placement_factory = neat.globals.vm_placement.bin_packing.best_fit_decreasing_factory - -# A JSON encoded parameters, which will be parsed and passed to the -# specified VM placement algorithm factory -algorithm_vm_placement_parameters = {"cpu_threshold": 0.8, "ram_threshold": 0.95, "last_n_vm_cpu": 2} - -[global_manager] - -[local_manager] - [collector] # The time interval between subsequent invocations of the data # collector in seconds data_collector_interval = 300 -# The number of the latest data values stored locally by the data -# collector and passed to the underload / overload detection and VM -# placement algorithms -data_collector_data_length = 100 +# The threshold on the overall (all cores) utilization of the physical +# CPU of a host, above which the host is considered to be overloaded. +# This is used for logging host overloads into the database. +host_cpu_overload_threshold = 0.8 + +[database] +# The host name and credentials for connecting to the MySQL database +# specified in the format supported by SQLAlchemy +sql_connection = mysql://terracotta:terracottapassword@controller/terracotta \ No newline at end of file diff --git a/terracotta/config.py b/terracotta/config.py index dbff237..da51739 100644 --- a/terracotta/config.py +++ b/terracotta/config.py @@ -37,7 +37,7 @@ default_opts = [ help='The port of the REST web service exposed by the global manager'), cfg.IntOpt('db_cleaner_interval', default=7200, help='The time interval between subsequent invocations of the database'), - cfg.StrOpt('local_data_directory', default='/var/lib/neat', + cfg.StrOpt('local_data_directory', default='/var/lib/terracotta', help='The directory used by the data collector to store the data on the' 'resource usage by the VMs running on the host'), cfg.FloatOpt('host_cpu_usable_by_vms', default=1.0, @@ -47,8 +47,8 @@ default_opts = [ help='The number of the latest data values stored locally ' 'by the data collector and passed to the underload / ' 'overload detection and VM placement algorithms'), - cfg.IntOpt('network_migration_bandwidth', default=10, - help='The network bandwidth in MB/s available for VM migration') + cfg.FloatOpt('network_migration_bandwidth', default=10, + help='The network bandwidth in MB/s available for VM migration') ] api_opts = [ @@ -97,10 +97,10 @@ global_manager_opts = [ help='A coma-separated list of compute host names'), cfg.BoolOpt('block_migration', default=True, help='Whether to use block migration (includes disk migration)'), - cfg.StrOpt('compute_user', default='neat', + cfg.StrOpt('compute_user', default='terracotta', help='The user name for connecting to the compute hosts ' 'to switch them into the sleep mode'), - cfg.StrOpt('compute_password', default='neatpassword', + cfg.StrOpt('compute_password', default='terracottapassword', help='The password of the user account used for connecting ' 'to the compute hosts to switch them into the sleep mode'), cfg.StrOpt('sleep_command', default='pm-suspend', @@ -110,7 +110,7 @@ global_manager_opts = [ help='The network interface to send a magic packet from ' 'using ether-wake'), cfg.StrOpt('algorithm_vm_placement_factory', - default='neat.globals.vm_placement.bin_packing.best_fit_decreasing_factory', + default='terracotta.globals.vm_placement.bin_packing.best_fit_decreasing_factory', help='The fully qualified name of a Python factory function that returns a' 'function implementing a VM placement algorithm'), cfg.DictOpt('algorithm_vm_placement_parameters', @@ -124,7 +124,7 @@ local_manager_opts = [ help='The time interval between subsequent invocations ' 'of the local manager in seconds'), cfg.StrOpt('algorithm_underload_detection_factory', - default='neat.locals.underload.trivial.last_n_average_threshold_factory', + default='terracotta.locals.underload.trivial.last_n_average_threshold_factory', help='The fully qualified name of a Python factory function that returns a' 'function implementing an underload detection algorithm'), cfg.DictOpt('algorithm_underload_detection_parameters', @@ -132,7 +132,7 @@ local_manager_opts = [ help='A JSON encoded parameters, which will be parsed and passed to the' 'specified underload detection algorithm factory'), cfg.StrOpt('algorithm_overload_detection_factory', - default='neat.locals.overload.mhod.core.mhod_factory', + default='terracotta.locals.overload.mhod.core.mhod_factory', help='The fully qualified name of a Python factory function that returns a' 'function implementing an overload detection algorithm'), cfg.DictOpt('algorithm_overload_detection_parameters', @@ -145,7 +145,7 @@ local_manager_opts = [ help='A JSON encoded parameters, which will be parsed and passed to the' 'specified overload detection algorithm factory'), cfg.StrOpt('algorithm_vm_selection_factory', - default='neat.locals.vm_selection.algorithms.minimum_migration_time_max_cpu_factory', + default='terracotta.locals.vm_selection.algorithms.minimum_migration_time_max_cpu_factory', help='The fully qualified name of a Python factory function that returns a' 'function implementing a VM selection algorithm'), cfg.DictOpt('algorithm_vm_selection_parameters', @@ -166,7 +166,7 @@ collector_opts = [ ] database_opts = [ - cfg.StrOpt('sql_connection', default='mysql://neat:neatpassword@controller/neat', + cfg.StrOpt('sql_connection', default='mysql://terracotta:terracottapassword@controller/terracotta', help='The host name and credentials for connecting ' 'to the MySQL database specified in the format ' 'supported by SQLAlchemy') diff --git a/terracotta/globals/manager.py b/terracotta/globals/manager.py index 2bcd8b9..12b9ab8 100644 --- a/terracotta/globals/manager.py +++ b/terracotta/globals/manager.py @@ -396,7 +396,7 @@ class GlobalManager(object): return self.state vms_cpu[vm] = self.state['db'].select_cpu_mhz_for_vm( vm, - int(CONF.data_collector_data_length)) + CONF.data_collector_data_length) vms_ram = vms_ram_limit(self.state['nova'], vms_to_migrate) # Remove VMs that are not in vms_ram @@ -413,10 +413,10 @@ class GlobalManager(object): if not vm in vms_ram: del vms_cpu[vm] - time_step = int(CONF.data_collector_interval) + time_step = CONF.data_collector_interval migration_time = common.calculate_migration_time( vms_ram, - float(CONF.network_migration_bandwidth)) + CONF.network_migration_bandwidth) if 'vm_placement' not in self.state: vm_placement_params = common.parse_parameters( @@ -462,7 +462,7 @@ class GlobalManager(object): self.state['nova'], CONF.vm_instance_directory, placement, - bool(CONF.block_migration)) + CONF.block_migration) LOG.info('Completed underload VM migrations') if hosts_to_deactivate: @@ -548,7 +548,7 @@ class GlobalManager(object): return self.state vms_cpu[vm] = self.state['db'].select_cpu_mhz_for_vm( vm, - int(CONF.data_collector_data_length)) + CONF.data_collector_data_length) vms_ram = vms_ram_limit(self.state['nova'], vms_to_migrate) # Remove VMs that are not in vms_ram @@ -565,10 +565,10 @@ class GlobalManager(object): if not vm in vms_ram: del vms_cpu[vm] - time_step = int(CONF.data_collector_interval) + time_step = CONF.data_collector_interval migration_time = common.calculate_migration_time( vms_ram, - float(CONF.network_migration_bandwidth)) + CONF.network_migration_bandwidth) if 'vm_placement' not in state: vm_placement_params = common.parse_parameters( @@ -610,7 +610,7 @@ class GlobalManager(object): self.state['nova'], CONF.vm_instance_directory, placement, - bool(CONF.block_migration)) + CONF.block_migration) LOG.info('Completed overload VM migrations') LOG.info('Completed processing an overload request') return state diff --git a/terracotta/locals/collector.py b/terracotta/locals/collector.py index 556c922..d7624b5 100644 --- a/terracotta/locals/collector.py +++ b/terracotta/locals/collector.py @@ -141,7 +141,7 @@ class Collector(periodic_task.PeriodicTasks): hostname = vir_connection.getHostname() host_cpu_mhz, host_ram = self.get_host_characteristics(vir_connection) physical_cpus = common.physical_cpu_count(vir_connection) - host_cpu_usable_by_vms = float(CONF.host_cpu_usable_by_vms) + host_cpu_usable_by_vms = CONF.host_cpu_usable_by_vms db = db_utils.init_db() db.update_host(hostname, @@ -158,7 +158,7 @@ class Collector(periodic_task.PeriodicTasks): 'vir_connection': vir_connection, 'hostname': hostname, 'host_cpu_overload_threshold': - float(CONF.host_cpu_overload_threshold) * \ + CONF.host_cpu_overload_threshold * \ host_cpu_usable_by_vms, 'physical_cpus': physical_cpus, 'physical_cpu_mhz': host_cpu_mhz, @@ -201,7 +201,7 @@ class Collector(periodic_task.PeriodicTasks): vm_path = common.build_local_vm_path(CONF.local_data_directory) host_path = common.build_local_host_path(CONF.local_data_directory) - data_length = int(CONF.data_collector_data_length) + data_length = CONF.data_collector_data_length vms_previous = self.get_previous_vms(vm_path) vms_current = self.get_current_vms(state['vir_connection']) diff --git a/terracotta/locals/manager.py b/terracotta/locals/manager.py index 09a853d..e5588ea 100644 --- a/terracotta/locals/manager.py +++ b/terracotta/locals/manager.py @@ -147,7 +147,7 @@ class LocalManager(periodic_task.PeriodicTasks): physical_cpu_mhz_total = int( common.physical_cpu_mhz_total(vir_connection) * - float(CONF.host_cpu_usable_by_vms)) + CONF.host_cpu_usable_by_vms) return {'previous_time': 0., 'vir_connection': vir_connection, 'db': db_utils.init_db(), @@ -218,9 +218,9 @@ class LocalManager(periodic_task.PeriodicTasks): LOG.info('Skipped an iteration') return - time_step = int(CONF.data_collector_interval) + time_step = CONF.data_collector_interval migration_time = common.calculate_migration_time( - vm_ram, float(CONF.network_migration_bandwidth)) + vm_ram, CONF.network_migration_bandwidth) if 'underload_detection' not in state: underload_detection_params = common.parse_parameters(