summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2011-03-30 12:34:10 -0700
committerVishvananda Ishaya <vishvananda@gmail.com>2011-03-30 12:34:10 -0700
commit1703592992ebdd5bbf19952f79f05022a4cdc849 (patch)
tree54ca1082b409edb4c3d7a40f922e377355c03454
parent323eb60884cf8736448d997068d32f252d22e7f3 (diff)
downloadnova-1703592992ebdd5bbf19952f79f05022a4cdc849.tar.gz
nova-1703592992ebdd5bbf19952f79f05022a4cdc849.tar.xz
nova-1703592992ebdd5bbf19952f79f05022a4cdc849.zip
remove all references to image_type and change nova-manage upload to set container format more intelligently
-rwxr-xr-xbin/nova-manage27
-rw-r--r--nova/api/openstack/servers.py2
-rw-r--r--nova/image/fake.py6
-rw-r--r--nova/image/s3.py1
-rw-r--r--nova/tests/api/openstack/test_image_metadata.py2
-rw-r--r--nova/virt/libvirt_conn.py1
6 files changed, 18 insertions, 21 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 6789efba8..4e14b6cab 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -894,20 +894,18 @@ class ImageCommands(object):
def __init__(self, *args, **kwargs):
self.image_service = utils.import_object(FLAGS.image_service)
- def _register(self, image_type, disk_format, container_format,
+ def _register(self, container_format, disk_format,
path, owner, name=None, is_public='T',
architecture='x86_64', kernel_id=None, ramdisk_id=None):
meta = {'is_public': True,
'name': name,
- 'disk_format': disk_format,
'container_format': container_format,
+ 'disk_format': disk_format,
'properties': {'image_state': 'available',
'owner_id': owner,
- 'type': image_type,
'architecture': architecture,
'image_location': 'local',
'is_public': (is_public == 'T')}}
- print image_type, meta
if kernel_id:
meta['properties']['kernel_id'] = int(kernel_id)
if ramdisk_id:
@@ -932,16 +930,17 @@ class ImageCommands(object):
ramdisk_id = self.ramdisk_register(ramdisk, owner, None,
is_public, architecture)
self.image_register(image, owner, name, is_public,
- architecture, kernel_id, ramdisk_id)
+ architecture, 'ami', 'ami',
+ kernel_id, ramdisk_id)
def image_register(self, path, owner, name=None, is_public='T',
- architecture='x86_64', kernel_id=None, ramdisk_id=None,
- disk_format='ami', container_format='ami'):
+ architecture='x86_64', container_format='bare',
+ disk_format='raw', kernel_id=None, ramdisk_id=None):
"""Uploads an image into the image_service
arguments: path owner [name] [is_public='T'] [architecture='x86_64']
- [kernel_id=None] [ramdisk_id=None]
- [disk_format='ami'] [container_format='ami']"""
- return self._register('machine', disk_format, container_format, path,
+ [container_format='bare'] [disk_format='raw']
+ [kernel_id=None] [ramdisk_id=None]"""
+ return self._register(container_format, disk_format, path,
owner, name, is_public, architecture,
kernel_id, ramdisk_id)
@@ -950,7 +949,7 @@ class ImageCommands(object):
"""Uploads a kernel into the image_service
arguments: path owner [name] [is_public='T'] [architecture='x86_64']
"""
- return self._register('kernel', 'aki', 'aki', path, owner, name,
+ return self._register('aki', 'aki', path, owner, name,
is_public, architecture)
def ramdisk_register(self, path, owner, name=None, is_public='T',
@@ -958,7 +957,7 @@ class ImageCommands(object):
"""Uploads a ramdisk into the image_service
arguments: path owner [name] [is_public='T'] [architecture='x86_64']
"""
- return self._register('ramdisk', 'ari', 'ari', path, owner, name,
+ return self._register('ari', 'ari', path, owner, name,
is_public, architecture)
def _lookup(self, old_image_id):
@@ -975,6 +974,9 @@ class ImageCommands(object):
'ramdisk': 'ari'}
container_format = mapping[old['type']]
disk_format = container_format
+ if container_format == 'ami' and not old.get('kernelId'):
+ container_format = 'bare'
+ disk_format = 'raw'
new = {'disk_format': disk_format,
'container_format': container_format,
'is_public': True,
@@ -982,7 +984,6 @@ class ImageCommands(object):
'properties': {'image_state': old['imageState'],
'owner_id': old['imageOwnerId'],
'architecture': old['architecture'],
- 'type': old['type'],
'image_location': old['imageLocation'],
'is_public': old['isPublic']}}
if old.get('kernelId'):
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index f7696d918..d640e8684 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -562,7 +562,7 @@ class Controller(wsgi.Controller):
_("Cannot build from image %(image_id)s, status not active") %
locals())
- if image_meta['properties']['disk_format'] != 'ami':
+ if image_meta.get('container_format') != 'ami':
return None, None
try:
diff --git a/nova/image/fake.py b/nova/image/fake.py
index 08302d6eb..d1c62757f 100644
--- a/nova/image/fake.py
+++ b/nova/image/fake.py
@@ -44,10 +44,10 @@ class FakeImageService(service.BaseImageService):
'created_at': timestamp,
'updated_at': timestamp,
'status': 'active',
- 'type': 'machine',
+ 'container_format': 'ami',
+ 'disk_format': 'raw',
'properties': {'kernel_id': FLAGS.null_kernel,
- 'ramdisk_id': FLAGS.null_kernel,
- 'disk_format': 'ami'}
+ 'ramdisk_id': FLAGS.null_kernel}
}
self.create(None, image)
super(FakeImageService, self).__init__()
diff --git a/nova/image/s3.py b/nova/image/s3.py
index ddec5f3aa..203bedc49 100644
--- a/nova/image/s3.py
+++ b/nova/image/s3.py
@@ -177,7 +177,6 @@ class S3ImageService(service.BaseImageService):
properties['ramdisk_id'] = ec2utils.ec2_id_to_id(ramdisk_id)
properties['is_public'] = False
- properties['type'] = image_type
metadata.update({'disk_format': image_format,
'container_format': image_format,
'status': 'queued',
diff --git a/nova/tests/api/openstack/test_image_metadata.py b/nova/tests/api/openstack/test_image_metadata.py
index 9be753f84..7c3287006 100644
--- a/nova/tests/api/openstack/test_image_metadata.py
+++ b/nova/tests/api/openstack/test_image_metadata.py
@@ -45,7 +45,6 @@ class ImageMetaDataTest(unittest.TestCase):
'is_public': True,
'deleted_at': None,
'properties': {
- 'type': 'ramdisk',
'key1': 'value1',
'key2': 'value2'
},
@@ -62,7 +61,6 @@ class ImageMetaDataTest(unittest.TestCase):
'is_public': True,
'deleted_at': None,
'properties': {
- 'type': 'ramdisk',
'key1': 'value1',
'key2': 'value2'
},
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index f34ea7225..adcb2ffa3 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -424,7 +424,6 @@ class LibvirtConnection(driver.ComputeDriver):
'container_format': base['container_format'],
'is_public': False,
'properties': {'architecture': base['architecture'],
- 'type': base['type'],
'name': '%s.%s' % (base['name'], image_id),
'kernel_id': instance['kernel_id'],
'image_location': 'snapshot',