Esempio n. 1
0
func (s *daemon) updateIndex() error {
	volumeUUIDs, err := util.ListConfigIDs(s.Root, VOLUME_CFG_PREFIX, CFG_POSTFIX)
	if err != nil {
		return err
	}
	for _, uuid := range volumeUUIDs {
		volume := s.loadVolume(uuid)
		if err := s.UUIDIndex.Add(uuid); err != nil {
			return err
		}
		if volume == nil {
			return fmt.Errorf("Volume list changed for volume %v, something is wrong", uuid)
		}
		if volume.Name != "" {
			if err := s.NameUUIDIndex.Add(volume.Name, volume.UUID); err != nil {
				return err
			}
		}
		for snapshotUUID, snapshot := range volume.Snapshots {
			if err := s.UUIDIndex.Add(snapshotUUID); err != nil {
				return err
			}
			if err := s.SnapshotVolumeIndex.Add(snapshotUUID, uuid); err != nil {
				return err
			}
			if snapshot.Name != "" {
				if err := s.NameUUIDIndex.Add(snapshot.Name, snapshot.UUID); err != nil {
					return err
				}
			}
		}
	}

	return nil
}
Esempio n. 2
0
func (s *daemon) listVolume() ([]byte, error) {
	resp := make(map[string]api.VolumeResponse)

	volumeUUIDs, err := util.ListConfigIDs(s.Root, VOLUME_CFG_PREFIX, CFG_POSTFIX)
	if err != nil {
		return nil, err
	}

	for _, uuid := range volumeUUIDs {
		volume := s.loadVolume(uuid)
		if volume == nil {
			return nil, fmt.Errorf("Volume list changed for volume %v", uuid)
		}
		r, err := s.listVolumeInfo(volume)
		if err != nil {
			return nil, err
		}
		resp[uuid] = *r
	}

	return api.ResponseOutput(resp)
}
Esempio n. 3
0
func (device *Device) listVolumeNames() ([]string, error) {
	return util.ListConfigIDs(device.Root, DRIVER_CFG_PREFIX+VOLUME_CFG_PREFIX, CFG_POSTFIX)
}
Esempio n. 4
0
func (d *Driver) listVolumeIDs() ([]string, error) {
	return util.ListConfigIDs(d.Root, CFG_PREFIX+VOLUME_CFG_PREFIX, CFG_POSTFIX)
}
Esempio n. 5
0
func (device *Device) listVolumeIDs() ([]string, error) {
	return util.ListConfigIDs(device.Root, LONGHORN_CFG_PREFIX+VOLUME_CFG_PREFIX, CFG_POSTFIX)
}