summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-09-02 15:02:07 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-09-02 15:02:07 -0700
commit98b6a25ea57c43ecd400eff49e23a202dc6f9869 (patch)
tree321dbaaa899091711d62f8cbb97d8b37cfd2096b
parentbcc0004e0ebd1345dc3580e1cb01f7ca1222ef51 (diff)
parentd0a353e4c46773f23a25ff372ed204d17e89e049 (diff)
downloadnova-98b6a25ea57c43ecd400eff49e23a202dc6f9869.tar.gz
nova-98b6a25ea57c43ecd400eff49e23a202dc6f9869.tar.xz
nova-98b6a25ea57c43ecd400eff49e23a202dc6f9869.zip
merged trunk
-rw-r--r--bzrplugins/novalog/__init__.py59
-rw-r--r--nova/tests/api/__init__.py (renamed from nova/api/test.py)12
-rw-r--r--nova/tests/api/rackspace/__init__.py0
-rw-r--r--nova/tests/api/rackspace/flavors.py34
-rw-r--r--nova/tests/api/rackspace/images.py39
-rw-r--r--nova/tests/api/rackspace/servers.py58
-rw-r--r--nova/tests/api/rackspace/sharedipgroups.py40
-rw-r--r--nova/tests/api/test_helper.py7
-rw-r--r--nova/tests/api/wsgi_test.py (renamed from nova/wsgi_test.py)0
-rw-r--r--nova/virt/libvirt_conn.py9
-rw-r--r--nova/wsgi.py31
-rw-r--r--setup.py6
12 files changed, 269 insertions, 26 deletions
diff --git a/bzrplugins/novalog/__init__.py b/bzrplugins/novalog/__init__.py
new file mode 100644
index 000000000..e16b2e00f
--- /dev/null
+++ b/bzrplugins/novalog/__init__.py
@@ -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)
+
diff --git a/nova/api/test.py b/nova/tests/api/__init__.py
index 51b114b8e..59c4adc3d 100644
--- a/nova/api/test.py
+++ b/nova/tests/api/__init__.py
@@ -26,7 +26,7 @@ import webob
import webob.dec
from nova import api
-
+from nova.tests.api.test_helper import *
class Test(unittest.TestCase):
@@ -52,10 +52,8 @@ class Test(unittest.TestCase):
result = webob.Request.blank('/test/cloud').get_response(api.API())
self.assertNotEqual(result.body, "/cloud")
+ def test_query_api_version(self):
+ pass
-class APIStub(object):
- """Class to verify request and mark it was called."""
-
- @webob.dec.wsgify
- def __call__(self, req):
- return req.path_info
+if __name__ == '__main__':
+ unittest.main()
diff --git a/nova/tests/api/rackspace/__init__.py b/nova/tests/api/rackspace/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nova/tests/api/rackspace/__init__.py
diff --git a/nova/tests/api/rackspace/flavors.py b/nova/tests/api/rackspace/flavors.py
new file mode 100644
index 000000000..fb8ba94a5
--- /dev/null
+++ b/nova/tests/api/rackspace/flavors.py
@@ -0,0 +1,34 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.
+
+import unittest
+
+from nova.api.rackspace import flavors
+from nova.tests.api.test_helper import *
+
+class FlavorsTest(unittest.TestCase):
+ def setUp(self):
+ self.stubs = stubout.StubOutForTesting()
+
+ def tearDown(self):
+ self.stubs.UnsetAll()
+
+ def test_get_flavor_list(self):
+ pass
+
+ def test_get_flavor_by_id(self):
+ pass
diff --git a/nova/tests/api/rackspace/images.py b/nova/tests/api/rackspace/images.py
new file mode 100644
index 000000000..560d8c898
--- /dev/null
+++ b/nova/tests/api/rackspace/images.py
@@ -0,0 +1,39 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.
+
+import unittest
+
+from nova.api.rackspace import images
+from nova.tests.api.test_helper import *
+
+class ImagesTest(unittest.TestCase):
+ def setUp(self):
+ self.stubs = stubout.StubOutForTesting()
+
+ def tearDown(self):
+ self.stubs.UnsetAll()
+
+ def test_get_image_list(self):
+ pass
+
+ def test_delete_image(self):
+ pass
+
+ def test_create_image(self):
+ pass
+
+
diff --git a/nova/tests/api/rackspace/servers.py b/nova/tests/api/rackspace/servers.py
new file mode 100644
index 000000000..6d628e78a
--- /dev/null
+++ b/nova/tests/api/rackspace/servers.py
@@ -0,0 +1,58 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.
+
+import unittest
+
+from nova.api.rackspace import servers
+from nova.tests.api.test_helper import *
+
+class ServersTest(unittest.TestCase):
+ def setUp(self):
+ self.stubs = stubout.StubOutForTesting()
+
+ def tearDown(self):
+ self.stubs.UnsetAll()
+
+ def test_get_server_list(self):
+ pass
+
+ def test_create_instance(self):
+ pass
+
+ def test_get_server_by_id(self):
+ pass
+
+ def test_get_backup_schedule(self):
+ pass
+
+ def test_get_server_details(self):
+ pass
+
+ def test_get_server_ips(self):
+ pass
+
+ def test_server_reboot(self):
+ pass
+
+ def test_server_rebuild(self):
+ pass
+
+ def test_server_resize(self):
+ pass
+
+ def test_delete_server_instance(self):
+ pass
diff --git a/nova/tests/api/rackspace/sharedipgroups.py b/nova/tests/api/rackspace/sharedipgroups.py
new file mode 100644
index 000000000..b4b281db7
--- /dev/null
+++ b/nova/tests/api/rackspace/sharedipgroups.py
@@ -0,0 +1,40 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# 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.
+
+import unittest
+
+from nova.api.rackspace import sharedipgroups
+from nova.tests.api.test_helper import *
+
+class SharedIpGroupsTest(unittest.TestCase):
+ def setUp(self):
+ self.stubs = stubout.StubOutForTesting()
+
+ def tearDown(self):
+ self.stubs.UnsetAll()
+
+ def test_get_shared_ip_groups(self):
+ pass
+
+ def test_create_shared_ip_group(self):
+ pass
+
+ def test_delete_shared_ip_group(self):
+ pass
+
+
+
diff --git a/nova/tests/api/test_helper.py b/nova/tests/api/test_helper.py
new file mode 100644
index 000000000..8151a4af6
--- /dev/null
+++ b/nova/tests/api/test_helper.py
@@ -0,0 +1,7 @@
+import webob.dec
+
+class APIStub(object):
+ """Class to verify request and mark it was called."""
+ @webob.dec.wsgify
+ def __call__(self, req):
+ return req.path_info
diff --git a/nova/wsgi_test.py b/nova/tests/api/wsgi_test.py
index 786dc1bce..786dc1bce 100644
--- a/nova/wsgi_test.py
+++ b/nova/tests/api/wsgi_test.py
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index 931355cbd..621b7d576 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -23,7 +23,7 @@ A connection to a hypervisor (e.g. KVM) through libvirt.
import json
import logging
-import os.path
+import os
import shutil
from twisted.internet import defer
@@ -232,8 +232,11 @@ class LibvirtConnection(object):
f.write(libvirt_xml)
f.close()
- user = manager.AuthManager().get_user(inst.user_id)
- project = manager.AuthManager().get_project(inst.project_id)
+ os.close(os.open(basepath('console.log'), os.O_CREAT | os.O_WRONLY, 0660))
+
+ user = manager.AuthManager().get_user(inst['user_id'])
+ project = manager.AuthManager().get_project(inst['project_id'])
+
if not os.path.exists(basepath('disk')):
yield images.fetch(inst.image_id, basepath('disk-raw'), user, project)
if not os.path.exists(basepath('kernel')):
diff --git a/nova/wsgi.py b/nova/wsgi.py
index bec0a7b1c..8a4e2a9f4 100644
--- a/nova/wsgi.py
+++ b/nova/wsgi.py
@@ -241,6 +241,9 @@ class Serializer(object):
"""
self.environ = environ
self.metadata = metadata or {}
+ self._methods = {
+ 'application/json': self._to_json,
+ 'application/xml': self._to_xml}
def to_content_type(self, data):
"""
@@ -250,20 +253,20 @@ class Serializer(object):
"""
mimetype = 'application/xml'
# TODO(gundlach): determine mimetype from request
-
- if mimetype == 'application/json':
- import json
- return json.dumps(data)
- elif mimetype == 'application/xml':
- metadata = self.metadata.get('application/xml', {})
- # We expect data to contain a single key which is the XML root.
- root_key = data.keys()[0]
- from xml.dom import minidom
- doc = minidom.Document()
- node = self._to_xml_node(doc, metadata, root_key, data[root_key])
- return node.toprettyxml(indent=' ')
- else:
- return repr(data)
+ return self._methods.get(mimetype, repr)(data)
+
+ def _to_json(self, data):
+ import json
+ return json.dumps(data)
+
+ def _to_xml(self, data):
+ metadata = self.metadata.get('application/xml', {})
+ # We expect data to contain a single key which is the XML root.
+ root_key = data.keys()[0]
+ from xml.dom import minidom
+ doc = minidom.Document()
+ node = self._to_xml_node(doc, metadata, root_key, data[root_key])
+ return node.toprettyxml(indent=' ')
def _to_xml_node(self, doc, metadata, nodename, data):
"""Recursive method to convert data members to XML nodes."""
diff --git a/setup.py b/setup.py
index 25252e8f4..1767b00f4 100644
--- a/setup.py
+++ b/setup.py
@@ -29,8 +29,10 @@ class local_sdist(sdist):
def run(self):
if os.path.isdir('.bzr'):
# We're in a bzr branch
- log_cmd = subprocess.Popen(["bzr", "log", "--gnu"],
- stdout=subprocess.PIPE)
+ env = os.environ.copy()
+ env['BZR_PLUGIN_PATH'] = os.path.abspath('./bzrplugins')
+ log_cmd = subprocess.Popen(["bzr", "log", "--novalog"],
+ stdout=subprocess.PIPE, env=env)
changelog = log_cmd.communicate()[0]
with open("ChangeLog", "w") as changelog_file:
changelog_file.write(changelog)