Return list of disk devices and work out if they are SSD or HDD.
190894
def _linux_disks():
    '''
    
    '''
    ret = {'disks': [], 'SSDs': []}

    for entry in glob.glob('/sys/block/*/queue/rotational'):
        try:
            with salt.utils.files.fopen(entry) as entry_fp:
                device = entry.split('/')[3]
                flag = entry_fp.read(1)
                if flag == '0':
                    ret['SSDs'].append(device)
                    log.trace('Device %s reports itself as an SSD', device)
                elif flag == '1':
                    ret['disks'].append(device)
                    log.trace('Device %s reports itself as an HDD', device)
                else:
                    log.trace(
                        'Unable to identify device %s as an SSD or HDD. It does '
                        'not report 0 or 1', device
                    )
        except IOError:
            pass
    return ret
885968
def _get_hdds(vm_):
    '''
    
    '''
    _hdds = config.get_cloud_config_value(
        'hdds', vm_, __opts__, default=None,
        search_global=False
    )

    hdds = []

    for hdd in _hdds:
        hdds.append(
            Hdd(
                size=hdd['size'],
                is_main=hdd['is_main']
            )
        )

    return hdds
402108
def devices(self):
		""""""

		response = self._call(
			mc_calls.DeviceManagementInfo
		)
		registered_devices = response.body.get('data', {}).get('items', [])

		return registered_devices
1045045
def list(self, device_path, timeout_ms=None):
    """"""
    return self.filesync_service.list(
        device_path, timeouts.PolledTimeout.from_millis(timeout_ms))
682985
def get_devices():
    """"""
    buf = create_string_buffer(512)
    buflen = c_uint32(sizeof(buf))
    DAQmxGetSysDevNames(buf, buflen)
    pybuf = buf.value
    devices = pybuf.decode(u'utf-8').split(u",")
    return devices
562269
def devices(self):
        
        if self._devices is None:
            self._devices = DeviceList(self._version, fleet_sid=self._solution['sid'], )
        return self._devices
685510
def retrieveVals(self):
        """"""
        if self._diskList:
            self._fetchDevAll('disk', self._diskList, 
                              self._info.getDiskStats)
        if self._mdList:
            self._fetchDevAll('md', self._mdList, 
                              self._info.getMDstats)
        if self._partList:
            self._fetchDevAll('part', self._partList, 
                              self._info.getPartitionStats) 
        if self._lvList:
            self._fetchDevAll('lv', self._lvList, 
                              self._info.getLVstats)
        self._fetchDevAll('fs', self._fsList, 
                          self._info.getFilesystemStats)
333040
def listDevices(self, interface_id):
        """"""
        LOG.debug("RPCFunctions.listDevices: interface_id = %s, _devices_raw = %s" % (
            interface_id, str(self._devices_raw)))
        remote = interface_id.split('-')[-1]
        if remote not in self._devices_raw:
            self._devices_raw[remote] = []
        if self.systemcallback:
            self.systemcallback('listDevices', interface_id)
        return self._devices_raw[remote]
1046344
def get_disks(vm_):
    '''
    
    '''
    with _get_xapi_session() as xapi:

        disk = {}

        vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
        if vm_uuid is False:
            return False
        for vbd in xapi.VM.get_VBDs(vm_uuid):
            dev = xapi.VBD.get_device(vbd)
            if not dev:
                continue
            prop = xapi.VBD.get_runtime_properties(vbd)
            disk[dev] = {
                'backend': prop['backend'],
                'type': prop['device-type'],
                'protocol': prop['protocol']
            }

        return disk
956723
def rw_active(self):
        """"""
        result = False
        for disk in self.disks:
            result = disk.rw_active() or result
        return result
467674
async def storage(dev: Device):
    """"""
    storages = await dev.get_storage_list()
    for storage in storages:
        click.echo(storage)
359142
def get_devices(self) -> list:
        """"""

        if not self.enabled:
            return None

        self.in_process = True

        response, _ = helpers.call_api(
            '/cloud/v1/deviceManaged/devices',
            'post',
            headers=helpers.req_headers(self),
            json=helpers.req_body(self, 'devicelist')
        )

        if response and helpers.check_response(response, 'get_devices'):
            if 'result' in response and 'list' in response['result']:
                device_list = response['result']['list']
                outlets, switches, fans = self.process_devices(device_list)
            else:
                logger.error('Device list in response not found')
        else:
            logger.error('Error retrieving device list')

        self.in_process = False

        return (outlets, switches, fans)
703085
def _get_devices_by_failover_status(self, status):
        '''
        '''

        devices_with_status = []
        for device in self.devices:
            if (self._check_device_failover_status(device, status)):
                devices_with_status.append(device)
        return devices_with_status
566380
def devices():
    '''
    
    '''
    out = __salt__['cmd.run_all']("blkid -o export")
    salt.utils.fsutils._verify_run(out)

    return salt.utils.fsutils._blkid_output(out['stdout'], fs_type='btrfs')
128500
def check_drives(drivename, drivestatus):
        
        return DISK_STATES[int(drivestatus)]["icingastatus"], "Drive '{}': {}".format(
            drivename, DISK_STATES[int(drivestatus)]["result"])
141458
def _diff_disk_lists(old, new):
    '''
    
    '''
    # Change the target device to avoid duplicates before diffing: this may lead
    # to additional changes. Think of unchanged disk 'hda' and another disk listed
    # before it becoming 'hda' too... the unchanged need to turn into 'hdb'.
    targets = []
    prefixes = ['fd', 'hd', 'vd', 'sd', 'xvd', 'ubd']
    for disk in new:
        target_node = disk.find('target')
        target = target_node.get('dev')
        prefix = [item for item in prefixes if target.startswith(item)][0]
        new_target = ['{0}{1}'.format(prefix, string.ascii_lowercase[i]) for i in range(len(new))
                      if '{0}{1}'.format(prefix, string.ascii_lowercase[i]) not in targets][0]
        target_node.set('dev', new_target)
        targets.append(new_target)

    return _diff_lists(old, new, _disks_equal)
623902
def get_physical_drives(self):
        
        physical_drives = []
        for controller in self.controllers:
            # First add unassigned physical drives.
            for physical_drive in controller.unassigned_physical_drives:
                physical_drives.append(physical_drive)
            # Now add physical drives part of RAID arrays.
            for array in controller.raid_arrays:
                for physical_drive in array.physical_drives:
                    physical_drives.append(physical_drive)

        return physical_drives