def test_CreatePartitionTable_OnA16GBDisk(self):
     self.expectedCommands.append(('sfdisk --dump /dev/sda', ""))
     self.expectedCommands.append(
         ('''busybox dd if=/dev/zero of=/dev/sda bs=1M count=512''', ""))
     self.expectedCommands.append((
         '''echo -ne '8,256,83\\n,,8e\\n' | sfdisk --unit M /dev/sda --in-order --force''',
         ""))
     self.expectedCommands.append(('''busybox mdev -s''', ""))
     self.expectedCommands.append(
         ('''sfdisk -s /dev/sda''', '%d\n' % (16 * 1024 * 1024)))
     self.expectedCommands.append(('''mkfs.ext4 /dev/sda1 -L BOOT''', ""))
     self.expectedCommands.append(('''lvm pvcreate /dev/sda2''', ""))
     self.expectedCommands.append(
         ('''lvm vgcreate inaugurator /dev/sda2''', ""))
     self.expectedCommands.append(
         ('''lvm lvcreate --zero n --name swap --size 1G inaugurator''',
          ""))
     self.expectedCommands.append((
         '''lvm lvcreate --zero n --name root --extents 100%FREE inaugurator''',
         ""))
     self.expectedCommands.append(('''lvm vgscan --mknodes''', ""))
     self.expectedCommands.append(
         ('''mkswap /dev/inaugurator/swap -L SWAP''', ""))
     self.expectedCommands.append(
         ('''mkfs.ext4 /dev/inaugurator/root -L ROOT''', ""))
     goodPartitionTable = "\n".join([
         "# partition table of /dev/sda", "unit: sectors", "",
         "/dev/sda1 : start=     2048, size=   512000, Id=83",
         "/dev/sda2 : start=   516000, size= 31000000, Id=8e",
         "/dev/sda3 : start=        0, size=        0, Id= 0",
         "/dev/sda4 : start=        0, size=        0, Id= 0", ""
     ])
     self.expectedCommands.append(
         ('sfdisk --dump /dev/sda', goodPartitionTable))
     self.expectedCommands.append(('lvm pvscan --cache /dev/sda2', ""))
     goodPhysicalVolume = "\n".join([
         "  PV        VG          Fmt  Attr PSize     PFree ",
         "  /dev/sda2 inaugurator lvm2 a--  16128.00m 16128.00m"
         ""
     ])
     self.expectedCommands.append(
         ('lvm pvdisplay --units m --columns /dev/sda2',
          goodPhysicalVolume))
     correctSwap = "\n".join([
         "  LV   VG          Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
         "  swap inaugurator -wi-a---- 1024.00m", ""
     ])
     self.expectedCommands.append(
         ('lvm lvdisplay --units m --columns /dev/inaugurator/swap',
          correctSwap))
     correctRoot = "\n".join([
         "  LV   VG          Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
         "  root inaugurator -wi-a---- 15104.00m", ""
     ])
     self.expectedCommands.append(
         ('lvm lvdisplay --units m --columns /dev/inaugurator/root',
          correctRoot))
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
    def test_ParseLVM(self):
        example = "\n".join([
            "  PV        VG    Fmt  Attr PSize  PFree ",
            "  %(lvmPartition)s dummy lvm2 a--  60.00m 60.00m"
            ""
        ]) % dict(lvmPartition=self.GPT_LVM_PARTITION)
        self.expectedCommands.append(
            ('lvm pvscan --cache %(lvmPartition)s' %
             dict(lvmPartition=self.GPT_LVM_PARTITION), ""))
        self.expectedCommands.append(
            ('lvm pvdisplay --units m --columns %(lvmPartition)s' %
             dict(lvmPartition=self.GPT_LVM_PARTITION), example))
        parsed = PartitionTable.parseLVMPhysicalVolume(self.GPT_LVM_PARTITION)
        self.assertEquals(parsed['name'], 'dummy')
        self.assertEquals(parsed['sizeMB'], 60)

        example = "\n".join([
            "  LV   VG    Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
            "  crap dummy -wi-a---- 20.00m", ""
        ])
        self.expectedCommands.append(
            ('lvm lvdisplay --units m --columns /dev/inaugurator/crap',
             example))
        parsed = PartitionTable.parseLVMLogicalVolume("crap")
        self.assertEquals(parsed['volumeGroup'], 'dummy')
        self.assertEquals(parsed['sizeMB'], 20)
 def test_WipeOtherPhysicalVolumesLabeledAsBoot(self):
     self._prepareExpectedCommandsFor128GBDisk(blkidResult={"/dev/sdb1": "BOOT",
                                                            "/dev/sda1": "BOOT",
                                                            "/dev/bla": "NOTBOOT"})
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
 def test_WipeOtherPhysicalVolumesWithAVolumeGroupByTheSameName(self):
     self._prepareExpectedCommandsFor128GBDisk(
         extraVolumeGroup="inaugurator",
         physicalVolumeOfExtraVolumeGroup="/dev/sdb2")
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
 def test_DontWipeTheWholePhysicalDeviceIfOneOfThePartitionsContainsAVolumeGroupByTheSameName(
         self):
     self._prepareExpectedCommandsFor128GBDisk(
         extraVolumeGroup="inaugurator",
         physicalVolumeOfExtraVolumeGroup="/dev/sda4")
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
 def test_WipeOtherPhysicalVolumesLabeledAsBoot(self):
     self._prepareExpectedCommandsFor128GBDisk(blkidResult={
         "/dev/sdb1": "BOOT",
         "/dev/sda1": "BOOT",
         "/dev/bla": "NOTBOOT"
     })
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
 def test_CreatePartitionTable_OnA16GBDisk(self):
     self.expectedCommands.append(("sfdisk --dump /dev/sda", ""))
     self.expectedCommands.append(("""busybox dd if=/dev/zero of=/dev/sda bs=1M count=512""", ""))
     self.expectedCommands.append(
         ("""echo -ne '8,256,83\\n,,8e\\n' | sfdisk --unit M /dev/sda --in-order --force""", "")
     )
     self.expectedCommands.append(("""busybox mdev -s""", ""))
     self.expectedCommands.append(("""sfdisk -s /dev/sda""", "%d\n" % (16 * 1024 * 1024)))
     self.expectedCommands.append(("""mkfs.ext4 /dev/sda1 -L BOOT""", ""))
     self.expectedCommands.append(("""lvm pvcreate /dev/sda2""", ""))
     self.expectedCommands.append(("""lvm vgcreate inaugurator /dev/sda2""", ""))
     self.expectedCommands.append(("""lvm lvcreate --zero n --name swap --size 1G inaugurator""", ""))
     self.expectedCommands.append(("""lvm lvcreate --zero n --name root --extents 100%FREE inaugurator""", ""))
     self.expectedCommands.append(("""lvm vgscan --mknodes""", ""))
     self.expectedCommands.append(("""mkswap /dev/inaugurator/swap -L SWAP""", ""))
     self.expectedCommands.append(("""mkfs.ext4 /dev/inaugurator/root -L ROOT""", ""))
     goodPartitionTable = "\n".join(
         [
             "# partition table of /dev/sda",
             "unit: sectors",
             "",
             "/dev/sda1 : start=     2048, size=   512000, Id=83",
             "/dev/sda2 : start=   516000, size= 31000000, Id=8e",
             "/dev/sda3 : start=        0, size=        0, Id= 0",
             "/dev/sda4 : start=        0, size=        0, Id= 0",
             "",
         ]
     )
     self.expectedCommands.append(("sfdisk --dump /dev/sda", goodPartitionTable))
     self.expectedCommands.append(("lvm pvscan --cache /dev/sda2", ""))
     goodPhysicalVolume = "\n".join(
         [
             "  PV        VG          Fmt  Attr PSize     PFree ",
             "  /dev/sda2 inaugurator lvm2 a--  16128.00m 16128.00m" "",
         ]
     )
     self.expectedCommands.append(("lvm pvdisplay --units m --columns /dev/sda2", goodPhysicalVolume))
     correctSwap = "\n".join(
         [
             "  LV   VG          Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
             "  swap inaugurator -wi-a---- 1024.00m",
             "",
         ]
     )
     self.expectedCommands.append(("lvm lvdisplay --units m --columns /dev/inaugurator/swap", correctSwap))
     correctRoot = "\n".join(
         [
             "  LV   VG          Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
             "  root inaugurator -wi-a---- 15104.00m",
             "",
         ]
     )
     self.expectedCommands.append(("lvm lvdisplay --units m --columns /dev/inaugurator/root", correctRoot))
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
 def test_CreatePartitionTable_OnA16GBDisk(self):
     self.diskSizeGB = 16
     self.expectedCommands.append(('parted -s -m /dev/sda unit MB print', ""))
     self.expectedCommands.append(('''busybox dd if=/dev/zero of=/dev/sda bs=1M count=512''', ""))
     self.expectedCommands.append(('''parted -s /dev/sda -- mklabel gpt mkpart primary ext4 1MiB '''
                                   '''3MiB mkpart primary ext4 3MiB %(bootPartitionEnd)sMiB mkpart '''
                                   '''primary ext4 %(bootPartitionEnd)sMiB -1''' %
                                   dict(bootPartitionEnd=self.bootPartitionEnd),
                                   ""))
     self.expectedCommands.append(('''parted -s /dev/sda set 1 bios_grub on''', ""))
     self.expectedCommands.append(('''parted -s /dev/sda set 2 boot on''', ""))
     self.expectedCommands.append(('''parted -s /dev/sda set 3 lvm on''', ""))
     self.expectedCommands.append(('''busybox mdev -s''', ""))
     self.expectedCommands.append(('''mkfs.ext4 /dev/sda2 -L BOOT''', ""))
     self.expectedCommands.append(('''lvm pvcreate -y -ff %(lvmPartition)s''' %
                                   dict(lvmPartition=self.GPT_LVM_PARTITION), ""))
     self.expectedCommands.append(('''lvm vgcreate -y inaugurator %(lvmPartition)s''' %
                                   dict(lvmPartition=self.GPT_LVM_PARTITION), ""))
     self.expectedCommands.append(('''lvm lvcreate --zero n --name swap --size 1G inaugurator''', ""))
     self.expectedCommands.append((
         '''lvm lvcreate --zero n --name root --extents 100%FREE inaugurator''', ""))
     self.validateVolumesCreation()
     self.expectedCommands.append(('''mkfs.ext4 /dev/inaugurator/root -L ROOT''', ""))
     goodPartitionTable = self._getPartitionTableInMachineFormat(diskSizeGB=self.diskSizeGB)
     self.expectedCommands.append(('parted -s -m /dev/sda unit MB print', goodPartitionTable))
     self.expectedCommands.append(('lvm pvscan --cache %(lvmPartition)s' %
                                   dict(lvmPartition=self.GPT_LVM_PARTITION), ""))
     goodPhysicalVolume = "\n".join([
         "  PV        VG          Fmt  Attr PSize     PFree ",
         "  %(lvmPartition)s inaugurator lvm2 a--  16128.00m 16128.00m"
         "" % dict(lvmPartition=self.GPT_LVM_PARTITION)])
     self.expectedCommands.append(('lvm pvdisplay --units m --columns %(lvmPartition)s' %
                                   dict(lvmPartition=self.GPT_LVM_PARTITION), goodPhysicalVolume))
     correctSwap = "\n".join([
         "  LV   VG          Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
         "  swap inaugurator -wi-a---- 1024.00m",
         ""])
     self.expectedCommands.append((
         'lvm lvdisplay --units m --columns /dev/inaugurator/swap', correctSwap))
     correctRoot = "\n".join([
         "  LV   VG          Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
         "  root inaugurator -wi-a---- 15104.00m",
         ""])
     self.expectedCommands.append((
         'lvm lvdisplay --units m --columns /dev/inaugurator/root', correctRoot))
     self.expectedCommands.append(("lvm pvscan",
                                   "PV %(lvmPartition)s   VG inaugurator   lvm2 [irrelevant size data]"
                                   % dict(lvmPartition=self.GPT_LVM_PARTITION),
                                   "Total: 1 more irrelevant data"))
     self.expectedCommands.append(("blkid", ""))
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
 def test_ParsePartitionTableMBR(self):
     self.expectedCommands.append(('parted -s -m /dev/sda unit MB print',
                                   self._getMBRPartitionTableInMachineFormat(diskSizeGB=self.diskSizeGB)))
     tested = PartitionTable("/dev/sda", layoutScheme="MBR")
     parsed = tested.parsePartitionTable()
     self.assertEquals(len(parsed), 2)
     self.assertEquals(parsed[0]['device'], '/dev/sda1')
     self.assertEquals(parsed[0]['sizeMB'], self.BOOT_PARTITION_SIZE)
     self.assertEquals(parsed[0]['fs'], "ext4")
     self.assertEquals(parsed[0]['flags'], "boot")
     MbrLvmPartition = "/dev/sda2"
     self.assertEquals(parsed[1]['device'], MbrLvmPartition)
     self.assertEquals(parsed[1]['sizeMB'],
                       self.diskSizeGB * self._NR_MBS_IN_GB - self.BOOT_PARTITION_SIZE)
     self.assertEquals(parsed[1]['fs'], "")
     self.assertEquals(parsed[1]['flags'], "lvm")
     self.assertEquals(len(self.expectedCommands), 0)
 def test_ParsePartitionTable(self):
     example = "\n".join([
         "# partition table of /dev/sda", "unit: sectors", "",
         "/dev/sda1 : start=     2048, size= 16023552, Id=82",
         "/dev/sda2 : start= 16025600, size=484091904, Id=83, bootable",
         "/dev/sda3 : start=        0, size=        0, Id= 0",
         "/dev/sda4 : start=        0, size=        0, Id= 0", ""
     ])
     self.expectedCommands.append(('sfdisk --dump /dev/sda', example))
     tested = PartitionTable("/dev/sda")
     parsed = tested.parsePartitionTable()
     self.assertEquals(len(parsed), 2)
     self.assertEquals(parsed[0]['device'], '/dev/sda1')
     self.assertEquals(parsed[0]['sizeMB'], 16023552 / 2 / 1024)
     self.assertEquals(parsed[0]['id'], 0x82)
     self.assertEquals(parsed[1]['device'], '/dev/sda2')
     self.assertEquals(parsed[1]['sizeMB'], 484091904 / 2 / 1024)
     self.assertEquals(parsed[1]['id'], 0x83)
     self.assertEquals(len(self.expectedCommands), 0)
 def test_ParsePartitionTableMBR(self):
     self.expectedCommands.append(
         ('parted -s -m /dev/sda unit MB print',
          self._getMBRPartitionTableInMachineFormat(
              diskSizeGB=self.diskSizeGB)))
     tested = PartitionTable("/dev/sda", layoutScheme="MBR")
     parsed = tested.parsePartitionTable()
     self.assertEquals(len(parsed), 2)
     self.assertEquals(parsed[0]['device'], '/dev/sda1')
     self.assertEquals(parsed[0]['sizeMB'], self.BOOT_PARTITION_SIZE)
     self.assertEquals(parsed[0]['fs'], "ext4")
     self.assertEquals(parsed[0]['flags'], "boot")
     MbrLvmPartition = "/dev/sda2"
     self.assertEquals(parsed[1]['device'], MbrLvmPartition)
     self.assertEquals(
         parsed[1]['sizeMB'],
         self.diskSizeGB * self._NR_MBS_IN_GB - self.BOOT_PARTITION_SIZE)
     self.assertEquals(parsed[1]['fs'], "")
     self.assertEquals(parsed[1]['flags'], "lvm")
     self.assertEquals(len(self.expectedCommands), 0)
