Пример #1
0
// Creates a volume on the given volume store, of the given size, with the given metadata.
func (m *MockVolumeStore) VolumeCreate(op trace.Operation, ID string, store *url.URL, capacityKB uint64, info map[string][]byte) (*Volume, error) {
	storeName, err := util.VolumeStoreName(store)
	if err != nil {
		return nil, err
	}

	selfLink, err := util.VolumeURL(storeName, ID)
	if err != nil {
		return nil, err
	}

	vol := &Volume{
		ID:       ID,
		Store:    store,
		SelfLink: selfLink,
	}

	m.db[ID] = vol

	return vol, nil
}
Пример #2
0
// NewVolume creates a Volume
func NewVolume(store *url.URL, ID string, info map[string][]byte, device Disk) (*Volume, error) {
	storeName, err := util.VolumeStoreName(store)
	if err != nil {
		return nil, err
	}

	selflink, err := util.VolumeURL(storeName, ID)
	if err != nil {
		return nil, err
	}

	// Set the label to the md5 of the ID

	vol := &Volume{
		ID:       ID,
		Label:    label(ID),
		Store:    store,
		SelfLink: selflink,
		Device:   device,
		Info:     info,
	}

	return vol, nil
}