Ejemplo n.º 1
0
    def test_create_configuration(self, controller_exec_cmd_mock,
                                  get_all_details_mock):

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

        ld1 = {
            'size_gb': 50,
            'raid_level': '1',
            'controller': 'Smart Array P822 in Slot 2',
            'physical_disks': ['5I:1:1', '5I:1:2']
        }
        ld2 = {
            'size_gb': 100,
            'raid_level': '5',
            'controller': 'Smart Array P822 in Slot 2',
            'physical_disks': ['5I:1:3', '5I:1:4', '6I:1:5']
        }

        raid_info = {'logical_disks': [ld1, ld2]}

        manager.create_configuration(raid_info)

        ld1_drives = '5I:1:1,5I:1:2'
        ld2_drives = '5I:1:3,5I:1:4,6I:1:5'
        controller_exec_cmd_mock.assert_any_call("create", "type=logicaldrive",
                                                 "drives=%s" % ld1_drives,
                                                 "raid=1",
                                                 "size=%d" % (50 * 1024))
        controller_exec_cmd_mock.assert_any_call("create", "type=logicaldrive",
                                                 "drives=%s" % ld2_drives,
                                                 "raid=5",
                                                 "size=%d" % (100 * 1024))
Ejemplo n.º 2
0
    def create_configuration(self, node, ports):
        """Create RAID configuration on the bare metal.

        This method creates the desired RAID configuration as read from
        node['target_raid_config'].

        :param node: A dictionary of the node object
        :param ports: A list of dictionaries containing information of ports
            for the node
        :returns: The current RAID configuration of the below format.
            raid_config = {
                'logical_disks': [{
                    'size_gb': 100,
                    'raid_level': 1,
                    'physical_disks': [
                        '5I:0:1',
                        '5I:0:2'],
                    'controller': 'Smart array controller'
                    },
                ]
            }
        """
        target_raid_config = node.get('target_raid_config', {}).copy()
        return hpssa_manager.create_configuration(
            raid_config=target_raid_config)
Ejemplo n.º 3
0
 def test_create_configuration_max_as_size_gb(
         self, controller_exec_cmd_mock, get_all_details_mock):
     no_drives = raid_constants.NO_DRIVES_HPSSA_7_DISKS
     one_drive = raid_constants.ONE_DRIVE_RAID_1_50_GB
     two_drives = raid_constants.TWO_DRIVES_50GB_RAID1_MAXGB_RAID5
     get_all_details_mock.side_effect = [no_drives, one_drive, two_drives]
     raid_info = {'logical_disks': [{'size_gb': 50,
                                     'raid_level': '1',
                                     'disk_type': 'hdd'},
                                    {'size_gb': 'MAX',
                                     'raid_level': '5',
                                     'disk_type': 'hdd'}]}
     raid_info = manager.create_configuration(raid_info)
     ld1 = raid_info['logical_disks'][0]
     ld2 = raid_info['logical_disks'][1]
     self.assertEqual('Smart Array P822 in Slot 3', ld1['controller'])
     self.assertEqual('Smart Array P822 in Slot 3', ld2['controller'])
     self.assertEqual(sorted(['5I:1:1', '5I:1:2']),
                      sorted(ld1['physical_disks']))
     self.assertEqual(sorted(['5I:1:3', '5I:1:4', '6I:1:5']),
                      sorted(ld2['physical_disks']))
     controller_exec_cmd_mock.assert_any_call(
         'create', 'type=logicaldrive', 'drives=5I:1:1,5I:1:2',
         'raid=1', 'size=51200')
     controller_exec_cmd_mock.assert_any_call(
         'create', 'type=logicaldrive', 'drives=5I:1:3,5I:1:4,6I:1:5',
         'raid=5')
Ejemplo n.º 4
0
    def test_create_configuration_without_disk_input_succeeds(
            self, controller_exec_cmd_mock, get_all_details_mock):
        no_drives = raid_constants.HPSSA_NO_DRIVES
        one_drive = raid_constants.HPSSA_ONE_DRIVE_100GB_RAID_5
        two_drives = raid_constants.HPSSA_TWO_DRIVES_100GB_RAID5_50GB_RAID1
        get_all_details_mock.side_effect = [no_drives, one_drive, two_drives]
        raid_info = {'logical_disks': [{'size_gb': 50,
                                        'raid_level': '1'},
                                       {'size_gb': 100,
                                        'raid_level': '5'}]}
        current_config = manager.create_configuration(raid_info)
        controller_exec_cmd_mock.assert_any_call("create",
                                                 "type=logicaldrive",
                                                 mock.ANY,
                                                 "raid=5",
                                                 "size=%d" % (100*1024))
        # Verify that we created the 50GB disk the last.
        controller_exec_cmd_mock.assert_called_with("create",
                                                    "type=logicaldrive",
                                                    mock.ANY,
                                                    "raid=1",
                                                    "size=%d" % (50*1024))

        ld1_ret = [x for x in current_config['logical_disks']
                   if x['raid_level'] == '1'][0]
        ld2_ret = [x for x in current_config['logical_disks']
                   if x['raid_level'] == '5'][0]
        self.assertEqual('0x600508b1001cc42c',
                         ld2_ret['root_device_hint']['wwn'])
        self.assertEqual('0x600508b1001ce1e1',
                         ld1_ret['root_device_hint']['wwn'])