예제 #12
0
 def test_ParsePartitionTableGPT(self):
     self.expectedCommands.append(('parted -s -m /dev/sda unit MB print',
                                   self._getPartitionTableInMachineFormat(diskSizeGB=self.diskSizeGB)))
     tested = PartitionTable("/dev/sda")
     parsed = tested.parsePartitionTable()
     self.assertEquals(len(parsed), 3)
     self.assertEquals(parsed[0]['device'], '/dev/sda1')
     self.assertEquals(parsed[0]['sizeMB'], 2)
     self.assertEquals(parsed[0]['fs'], "")
     self.assertEquals(parsed[0]['flags'], "bios_grub")
     self.assertEquals(parsed[1]['device'], '/dev/sda2')
     self.assertEquals(parsed[1]['sizeMB'], self.BOOT_PARTITION_SIZE)
     self.assertEquals(parsed[1]['fs'], "ext4")
     self.assertEquals(parsed[1]['flags'], "boot")
     self.assertEquals(parsed[2]['device'], self.GPT_LVM_PARTITION)
     self.assertEquals(parsed[2]['sizeMB'],
                       self.diskSizeGB * self._NR_MBS_IN_GB -
                       (self.BIOS_BOOT_PARTITION_SIZE + self.BOOT_PARTITION_SIZE))
     self.assertEquals(parsed[2]['fs'], "")
     self.assertEquals(parsed[2]['flags'], "lvm")
     self.assertEquals(len(self.expectedCommands), 0)
    def test_ParseLVM(self):
        example = "\n".join(
            ["  PV        VG    Fmt  Attr PSize  PFree ", "  /dev/sda2 dummy lvm2 a--  60.00m 60.00m" ""]
        )
        self.expectedCommands.append(("lvm pvscan --cache /dev/sda2", ""))
        self.expectedCommands.append(("lvm pvdisplay --units m --columns /dev/sda2", example))
        parsed = PartitionTable.parseLVMPhysicalVolume("/dev/sda2")
        self.assertEquals(parsed["name"], "dummy")
        self.assertEquals(parsed["sizeMB"], 60)

        example = "\n".join(
            [
                "  LV   VG    Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
                "  crap dummy -wi-a---- 20.00m",
                "",
            ]
        )
        self.expectedCommands.append(("lvm lvdisplay --units m --columns /dev/inaugurator/crap", example))
        parsed = PartitionTable.parseLVMLogicalVolume("crap")
        self.assertEquals(parsed["volumeGroup"], "dummy")
        self.assertEquals(parsed["sizeMB"], 20)
 def test_ParsePartitionTableGPT(self):
     self.expectedCommands.append(('parted -s -m /dev/sda unit MB print',
                                   self._getPartitionTableInMachineFormat(
                                       diskSizeGB=self.diskSizeGB)))
     tested = PartitionTable("/dev/sda")
     parsed = tested.parsePartitionTable()
     self.assertEquals(len(parsed), 3)
     self.assertEquals(parsed[0]['device'], '/dev/sda1')
     self.assertEquals(parsed[0]['sizeMB'], 2)
     self.assertEquals(parsed[0]['fs'], "")
     self.assertEquals(parsed[0]['flags'], "bios_grub")
     self.assertEquals(parsed[1]['device'], '/dev/sda2')
     self.assertEquals(parsed[1]['sizeMB'], self.BOOT_PARTITION_SIZE)
     self.assertEquals(parsed[1]['fs'], "ext4")
     self.assertEquals(parsed[1]['flags'], "boot")
     self.assertEquals(parsed[2]['device'], self.GPT_LVM_PARTITION)
     self.assertEquals(
         parsed[2]['sizeMB'], self.diskSizeGB * self._NR_MBS_IN_GB -
         (self.BIOS_BOOT_PARTITION_SIZE + self.BOOT_PARTITION_SIZE))
     self.assertEquals(parsed[2]['fs'], "")
     self.assertEquals(parsed[2]['flags'], "lvm")
     self.assertEquals(len(self.expectedCommands), 0)
