List the storage IDs for the unit
503817
def storage_list(storage_name=None):
    """"""
    _args = ['storage-list', '--format=json']
    if storage_name:
        _args.append(storage_name)
    try:
        return json.loads(subprocess.check_output(_args).decode('UTF-8'))
    except ValueError:
        return None
    except OSError as e:
        import errno
        if e.errno == errno.ENOENT:
            # storage-list does not exist
            return []
        raise
809015
def list_dir(self):
        

        bucket = self.blob.bucket
        prefix = self.blob.name
        if not prefix.endswith('/'): prefix += '/'

        for blob in bucket.list_blobs(prefix=prefix, delimiter='/'):
            yield 'gs://{}/{}'.format(blob.bucket.name, blob.name)
117204
def get_asset_ids(self):
        
        if not self.is_asset_based_activity():
            raise IllegalState()
        else:
            ids = []
            for i in self._my_map['assetIds']:
                ids.append(Id(i))
            return IdList(ids)
24380
private void collectScsiRuntimeNames() {

        // To hold all the Scsi Luns that are disks
        ArrayList<ScsiLun> sortedScsiLuns = new ArrayList<ScsiLun>();

        // Check to see that this device has luns
        if (storageDeviceInfo.getScsiLun().length == 0) {
            log.trace("There are no Scsi LUNS on this storage device.");
            return;
        }

        // Collect all the scsi luns which are disks
        for (ScsiLun lun : storageDeviceInfo.getScsiLun()) {
            if (lun.lunType.equals("disk")) {
                sortedScsiLuns.add(lun);
            }
        }

        // To collect the Scsi Topology information
        ArrayList<Map> scsiTopologyInfo = new ArrayList<Map>();

        // Get the HostScsiTopology information
        HostScsiTopology scsiTopology = storageDeviceInfo.scsiTopology;

        // Check to see that adapters are present
        if (null == scsiTopology.adapter || scsiTopology.adapter.length == 0) {
            log.trace("There are no adapters on this storage device.");
            return;
        }

        // Get the adapters from scsi topology
        for (HostScsiTopologyInterface adapter : scsiTopology.adapter) {

            // Check to see that these adapters have targets
            if (null == adapter.target || adapter.target.length == 0) {
                log.trace("This adapter has no targets. Adapter:" + adapter.adapter);
                continue;
            }

            // For each target on these adapters
            for (HostScsiTopologyTarget target : adapter.target) {

                // Check to see that the target has LUNs
                if (null == target.lun || target.lun.length == 0) {
                    log.trace("This target has no LUNs on it. Target:" + target.key);
                    continue;
                }

                // For each lun on these targets
                for (HostScsiTopologyLun lun : target.lun) {

                    // Create a Map with The target key and lun information
                    Map<String, Object> scsiInfo = new HashMap<String, Object>();

                    // Add this information to map
                    scsiInfo.put("key", target.key);
                    scsiInfo.put("lunInfo", lun);

                    // Add this map to Scsi info list
                    scsiTopologyInfo.add(scsiInfo);
                }
            }
        }

        // Make sure that information is available.
        if (sortedScsiLuns.size() == 0 || scsiTopologyInfo.size() == 0) {
            log.trace("There is no SCSI Lun information on this host");
            return;
        }

        // For each Lun in sortedScsiLuns
        for (ScsiLun lun : sortedScsiLuns) {

            // For each of the ScisiTopology
            for (Map info : scsiTopologyInfo) {

                // Get the lun information on the target
                HostScsiTopologyLun scsiTopologyLun = (HostScsiTopologyLun) info.get("lunInfo");

                // If the target
                if (scsiTopologyLun.scsiLun.equals(lun.key)) {

                    // Get the key name and split it
                    String[] names = info.get("key").toString().split("-");
                    String name = names[names.length - 1];

                    // The name will look something like this: "vmhba0:2:0"
                    // This needs to be split with ':' such that we have ["vmhba0", "2", "0"]
                    String[] nameSplit = name.split(":");

                    // We then get the lun number from info
                    // We create the RuntimeName (A:C:T:L form) which will finally look like: "vmhba0:C2:T0:L0"
                    // "L" is followed by the Lun Number
                    // Create a Map with LunKey vs RuntimeName
                    this.scsiRuntimeNames.put(lun.key, (nameSplit[0] + ":C" + nameSplit[1] + ":T" + nameSplit[2] + ":L" + scsiTopologyLun.getLun()));
                }
            }
        }
    }
