示例#1
0
def validate_spec(spec,
                  disk_array = None, size_dict = None):
    if size_dict == None:
	size_dict = get_disk_list()
    
    if disk_array == None:
        disk_array = DiskArray()
        disk_array.fill_from_system_info(spec)

    # all the required drives must be present.
    # we can't use anything other than missing since that requires arrays to be up
    # and we don't care about array status with this command.
    for drive in disk_array.get_drive_list():
        if drive.is_missing() or drive.get_scsi_state() != 'online':
            return (False, '%s is missing.' % drive.get_devname())

        if not drive.get_license():
            # we'll log a message for unlicensed disks, since this shouldnt 
            # ever happen.
            return (False, '%s is unlicensed' % drive.get_devname())
        # the output from size_dict is a string numeral, so need to convert it into an int
        if int(spec.get_disk_size_by_id(drive.portnum)) > int(size_dict['disk%s' % drive.portnum]):
            return (False, 'Disks are the wrong size')

    # double check that we have enough disks for this spec.
    if spec.get_disk_count() > disk_array.get_num_drives():
        return (False, 'Insufficient disks for spec %s' % spec.get_name())

    return (True, 'System hardware and specification are compatible')
示例#2
0
def validate_spec(spec,
                  disk_array = None, size_dict = None):
    if size_dict == None:
	size_dict = get_disk_list()
    
    if disk_array == None:
        disk_array = DiskArray()
        disk_array.fill_from_system_info(spec)

    # all the required drives must be present.
    # we can't use anything other than missing since that requires arrays to be up
    # and we don't care about array status with this command.
    for drive in disk_array.get_drive_list():
        if drive.is_missing() or drive.get_scsi_state() != 'online':
            return (False, '%s is missing.' % drive.get_devname())

        # tests if the physical disks media (hdd or ssd) match what's in the
        # spec file
        # this is kinda complicated: The first thing we need is what
        # kind of media each drive is: drive.get_devname().get_media.
        # then we plug that into the .is_media_valid method of the same 
        # drive in the new spec
        # this will probably bail on on legacy specs that don't use disk
        # zones or maps
        try:
            cur_media = disk_info_map.get_disk_info(drive.get_devname()).get_media()
            if not spec.get_disk_zone_spec(drive.portnum).is_media_valid(cur_media):
                return (False, '%s is wrong type.'  % drive.get_devname())
        except:
            print 'Error getting media for %s: legacy spec error for spec %s' % ( drive.get_devname(), spec.name )
            pass
            
        if not drive.get_license():
            # we'll log a message for unlicensed disks, since this shouldnt 
            # ever happen.
            return (False, '%s is unlicensed' % drive.get_devname())
        # the output from size_dict is a string numeral, so need to convert it into an int
        if int(spec.get_disk_size_by_id(drive.portnum)) > int(size_dict['disk%s' % drive.portnum]):
            return (False, 'Disks are the wrong size')

    # double check that we have enough disks for this spec.
    if spec.get_disk_count() > disk_array.get_num_drives():
        return (False, 'Insufficient disks for spec %s' % spec.get_name())

    return (True, 'System hardware and specification are compatible')