예제 #15
0
    def test_ParseLVM(self):
        example = "\n".join([
            "  PV        VG    Fmt  Attr PSize  PFree ",
            "  %(lvmPartition)s dummy lvm2 a--  60.00m 60.00m"
            ""]) % dict(lvmPartition=self.GPT_LVM_PARTITION)
        self.expectedCommands.append(('lvm pvscan --cache %(lvmPartition)s' %
                                      dict(lvmPartition=self.GPT_LVM_PARTITION), ""))
        self.expectedCommands.append(('lvm pvdisplay --units m --columns %(lvmPartition)s' %
                                      dict(lvmPartition=self.GPT_LVM_PARTITION),
                                      example))
        parsed = PartitionTable.parseLVMPhysicalVolume(self.GPT_LVM_PARTITION)
        self.assertEquals(parsed['name'], 'dummy')
        self.assertEquals(parsed['sizeMB'], 60)

        example = "\n".join([
            "  LV   VG    Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
            "  crap dummy -wi-a---- 20.00m",
            ""])
        self.expectedCommands.append(('lvm lvdisplay --units m --columns /dev/inaugurator/crap', example))
        parsed = PartitionTable.parseLVMLogicalVolume("crap")
        self.assertEquals(parsed['volumeGroup'], 'dummy')
        self.assertEquals(parsed['sizeMB'], 20)
 def test_ParsePartitionTable(self):
     example = "\n".join(
         [
             "# partition table of /dev/sda",
             "unit: sectors",
             "",
             "/dev/sda1 : start=     2048, size= 16023552, Id=82",
             "/dev/sda2 : start= 16025600, size=484091904, Id=83, bootable",
             "/dev/sda3 : start=        0, size=        0, Id= 0",
             "/dev/sda4 : start=        0, size=        0, Id= 0",
             "",
         ]
     )
     self.expectedCommands.append(("sfdisk --dump /dev/sda", example))
     tested = PartitionTable("/dev/sda")
     parsed = tested.parsePartitionTable()
     self.assertEquals(len(parsed), 2)
     self.assertEquals(parsed[0]["device"], "/dev/sda1")
     self.assertEquals(parsed[0]["sizeMB"], 16023552 / 2 / 1024)
     self.assertEquals(parsed[0]["id"], 0x82)
     self.assertEquals(parsed[1]["device"], "/dev/sda2")
     self.assertEquals(parsed[1]["sizeMB"], 484091904 / 2 / 1024)
     self.assertEquals(parsed[1]["id"], 0x83)
     self.assertEquals(len(self.expectedCommands), 0)