Ejemplo n.º 5
0
 def test_create_configuration_max_as_size_gb(
         self, controller_exec_cmd_mock, get_all_details_mock):
     no_drives = raid_constants.NO_DRIVES_HPSSA_7_DISKS
     one_drive = raid_constants.ONE_DRIVE_RAID_1_50_GB
     two_drives = raid_constants.TWO_DRIVES_50GB_RAID1_MAXGB_RAID5
     get_all_details_mock.side_effect = [no_drives, one_drive, two_drives]
     raid_info = {'logical_disks': [{'size_gb': 50,
                                     'raid_level': '1',
                                     'disk_type': 'hdd'},
                                    {'size_gb': 'MAX',
                                     'raid_level': '5',
                                     'disk_type': 'hdd'}]}
     raid_info = manager.create_configuration(raid_info)
     ld1 = raid_info['logical_disks'][0]
     ld2 = raid_info['logical_disks'][1]
     self.assertEqual('Smart Array P822 in Slot 3', ld1['controller'])
     self.assertEqual('Smart Array P822 in Slot 3', ld2['controller'])
     self.assertEqual(sorted(['5I:1:1', '5I:1:2']),
                      sorted(ld1['physical_disks']))
     self.assertEqual(sorted(['5I:1:3', '5I:1:4', '6I:1:5']),
                      sorted(ld2['physical_disks']))
     controller_exec_cmd_mock.assert_any_call(
         'create', 'type=logicaldrive', 'drives=5I:1:1,5I:1:2',
         'raid=1', 'size=51200', process_input='y')
     controller_exec_cmd_mock.assert_any_call(
         'create', 'type=logicaldrive', 'drives=5I:1:3,5I:1:4,6I:1:5',
         'raid=5', process_input='y')
Ejemplo n.º 6
0
 def test_create_configuration_share_nonshare_physical_disks(
         self, controller_exec_cmd_mock, get_all_details_mock):
     no_drives = raid_constants.HPSSA_NO_DRIVES_3_PHYSICAL_DISKS
     one_drive = raid_constants.ONE_DRIVE_RAID_1
     two_drives = raid_constants.TWO_DRIVES_50GB_RAID1
     get_all_details_mock.side_effect = [no_drives, one_drive, two_drives]
     controller_exec_cmd_mock.side_effect = [
         (None, None),
         (raid_constants.DRIVE_2_RAID_1_OKAY_TO_SHARE, None),
         (None, None)]
     raid_info = {'logical_disks': [{'size_gb': 50,
                                     'raid_level': '1',
                                     'disk_type': 'hdd'},
                                    {'size_gb': 50,
                                     'share_physical_disks': True,
                                     'raid_level': '0',
                                     'disk_type': 'hdd'}]}
     raid_info = manager.create_configuration(raid_info)
     ld1 = raid_info['logical_disks'][0]
     ld2 = raid_info['logical_disks'][1]
     self.assertEqual('Smart Array P822 in Slot 2', ld1['controller'])
     self.assertEqual('Smart Array P822 in Slot 2', ld2['controller'])
     self.assertEqual(sorted(['5I:1:1', '5I:1:2']),
                      sorted(ld1['physical_disks']))
     self.assertEqual(sorted(['5I:1:1', '5I:1:2']),
                      sorted(ld2['physical_disks']))
     controller_exec_cmd_mock.assert_any_call(
         'create', 'type=logicaldrive', 'drives=5I:1:1,5I:1:2',
         'raid=1', 'size=51200', process_input='y')
     controller_exec_cmd_mock.assert_any_call(
         'create', 'type=logicaldrive', 'drives=5I:1:3', 'raid=0',
         'size=51200', process_input='y')
