Moved migration and fixed tests from upstream
This commit is contained in:
@@ -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 = []
|
||||
|
||||
@@ -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)
|
||||
@@ -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": [
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user