382304
def get_volumes_for_container(self, container_id, skip_empty_source=True):
        
        logger.info("listing volumes for container '%s'", container_id)
        inspect_output = self.d.inspect_container(container_id)
        volumes = inspect_output['Mounts'] or []
        volume_names = [x['Name'] for x in volumes]

        if skip_empty_source:
            # Don't show volumes which are not on the filesystem
            volume_names = [x['Name'] for x in volumes if x['Source'] != ""]

        logger.debug("volumes = %s", volume_names)
        return volume_names
1263710
def member_ids(self):
        """"""
        info = self.raw.get(ATTR_MEMBERS, {})

        if not info or ROOT_DEVICES2 not in info:
            return []

        return info[ROOT_DEVICES2].get(ATTR_ID, [])
430559
def cli(env, volume_id):
    """"""
    block_manager = SoftLayer.BlockStorageManager(env.client)
    block_volume = block_manager.get_block_volume_details(volume_id)
    block_volume = utils.NestedDict(block_volume)

    table = formatting.KeyValueTable(['Name', 'Value'])
    table.align['Name'] = 'r'
    table.align['Value'] = 'l'

    storage_type = block_volume['storageType']['keyName'].split('_').pop(0)
    table.add_row(['ID', block_volume['id']])
    table.add_row(['Username', block_volume['username']])
    table.add_row(['Type', storage_type])
    table.add_row(['Capacity (GB)', "%iGB" % block_volume['capacityGb']])
    table.add_row(['LUN Id', "%s" % block_volume['lunId']])

    if block_volume.get('provisionedIops'):
        table.add_row(['IOPs', float(block_volume['provisionedIops'])])

    if block_volume.get('storageTierLevel'):
        table.add_row([
            'Endurance Tier',
            block_volume['storageTierLevel'],
        ])

    table.add_row([
        'Data Center',
        block_volume['serviceResource']['datacenter']['name'],
    ])
    table.add_row([
        'Target IP',
        block_volume['serviceResourceBackendIpAddress'],
    ])

    if block_volume['snapshotCapacityGb']:
        table.add_row([
            'Snapshot Capacity (GB)',
            block_volume['snapshotCapacityGb'],
        ])
        if 'snapshotSizeBytes' in block_volume['parentVolume']:
            table.add_row([
                'Snapshot Used (Bytes)',
                block_volume['parentVolume']['snapshotSizeBytes'],
            ])

    table.add_row(['# of Active Transactions', "%i"
                   % block_volume['activeTransactionCount']])

    if block_volume['activeTransactions']:
        for trans in block_volume['activeTransactions']:
            if 'transactionStatus' in trans and 'friendlyName' in trans['transactionStatus']:
                table.add_row(['Ongoing Transaction', trans['transactionStatus']['friendlyName']])

    table.add_row(['Replicant Count', "%u" % block_volume.get('replicationPartnerCount', 0)])

    if block_volume['replicationPartnerCount'] > 0:
        # This if/else temporarily handles a bug in which the SL API
        # returns a string or object for 'replicationStatus'; it seems that
        # the type is string for File volumes and object for Block volumes
        if 'message' in block_volume['replicationStatus']:
            table.add_row(['Replication Status', "%s"
                           % block_volume['replicationStatus']['message']])
        else:
            table.add_row(['Replication Status', "%s"
                           % block_volume['replicationStatus']])

        replicant_list = []
        for replicant in block_volume['replicationPartners']:
            replicant_table = formatting.Table(['Replicant ID',
                                                replicant['id']])
            replicant_table.add_row([
                'Volume Name',
                utils.lookup(replicant, 'username')])
            replicant_table.add_row([
                'Target IP',
                utils.lookup(replicant, 'serviceResourceBackendIpAddress')])
            replicant_table.add_row([
                'Data Center',
                utils.lookup(replicant,
                             'serviceResource', 'datacenter', 'name')])
            replicant_table.add_row([
                'Schedule',
                utils.lookup(replicant,
                             'replicationSchedule', 'type', 'keyname')])
            replicant_list.append(replicant_table)
        table.add_row(['Replicant Volumes', replicant_list])

    if block_volume.get('originalVolumeSize'):
        original_volume_info = formatting.Table(['Property', 'Value'])
        original_volume_info.add_row(['Original Volume Size', block_volume['originalVolumeSize']])
        if block_volume.get('originalVolumeName'):
            original_volume_info.add_row(['Original Volume Name', block_volume['originalVolumeName']])
        if block_volume.get('originalSnapshotName'):
            original_volume_info.add_row(['Original Snapshot Name', block_volume['originalSnapshotName']])
        table.add_row(['Original Volume Properties', original_volume_info])

    env.fout(table)
286868
def ids(self):
        
        if self._ids is None:
            if self._columns:
                if isinstance(self._columns, OrderedDict):
                    return [list(self._columns.keys())[0]]
                return [self._columns[0]]
        else:
            return self._ids
