From 6ae3ff0a4e8503acd6ceddbe87878c0d3cdfe9bd Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 28 Nov 2012 15:50:41 +0000 Subject: [PATCH] Remove heat-metadata service Remove heat-metadata service, since the last remaining function (waitcondition handle notification) is now handled via the CFN API blueprint metsrv-remove Signed-off-by: Steven Hardy Change-Id: Ie36c86ce86f6c47e8d9f8accf8ec17084fb8cffd --- bin/heat-metadata | 61 ------------------------- docs/GettingStarted.rst | 35 +++++---------- etc/heat/heat-metadata-paste.ini | 15 ------- etc/heat/heat-metadata.conf | 27 ------------ heat/common/config.py | 6 --- heat/metadata/__init__.py | 0 heat/metadata/api/__init__.py | 0 heat/metadata/api/v1/__init__.py | 46 ------------------- heat/metadata/api/v1/metadata.py | 76 -------------------------------- setup.py | 1 - 10 files changed, 12 insertions(+), 255 deletions(-) delete mode 100755 bin/heat-metadata delete mode 100644 etc/heat/heat-metadata-paste.ini delete mode 100644 etc/heat/heat-metadata.conf delete mode 100644 heat/metadata/__init__.py delete mode 100644 heat/metadata/api/__init__.py delete mode 100644 heat/metadata/api/v1/__init__.py delete mode 100644 heat/metadata/api/v1/metadata.py diff --git a/bin/heat-metadata b/bin/heat-metadata deleted file mode 100755 index bb1ea63e4c..0000000000 --- a/bin/heat-metadata +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# -# 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. - -""" -Heat Metadata Server. - -This makes the instance metadata accessible both to the instance and Heat Engine. -""" - -import gettext -import os -import sys - -# If ../heat/__init__.py exists, add ../ to Python search path, so that -# it will override what happens to be installed in /usr/(local/)lib/python... -possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), - os.pardir, - os.pardir)) -if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')): - sys.path.insert(0, possible_topdir) - -gettext.install('heat', unicode=1) - -from heat.common import config -from heat.common import wsgi - -from heat.openstack.common import log as logging -from heat.openstack.common import cfg - -LOG = logging.getLogger('heat.metadata') - - -if __name__ == '__main__': - try: - cfg.CONF(project='heat', prog='heat-metadata') - - config.setup_logging() - config.register_metadata_opts() - - app = config.load_paste_app() - - port = cfg.CONF.bind_port - host = cfg.CONF.bind_host - LOG.info(('Starting Heat Metadata on %s:%s') % (host, port)) - server = wsgi.Server() - server.start(app, cfg.CONF, default_port=port) - server.wait() - except RuntimeError, e: - sys.exit("ERROR: %s" % e) diff --git a/docs/GettingStarted.rst b/docs/GettingStarted.rst index ad5dab041e..1e87e300e9 100644 --- a/docs/GettingStarted.rst +++ b/docs/GettingStarted.rst @@ -314,38 +314,27 @@ Other Templates =============== Check out the ``Wordpress_2_Instances_with_EBS_EIP.template``. This uses a few different APIs in OpenStack nova, such as the Volume API, the Floating IP API and the Security Groups API, as well as the general nova launching and monitoring APIs. -Configure the Metadata server ------------------------------ +IPtables rules +-------------- -Some templates require the ``heat-metadata`` server also. The metadata server must be configured to bind to the IP address of the host machine on the Nova network created above (``demonetbr0``). This allows the launched instances to access the metadata server. However, the bridge interface is not actually created until an instance is launched in Nova. If you have completed the preceding steps the bridge will now have been created, so you can proceed to edit the file ``/etc/heat/heat-metadata.conf`` to change the ``bind_host`` value from the default ``0.0.0.0`` to the correct IP address and launch the metadata server:: +Some templates require the instances to be able to connect to the heat CFN API (for metadata update via cfn-hup and waitcondition notification via cfn-signal): - BIND_IP=`ifconfig demonetbr0 | sed -e 's/ *inet \(addr:\)\?\([0-9.]\+\).*/\2/' -e t -e d` - sudo sed -i -e "/^bind_host *=/ s/0\.0\.0\.0/${BIND_IP:?}/" /etc/heat/heat-metadata.conf - - sudo -E bash -c 'heat-metadata &' - -Open up port 8002 so that the guests can communicate with the heat-metadata server:: - - sudo iptables -I INPUT -p tcp --dport 8002 -j ACCEPT -i demonetbr0 - -Note Instance/resource metadata is actually now served via the cloudformation API, so it is necessary to also open up port 8000 so that the guests can communicate with the heat-api-cfn server:: +Open up port 8000 so that the guests can communicate with the heat-api-cfn server:: sudo iptables -I INPUT -p tcp --dport 8000 -j ACCEPT -i demonetbr0 -Note the above rules will not persist across reboot, so you may wish to add them to /etc/sysconfig/iptables - -Configure Heat Cloudwatch server --------------------------------- - -If you wish to try any of the HA or autoscaling templates (which collect stats from instances via the CloudWatch API), it is neccessary to start the heat-api-cloudwatch server:: - - sudo -E bash -c 'heat-api-cloudwatch &' - Open up port 8003 so that the guests can communicate with the heat-api-cloudwatch server:: sudo iptables -I INPUT -p tcp --dport 8003 -j ACCEPT -i demonetbr0 -Note the above rule will not persist across reboot, so you may wish to add it to /etc/sysconfig/iptables +Note the above rules will not persist across reboot, so you may wish to add them to /etc/sysconfig/iptables + +Start the Heat Cloudwatch server +-------------------------------- + +If you wish to try any of the HA or autoscaling templates (which collect stats from instances via the CloudWatch API), it is neccessary to start the heat-api-cloudwatch server:: + + sudo -E bash -c 'heat-api-cloudwatch &' Further information on using the heat cloudwatch features is available in the Using-Cloudwatch_ wiki page diff --git a/etc/heat/heat-metadata-paste.ini b/etc/heat/heat-metadata-paste.ini deleted file mode 100644 index e63321eb5d..0000000000 --- a/etc/heat/heat-metadata-paste.ini +++ /dev/null @@ -1,15 +0,0 @@ -# Default minimal pipeline -[pipeline:heat-metadata] -pipeline = context metadatav1app - -# Use the following pipeline for keystone auth -# i.e. in heat-metadata.conf: -# [paste_deploy] -# flavor = keystone -# -[app:metadatav1app] -paste.app_factory = heat.common.wsgi:app_factory -heat.app_factory = heat.metadata.api.v1:API - -[filter:context] -paste.filter_factory = heat.common.context:ContextMiddleware_filter_factory diff --git a/etc/heat/heat-metadata.conf b/etc/heat/heat-metadata.conf deleted file mode 100644 index c7f55488da..0000000000 --- a/etc/heat/heat-metadata.conf +++ /dev/null @@ -1,27 +0,0 @@ -[DEFAULT] -# Show more verbose log output (sets INFO log level output) -verbose = True - -# Show debugging output in logs (sets DEBUG log level output) -debug = True - -# Address to bind the server to -bind_host = 0.0.0.0 - -# Port the bind the server to -bind_port = 8002 - -# Log to this file. Make sure the user running heat-metadata has -# permissions to write to this file! -log_file = /var/log/heat/metadata.log - -# ================= Syslog Options ============================ - -# Send logs to syslog (/dev/log) instead of to file specified -# by `log_file` -use_syslog = False - -# Facility to use. If unset defaults to LOG_USER. -# syslog_log_facility = LOG_LOCAL0 - -rpc_backend=heat.openstack.common.rpc.impl_qpid diff --git a/heat/common/config.py b/heat/common/config.py index d56ef88f13..8b9daa1714 100644 --- a/heat/common/config.py +++ b/heat/common/config.py @@ -113,12 +113,6 @@ cfg.StrOpt('engine_topic', ] -def register_metadata_opts(): - cfg.CONF.register_opts(service_opts) - cfg.CONF.register_opts(bind_opts) - cfg.CONF.register_opts(rpc_opts) - - def register_api_opts(): cfg.CONF.register_opts(bind_opts) cfg.CONF.register_opts(rpc_opts) diff --git a/heat/metadata/__init__.py b/heat/metadata/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/heat/metadata/api/__init__.py b/heat/metadata/api/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/heat/metadata/api/v1/__init__.py b/heat/metadata/api/v1/__init__.py deleted file mode 100644 index 91cd823386..0000000000 --- a/heat/metadata/api/v1/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# -# 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. - -import routes - -from heat.common import wsgi -from heat.metadata.api.v1 import metadata - -from heat.openstack.common import log as logging - - -class API(wsgi.Router): - """ - WSGI router for Heat Metadata Server API v1 requests. - """ - - def __init__(self, conf, **local_conf): - self.cong = conf - mapper = routes.Mapper() - metadata_controller = metadata.create_resource(conf) - - mapper.connect('/', - controller=metadata_controller, action='entry_point', - conditions=dict(method=['GET'])) - mapper.connect('/stacks/:stack_id/resources/:resource_name', - controller=metadata_controller, - action='update_metadata', - conditions=dict(method=['PUT'])) - - # TODO(shadower): make sure all responses are JSON-encoded - # currently, calling an unknown route uses the default handler which - # produces a HTML response. - - super(API, self).__init__(mapper) diff --git a/heat/metadata/api/v1/metadata.py b/heat/metadata/api/v1/metadata.py deleted file mode 100644 index f8df7f01c9..0000000000 --- a/heat/metadata/api/v1/metadata.py +++ /dev/null @@ -1,76 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# -# 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. - -import json - -from webob.exc import Response - -from heat.common import wsgi -from heat.common import context -from heat.engine import rpcapi as engine_rpcapi -from heat.openstack.common import rpc - - -def json_response(http_status, data): - """Create a JSON response with a specific HTTP code.""" - response = Response(json.dumps(data)) - response.status = http_status - response.content_type = 'application/json' - return response - - -def json_error(http_status, message): - """Create a JSON error response.""" - body = {'error': message} - return json_response(http_status, body) - - -class MetadataController: - def __init__(self, options): - self.options = options - self.engine_rpcapi = engine_rpcapi.EngineAPI() - - def entry_point(self, req): - return { - 'name': 'Heat Metadata Server API', - 'version': '1', - } - - def update_metadata(self, req, body, stack_id, resource_name): - con = context.get_admin_context() - [error, metadata] = self.engine_rpcapi.metadata_update(con, - stack_id=stack_id, - resource_name=resource_name, - metadata=body) - if error: - if error == 'stack': - return json_error(404, - 'The stack "%s" does not exist.' % stack_id) - else: - return json_error(404, - 'The resource "%s" does not exist.' % resource_name) - return json_response(201, { - 'resource': resource_name, - 'metadata': body, - }) - - -def create_resource(options): - """ - Stacks resource factory method. - """ - deserializer = wsgi.JSONRequestDeserializer() - serializer = wsgi.JSONResponseSerializer() - return wsgi.Resource(MetadataController(options), deserializer, serializer) diff --git a/setup.py b/setup.py index 1c8d7ff158..1952b25b90 100755 --- a/setup.py +++ b/setup.py @@ -48,7 +48,6 @@ setuptools.setup( 'bin/heat-api-cfn', 'bin/heat-api-cloudwatch', 'bin/heat-boto', - 'bin/heat-metadata', 'bin/heat-engine', 'bin/heat-watch', 'bin/heat-db-setup',