Add raw disk image support.
This commit is contained in:
1
.mailmap
1
.mailmap
@@ -19,6 +19,7 @@
|
|||||||
<mordred@inaugust.com> <mordred@hudson>
|
<mordred@inaugust.com> <mordred@hudson>
|
||||||
<paul@openstack.org> <pvoccio@castor.local>
|
<paul@openstack.org> <pvoccio@castor.local>
|
||||||
<paul@openstack.org> <paul.voccio@rackspace.com>
|
<paul@openstack.org> <paul.voccio@rackspace.com>
|
||||||
|
<soren.hansen@rackspace.com> <soren@linux2go.dk>
|
||||||
<todd@ansolabs.com> <todd@lapex>
|
<todd@ansolabs.com> <todd@lapex>
|
||||||
<todd@ansolabs.com> <todd@rubidine.com>
|
<todd@ansolabs.com> <todd@rubidine.com>
|
||||||
<vishvananda@gmail.com> <vishvananda@yahoo.com>
|
<vishvananda@gmail.com> <vishvananda@yahoo.com>
|
||||||
|
@@ -13,7 +13,7 @@ include nova/cloudpipe/client.ovpn.template
|
|||||||
include nova/compute/fakevirtinstance.xml
|
include nova/compute/fakevirtinstance.xml
|
||||||
include nova/compute/interfaces.template
|
include nova/compute/interfaces.template
|
||||||
include nova/virt/interfaces.template
|
include nova/virt/interfaces.template
|
||||||
include nova/virt/libvirt.*.xml.template
|
include nova/virt/libvirt*.xml.template
|
||||||
include nova/tests/CA/
|
include nova/tests/CA/
|
||||||
include nova/tests/CA/cacert.pem
|
include nova/tests/CA/cacert.pem
|
||||||
include nova/tests/CA/private/
|
include nova/tests/CA/private/
|
||||||
|
@@ -235,12 +235,11 @@ DEFINE_string('ec2_url', 'http://127.0.0.1:8773/services/Cloud',
|
|||||||
|
|
||||||
DEFINE_string('default_image', 'ami-11111',
|
DEFINE_string('default_image', 'ami-11111',
|
||||||
'default image to use, testing only')
|
'default image to use, testing only')
|
||||||
DEFINE_string('default_kernel', 'aki-11111',
|
|
||||||
'default kernel to use, testing only')
|
|
||||||
DEFINE_string('default_ramdisk', 'ari-11111',
|
|
||||||
'default ramdisk to use, testing only')
|
|
||||||
DEFINE_string('default_instance_type', 'm1.small',
|
DEFINE_string('default_instance_type', 'm1.small',
|
||||||
'default instance type to use, testing only')
|
'default instance type to use, testing only')
|
||||||
|
DEFINE_string('null_kernel', 'nokernel',
|
||||||
|
'kernel image that indicates not to use a kernel,'
|
||||||
|
' but to use a raw disk image instead')
|
||||||
|
|
||||||
DEFINE_string('vpn_image_id', 'ami-CLOUDPIPE', 'AMI for cloudpipe vpn server')
|
DEFINE_string('vpn_image_id', 'ami-CLOUDPIPE', 'AMI for cloudpipe vpn server')
|
||||||
DEFINE_string('vpn_key_suffix',
|
DEFINE_string('vpn_key_suffix',
|
||||||
|
@@ -40,19 +40,51 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
self.network = utils.import_object(FLAGS.network_manager)
|
self.network = utils.import_object(FLAGS.network_manager)
|
||||||
FLAGS.instances_path = ''
|
FLAGS.instances_path = ''
|
||||||
|
|
||||||
def test_get_uri_and_template(self):
|
test_ip = '10.11.12.13'
|
||||||
ip = '10.11.12.13'
|
test_instance = {'memory_kb': '1024000',
|
||||||
|
'basepath': '/some/path',
|
||||||
|
'bridge_name': 'br100',
|
||||||
|
'mac_address': '02:12:34:46:56:67',
|
||||||
|
'vcpus': 2,
|
||||||
|
'project_id': 'fake',
|
||||||
|
'bridge': 'br101',
|
||||||
|
'instance_type': 'm1.small'}
|
||||||
|
|
||||||
instance = {'internal_id': 1,
|
def test_xml_and_uri_no_ramdisk_no_kernel(self):
|
||||||
'memory_kb': '1024000',
|
instance_data = dict(self.test_instance)
|
||||||
'basepath': '/some/path',
|
self.do_test_xml_and_uri(instance_data,
|
||||||
'bridge_name': 'br100',
|
expect_kernel=False, expect_ramdisk=False)
|
||||||
'mac_address': '02:12:34:46:56:67',
|
|
||||||
'vcpus': 2,
|
|
||||||
'project_id': 'fake',
|
|
||||||
'bridge': 'br101',
|
|
||||||
'instance_type': 'm1.small'}
|
|
||||||
|
|
||||||
|
def test_xml_and_uri_no_ramdisk(self):
|
||||||
|
instance_data = dict(self.test_instance)
|
||||||
|
instance_data['kernel_id'] = 'aki-deadbeef'
|
||||||
|
self.do_test_xml_and_uri(instance_data,
|
||||||
|
expect_kernel=True, expect_ramdisk=False)
|
||||||
|
|
||||||
|
def test_xml_and_uri_no_kernel(self):
|
||||||
|
instance_data = dict(self.test_instance)
|
||||||
|
instance_data['ramdisk_id'] = 'ari-deadbeef'
|
||||||
|
self.do_test_xml_and_uri(instance_data,
|
||||||
|
expect_kernel=False, expect_ramdisk=False)
|
||||||
|
|
||||||
|
def test_xml_and_uri(self):
|
||||||
|
instance_data = dict(self.test_instance)
|
||||||
|
instance_data['ramdisk_id'] = 'ari-deadbeef'
|
||||||
|
instance_data['kernel_id'] = 'aki-deadbeef'
|
||||||
|
self.do_test_xml_and_uri(instance_data,
|
||||||
|
expect_kernel=True, expect_ramdisk=True)
|
||||||
|
|
||||||
|
def test_xml_and_uri_rescue(self):
|
||||||
|
instance_data = dict(self.test_instance)
|
||||||
|
instance_data['ramdisk_id'] = 'ari-deadbeef'
|
||||||
|
instance_data['kernel_id'] = 'aki-deadbeef'
|
||||||
|
self.do_test_xml_and_uri(instance_data,
|
||||||
|
expect_kernel=True, expect_ramdisk=True,
|
||||||
|
rescue=True)
|
||||||
|
|
||||||
|
def do_test_xml_and_uri(self, instance,
|
||||||
|
expect_ramdisk, expect_kernel,
|
||||||
|
rescue=False):
|
||||||
user_context = context.RequestContext(project=self.project,
|
user_context = context.RequestContext(project=self.project,
|
||||||
user=self.user)
|
user=self.user)
|
||||||
instance_ref = db.instance_create(user_context, instance)
|
instance_ref = db.instance_create(user_context, instance)
|
||||||
@@ -60,13 +92,14 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
self.network.set_network_host(context.get_admin_context(),
|
self.network.set_network_host(context.get_admin_context(),
|
||||||
network_ref['id'])
|
network_ref['id'])
|
||||||
|
|
||||||
fixed_ip = {'address': ip,
|
fixed_ip = {'address': self.test_ip,
|
||||||
'network_id': network_ref['id']}
|
'network_id': network_ref['id']}
|
||||||
|
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
fixed_ip_ref = db.fixed_ip_create(ctxt, fixed_ip)
|
fixed_ip_ref = db.fixed_ip_create(ctxt, fixed_ip)
|
||||||
db.fixed_ip_update(ctxt, ip, {'allocated': True,
|
db.fixed_ip_update(ctxt, self.test_ip,
|
||||||
'instance_id': instance_ref['id']})
|
{'allocated': True,
|
||||||
|
'instance_id': instance_ref['id']})
|
||||||
|
|
||||||
type_uri_map = {'qemu': ('qemu:///system',
|
type_uri_map = {'qemu': ('qemu:///system',
|
||||||
[(lambda t: t.find('.').get('type'), 'qemu'),
|
[(lambda t: t.find('.').get('type'), 'qemu'),
|
||||||
@@ -78,23 +111,71 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
(lambda t: t.find('./devices/emulator'), None)]),
|
(lambda t: t.find('./devices/emulator'), None)]),
|
||||||
'uml': ('uml:///system',
|
'uml': ('uml:///system',
|
||||||
[(lambda t: t.find('.').get('type'), 'uml'),
|
[(lambda t: t.find('.').get('type'), 'uml'),
|
||||||
(lambda t: t.find('./os/type').text, 'uml')])}
|
(lambda t: t.find('./os/type').text, 'uml')]),
|
||||||
|
'xen': ('xen:///',
|
||||||
|
[(lambda t: t.find('.').get('type'), 'xen'),
|
||||||
|
(lambda t: t.find('./os/type').text, 'linux')]),
|
||||||
|
}
|
||||||
|
|
||||||
|
for hypervisor_type in ['qemu', 'kvm', 'xen']:
|
||||||
|
check_list = type_uri_map[hypervisor_type][1]
|
||||||
|
|
||||||
|
if rescue:
|
||||||
|
check = (lambda t: t.find('./os/kernel').text.split('/')[1],
|
||||||
|
'rescue-kernel')
|
||||||
|
check_list.append(check)
|
||||||
|
check = (lambda t: t.find('./os/initrd').text.split('/')[1],
|
||||||
|
'rescue-ramdisk')
|
||||||
|
check_list.append(check)
|
||||||
|
else:
|
||||||
|
if expect_kernel:
|
||||||
|
check = (lambda t: t.find('./os/kernel').text.split('/'
|
||||||
|
)[1], 'kernel')
|
||||||
|
else:
|
||||||
|
check = (lambda t: t.find('./os/kernel'), None)
|
||||||
|
check_list.append(check)
|
||||||
|
|
||||||
|
if expect_ramdisk:
|
||||||
|
check = (lambda t: t.find('./os/initrd').text.split('/'
|
||||||
|
)[1], 'ramdisk')
|
||||||
|
else:
|
||||||
|
check = (lambda t: t.find('./os/initrd'), None)
|
||||||
|
check_list.append(check)
|
||||||
|
|
||||||
common_checks = [
|
common_checks = [
|
||||||
(lambda t: t.find('.').tag, 'domain'),
|
(lambda t: t.find('.').tag, 'domain'),
|
||||||
(lambda t: t.find('./devices/interface/filterref/parameter').\
|
(lambda t: t.find('./devices/interface/filterref/parameter'
|
||||||
get('name'), 'IP'),
|
).get('name'), 'IP'),
|
||||||
(lambda t: t.find('./devices/interface/filterref/parameter').\
|
(lambda t: t.find('./devices/interface/filterref/parameter'
|
||||||
get('value'), '10.11.12.13')]
|
).get('value'), '10.11.12.13'),
|
||||||
|
(lambda t: t.findall('./devices/interface/filterref/parameter'
|
||||||
|
)[1].get('name'), 'DHCPSERVER'),
|
||||||
|
(lambda t: t.findall('./devices/interface/filterref/parameter'
|
||||||
|
)[1].get('value'), '10.0.0.1'),
|
||||||
|
(lambda t: t.find('./devices/serial/source').get('path'
|
||||||
|
).split('/')[1], 'console.log'),
|
||||||
|
(lambda t: t.find('./memory').text, '2097152')]
|
||||||
|
|
||||||
|
if rescue:
|
||||||
|
common_checks += [(lambda t: t.findall('./devices/disk/source'
|
||||||
|
)[0].get('file').split('/')[1],
|
||||||
|
'rescue-disk'),
|
||||||
|
(lambda t: t.findall('./devices/disk/source'
|
||||||
|
)[1].get('file').split('/')[1],
|
||||||
|
'disk')]
|
||||||
|
else:
|
||||||
|
common_checks += [(lambda t: t.findall('./devices/disk/source'
|
||||||
|
)[0].get('file').split('/')[1],
|
||||||
|
'disk')]
|
||||||
|
|
||||||
for (libvirt_type, (expected_uri, checks)) in type_uri_map.iteritems():
|
for (libvirt_type, (expected_uri, checks)) in type_uri_map.iteritems():
|
||||||
FLAGS.libvirt_type = libvirt_type
|
FLAGS.libvirt_type = libvirt_type
|
||||||
conn = libvirt_conn.LibvirtConnection(True)
|
conn = libvirt_conn.LibvirtConnection(True)
|
||||||
|
|
||||||
uri, _template, _rescue = conn.get_uri_and_templates()
|
uri = conn.get_uri()
|
||||||
self.assertEquals(uri, expected_uri)
|
self.assertEquals(uri, expected_uri)
|
||||||
|
|
||||||
xml = conn.to_xml(instance_ref)
|
xml = conn.to_xml(instance_ref, rescue)
|
||||||
tree = xml_to_tree(xml)
|
tree = xml_to_tree(xml)
|
||||||
for i, (check, expected_result) in enumerate(checks):
|
for i, (check, expected_result) in enumerate(checks):
|
||||||
self.assertEqual(check(tree),
|
self.assertEqual(check(tree),
|
||||||
@@ -106,6 +187,9 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
expected_result,
|
expected_result,
|
||||||
'%s failed common check %d' % (xml, i))
|
'%s failed common check %d' % (xml, i))
|
||||||
|
|
||||||
|
# This test is supposed to make sure we don't override a specifically
|
||||||
|
# set uri
|
||||||
|
#
|
||||||
# Deliberately not just assigning this string to FLAGS.libvirt_uri and
|
# Deliberately not just assigning this string to FLAGS.libvirt_uri and
|
||||||
# checking against that later on. This way we make sure the
|
# checking against that later on. This way we make sure the
|
||||||
# implementation doesn't fiddle around with the FLAGS.
|
# implementation doesn't fiddle around with the FLAGS.
|
||||||
@@ -114,7 +198,7 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
for (libvirt_type, (expected_uri, checks)) in type_uri_map.iteritems():
|
for (libvirt_type, (expected_uri, checks)) in type_uri_map.iteritems():
|
||||||
FLAGS.libvirt_type = libvirt_type
|
FLAGS.libvirt_type = libvirt_type
|
||||||
conn = libvirt_conn.LibvirtConnection(True)
|
conn = libvirt_conn.LibvirtConnection(True)
|
||||||
uri, _template, _rescue = conn.get_uri_and_templates()
|
uri = conn.get_uri()
|
||||||
self.assertEquals(uri, testuri)
|
self.assertEquals(uri, testuri)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
Reference in New Issue
Block a user