From e7a701446b631b60ac82f2e85dd6cbebb2c063fd Mon Sep 17 00:00:00 2001 From: LingxianKong Date: Fri, 8 May 2015 12:06:56 +0800 Subject: [PATCH] refactor-at-the-very-early-age Change-Id: I327d1d646cae065896ad2caa40b68a951f9405ee --- etc/terracotta.conf.sample | 24 ++++++++++++++++++++++++ requirements.txt | 12 +++++++++++- terracotta/api/app.py | 1 - terracotta/cmd/launch.py | 10 +++++----- terracotta/config.py | 21 ++++++++++++++++++++- terracotta/rpc.py | 6 +++--- 6 files changed, 63 insertions(+), 11 deletions(-) diff --git a/etc/terracotta.conf.sample b/etc/terracotta.conf.sample index f72263c..ea863dc 100644 --- a/etc/terracotta.conf.sample +++ b/etc/terracotta.conf.sample @@ -57,6 +57,14 @@ debug = False auth_enable = True [global_manager] +# The message topic that the global_manager listens on. (string value) +#topic=global_manager + +# Name of the global_manager node. This can be an opaque identifier. +# It is not necessarily a hostname, FQDN, or IP address. +# (string value) +#host=0.0.0.0 + # The directory, where the VM instance data are stored vm_instance_directory = /var/lib/nova/instances @@ -96,6 +104,14 @@ algorithm_vm_placement_factory = terracotta.globals.vm_placement.bin_packing.bes algorithm_vm_placement_parameters = {"cpu_threshold": 0.8, "ram_threshold": 0.95, "last_n_vm_cpu": 2} [local_manager] +# The message topic that the local_manager listens on. (string value) +#topic=local_manager + +# Name of the local_manager node. This can be an opaque identifier. +# It is not necessarily a hostname, FQDN, or IP address. +# (string value) +#host=0.0.0.0 + # The time interval between subsequent invocations of the local # manager in seconds local_manager_interval = 300 @@ -142,6 +158,14 @@ algorithm_vm_selection_parameters = {"last_n": 2} # This is used for logging host overloads into the database. host_cpu_overload_threshold = 0.8 +# The message topic that the collector listens on. (string value) +#topic=collector + +# Name of the collector node. This can be an opaque identifier. +# It is not necessarily a hostname, FQDN, or IP address. +# (string value) +#host=0.0.0.0 + [database] # The host name and credentials for connecting to the MySQL database # specified in the format supported by SQLAlchemy diff --git a/requirements.txt b/requirements.txt index 9b597ef..3e1ef9b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,28 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. +amqplib>=0.6.1 # This is not in global requirements (master branch) +kombu>=3.0.7 pbr>=0.6,!=0.7,<1.0 eventlet>=0.17.3 pecan>=0.8.0 WSME>=0.6 +WebOb>=1.2.3 Babel>=1.3 -kombu>=3.0.7 oslo.config>=1.11.0 # Apache-2.0 oslo.db>=1.7.0 # Apache-2.0 +oslo.log>=1.0.0 # Apache-2.0 oslo.messaging>=1.8.0 # Apache-2.0 oslo.utils>=1.4.0 # Apache-2.0 python-novaclient>=2.22.0 +python-keystoneclient>=1.3.0 six>=1.9.0 SQLAlchemy>=0.9.7,<=0.9.99 stevedore>=1.3.0 # Apache-2.0 keystonemiddleware>=1.5.0 +libvirt-python>=1.2.5 # LGPLv2+ +netaddr>=0.7.12 +Mako>=0.4.0 +numpy # This is not in global requirements +scipy # This is not in global requirements +netifaces>=0.10.4 diff --git a/terracotta/api/app.py b/terracotta/api/app.py index 619ab53..7c5e9d2 100644 --- a/terracotta/api/app.py +++ b/terracotta/api/app.py @@ -16,7 +16,6 @@ from oslo_config import cfg import pecan from terracotta.api import access_control -from terracotta import context as ctx def get_pecan_config(): diff --git a/terracotta/cmd/launch.py b/terracotta/cmd/launch.py index 75ad49b..554ef29 100644 --- a/terracotta/cmd/launch.py +++ b/terracotta/cmd/launch.py @@ -45,6 +45,7 @@ from terracotta.globals import manager as global_mgr from terracotta import version +CONF = cfg.CONF LOG = logging.getLogger(__name__) @@ -108,8 +109,8 @@ def launch_gm(transport): def launch_collector(transport): target = messaging.Target( - topic=cfg.CONF.local_collector.topic, - server=cfg.CONF.local_collector.host + topic=cfg.CONF.collector.topic, + server=cfg.CONF.collector.host ) global_manager = collector.Collector() @@ -119,8 +120,7 @@ def launch_collector(transport): transport, target, endpoints, - executor='eventlet', - serializer=ctx.RpcContextSerializer(ctx.JsonPayloadSerializer()) + executor='eventlet' ) server.start() @@ -168,7 +168,7 @@ def main(): try: config.parse_args() print_service_info() - logging.setup(cfg.CONF, 'Terracotta') + logging.setup(CONF, 'Terracotta') transport = rpc.get_transport() launch_any(transport, set(cfg.CONF.server)) diff --git a/terracotta/config.py b/terracotta/config.py index 621ba6c..f76693f 100644 --- a/terracotta/config.py +++ b/terracotta/config.py @@ -95,6 +95,12 @@ use_debugger = cfg.BoolOpt( ) global_manager_opts = [ + cfg.StrOpt('host', default='0.0.0.0', + help='Name of the global_manager node. This can be an opaque ' + 'identifier. It is not necessarily a hostname, ' + 'FQDN, or IP address.'), + cfg.StrOpt('topic', default='global_manager', + help='The message topic that the global_manager listens on.'), cfg.StrOpt('vm_instance_directory', default='/var/lib/nova/instances', help='The directory, where the VM instance data are stored'), cfg.StrOpt('os_admin_tenant_name', default='tenantname', @@ -135,6 +141,12 @@ global_manager_opts = [ ] local_manager_opts = [ + cfg.StrOpt('host', default='0.0.0.0', + help='Name of the local_manager node. This can be an opaque ' + 'identifier. It is not necessarily a hostname, ' + 'FQDN, or IP address.'), + cfg.StrOpt('topic', default='local_manager', + help='The message topic that the local_manager listens on.'), cfg.IntOpt('local_manager_interval', default=300, help='The time interval between subsequent invocations ' 'of the local manager in seconds'), @@ -183,7 +195,13 @@ collector_opts = [ '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.') + ' database.'), + cfg.StrOpt('host', default='0.0.0.0', + help='Name of the collector node. This can be an opaque ' + 'identifier. It is not necessarily a hostname, ' + 'FQDN, or IP address.'), + cfg.StrOpt('topic', default='collector', + help='The message topic that the collector listens on.'), ] database_opts = [ @@ -209,6 +227,7 @@ CONF.register_cli_opt(launch_opt) def parse_args(args=None, usage=None, default_config_files=None): + logging.register_options(CONF) CONF( args=args, project='terracotta', diff --git a/terracotta/rpc.py b/terracotta/rpc.py index 7283233..29754a1 100644 --- a/terracotta/rpc.py +++ b/terracotta/rpc.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +from oslo import messaging from oslo_config import cfg from oslo_log import log as logging from oslo_messaging.rpc import client -from terracotta import context as auth_ctx from terracotta import exceptions as exc @@ -96,7 +96,7 @@ def wrap_messaging_exception(method): return decorator -class EngineClient(base.Engine): +class EngineClient(): """RPC Engine client.""" def __init__(self, transport): @@ -121,7 +121,7 @@ class LocalManagerServer(object): self._executor = manager -class ExecutorClient(base.Executor): +class ExecutorClient(): """RPC Executor client.""" def __init__(self, transport):