예제 #1
0
    def _test_create_configuration_single_logical_drive(self, raid_level):

        server = self._get_server()
        size_gb = 100

        manager.delete_configuration()
        devices_before_create = set(glob.glob('/dev/sd[a-z]'))

        minimum_disks_required = constants.RAID_LEVEL_MIN_DISKS[raid_level]
        self._get_physical_drives(server, minimum_disks_required, size_gb)

        raid_config = {
            'logical_disks': [{'size_gb': size_gb, 'raid_level': raid_level}]}

        current_config = manager.create_configuration(raid_config)

        logical_disk = current_config['logical_disks'][0]
        self.assertIsNotNone(logical_disk['root_device_hint'])
        self.assertIsNotNone(logical_disk['volume_name'])

        devices_after_create = set(glob.glob('/dev/sd[a-z]'))
        new_device = devices_after_create - devices_before_create

        # Make sure only one new device appeared now.
        if len(new_device) != 1:
            self.fail("More than 1 block devices were found after "
                      "creating RAID volume")

        new_device_file = new_device.pop()
        s = os.stat(new_device_file)
        if not stat.S_ISBLK(s.st_mode):
            self.fail("Newly created disk %s is not a block device"
                      % new_device_file)

        # SCSI disk devices have major number 8
        # https://www.kernel.org/doc/Documentation/devices.txt
        # TODO(rameshg87: Need to check if any more assetions need to be
        # done on the newly created disk device.
        self.assertEqual(8, os.major(s.st_rdev))

        stdout, stderr = processutils.execute("lsblk", "-Pio", "SIZE",
                                              new_device_file)
        # Output is like (two times printed):
        # SIZE="8G"
        # SIZE="8G"
        created_disk_size = stdout.split("\n")[0].split('"')[1][:-1]
        self.assertEqual(size_gb, int(created_disk_size))

        stdout, stderr = processutils.execute("lsblk", "-Pio", "WWN",
                                              new_device_file)
        # Output is like:
        # WWN="0x600508b1001cca7f"
        # TODO(rameshg87: Check with hpssa team whether this can be
        # assumed.
        wwn = stdout.split("\n")[0].split('"')[1]
        self.assertEqual(logical_disk['root_device_hint']['wwn'], wwn)

        manager.delete_configuration()
예제 #2
0
    def test_delete_configuration(self, controller_exec_cmd_mock,
                                  get_all_details_mock):

        fobj = open('proliantutils/tests/hpssa/outputs/one_drive.out', 'r')
        stdout = '\n'.join(fobj.readlines())
        get_all_details_mock.return_value = stdout

        manager.delete_configuration()

        controller_exec_cmd_mock.assert_called_with("logicaldrive", "all",
                                                    "delete", "forced")
예제 #3
0
    def delete_configuration(self, node, ports):
        """Deletes RAID configuration on the bare metal.

        This method deletes all the RAID disks on the bare metal.
        :param node: A dictionary of the node object
        :param ports: A list of dictionaries containing information of ports
            for the node
        """
        return hpssa_manager.delete_configuration()
예제 #4
0
    def delete_configuration(self, node, ports):
        """Deletes RAID configuration on the bare metal.

        This method deletes all the RAID disks on the bare metal.
        :param node: A dictionary of the node object
        :param ports: A list of dictionaries containing information of ports
            for the node
        """
        return hpssa_manager.delete_configuration()
예제 #5
0
    def test_delete_configuration_no_arrays(
            self, controller_exec_cmd_mock,
            get_configuration_mock, get_all_details_mock):

        get_all_details_mock.return_value = raid_constants.HPSSA_NO_DRIVES
        get_configuration_mock.return_value = 'foo'

        ret = manager.delete_configuration()

        self.assertFalse(controller_exec_cmd_mock.called)
        get_configuration_mock.assert_called_once_with()
        self.assertEqual('foo', ret)
