diff options
| author | Isaku Yamahata <yamahata@valinux.co.jp> | 2011-09-17 17:50:41 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-09-17 17:50:41 +0000 |
| commit | 830a85815cc6b53395a91efb93466692dc33fc83 (patch) | |
| tree | f617030c61446d59faf6ccb14fe5a76fa324c583 /nova/compute | |
| parent | 0dc06712aa06a60a582938770a9555b9df90fa22 (diff) | |
| parent | 24db80baa4a5125ba32250b7aa495b58465cfdf5 (diff) | |
When swap is specified as block device mapping, its size becomes 0 wrongly.
This patch make it set to correct size according to instance_type.
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 95ea13f61..d8657d403 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -287,18 +287,24 @@ class API(base.Base): return (num_instances, base_options, image) @staticmethod - def _ephemeral_size(instance_type, ephemeral_name): - num = block_device.ephemeral_num(ephemeral_name) + def _volume_size(instance_type, virtual_name): + size = 0 + if virtual_name == 'swap': + size = instance_type.get('swap', 0) + elif block_device.is_ephemeral(virtual_name): + num = block_device.ephemeral_num(virtual_name) - # TODO(yamahata): ephemeralN where N > 0 - # Only ephemeral0 is allowed for now because InstanceTypes - # table only allows single local disk, local_gb. - # In order to enhance it, we need to add a new columns to - # instance_types table. - if num > 0: - return 0 + # TODO(yamahata): ephemeralN where N > 0 + # Only ephemeral0 is allowed for now because InstanceTypes + # table only allows single local disk, local_gb. + # In order to enhance it, we need to add a new columns to + # instance_types table. + if num > 0: + return 0 - return instance_type.get('local_gb') + size = instance_type.get('local_gb') + + return size def _update_image_block_device_mapping(self, elevated_context, instance_type, instance_id, @@ -319,12 +325,7 @@ class API(base.Base): if not block_device.is_swap_or_ephemeral(virtual_name): continue - size = 0 - if virtual_name == 'swap': - size = instance_type.get('swap', 0) - elif block_device.is_ephemeral(virtual_name): - size = self._ephemeral_size(instance_type, virtual_name) - + size = self._volume_size(instance_type, virtual_name) if size == 0: continue @@ -354,8 +355,8 @@ class API(base.Base): virtual_name = bdm.get('virtual_name') if (virtual_name is not None and - block_device.is_ephemeral(virtual_name)): - size = self._ephemeral_size(instance_type, virtual_name) + block_device.is_swap_or_ephemeral(virtual_name)): + size = self._volume_size(instance_type, virtual_name) if size == 0: continue values['volume_size'] = size |