1193058
def list():
    ''''''
    fields = [
        ('Name', 'name'),
        ('ID', 'id'),
        ('Owner', 'is_owner'),
        ('Permission', 'permission'),
    ]
    with Session() as session:
        try:
            resp = session.VFolder.list()
            if not resp:
                print('There is no virtual folders created yet.')
                return
            rows = (tuple(vf[key] for _, key in fields) for vf in resp)
            hdrs = (display_name for display_name, _ in fields)
            print(tabulate(rows, hdrs))
        except Exception as e:
            print_error(e)
            sys.exit(1)
251392
def list_blobs(storage_conn=None, **kwargs):
    '''
    
    '''
    if not storage_conn:
        storage_conn = get_storage_conn(opts=kwargs)

    if 'container' not in kwargs:
        raise SaltSystemExit(
            code=42,
            msg='An storage container name must be specified as "container"'
        )

    data = storage_conn.list_blobs(
        container_name=kwargs['container'],
        prefix=kwargs.get('prefix', None),
        marker=kwargs.get('marker', None),
        maxresults=kwargs.get('maxresults', None),
        include=kwargs.get('include', None),
        delimiter=kwargs.get('delimiter', None),
    )

    ret = {}
    for item in data.blobs:
        ret[item.name] = object_to_dict(item)
    return ret
32217
def list_(device, unit=None):
    '''
    
    '''
    _validate_device(device)

    if unit:
        if unit not in VALID_UNITS:
            raise CommandExecutionError(
                'Invalid unit passed to partition.part_list'
            )
        cmd = 'parted -m -s {0} unit {1} print'.format(device, unit)
    else:
        cmd = 'parted -m -s {0} print'.format(device)

    out = __salt__['cmd.run_stdout'](cmd).splitlines()
    ret = {'info': {}, 'partitions': {}}
    mode = 'info'
    for line in out:
        if line in ('BYT;', 'CHS;', 'CYL;'):
            continue
        cols = line.rstrip(';').split(':')
        if mode == 'info':
            if 7 <= len(cols) <= 8:
                ret['info'] = {
                    'disk': cols[0],
                    'size': cols[1],
                    'interface': cols[2],
                    'logical sector': cols[3],
                    'physical sector': cols[4],
                    'partition table': cols[5],
                    'model': cols[6]}
                if len(cols) == 8:
                    ret['info']['disk flags'] = cols[7]
                    # Older parted (2.x) doesn't show disk flags in the 'print'
                    # output, and will return a 7-column output for the info
                    # line. In these cases we just leave this field out of the
                    # return dict.
                mode = 'partitions'
            else:
                raise CommandExecutionError(
                    'Problem encountered while parsing output from parted')
        else:
            # Parted (v3.1) have a variable field list in machine
            # readable output:
            #
            # number:start:end:[size:]([file system:name:flags;]|[free;])
            #
            # * If units are in CHS 'size' is not printed.
            # * If is a logical partition with PED_PARTITION_FREESPACE
            #   set, the last three fields are replaced with the
            #   'free' text.
            #
            fields = ['number', 'start', 'end']
            if unit != 'chs':
                fields.append('size')
            if cols[-1] == 'free':
                # Drop the last element from the list
                cols.pop()
            else:
                fields.extend(['file system', 'name', 'flags'])
            if len(fields) == len(cols):
                ret['partitions'][cols[0]] = dict(six.moves.zip(fields, cols))
            else:
                raise CommandExecutionError(
                    'Problem encountered while parsing output from parted')
    return ret
914247
def _listdir(self, root):
        ""
        res = []
        for name in os.listdir(root):
            path = os.path.join(root, name)
            if os.path.isdir(path):
                name += os.sep
            res.append(name)
        return res
46420
static List<String> findStorageIds( Map<String,String> targetProperties ) {

		List<String> result = new ArrayList<> ();
		String prop = targetProperties.get( USE_BLOCK_STORAGE );
		if( ! Utils.isEmptyOrWhitespaces( prop )) {
			for( String s : Utils.splitNicely( prop, "," )) {
				if( ! Utils.isEmptyOrWhitespaces( s ))
					result.add( s );
			}
		}

		return result;
	}
1045045
def list(self, device_path, timeout_ms=None):
    """"""
    return self.filesync_service.list(
        device_path, timeouts.PolledTimeout.from_millis(timeout_ms))
362311
def release_ids(self):
        
        r = [(k, self._releases[k][0]['upload_time'])
             for k in self._releases.keys()
             if len(self._releases[k]) > 0]
        return [k[0] for k in sorted(r, key=lambda k: k[1])]
