Moved migration and fixed tests from upstream

This commit is contained in:
Christopher MacGown
2011-08-22 22:17:51 -07:00
parent b91a5542c1
commit 7f1adb50cf
7 changed files with 61 additions and 20 deletions

View File

@@ -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 = []

View File

@@ -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)

View File

@@ -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": [

View File

@@ -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)

View File

@@ -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))

View File

@@ -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"

View File

@@ -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