예제 #6
0
    def test_delete_configuration_no_arrays(
            self, controller_exec_cmd_mock,
            get_configuration_mock, get_all_details_mock):

        get_all_details_mock.return_value = raid_constants.HPSSA_NO_DRIVES
        get_configuration_mock.return_value = 'foo'

        ret = manager.delete_configuration()

        self.assertFalse(controller_exec_cmd_mock.called)
        get_configuration_mock.assert_called_once_with()
        self.assertEqual('foo', ret)
예제 #7
0
    def test_delete_configuration(self, controller_exec_cmd_mock,
                                  get_configuration_mock,
                                  get_all_details_mock):
        get_all_details_mock.return_value = raid_constants.HPSSA_ONE_DRIVE
        get_configuration_mock.return_value = 'foo'

        ret = manager.delete_configuration()

        controller_exec_cmd_mock.assert_called_with(
            "logicaldrive", "all", "delete", "forced")
        get_configuration_mock.assert_called_once_with()
        self.assertEqual('foo', ret)
예제 #8
0
    def test_delete_configuration(self, controller_exec_cmd_mock,
                                  get_configuration_mock,
                                  get_all_details_mock):

        get_all_details_mock.return_value = raid_constants.HPSSA_ONE_DRIVE
        get_configuration_mock.return_value = 'foo'

        ret = manager.delete_configuration()

        controller_exec_cmd_mock.assert_called_with(
            "logicaldrive", "all", "delete", "forced")
        get_configuration_mock.assert_called_once_with()
        self.assertEqual('foo', ret)
예제 #9
0
 def tearDown(self):
     super(HPSSATestCase, self).tearDown()
     manager.delete_configuration()
예제 #10
0
    def _test_create_configuration_single_logical_drive(self, raid_level):

        server = self._get_server()
        size_gb = 100

        manager.delete_configuration()
        devices_before_create = set(glob.glob('/dev/sd[a-z]'))

        minimum_disks_required = constants.RAID_LEVEL_MIN_DISKS[raid_level]
        self._get_physical_drives(server, minimum_disks_required, size_gb)

        raid_config = {
            'logical_disks': [{
                'size_gb': size_gb,
                'raid_level': raid_level
            }]
        }

        current_config = manager.create_configuration(raid_config)

        logical_disk = current_config['logical_disks'][0]
        self.assertIsNotNone(logical_disk['root_device_hint'])
        self.assertIsNotNone(logical_disk['volume_name'])

        devices_after_create = set(glob.glob('/dev/sd[a-z]'))
        new_device = devices_after_create - devices_before_create

        # Make sure only one new device appeared now.
        if len(new_device) != 1:
            self.fail("More than 1 block devices were found after "
                      "creating RAID volume")

        new_device_file = new_device.pop()
        s = os.stat(new_device_file)
        if not stat.S_ISBLK(s.st_mode):
            self.fail("Newly created disk %s is not a block device" %
                      new_device_file)

        # SCSI disk devices have major number 8
        # https://www.kernel.org/doc/Documentation/devices.txt
        # TODO(rameshg87: Need to check if any more assetions need to be
        # done on the newly created disk device.
        self.assertEqual(8, os.major(s.st_rdev))

        stdout, stderr = processutils.execute("lsblk", "-Pio", "SIZE",
                                              new_device_file)
        # Output is like (two times printed):
        # SIZE="8G"
        # SIZE="8G"
        created_disk_size = stdout.split("\n")[0].split('"')[1][:-1]
        self.assertEqual(size_gb, int(created_disk_size))

        stdout, stderr = processutils.execute("lsblk", "-Pio", "WWN",
                                              new_device_file)
        # Output is like:
        # WWN="0x600508b1001cca7f"
        # TODO(rameshg87: Check with hpssa team whether this can be
        # assumed.
        wwn = stdout.split("\n")[0].split('"')[1]
        self.assertEqual(logical_disk['root_device_hint']['wwn'], wwn)

        manager.delete_configuration()
예제 #11
0
 def tearDown(self):
     super(HPSSATestCase, self).tearDown()
     manager.delete_configuration()