~gandelman-a/ubuntu/precise/nova/891227

« back to all changes in this revision

Viewing changes to nova/compute/api.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-09-20 15:44:39 UTC
  • mfrom: (1.1.31 upstream)
  • Revision ID: package-import@ubuntu.com-20110920154439-fb1rlzl2lb4hew92
Tags: 2011.3~rc~20110920.r1192-0ubuntu2
* debian/nova_sudoers:
  + Fix typo in nova_sudoers. 
  + Tabs vs Spaces.
* debian/nova.conf:
  + Use force_dhcp_release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
287
287
        return (num_instances, base_options, image)
288
288
 
289
289
    @staticmethod
290
 
    def _ephemeral_size(instance_type, ephemeral_name):
291
 
        num = block_device.ephemeral_num(ephemeral_name)
292
 
 
293
 
        # TODO(yamahata): ephemeralN where N > 0
294
 
        # Only ephemeral0 is allowed for now because InstanceTypes
295
 
        # table only allows single local disk, local_gb.
296
 
        # In order to enhance it, we need to add a new columns to
297
 
        # instance_types table.
298
 
        if num > 0:
299
 
            return 0
300
 
 
301
 
        return instance_type.get('local_gb')
 
290
    def _volume_size(instance_type, virtual_name):
 
291
        size = 0
 
292
        if virtual_name == 'swap':
 
293
            size = instance_type.get('swap', 0)
 
294
        elif block_device.is_ephemeral(virtual_name):
 
295
            num = block_device.ephemeral_num(virtual_name)
 
296
 
 
297
            # TODO(yamahata): ephemeralN where N > 0
 
298
            # Only ephemeral0 is allowed for now because InstanceTypes
 
299
            # table only allows single local disk, local_gb.
 
300
            # In order to enhance it, we need to add a new columns to
 
301
            # instance_types table.
 
302
            if num > 0:
 
303
                return 0
 
304
 
 
305
            size = instance_type.get('local_gb')
 
306
 
 
307
        return size
302
308
 
303
309
    def _update_image_block_device_mapping(self, elevated_context,
304
310
                                           instance_type, instance_id,
319
325
            if not block_device.is_swap_or_ephemeral(virtual_name):
320
326
                continue
321
327
 
322
 
            size = 0
323
 
            if virtual_name == 'swap':
324
 
                size = instance_type.get('swap', 0)
325
 
            elif block_device.is_ephemeral(virtual_name):
326
 
                size = self._ephemeral_size(instance_type, virtual_name)
327
 
 
 
328
            size = self._volume_size(instance_type, virtual_name)
328
329
            if size == 0:
329
330
                continue
330
331
 
354
355
 
355
356
            virtual_name = bdm.get('virtual_name')
356
357
            if (virtual_name is not None and
357
 
                block_device.is_ephemeral(virtual_name)):
358
 
                size = self._ephemeral_size(instance_type, virtual_name)
 
358
                block_device.is_swap_or_ephemeral(virtual_name)):
 
359
                size = self._volume_size(instance_type, virtual_name)
359
360
                if size == 0:
360
361
                    continue
361
362
                values['volume_size'] = size