Ejemplo n.º 7
0
    def test_create_configuration_without_disk_input_succeeds(
            self, controller_exec_cmd_mock, get_all_details_mock):
        no_drives = raid_constants.HPSSA_NO_DRIVES
        one_drive = raid_constants.HPSSA_ONE_DRIVE_100GB_RAID_5
        two_drives = raid_constants.HPSSA_TWO_DRIVES_100GB_RAID5_50GB_RAID1
        get_all_details_mock.side_effect = [no_drives, one_drive, two_drives]
        raid_info = {'logical_disks': [{'size_gb': 50,
                                        'raid_level': '1'},
                                       {'size_gb': 100,
                                        'raid_level': '5'}]}
        current_config = manager.create_configuration(raid_info)
        controller_exec_cmd_mock.assert_any_call("create",
                                                 "type=logicaldrive",
                                                 mock.ANY,
                                                 "raid=5",
                                                 "size=%d" % (100*1024),
                                                 process_input='y')
        # Verify that we created the 50GB disk the last.
        controller_exec_cmd_mock.assert_called_with("create",
                                                    "type=logicaldrive",
                                                    mock.ANY,
                                                    "raid=1",
                                                    "size=%d" % (50*1024),
                                                    process_input='y')

        ld1_ret = [x for x in current_config['logical_disks']
                   if x['raid_level'] == '1'][0]
        ld2_ret = [x for x in current_config['logical_disks']
                   if x['raid_level'] == '5'][0]
        self.assertEqual('0x600508b1001cc42c',
                         ld2_ret['root_device_hint']['wwn'])
        self.assertEqual('0x600508b1001ce1e1',
                         ld1_ret['root_device_hint']['wwn'])
Ejemplo n.º 8
0
    def create_configuration(self, node, ports):
        """Create RAID configuration on the bare metal.

        This method creates the desired RAID configuration as read from
        node['target_raid_config'].

        :param node: A dictionary of the node object
        :param ports: A list of dictionaries containing information of ports
            for the node
        :returns: The current RAID configuration of the below format.
            raid_config = {
                'logical_disks': [{
                    'size_gb': 100,
                    'raid_level': 1,
                    'physical_disks': [
                        '5I:0:1',
                        '5I:0:2'],
                    'controller': 'Smart array controller'
                    },
                ]
            }
        """
        target_raid_config = node.get('target_raid_config', {}).copy()
        return hpssa_manager.create_configuration(
            raid_config=target_raid_config)
Ejemplo n.º 9
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()
Ejemplo n.º 10
0
    def _test_create_configuration_with_disk_input(self,
                                                   controller_exec_cmd_mock,
                                                   get_all_details_mock):
        ld1 = {'size_gb': 50,
               'raid_level': '1',
               'controller': 'Smart Array P822 in Slot 2',
               'physical_disks': ['5I:1:1',
                                  '5I:1:2']}
        ld2 = {'size_gb': 100,
               'raid_level': '5',
               'controller': 'Smart Array P822 in Slot 2',
               'physical_disks': ['5I:1:3',
                                  '5I:1:4',
                                  '6I:1:5']}

        raid_info = {'logical_disks': [ld1, ld2]}

        current_config = manager.create_configuration(raid_info)

        ld1_drives = '5I:1:1,5I:1:2'
        ld2_drives = '5I:1:3,5I:1:4,6I:1:5'
        controller_exec_cmd_mock.assert_any_call("create",
                                                 "type=logicaldrive",
                                                 "drives=%s" % ld2_drives,
                                                 "raid=5",
                                                 "size=%d" % (100*1024),
                                                 process_input='y')
        # Verify that we created the 50GB disk the last.
        controller_exec_cmd_mock.assert_called_with("create",
                                                    "type=logicaldrive",
                                                    "drives=%s" % ld1_drives,
                                                    "raid=1",
                                                    "size=%d" % (50*1024),
                                                    process_input='y')

        ld1_ret = [x for x in current_config['logical_disks']
                   if x['raid_level'] == '1'][0]
        ld2_ret = [x for x in current_config['logical_disks']
                   if x['raid_level'] == '5'][0]

        self.assertIsNotNone(ld1_ret['root_device_hint']['wwn'])
        self.assertIsNotNone(ld2_ret['root_device_hint']['wwn'])
        self.assertIsNotNone(ld1_ret['volume_name'])
        self.assertIsNotNone(ld2_ret['volume_name'])

        # Assert physical disk info
        pds_active = [x['id'] for x in current_config['physical_disks']
                      if x['status'] == 'active']
        pds_ready = [x['id'] for x in current_config['physical_disks']
                     if x['status'] == 'ready']
        pds_active_expected = ['5I:1:3', '5I:1:4', '6I:1:5',
                               '5I:1:1', '5I:1:2']
        pds_ready_expected = ['6I:1:6', '6I:1:7']
        self.assertEqual(sorted(pds_active_expected), sorted(pds_active))
        self.assertEqual(sorted(pds_ready_expected), sorted(pds_ready))
