func (d *Driver) Snapshot(volumeID string, readonly bool, locator *api.VolumeLocator) (string, error) { dryRun := false vols, err := d.DefaultEnumerator.Inspect([]string{volumeID}) if err != nil { return "", err } if len(vols) != 1 { return "", fmt.Errorf("Failed to inspect %v len %v", volumeID, len(vols)) } awsID := volumeID request := &ec2.CreateSnapshotInput{ VolumeId: &awsID, DryRun: &dryRun, } snap, err := d.ec2.CreateSnapshot(request) chaos.Now(koStrayCreate) vols[0].Id = *snap.SnapshotId vols[0].Source = &api.Source{Parent: volumeID} vols[0].Locator = locator vols[0].Ctime = prototime.Now() chaos.Now(koStrayCreate) err = d.CreateVol(vols[0]) if err != nil { return "", err } return vols[0].Id, nil }
func (d *Driver) Snapshot(volumeID api.VolumeID, readonly bool, locator api.VolumeLocator) (api.VolumeID, error) { dryRun := false vols, err := d.DefaultEnumerator.Inspect([]api.VolumeID{volumeID}) if err != nil { return api.BadVolumeID, err } if len(vols) != 1 { return api.BadVolumeID, fmt.Errorf("Failed to inspect %v len %v", volumeID, len(vols)) } awsID := string(volumeID) request := &ec2.CreateSnapshotInput{ VolumeID: &awsID, DryRun: &dryRun, } snap, err := d.ec2.CreateSnapshot(request) chaos.Now(koStrayCreate) vols[0].ID = api.VolumeID(*snap.SnapshotID) vols[0].Parent = volumeID vols[0].Locator = locator vols[0].Ctime = time.Now() chaos.Now(koStrayCreate) err = d.CreateVol(&vols[0]) if err != nil { return api.BadVolumeID, err } return vols[0].ID, nil }
// Snapshot create new subvolume from volume func (d *driver) Snapshot(volumeID api.VolumeID, readonly bool, locator api.VolumeLocator) (api.VolumeID, error) { vols, err := d.Inspect([]api.VolumeID{volumeID}) if err != nil { return api.BadVolumeID, err } if len(vols) != 1 { return api.BadVolumeID, fmt.Errorf("Failed to inspect %v len %v", volumeID, len(vols)) } snapID := uuid.New() vols[0].ID = api.VolumeID(snapID) vols[0].Parent = volumeID vols[0].Locator = locator vols[0].Ctime = time.Now() err = d.CreateVol(&vols[0]) if err != nil { return api.BadVolumeID, err } chaos.Now(koStrayCreate) err = d.btrfs.Create(snapID, string(volumeID)) if err != nil { return api.BadVolumeID, err } return vols[0].ID, nil }
// Delete subvolume func (d *driver) Delete(volumeID string) error { if err := d.DeleteVol(volumeID); err != nil { return err } chaos.Now(koStrayDelete) return d.btrfs.Remove(volumeID) }
// SnapDelete Delete subvolume func (d *driver) SnapDelete(snapID api.SnapID) error { err := d.DeleteSnap(snapID) chaos.Now(koStrayDelete) if err == nil { err = d.btrfs.Remove(string(snapID)) } return err }
// Delete subvolume func (d *btrfsDriver) Delete(volumeID api.VolumeID) error { err := d.DeleteVol(volumeID) chaos.Now(koStrayDelete) if err == nil { err = d.btrfs.Remove(string(volumeID)) } return err }
// Delete subvolume func (d *driver) Delete(volumeID api.VolumeID) error { err := d.DeleteVol(volumeID) if err != nil { log.Println(err) return err } chaos.Now(koStrayDelete) if err == nil { err = d.btrfs.Remove(string(volumeID)) } return err }
func (d *Driver) Snapshot(volumeID api.VolumeID, labels api.Labels) (api.SnapID, error) { dryRun := false awsID := string(volumeID) request := &ec2.CreateSnapshotInput{ VolumeID: &awsID, DryRun: &dryRun, } snap, err := d.ec2.CreateSnapshot(request) chaos.Now(koStrayCreate) volSnap := &api.VolumeSnap{ ID: api.SnapID(*snap.SnapshotID), VolumeID: volumeID, SnapLabels: labels, Ctime: time.Now(), } chaos.Now(koStrayCreate) err = d.CreateSnap(volSnap) if err != nil { return api.BadSnapID, err } return volSnap.ID, nil }
// Snapshot create new subvolume from volume func (d *driver) Snapshot(volumeID api.VolumeID, labels api.Labels) (api.SnapID, error) { snapID := uuid.New() snap := &api.VolumeSnap{ ID: api.SnapID(snapID), VolumeID: volumeID, SnapLabels: labels, Ctime: time.Now(), } err := d.CreateSnap(snap) if err != nil { return api.BadSnapID, err } chaos.Now(koStrayCreate) err = d.btrfs.Create(snapID, string(volumeID)) if err != nil { return api.BadSnapID, err } return snap.ID, nil }
// Snapshot create new subvolume from volume func (d *driver) Snapshot(volumeID string, readonly bool, locator *api.VolumeLocator) (string, error) { vols, err := d.Inspect([]string{volumeID}) if err != nil { return "", err } if len(vols) != 1 { return "", fmt.Errorf("Failed to inspect %v len %v", volumeID, len(vols)) } snapID := uuid.New() vols[0].Id = snapID vols[0].Source = &api.Source{Parent: volumeID} vols[0].Locator = locator vols[0].Ctime = prototime.Now() if err := d.CreateVol(vols[0]); err != nil { return "", err } chaos.Now(koStrayCreate) err = d.btrfs.Create(snapID, volumeID, "") if err != nil { return "", err } return vols[0].Id, nil }