func createBlockMetadata(mds torus.MetadataService, name string, vid torus.VolumeID) (blockMetadata, error) { switch mds.Kind() { case torus.EtcdMetadata: return createBlockEtcdMetadata(mds, name, vid) case torus.TempMetadata: return createBlockTempMetadata(mds, name, vid) default: return nil, errors.New("unimplemented for this kind of metadata") } }
func DeleteBlockVolume(mds torus.MetadataService, volume string) error { vol, err := mds.GetVolume(volume) if err != nil { return err } bmds, err := createBlockMetadata(mds, vol.Name, torus.VolumeID(vol.Id)) if err != nil { return err } return bmds.DeleteVolume() }
func CreateBlockVolume(mds torus.MetadataService, volume string, size uint64) error { id, err := mds.NewVolumeID() if err != nil { return err } blkmd, err := createBlockMetadata(mds, volume, id) if err != nil { return err } return blkmd.CreateBlockVolume(&models.Volume{ Name: volume, Id: uint64(id), Type: VolumeType, MaxBytes: size, }) }