lxd/db/storage_pools.go
func (c *Cluster) StoragePoolVolumeGetType(project string, volumeName string, volumeType int, poolID, nodeID int64) (int64, *api.StorageVolume, error) {
	// Custom volumes are "global", i.e. they are associated with the
	// default project.
	if volumeType == StoragePoolVolumeTypeCustom {
		project = "default"
	}

	volumeID, err := c.StoragePoolVolumeGetTypeID(project, volumeName, volumeType, poolID, nodeID)
	if err != nil {
		return -1, nil, err
	}

	volumeNode, err := c.StorageVolumeNodeGet(volumeID)
	if err != nil {
		return -1, nil, err
	}

	volumeConfig, err := c.StorageVolumeConfigGet(volumeID)
	if err != nil {
		return -1, nil, err
	}

	volumeDescription, err := c.StorageVolumeDescriptionGet(volumeID)
	if err != nil {
		return -1, nil, err
	}

	volumeTypeName, err := StoragePoolVolumeTypeToName(volumeType)
	if err != nil {
		return -1, nil, err
	}

	storageVolume := api.StorageVolume{
		Type: volumeTypeName,
	}
	storageVolume.Name = volumeName
	storageVolume.Description = volumeDescription
	storageVolume.Config = volumeConfig
	storageVolume.Location = volumeNode

	return volumeID, &storageVolume, nil
}
func (c *Cluster) StoragePoolVolumeGetType(project string, volumeName string, volumeType int, poolID, nodeID int64) (int64, *api.StorageVolume, error) {
	// Custom volumes are "global", i.e. they are associated with the
	// default project.
	if volumeType == StoragePoolVolumeTypeCustom {
		project = "default"
	}

	volumeID, err := c.StoragePoolVolumeGetTypeID(project, volumeName, volumeType, poolID, nodeID)
	if err != nil {
		return -1, nil, err
	}

	volumeNode, err := c.StorageVolumeNodeGet(volumeID)
	if err != nil {
		return -1, nil, err
	}

	volumeConfig, err := c.StorageVolumeConfigGet(volumeID)
	if err != nil {
		return -1, nil, err
	}

	volumeDescription, err := c.StorageVolumeDescriptionGet(volumeID)
	if err != nil {
		return -1, nil, err
	}

	volumeTypeName, err := StoragePoolVolumeTypeToName(volumeType)
	if err != nil {
		return -1, nil, err
	}

	storageVolume := api.StorageVolume{
		Type: volumeTypeName,
	}
	storageVolume.Name = volumeName
	storageVolume.Description = volumeDescription
	storageVolume.Config = volumeConfig
	storageVolume.Location = volumeNode

	return volumeID, &storageVolume, nil
}
func ( c * Cluster ) StoragePoolVolumeGetType ( project string , volumeName string , volumeType int , poolID , nodeID int64 ) ( int64 , * api . StorageVolume , error ) { // Custom volumes are "global", i.e. they are associated with the // default project. if volumeType == StoragePoolVolumeTypeCustom { project = " " } volumeID , err := c . StoragePoolVolumeGetTypeID ( project , volumeName , volumeType , poolID , nodeID ) if err != nil { return - 1 , nil , err } volumeNode , err := c . StorageVolumeNodeGet ( volumeID ) if err != nil { return - 1 , nil , err } volumeConfig , err := c . StorageVolumeConfigGet ( volumeID ) if err != nil { return - 1 , nil , err } volumeDescription , err := c . StorageVolumeDescriptionGet ( volumeID ) if err != nil { return - 1 , nil , err } volumeTypeName , err := StoragePoolVolumeTypeToName ( volumeType ) if err != nil { return - 1 , nil , err } storageVolume := api . StorageVolume { Type : volumeTypeName , } storageVolume . Name = volumeName storageVolume . Description = volumeDescription storageVolume . Config = volumeConfig storageVolume . Location = volumeNode return volumeID , & storageVolume , nil }
// StoragePoolVolumeGetType returns a single storage volume attached to a
// given storage pool of a given type, on the node with the given ID.
StoragePoolVolumeGetType returns a single storage volume attached to a given storage pool of a given type on the node with the given ID .