Ejemplo n.º 11
0
    def _test_create_configuration_with_disk_input(self,
                                                   controller_exec_cmd_mock,
                                                   get_all_details_mock):
        ld1 = {'size_gb': 50,
               'raid_level': '1',
               'controller': 'Smart Array P822 in Slot 2',
               'physical_disks': ['5I:1:1',
                                  '5I:1:2']}
        ld2 = {'size_gb': 100,
               'raid_level': '5',
               'controller': 'Smart Array P822 in Slot 2',
               'physical_disks': ['5I:1:3',
                                  '5I:1:4',
                                  '6I:1:5']}

        raid_info = {'logical_disks': [ld1, ld2]}

        current_config = manager.create_configuration(raid_info)

        ld1_drives = '5I:1:1,5I:1:2'
        ld2_drives = '5I:1:3,5I:1:4,6I:1:5'
        controller_exec_cmd_mock.assert_any_call("create",
                                                 "type=logicaldrive",
                                                 "drives=%s" % ld2_drives,
                                                 "raid=5",
                                                 "size=%d" % (100*1024))
        # Verify that we created the 50GB disk the last.
        controller_exec_cmd_mock.assert_called_with("create",
                                                    "type=logicaldrive",
                                                    "drives=%s" % ld1_drives,
                                                    "raid=1",
                                                    "size=%d" % (50*1024))

        ld1_ret = [x for x in current_config['logical_disks']
                   if x['raid_level'] == '1'][0]
        ld2_ret = [x for x in current_config['logical_disks']
                   if x['raid_level'] == '5'][0]

        self.assertIsNotNone(ld1_ret['root_device_hint']['wwn'])
        self.assertIsNotNone(ld2_ret['root_device_hint']['wwn'])
        self.assertIsNotNone(ld1_ret['volume_name'])
        self.assertIsNotNone(ld2_ret['volume_name'])

        # Assert physical disk info
        pds_active = [x['id'] for x in current_config['physical_disks']
                      if x['status'] == 'active']
        pds_ready = [x['id'] for x in current_config['physical_disks']
                     if x['status'] == 'ready']
        pds_active_expected = ['5I:1:3', '5I:1:4', '6I:1:5',
                               '5I:1:1', '5I:1:2']
        pds_ready_expected = ['6I:1:6', '6I:1:7']
        self.assertEqual(sorted(pds_active_expected), sorted(pds_active))
        self.assertEqual(sorted(pds_ready_expected), sorted(pds_ready))
Ejemplo n.º 12
0
 def test_create_configuration_share_physical_disks(
         self, controller_exec_cmd_mock, get_all_details_mock):
     no_drives = raid_constants.HPSSA_NO_DRIVES_2_PHYSICAL_DISKS
     one_drive = raid_constants.ONE_DRIVE_RAID_1
     two_drives = raid_constants.TWO_DRIVES_50GB_RAID1
     get_all_details_mock.side_effect = [no_drives, one_drive, two_drives]
     controller_exec_cmd_mock.side_effect = [
         (None, None),
         (raid_constants.DRIVE_2_RAID_1_OKAY_TO_SHARE, None),
         (None, None)]
     raid_info = {'logical_disks': [{'size_gb': 50,
                                     'share_physical_disks': True,
                                     'raid_level': '1',
                                     'disk_type': 'hdd'},
                                    {'size_gb': 50,
                                     'share_physical_disks': True,
                                     'raid_level': '1',
                                     'disk_type': 'hdd'}]}
     raid_info = manager.create_configuration(raid_info)
     ld1 = raid_info['logical_disks'][0]
     ld2 = raid_info['logical_disks'][1]
     self.assertEqual('Smart Array P822 in Slot 2', ld1['controller'])
     self.assertEqual('Smart Array P822 in Slot 2', ld2['controller'])
     self.assertEqual(sorted(['5I:1:1', '5I:1:2']),
                      sorted(ld1['physical_disks']))
     self.assertEqual(sorted(['5I:1:1', '5I:1:2']),
                      sorted(ld2['physical_disks']))
     controller_exec_cmd_mock.assert_any_call(
         'create', 'type=logicaldrive', 'drives=5I:1:1,5I:1:2',
         'raid=1', 'size=51200')
     controller_exec_cmd_mock.assert_any_call(
         'array', 'A', 'create', 'type=logicaldrive', 'raid=1', 'size=?',
         dont_transform_to_hpssa_exception=True)
     controller_exec_cmd_mock.assert_any_call(
         'array', 'A', 'create', 'type=logicaldrive', 'raid=1',
         'size=51200')
Ejemplo n.º 13
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()