diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-11-16 23:35:08 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-11-16 23:35:08 +0000 |
| commit | 36dcc2d9230f8104f0defc8fa27ee8f6c2f2eeaf (patch) | |
| tree | b6fb06617cbcfbf985b7186a4e430b5f6cd75500 /nova | |
| parent | 381e5e5b0dbbb6fefdc8194fa103176f18760060 (diff) | |
| parent | e6073532e5020203a8ec2247ca7ddd481c6ec517 (diff) | |
| download | nova-36dcc2d9230f8104f0defc8fa27ee8f6c2f2eeaf.tar.gz nova-36dcc2d9230f8104f0defc8fa27ee8f6c2f2eeaf.tar.xz nova-36dcc2d9230f8104f0defc8fa27ee8f6c2f2eeaf.zip | |
Merge "Separate metadata api into its own service"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/__init__.py | 2 | ||||
| -rw-r--r-- | nova/api/ec2/__init__.py | 23 | ||||
| -rw-r--r-- | nova/api/manager.py | 8 | ||||
| -rw-r--r-- | nova/api/metadata/__init__.py | 25 | ||||
| -rw-r--r-- | nova/api/metadata/handler.py (renamed from nova/api/ec2/metadatarequesthandler.py) | 25 | ||||
| -rw-r--r-- | nova/auth/__init__.py | 2 | ||||
| -rw-r--r-- | nova/cloudpipe/__init__.py | 2 | ||||
| -rw-r--r-- | nova/flags.py | 5 | ||||
| -rwxr-xr-x | nova/network/linux_net.py | 7 | ||||
| -rw-r--r-- | nova/objectstore/__init__.py | 2 | ||||
| -rw-r--r-- | nova/service.py | 10 | ||||
| -rw-r--r-- | nova/tests/__init__.py | 2 | ||||
| -rw-r--r-- | nova/tests/integrated/integrated_helpers.py | 1 | ||||
| -rw-r--r-- | nova/tests/test_metadata.py | 4 |
14 files changed, 72 insertions, 46 deletions
diff --git a/nova/__init__.py b/nova/__init__.py index 884c4a713..f2e9684d3 100644 --- a/nova/__init__.py +++ b/nova/__init__.py @@ -25,7 +25,7 @@ :synopsis: Infrastructure-as-a-Service Cloud platform. .. moduleauthor:: Jesse Andrews <jesse@ansolabs.com> .. moduleauthor:: Devin Carlen <devin.carlen@gmail.com> -.. moduleauthor:: Vishvananda Ishaya <vishvananda@yahoo.com> +.. moduleauthor:: Vishvananda Ishaya <vishvananda@gmail.com> .. moduleauthor:: Joshua McKenty <joshua@cognition.ca> .. moduleauthor:: Manish Singh <yosh@gimp.org> .. moduleauthor:: Andy Smith <andy@anarkystic.com> diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index db92ca053..100837631 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -20,10 +20,7 @@ Starting point for routing EC2 requests. """ -from urlparse import urlparse -import eventlet -from eventlet.green import httplib import webob import webob.dec import webob.exc @@ -437,23 +434,3 @@ class Executor(wsgi.Application): (utils.utf8(code), utils.utf8(message), utils.utf8(context.request_id))) return resp - - -class Versions(wsgi.Application): - - @webob.dec.wsgify(RequestClass=wsgi.Request) - def __call__(self, req): - """Respond to a request for all EC2 versions.""" - # available api versions - versions = [ - '1.0', - '2007-01-19', - '2007-03-01', - '2007-08-29', - '2007-10-10', - '2007-12-15', - '2008-02-01', - '2008-09-01', - '2009-04-04', - ] - return ''.join('%s\n' % v for v in versions) diff --git a/nova/api/manager.py b/nova/api/manager.py index 9cb364e2d..35ea8100c 100644 --- a/nova/api/manager.py +++ b/nova/api/manager.py @@ -23,14 +23,14 @@ from nova import utils FLAGS = flags.FLAGS -class EC2Manager(manager.Manager): - """EC2 API manager. +class MetadataManager(manager.Manager): + """Metadata Manager. - This class manages the EC2 API service initialization. Currently, it + This class manages the Metadata API service initialization. Currently, it just adds an iptables filter rule for the metadata service. """ def __init__(self, *args, **kwargs): - super(EC2Manager, self).__init__(*args, **kwargs) + super(MetadataManager, self).__init__(*args, **kwargs) self.network_driver = utils.import_object(FLAGS.network_driver) def init_host(self): diff --git a/nova/api/metadata/__init__.py b/nova/api/metadata/__init__.py new file mode 100644 index 000000000..f09dfc326 --- /dev/null +++ b/nova/api/metadata/__init__.py @@ -0,0 +1,25 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 Openstack, LLC. +# +# 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. + +""" +:mod:`nova.api.metadata` -- Nova Metadata Server +================================================ + +.. automodule:: nova.api.metadata + :platform: Unix + :synopsis: Metadata Server for Nova +.. moduleauthor:: Vishvananda Ishaya <vishvananda@gmail.com> +""" diff --git a/nova/api/ec2/metadatarequesthandler.py b/nova/api/metadata/handler.py index 0198bf490..5d63c6dce 100644 --- a/nova/api/ec2/metadatarequesthandler.py +++ b/nova/api/metadata/handler.py @@ -23,18 +23,37 @@ import webob.exc from nova import log as logging from nova import flags -from nova import utils from nova import wsgi from nova.api.ec2 import cloud -LOG = logging.getLogger('nova.api.ec2.metadata') +LOG = logging.getLogger('nova.api.metadata') FLAGS = flags.FLAGS flags.DECLARE('use_forwarded_for', 'nova.api.auth') +class Versions(wsgi.Application): + + @webob.dec.wsgify(RequestClass=wsgi.Request) + def __call__(self, req): + """Respond to a request for all versions.""" + # available api versions + versions = [ + '1.0', + '2007-01-19', + '2007-03-01', + '2007-08-29', + '2007-10-10', + '2007-12-15', + '2008-02-01', + '2008-09-01', + '2009-04-04', + ] + return ''.join('%s\n' % v for v in versions) + + class MetadataRequestHandler(wsgi.Application): - """Serve metadata from the EC2 API.""" + """Serve metadata.""" def __init__(self): self.cc = cloud.CloudController() diff --git a/nova/auth/__init__.py b/nova/auth/__init__.py index e2a140e83..e81c739da 100644 --- a/nova/auth/__init__.py +++ b/nova/auth/__init__.py @@ -23,6 +23,6 @@ :platform: Unix :synopsis: User-and-Project based RBAC using LDAP, SAML. .. moduleauthor:: Jesse Andrews <jesse@ansolabs.com> -.. moduleauthor:: Vishvananda Ishaya <vishvananda@yahoo.com> +.. moduleauthor:: Vishvananda Ishaya <vishvananda@gmail.com> .. moduleauthor:: Joshua McKenty <joshua@cognition.ca> """ diff --git a/nova/cloudpipe/__init__.py b/nova/cloudpipe/__init__.py index cfadc30e9..3d683a0e2 100644 --- a/nova/cloudpipe/__init__.py +++ b/nova/cloudpipe/__init__.py @@ -24,6 +24,6 @@ :platform: Unix :synopsis: An OpenVPN server for every nova user. .. moduleauthor:: Devin Carlen <devin.carlen@gmail.com> -.. moduleauthor:: Vishvananda Ishaya <vishvananda@yahoo.com> +.. moduleauthor:: Vishvananda Ishaya <vishvananda@gmail.com> .. moduleauthor:: Joshua McKenty <jmckenty@gmail.com> """ diff --git a/nova/flags.py b/nova/flags.py index 9d6ef2a94..32cec119f 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -361,7 +361,7 @@ DEFINE_integer('rabbit_max_retries', 0, 'maximum rabbit connection attempts (0=try forever)') DEFINE_string('control_exchange', 'nova', 'the main exchange to connect to') DEFINE_boolean('rabbit_durable_queues', False, 'use durable queues') -DEFINE_list('enabled_apis', ['ec2', 'osapi'], +DEFINE_list('enabled_apis', ['ec2', 'osapi', 'metadata'], 'list of APIs to enable by default') DEFINE_string('ec2_host', '$my_ip', 'ip of api server') DEFINE_string('ec2_dmz_host', '$my_ip', 'internal ip of api server') @@ -377,7 +377,8 @@ DEFINE_integer('osapi_port', 8774, 'OpenStack API port') DEFINE_string('osapi_path', '/v1.1/', 'suffix for openstack') DEFINE_integer('osapi_max_limit', 1000, 'max number of items returned in a collection response') - +DEFINE_string('metadata_host', '$my_ip', 'ip of metadata server') +DEFINE_integer('metadata_port', 8775, 'Metadata API port') DEFINE_string('default_project', 'openstack', 'default project for openstack') DEFINE_string('default_image', 'ami-11111', 'default image to use, testing only') diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 6773bd619..2b6e62792 100755 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -377,7 +377,8 @@ def metadata_forward(): '-s 0.0.0.0/0 -d 169.254.169.254/32 ' '-p tcp -m tcp --dport 80 -j DNAT ' '--to-destination %s:%s' % \ - (FLAGS.ec2_dmz_host, FLAGS.ec2_port)) + (FLAGS.metadata_host, + FLAGS.metadata_port)) iptables_manager.apply() @@ -387,8 +388,8 @@ def metadata_accept(): '-s 0.0.0.0/0 -d %s ' '-p tcp -m tcp --dport %s ' '-j ACCEPT' % \ - (FLAGS.ec2_dmz_host, - FLAGS.ec2_port)) + (FLAGS.metadata_host, + FLAGS.metadata_port)) iptables_manager.apply() diff --git a/nova/objectstore/__init__.py b/nova/objectstore/__init__.py index ecad9be7c..f423f8845 100644 --- a/nova/objectstore/__init__.py +++ b/nova/objectstore/__init__.py @@ -25,7 +25,7 @@ :synopsis: Currently a trivial file-based system, getting extended w/ swift. .. moduleauthor:: Jesse Andrews <jesse@ansolabs.com> .. moduleauthor:: Devin Carlen <devin.carlen@gmail.com> -.. moduleauthor:: Vishvananda Ishaya <vishvananda@yahoo.com> +.. moduleauthor:: Vishvananda Ishaya <vishvananda@gmail.com> .. moduleauthor:: Joshua McKenty <joshua@cognition.ca> .. moduleauthor:: Manish Singh <yosh@gimp.org> .. moduleauthor:: Andy Smith <andy@anarkystic.com> diff --git a/nova/service.py b/nova/service.py index b9ad57943..47c88eede 100644 --- a/nova/service.py +++ b/nova/service.py @@ -45,16 +45,18 @@ flags.DEFINE_integer('report_interval', 10, flags.DEFINE_integer('periodic_interval', 60, 'seconds between running periodic tasks', lower_bound=1) -flags.DEFINE_string('ec2_manager', 'nova.api.manager.EC2Manager', - 'EC2 API service manager') flags.DEFINE_string('ec2_listen', "0.0.0.0", 'IP address for EC2 API to listen') flags.DEFINE_integer('ec2_listen_port', 8773, 'port for ec2 api to listen') -flags.DEFINE_string('osapi_manager', None, - 'OpenStack API service manager') flags.DEFINE_string('osapi_listen', "0.0.0.0", 'IP address for OpenStack API to listen') flags.DEFINE_integer('osapi_listen_port', 8774, 'port for os api to listen') +flags.DEFINE_string('metadata_manager', 'nova.api.manager.MetadataManager', + 'OpenStack metadata service manager') +flags.DEFINE_string('metadata_listen', "0.0.0.0", + 'IP address for metadata api to listen') +flags.DEFINE_integer('metadata_listen_port', 8775, + 'port for metadata api to listen') flags.DEFINE_string('api_paste_config', "api-paste.ini", 'File name for the paste.deploy config for nova-api') diff --git a/nova/tests/__init__.py b/nova/tests/__init__.py index 1109dfb70..676518a48 100644 --- a/nova/tests/__init__.py +++ b/nova/tests/__init__.py @@ -24,7 +24,7 @@ :platform: Unix .. moduleauthor:: Jesse Andrews <jesse@ansolabs.com> .. moduleauthor:: Devin Carlen <devin.carlen@gmail.com> -.. moduleauthor:: Vishvananda Ishaya <vishvananda@yahoo.com> +.. moduleauthor:: Vishvananda Ishaya <vishvananda@gmail.com> .. moduleauthor:: Joshua McKenty <joshua@cognition.ca> .. moduleauthor:: Manish Singh <yosh@gimp.org> .. moduleauthor:: Andy Smith <andy@anarkystic.com> diff --git a/nova/tests/integrated/integrated_helpers.py b/nova/tests/integrated/integrated_helpers.py index 5351c53f6..f9e1c76c4 100644 --- a/nova/tests/integrated/integrated_helpers.py +++ b/nova/tests/integrated/integrated_helpers.py @@ -93,6 +93,7 @@ class _IntegratedTestBase(test.TestCase): # Auto-assign ports to allow concurrent tests f['ec2_listen_port'] = 0 f['osapi_listen_port'] = 0 + f['metadata_listen_port'] = 0 f['image_service'] = 'nova.image.fake.FakeImageService' f['fake_network'] = True diff --git a/nova/tests/test_metadata.py b/nova/tests/test_metadata.py index 5aba8a545..283b6a7cb 100644 --- a/nova/tests/test_metadata.py +++ b/nova/tests/test_metadata.py @@ -21,7 +21,7 @@ import base64 import webob -from nova.api.ec2 import metadatarequesthandler +from nova.api.metadata import handler from nova.db.sqlalchemy import api from nova import exception from nova import flags @@ -86,7 +86,7 @@ class MetadataTestCase(test.TestCase): self.stubs.Set(api, 'instance_get', instance_get) self.stubs.Set(api, 'instance_get_all_by_filters', instance_get_list) self.stubs.Set(api, 'instance_get_floating_address', floating_get) - self.app = metadatarequesthandler.MetadataRequestHandler() + self.app = handler.MetadataRequestHandler() network_manager = fake_network.FakeNetworkManager() self.stubs.Set(self.app.cc.network_api, 'get_instance_uuids_by_ip_filter', |
