Merge from trunk in an attempt to figure out why signer is generating the wrong signature
This commit is contained in:
@@ -26,7 +26,6 @@ from tornado import httpserver
|
||||
from tornado import ioloop
|
||||
|
||||
from nova import flags
|
||||
from nova import rpc
|
||||
from nova import server
|
||||
from nova import utils
|
||||
from nova.endpoint import admin
|
||||
@@ -43,14 +42,7 @@ def main(_argv):
|
||||
'Admin': admin.AdminController()}
|
||||
_app = api.APIServerApplication(controllers)
|
||||
|
||||
conn = rpc.Connection.instance()
|
||||
consumer = rpc.AdapterConsumer(connection=conn,
|
||||
topic=FLAGS.cloud_topic,
|
||||
proxy=controllers['Cloud'])
|
||||
|
||||
io_inst = ioloop.IOLoop.instance()
|
||||
_injected = consumer.attach_to_tornado(io_inst)
|
||||
|
||||
http_server = httpserver.HTTPServer(_app)
|
||||
http_server.listen(FLAGS.cc_port)
|
||||
logging.debug('Started HTTP server on %s', FLAGS.cc_port)
|
||||
|
||||
59
bzrplugins/novalog/__init__.py
Normal file
59
bzrplugins/novalog/__init__.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# Copyright 2010 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.
|
||||
|
||||
"""Log format for Nova's changelog."""
|
||||
|
||||
import bzrlib.log
|
||||
from bzrlib.osutils import format_date
|
||||
|
||||
#
|
||||
# This is mostly stolen from bzrlib.log.GnuChangelogLogFormatter
|
||||
# The difference is that it logs the author rather than the committer
|
||||
# which for Nova always is Tarmac.
|
||||
#
|
||||
class NovaLogFormat(bzrlib.log.GnuChangelogLogFormatter):
|
||||
preferred_levels = 1
|
||||
def log_revision(self, revision):
|
||||
"""Log a revision, either merged or not."""
|
||||
to_file = self.to_file
|
||||
|
||||
date_str = format_date(revision.rev.timestamp,
|
||||
revision.rev.timezone or 0,
|
||||
self.show_timezone,
|
||||
date_fmt='%Y-%m-%d',
|
||||
show_offset=False)
|
||||
|
||||
authors = revision.rev.get_apparent_authors()
|
||||
to_file.write('%s %s\n\n' % (date_str, ", ".join(authors)))
|
||||
|
||||
if revision.delta is not None and revision.delta.has_changed():
|
||||
for c in revision.delta.added + revision.delta.removed + revision.delta.modified:
|
||||
path, = c[:1]
|
||||
to_file.write('\t* %s:\n' % (path,))
|
||||
for c in revision.delta.renamed:
|
||||
oldpath,newpath = c[:2]
|
||||
# For renamed files, show both the old and the new path
|
||||
to_file.write('\t* %s:\n\t* %s:\n' % (oldpath,newpath))
|
||||
to_file.write('\n')
|
||||
|
||||
if not revision.rev.message:
|
||||
to_file.write('\tNo commit message\n')
|
||||
else:
|
||||
message = revision.rev.message.rstrip('\r\n')
|
||||
for l in message.split('\n'):
|
||||
to_file.write('\t%s\n' % (l.lstrip(),))
|
||||
to_file.write('\n')
|
||||
|
||||
bzrlib.log.register_formatter('novalog', NovaLogFormat)
|
||||
|
||||
@@ -169,7 +169,6 @@ def DECLARE(name, module_string, flag_values=FLAGS):
|
||||
DEFINE_string('connection_type', 'libvirt', 'libvirt, xenapi or fake')
|
||||
DEFINE_integer('s3_port', 3333, 's3 port')
|
||||
DEFINE_string('s3_host', '127.0.0.1', 's3 host')
|
||||
#DEFINE_string('cloud_topic', 'cloud', 'the topic clouds listen on')
|
||||
DEFINE_string('compute_topic', 'compute', 'the topic compute nodes listen on')
|
||||
DEFINE_string('volume_topic', 'volume', 'the topic volume nodes listen on')
|
||||
DEFINE_string('network_topic', 'network', 'the topic network nodes listen on')
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Unit tests for the API endpoint"""
|
||||
|
||||
import boto
|
||||
from boto.ec2 import regioninfo
|
||||
import httplib
|
||||
@@ -30,16 +32,17 @@ from nova.api.ec2 import cloud
|
||||
|
||||
|
||||
class FakeHttplibSocket(object):
|
||||
""" a fake socket implementation for httplib.HTTPResponse, trivial """
|
||||
def __init__(self, s):
|
||||
self.fp = StringIO.StringIO(s)
|
||||
"""a fake socket implementation for httplib.HTTPResponse, trivial"""
|
||||
def __init__(self, response_string):
|
||||
self._buffer = StringIO.StringIO(response_string)
|
||||
|
||||
def makefile(self, mode, other):
|
||||
return self.fp
|
||||
def makefile(self, _mode, _other):
|
||||
"""Returns the socket's internal buffer"""
|
||||
return self._buffer
|
||||
|
||||
|
||||
class FakeHttplibConnection(object):
|
||||
""" a fake httplib.HTTPConnection for boto to use
|
||||
"""A fake httplib.HTTPConnection for boto to use
|
||||
|
||||
requests made via this connection actually get translated and routed into
|
||||
our WSGI app, we then wait for the response and turn it back into
|
||||
@@ -70,11 +73,13 @@ class FakeHttplibConnection(object):
|
||||
return self.http_response
|
||||
|
||||
def close(self):
|
||||
"""Required for compatibility with boto/tornado"""
|
||||
pass
|
||||
|
||||
|
||||
class ApiEc2TestCase(test.BaseTestCase):
|
||||
def setUp(self):
|
||||
"""Unit test for the cloud controller on an EC2 API"""
|
||||
def setUp(self): # pylint: disable-msg=C0103,C0111
|
||||
super(ApiEc2TestCase, self).setUp()
|
||||
|
||||
self.manager = manager.AuthManager()
|
||||
@@ -94,12 +99,16 @@ class ApiEc2TestCase(test.BaseTestCase):
|
||||
self.mox.StubOutWithMock(self.ec2, 'new_http_connection')
|
||||
|
||||
def expect_http(self, host=None, is_secure=False):
|
||||
"""Returns a new EC2 connection"""
|
||||
http = FakeHttplibConnection(
|
||||
self.app, '%s:0' % (self.host), False)
|
||||
# pylint: disable-msg=E1103
|
||||
self.ec2.new_http_connection(host, is_secure).AndReturn(http)
|
||||
return http
|
||||
|
||||
def test_describe_instances(self):
|
||||
"""Test that, after creating a user and a project, the describe
|
||||
instances call to the API works properly"""
|
||||
self.expect_http()
|
||||
self.mox.ReplayAll()
|
||||
user = self.manager.create_user('fake', 'fake', 'fake')
|
||||
@@ -110,14 +119,18 @@ class ApiEc2TestCase(test.BaseTestCase):
|
||||
|
||||
|
||||
def test_get_all_key_pairs(self):
|
||||
"""Test that, after creating a user and project and generating
|
||||
a key pair, that the API call to list key pairs works properly"""
|
||||
self.expect_http()
|
||||
self.mox.ReplayAll()
|
||||
keyname = "".join(random.choice("sdiuisudfsdcnpaqwertasd") for x in range(random.randint(4, 8)))
|
||||
keyname = "".join(random.choice("sdiuisudfsdcnpaqwertasd") \
|
||||
for x in range(random.randint(4, 8)))
|
||||
user = self.manager.create_user('fake', 'fake', 'fake')
|
||||
project = self.manager.create_project('fake', 'fake', 'fake')
|
||||
self.manager.generate_key_pair(user.id, keyname)
|
||||
|
||||
rv = self.ec2.get_all_key_pairs()
|
||||
self.assertTrue(filter(lambda k: k.name == keyname, rv))
|
||||
results = [k for k in rv if k.name == keyname]
|
||||
self.assertEquals(len(results), 1)
|
||||
self.manager.delete_project(project)
|
||||
self.manager.delete_user(user)
|
||||
|
||||
@@ -47,10 +47,6 @@ class CloudTestCase(test.BaseTestCase):
|
||||
|
||||
# set up our cloud
|
||||
self.cloud = cloud.CloudController()
|
||||
self.cloud_consumer = rpc.AdapterConsumer(connection=self.conn,
|
||||
topic=FLAGS.cloud_topic,
|
||||
proxy=self.cloud)
|
||||
self.injected.append(self.cloud_consumer.attach_to_tornado(self.ioloop))
|
||||
|
||||
# set up a service
|
||||
self.compute = service.ComputeService()
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2010 United States Government as represented by the
|
||||
# Administrator of the National Aeronautics and Space Administration.
|
||||
# Copyright 2010 OpenStack LLC.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
Test WSGI basics and provide some helper functions for other WSGI tests.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import routes
|
||||
import webob
|
||||
|
||||
from nova import wsgi
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
def test_debug(self):
|
||||
|
||||
class Application(wsgi.Application):
|
||||
"""Dummy application to test debug."""
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
start_response("200", [("X-Test", "checking")])
|
||||
return ['Test result']
|
||||
|
||||
application = wsgi.Debug(Application())
|
||||
result = webob.Request.blank('/').get_response(application)
|
||||
self.assertEqual(result.body, "Test result")
|
||||
|
||||
def test_router(self):
|
||||
|
||||
class Application(wsgi.Application):
|
||||
"""Test application to call from router."""
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
start_response("200", [])
|
||||
return ['Router result']
|
||||
|
||||
class Router(wsgi.Router):
|
||||
"""Test router."""
|
||||
|
||||
def __init__(self):
|
||||
mapper = routes.Mapper()
|
||||
mapper.connect("/test", controller=Application())
|
||||
super(Router, self).__init__(mapper)
|
||||
|
||||
result = webob.Request.blank('/test').get_response(Router())
|
||||
self.assertEqual(result.body, "Router result")
|
||||
result = webob.Request.blank('/bad').get_response(Router())
|
||||
self.assertNotEqual(result.body, "Router result")
|
||||
|
||||
def test_controller(self):
|
||||
|
||||
class Controller(wsgi.Controller):
|
||||
"""Test controller to call from router."""
|
||||
test = self
|
||||
|
||||
def show(self, req, id): # pylint: disable-msg=W0622,C0103
|
||||
"""Default action called for requests with an ID."""
|
||||
self.test.assertEqual(req.path_info, '/tests/123')
|
||||
self.test.assertEqual(id, '123')
|
||||
return id
|
||||
|
||||
class Router(wsgi.Router):
|
||||
"""Test router."""
|
||||
|
||||
def __init__(self):
|
||||
mapper = routes.Mapper()
|
||||
mapper.resource("test", "tests", controller=Controller())
|
||||
super(Router, self).__init__(mapper)
|
||||
|
||||
result = webob.Request.blank('/tests/123').get_response(Router())
|
||||
self.assertEqual(result.body, "123")
|
||||
result = webob.Request.blank('/test/123').get_response(Router())
|
||||
self.assertNotEqual(result.body, "123")
|
||||
|
||||
def test_serializer(self):
|
||||
# TODO(eday): Placeholder for serializer testing.
|
||||
pass
|
||||
Reference in New Issue
Block a user