709404
public static List<StorageInfo> getStorageList() {

        List<StorageInfo> list = new ArrayList<StorageInfo>();
        String def_path = "";
        boolean def_path_internal = false;
        String def_path_state = "";
        boolean def_path_readonly = true;
        boolean def_path_available = false;
        try {
            if (Environment.getExternalStorageDirectory() != null) {
                def_path = Environment.getExternalStorageDirectory().getPath();
            }
        } catch (Throwable ex) {
            //trap for android studio layout editor and some for certain devices
            //see https://github.com/osmdroid/osmdroid/issues/508
            ex.printStackTrace();
        }
        try {
            def_path_internal = (Build.VERSION.SDK_INT >= 9) && !Environment.isExternalStorageRemovable();
        } catch (Throwable ex) {
            //trap for android studio layout editor and some for certain devices
            //see https://github.com/osmdroid/osmdroid/issues/508
            ex.printStackTrace();
        }
        try {
            def_path_state = Environment.getExternalStorageState();
        } catch (Throwable ex) {
            //trap for android studio layout editor and some for certain devices
            //see https://github.com/osmdroid/osmdroid/issues/508
            ex.printStackTrace();
        }
        try {
            def_path_available = def_path_state.equals(Environment.MEDIA_MOUNTED) || def_path_state.equals(Environment.MEDIA_MOUNTED_READ_ONLY);
        } catch (Throwable ex) {
            //trap for android studio layout editor and some for certain devices
            //see https://github.com/osmdroid/osmdroid/issues/508
            ex.printStackTrace();
        }

        try {
            def_path_readonly = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY);
        } catch (Throwable ex) {
            //trap for android studio layout editor and some for certain devices
            //see https://github.com/osmdroid/osmdroid/issues/508
            ex.printStackTrace();
        }
        BufferedReader buf_reader = null;
        try {
            HashSet<String> paths = new HashSet<String>();
            buf_reader = new BufferedReader(new FileReader("/proc/mounts"));
            String line;
            int cur_display_number = 1;
            Log.d(TAG, "/proc/mounts");
            while ((line = buf_reader.readLine()) != null) {
                Log.d(TAG, line);
                if (line.contains("vfat") || line.contains("/mnt")) {
                    StringTokenizer tokens = new StringTokenizer(line, " ");
                    String unused = tokens.nextToken(); //device
                    String mount_point = tokens.nextToken(); //mount point
                    if (paths.contains(mount_point)) {
                        continue;
                    }
                    unused = tokens.nextToken(); //file system
                    List<String> flags = Arrays.asList(tokens.nextToken().split(",")); //flags
                    boolean readonly = flags.contains("ro");

                    if (mount_point.equals(def_path)) {
                        paths.add(def_path);
                        list.add(0, new StorageInfo(def_path, def_path_internal, readonly, -1));
                    } else if (line.contains("/dev/block/vold")) {
                        if (!line.contains("/mnt/secure")
                            && !line.contains("/mnt/asec")
                            && !line.contains("/mnt/obb")
                            && !line.contains("/dev/mapper")
                            && !line.contains("tmpfs")) {
                            paths.add(mount_point);
                            // if (isWritable(new File(mount_point+ File.separator)))
                            list.add(new StorageInfo(mount_point, false, readonly, cur_display_number++));
                        }
                    }
                }
            }

            if (!paths.contains(def_path) && def_path_available && def_path.length() > 0) {
                list.add(0, new StorageInfo(def_path, def_path_internal, def_path_readonly, -1));
            }

        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            if (buf_reader != null) {
                try {
                    buf_reader.close();
                } catch (IOException ex) {
                }
            }
        }
        Set<File> allStorageLocationsRevised = getAllStorageLocationsRevised();
        Iterator<File> iterator = allStorageLocationsRevised.iterator();
        while (iterator.hasNext()) {
            File next = iterator.next();
            boolean found = false;
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i).path.equals(next.getAbsolutePath())) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                list.add(new StorageInfo(next.getAbsolutePath(), false, false, -1));
            }
        }


        return list;
    }
490627
def list_dfu_devices(*args, **kwargs):
    """"""
    devices = get_dfu_devices(*args, **kwargs)
    if not devices:
        print("No DFU capable devices found")
        return
    for device in devices:
        print("Bus {} Device {:03d}: ID {:04x}:{:04x}"
              .format(device.bus, device.address,
                      device.idVendor, device.idProduct))
        layout = get_memory_layout(device)
        print("Memory Layout")
        for entry in layout:
            print("    0x{:x} {:2d} pages of {:3d}K bytes"
                  .format(entry['addr'], entry['num_pages'],
                          entry['page_size'] // 1024))