summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher MacGown <chris@pistoncloud.com>2011-08-22 22:17:51 -0700
committerChristopher MacGown <chris@pistoncloud.com>2011-08-22 22:17:51 -0700
commit7f1adb50cfab91a553f2d129b9b2eef1e5b2145b (patch)
tree2d0c37cde4586fe778d02c536c820d332a79c666
parentb91a5542c17e25e3b1cf08a79d88673cfe0a7e9e (diff)
downloadnova-7f1adb50cfab91a553f2d129b9b2eef1e5b2145b.tar.gz
nova-7f1adb50cfab91a553f2d129b9b2eef1e5b2145b.tar.xz
nova-7f1adb50cfab91a553f2d129b9b2eef1e5b2145b.zip
Moved migration and fixed tests from upstream
-rw-r--r--nova/compute/api.py2
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/041_add_config_drive_to_instances.py38
-rw-r--r--nova/tests/api/openstack/test_servers.py28
-rw-r--r--nova/tests/test_compute.py2
-rw-r--r--nova/virt/disk.py2
-rw-r--r--nova/virt/libvirt/connection.py7
-rw-r--r--nova/virt/xenapi/vm_utils.py2
7 files changed, 61 insertions, 20 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 74149f17d..69f76bf40 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -526,7 +526,7 @@ class API(base.Base):
availability_zone, user_data, metadata,
injected_files, admin_password, zone_blob,
reservation_id, access_ip_v4, access_ip_v6,
- requested_networks, config_drive
+ requested_networks, config_drive)
block_device_mapping = block_device_mapping or []
instances = []
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/041_add_config_drive_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/041_add_config_drive_to_instances.py
new file mode 100644
index 000000000..d3058f00d
--- /dev/null
+++ b/nova/db/sqlalchemy/migrate_repo/versions/041_add_config_drive_to_instances.py
@@ -0,0 +1,38 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# Copyright 2011 Piston Cloud Computing, Inc.
+#
+# 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.
+
+from sqlalchemy import Column, Integer, MetaData, String, Table
+
+from nova import utils
+
+
+meta = MetaData()
+
+instances = Table("instances", meta,
+ Column("id", Integer(), primary_key=True, nullable=False))
+
+# matches the size of an image_ref
+config_drive_column = Column("config_drive", String(255), nullable=True)
+
+
+def upgrade(migrate_engine):
+ meta.bind = migrate_engine
+ instances.create_column(config_drive_column)
+
+
+def downgrade(migrate_engine):
+ meta.bind = migrate_engine
+ instances.drop_column(config_drive_column)
diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py
index f854a500c..aec2ad947 100644
--- a/nova/tests/api/openstack/test_servers.py
+++ b/nova/tests/api/openstack/test_servers.py
@@ -1776,8 +1776,8 @@ class ServersTest(test.TestCase):
self.config_drive = True
self._setup_for_create_instance()
- image_href = 'http://localhost/v1.1/images/2'
- flavor_ref = 'http://localhost/v1.1/flavors/3'
+ image_href = 'http://localhost/v1.1/123/images/2'
+ flavor_ref = 'http://localhost/v1.1/123/flavors/3'
body = {
'server': {
'name': 'config_drive_test',
@@ -1792,12 +1792,13 @@ class ServersTest(test.TestCase):
},
}
- req = webob.Request.blank('/v1.1/servers')
+ req = webob.Request.blank('/v1.1/123/servers')
req.method = 'POST'
req.body = json.dumps(body)
req.headers["content-type"] = "application/json"
res = req.get_response(fakes.wsgi_app())
+ print res
self.assertEqual(res.status_int, 202)
server = json.loads(res.body)['server']
self.assertEqual(1, server['id'])
@@ -1807,8 +1808,8 @@ class ServersTest(test.TestCase):
self.config_drive = 2
self._setup_for_create_instance()
- image_href = 'http://localhost/v1.1/images/2'
- flavor_ref = 'http://localhost/v1.1/flavors/3'
+ image_href = 'http://localhost/v1.1/123/images/2'
+ flavor_ref = 'http://localhost/v1.1/123/flavors/3'
body = {
'server': {
'name': 'config_drive_test',
@@ -1823,7 +1824,7 @@ class ServersTest(test.TestCase):
},
}
- req = webob.Request.blank('/v1.1/servers')
+ req = webob.Request.blank('/v1.1/123/servers')
req.method = 'POST'
req.body = json.dumps(body)
req.headers["content-type"] = "application/json"
@@ -1840,8 +1841,8 @@ class ServersTest(test.TestCase):
self.config_drive = "asdf"
self._setup_for_create_instance()
- image_href = 'http://localhost/v1.1/images/2'
- flavor_ref = 'http://localhost/v1.1/flavors/3'
+ image_href = 'http://localhost/v1.1/123/images/2'
+ flavor_ref = 'http://localhost/v1.1/123/flavors/3'
body = {
'server': {
'name': 'config_drive_test',
@@ -1856,7 +1857,7 @@ class ServersTest(test.TestCase):
},
}
- req = webob.Request.blank('/v1.1/servers')
+ req = webob.Request.blank('/v1.1/123/servers')
req.method = 'POST'
req.body = json.dumps(body)
req.headers["content-type"] = "application/json"
@@ -1867,8 +1868,8 @@ class ServersTest(test.TestCase):
def test_create_instance_without_config_drive_v1_1(self):
self._setup_for_create_instance()
- image_href = 'http://localhost/v1.1/images/2'
- flavor_ref = 'http://localhost/v1.1/flavors/3'
+ image_href = 'http://localhost/v1.1/123/images/2'
+ flavor_ref = 'http://localhost/v1.1/123/flavors/3'
body = {
'server': {
'name': 'config_drive_test',
@@ -1883,7 +1884,7 @@ class ServersTest(test.TestCase):
},
}
- req = webob.Request.blank('/v1.1/servers')
+ req = webob.Request.blank('/v1.1/123/servers')
req.method = 'POST'
req.body = json.dumps(body)
req.headers["content-type"] = "application/json"
@@ -3588,6 +3589,7 @@ class ServersViewBuilderV11Test(test.TestCase):
"id": 1,
"uuid": self.instance['uuid'],
"name": "test_server",
+ "config_drive": None,
"links": [
{
"rel": "self",
@@ -3747,6 +3749,7 @@ class ServersViewBuilderV11Test(test.TestCase):
},
"addresses": {},
"metadata": {},
+ "config_drive": None,
"accessIPv4": "1.2.3.4",
"accessIPv6": "",
"links": [
@@ -3801,6 +3804,7 @@ class ServersViewBuilderV11Test(test.TestCase):
},
"addresses": {},
"metadata": {},
+ "config_drive": None,
"accessIPv4": "",
"accessIPv6": "fead::1234",
"links": [
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py
index b75e25dda..0523d73b6 100644
--- a/nova/tests/test_compute.py
+++ b/nova/tests/test_compute.py
@@ -163,7 +163,7 @@ class ComputeTestCase(test.TestCase):
def test_create_instance_associates_config_drive(self):
"""Make sure create associates a config drive."""
- instance_id = self._create_instance(params={'config_drive': True,})
+ instance_id = self._create_instance(params={'config_drive': True, })
try:
self.compute.run_instance(self.context, instance_id)
diff --git a/nova/virt/disk.py b/nova/virt/disk.py
index 809d3323c..52b2881e8 100644
--- a/nova/virt/disk.py
+++ b/nova/virt/disk.py
@@ -228,7 +228,7 @@ def _inject_metadata_into_fs(metadata, fs, execute=None):
metadata_path = os.path.join(fs, "meta.js")
metadata = dict([(m.key, m.value) for m in metadata])
- utils.execute('sudo', 'tee', metadata_path,
+ utils.execute('sudo', 'tee', metadata_path,
process_input=json.dumps(metadata))
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 23fa86f65..4388291db 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -131,8 +131,8 @@ flags.DEFINE_string('libvirt_vif_type', 'bridge',
flags.DEFINE_string('libvirt_vif_driver',
'nova.virt.libvirt.vif.LibvirtBridgeDriver',
'The libvirt VIF driver to configure the VIFs.')
-flags.DEFINE_string('default_local_format',
- None,
+flags.DEFINE_string('default_local_format',
+ None,
'The default format a local_volume will be formatted with '
'on creation.')
@@ -970,7 +970,7 @@ class LibvirtConnection(driver.ComputeDriver):
for injection in ('metadata', 'key', 'net'):
if locals()[injection]:
LOG.info(_('instance %(inst_name)s: injecting '
- '%(injection)s into image %(img_id)s'
+ '%(injection)s into image %(img_id)s'
% locals()))
try:
disk.inject_data(injection_path, key, net, metadata,
@@ -1106,7 +1106,6 @@ class LibvirtConnection(driver.ComputeDriver):
block_device_info)):
xml_info['swap_device'] = self.default_swap_device
-
config_drive = False
if instance.get('config_drive') or instance.get('config_drive_id'):
xml_info['config_drive'] = xml_info['basepath'] + "/disk.config"
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 18fe84e6c..efbea7076 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -741,7 +741,7 @@ class VMHelper(HelperBase):
# if at all, so determine whether it's required first, and then do
# everything
mount_required = False
- key, net, metadata = _prepare_injectables(instance, network_info)
+ key, net, metadata = _prepare_injectables(instance, network_info)
mount_required = key or net or metadata
if not mount_required:
return