Esempio n. 1
0
    def CreateScratchDisk(self, disk_spec):
        """Create a VM's scratch disk.

    Args:
      disk_spec: virtual_machine.BaseDiskSpec object of the disk.
    """
        # Instantiate the disk(s) that we want to create.
        disks = []
        for _ in range(disk_spec.num_striped_disks):
            data_disk = aws_disk.AwsDisk(disk_spec, self.zone,
                                         self.machine_type)
            if disk_spec.disk_type == disk.LOCAL:
                data_disk.device_letter = chr(
                    ord(DRIVE_START_LETTER) + self.local_disk_counter)
                # Local disk numbers start at 1 (0 is the system disk).
                data_disk.disk_number = self.local_disk_counter + 1
                self.local_disk_counter += 1
                if self.local_disk_counter > self.max_local_disks:
                    raise errors.Error('Not enough local disks.')
            else:
                # Remote disk numbers start at 1 + max_local disks (0 is the system disk
                # and local disks occupy [1, max_local_disks]).
                data_disk.disk_number = (self.remote_disk_counter + 1 +
                                         self.max_local_disks)
                self.remote_disk_counter += 1
            disks.append(data_disk)

        self._CreateScratchDiskFromDisks(disk_spec, disks)
Esempio n. 2
0
 def setUp(self):
     p = mock.patch(util.__name__ + '.IssueRetryableCommand')
     p.start()
     self.addCleanup(p.stop)
     self.disk = aws_disk.AwsDisk(
         aws_disk.AwsDiskSpec(_COMPONENT, disk_type='standard'),
         'us-east-1', 'm4.2xlarge')
     self.disk.id = 'vol-foo'
    def CreateScratchDisk(self, disk_spec):
        """Create a VM's scratch disk.

    Args:
      disk_spec: virtual_machine.BaseDiskSpec object of the disk.

    Raises:
      CreationError: If an NFS disk is listed but the NFS service not created.
    """
        # Instantiate the disk(s) that we want to create.
        disks = []
        for _ in range(disk_spec.num_striped_disks):
            if disk_spec.disk_type == disk.NFS:
                nfs = getattr(context.GetThreadBenchmarkSpec(), 'nfs_service')
                if nfs is None:
                    raise errors.Resource.CreationError(
                        'Have an NFS disk but no NFS service created')
                data_disk = nfs.CreateNfsDisk()
            else:
                data_disk = aws_disk.AwsDisk(disk_spec, self.zone,
                                             self.machine_type)
            if disk_spec.disk_type == disk.LOCAL:
                data_disk.device_letter = chr(
                    ord(DRIVE_START_LETTER) + self.local_disk_counter)
                # Local disk numbers start at 1 (0 is the system disk).
                data_disk.disk_number = self.local_disk_counter + 1
                self.local_disk_counter += 1
                if self.local_disk_counter > self.max_local_disks:
                    raise errors.Error('Not enough local disks.')
            elif disk_spec.disk_type == disk.NFS:
                pass
            else:
                # Remote disk numbers start at 1 + max_local disks (0 is the system disk
                # and local disks occupy [1, max_local_disks]).
                data_disk.disk_number = (self.remote_disk_counter + 1 +
                                         self.max_local_disks)
                self.remote_disk_counter += 1
            disks.append(data_disk)

        self._CreateScratchDiskFromDisks(disk_spec, disks)
Esempio n. 4
0
    def CreateScratchDisk(self, disk_spec):
        """Create a VM's scratch disk.

    Args:
      disk_spec: virtual_machine.BaseDiskSpec object of the disk.

    Raises:
      CreationError: If an NFS disk is listed but the NFS service not created.
    """
        # Instantiate the disk(s) that we want to create.
        disks = []
        nvme_boot_drive_index = self._GetNvmeBootIndex()
        for _ in range(disk_spec.num_striped_disks):
            if disk_spec.disk_type == disk.NFS:
                data_disk = self._GetNfsService().CreateNfsDisk()
            else:
                data_disk = aws_disk.AwsDisk(disk_spec, self.zone,
                                             self.machine_type)
            if disk_spec.disk_type == disk.LOCAL:
                device_letter = chr(
                    ord(DRIVE_START_LETTER) + self.local_disk_counter)
                data_disk.AssignDeviceLetter(device_letter,
                                             nvme_boot_drive_index)
                # Local disk numbers start at 1 (0 is the system disk).
                data_disk.disk_number = self.local_disk_counter + 1
                self.local_disk_counter += 1
                if self.local_disk_counter > self.max_local_disks:
                    raise errors.Error('Not enough local disks.')
            elif disk_spec.disk_type == disk.NFS:
                pass
            else:
                # Remote disk numbers start at 1 + max_local disks (0 is the system disk
                # and local disks occupy [1, max_local_disks]).
                data_disk.disk_number = (self.remote_disk_counter + 1 +
                                         self.max_local_disks)
                self.remote_disk_counter += 1
            disks.append(data_disk)

        self._CreateScratchDiskFromDisks(disk_spec, disks)