예제 #17
0
 def test_CreatePartitionTable_OnA128GBDisk(self):
     self._prepareExpectedCommandsFor128GBDisk()
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
예제 #18
0
 def test_DontWipeTheWholePhysicalDeviceIfOneOfThePartitionsContainsAVolumeGroupByTheSameName(self):
     self._prepareExpectedCommandsFor128GBDisk(extraVolumeGroup="inaugurator",
                                               physicalVolumeOfExtraVolumeGroup="/dev/sda4")
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
 def test_CreatePartitionTable_OnA128GBDisk(self):
     self._prepareExpectedCommandsFor128GBDisk()
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
 def test_CreatePartitionTable_OnA16GBDisk(self):
     self.diskSizeGB = 16
     self.expectedCommands.append(
         ('parted -s -m /dev/sda unit MB print', ""))
     self.expectedCommands.append(
         ('''busybox dd if=/dev/zero of=/dev/sda bs=1M count=512''', ""))
     self.expectedCommands.append((
         '''parted -s /dev/sda -- mklabel gpt mkpart primary ext4 1MiB '''
         '''3MiB mkpart primary ext4 3MiB %(bootPartitionEnd)sMiB mkpart '''
         '''primary ext4 %(bootPartitionEnd)sMiB -1''' %
         dict(bootPartitionEnd=self.bootPartitionEnd), ""))
     self.expectedCommands.append(
         ('''parted -s /dev/sda set 1 bios_grub on''', ""))
     self.expectedCommands.append(
         ('''parted -s /dev/sda set 2 boot on''', ""))
     self.expectedCommands.append(
         ('''parted -s /dev/sda set 3 lvm on''', ""))
     self.expectedCommands.append(('''busybox mdev -s''', ""))
     self.expectedCommands.append(('''mkfs.ext4 /dev/sda2 -L BOOT''', ""))
     self.expectedCommands.append(
         ('''lvm pvcreate -y -ff %(lvmPartition)s''' %
          dict(lvmPartition=self.GPT_LVM_PARTITION), ""))
     self.expectedCommands.append(
         ('''lvm vgcreate -y inaugurator %(lvmPartition)s''' %
          dict(lvmPartition=self.GPT_LVM_PARTITION), ""))
     self.expectedCommands.append(
         ('''lvm lvcreate --zero n --name swap --size 1G inaugurator''',
          ""))
     self.expectedCommands.append((
         '''lvm lvcreate --zero n --name root --extents 100%FREE inaugurator''',
         ""))
     self.validateVolumesCreation()
     self.expectedCommands.append(
         ('''mkfs.ext4 /dev/inaugurator/root -L ROOT''', ""))
     goodPartitionTable = self._getPartitionTableInMachineFormat(
         diskSizeGB=self.diskSizeGB)
     self.expectedCommands.append(
         ('parted -s -m /dev/sda unit MB print', goodPartitionTable))
     self.expectedCommands.append(
         ('lvm pvscan --cache %(lvmPartition)s' %
          dict(lvmPartition=self.GPT_LVM_PARTITION), ""))
     goodPhysicalVolume = "\n".join([
         "  PV        VG          Fmt  Attr PSize     PFree ",
         "  %(lvmPartition)s inaugurator lvm2 a--  16128.00m 16128.00m"
         "" % dict(lvmPartition=self.GPT_LVM_PARTITION)
     ])
     self.expectedCommands.append(
         ('lvm pvdisplay --units m --columns %(lvmPartition)s' %
          dict(lvmPartition=self.GPT_LVM_PARTITION), goodPhysicalVolume))
     correctSwap = "\n".join([
         "  LV   VG          Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
         "  swap inaugurator -wi-a---- 1024.00m", ""
     ])
     self.expectedCommands.append(
         ('lvm lvdisplay --units m --columns /dev/inaugurator/swap',
          correctSwap))
     correctRoot = "\n".join([
         "  LV   VG          Attr      LSize  Pool Origin Data%  Move Log Copy%  Convert",
         "  root inaugurator -wi-a---- 15104.00m", ""
     ])
     self.expectedCommands.append(
         ('lvm lvdisplay --units m --columns /dev/inaugurator/root',
          correctRoot))
     self.expectedCommands.append((
         "lvm pvscan",
         "PV %(lvmPartition)s   VG inaugurator   lvm2 [irrelevant size data]"
         % dict(lvmPartition=self.GPT_LVM_PARTITION),
         "Total: 1 more irrelevant data"))
     self.expectedCommands.append(("blkid", ""))
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)
예제 #21
0
 def test_DontWipeTargetDeviceInCaseOfOtherPhysicalVolumesWithAVolumeGroupByTheSameName(self):
     self._prepareExpectedCommandsFor128GBDisk(extraVolumeGroup="non-inaugurator",
                                               physicalVolumeOfExtraVolumeGroup="/dev/sdb2")
     tested = PartitionTable("/dev/sda")
     tested.verify()
     self.assertEquals(len(self.expectedCommands), 0)