// Deletes a vmsnapshot.
967126
func (s *SnapshotService) DeleteVMSnapshot(p *DeleteVMSnapshotParams) (*DeleteVMSnapshotResponse, error) {
	resp, err := s.cs.newRequest("deleteVMSnapshot", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r DeleteVMSnapshotResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
1345159
func (d *DeviceMapperDriver) cleanUpSnapshots() {
	snapshotsOnDisk, err := d.getSnapshotsOnDisk()
	if err != nil || snapshotsOnDisk == nil {
		return
	}

	glog.V(2).Infof("Snapshots on disk: %v", snapshotsOnDisk)

	snapshotsInMetadata, err := d.getSnapshotsFromMetadata()
	if err != nil || snapshotsInMetadata == nil {
		return
	}

	glog.V(2).Infof("Snapshots in metadata: %v", snapshotsInMetadata)

	for _, snapshotOnDisk := range snapshotsOnDisk {
		if _, ok := snapshotsInMetadata[snapshotOnDisk]; !ok {
			glog.V(2).Infof("Removing Snapshot: %v", snapshotOnDisk)
			os.RemoveAll(filepath.Join(d.MetadataDir(), snapshotOnDisk))
		} else {
			// Remove the snapshot on disk since it was found in the metadata map.  This
			// will leave the snapshotsInMetadata map with only snapshots that are in metadata but
			// not on disk, so they should all be removed from the metadata.
			delete(snapshotsInMetadata, snapshotOnDisk)
		}
	}

	for snapshotInMetadata, volumeName := range snapshotsInMetadata {
		glog.V(2).Infof("Removing Snapshot from metadata: %v", snapshotInMetadata)
		v, err := d.getVolume(volumeName, false)
		if err != nil {
			continue
		}

		v.Lock()
		defer v.Unlock()

		deviceHash, err := v.Metadata.LookupSnapshotDevice(snapshotInMetadata)
		if err != nil {
			glog.Errorf("Error removing snapshot: %v", err)
			continue
		}

		// Remove the snapshot info from the volume metadata
		if err := v.Metadata.RemoveSnapshot(snapshotInMetadata); err != nil {
			glog.Errorf("Error removing snapshot: %v", err)
			continue
		}

		glog.V(2).Infof("Deactivating snapshot device %s", deviceHash)
		v.driver.DeviceSet.Lock()
		err = v.driver.DeactivateDevice(deviceHash)
		v.driver.DeviceSet.Unlock()
		if err != nil {
			glog.Errorf("Error deactivating device (%s): %s", deviceHash, err)
			continue
		}
		if err := v.driver.deleteDevice(deviceHash, false); err != nil {
			glog.Errorf("Error removing snapshot: %v", err)
			continue
		}
	}
}
834766
func (c *BlobDiskController) deleteVhdBlob(accountName, accountKey, blobName string) error {
	client, err := azstorage.NewBasicClientOnSovereignCloud(accountName, accountKey, c.common.cloud.Environment)
	if err != nil {
		return err
	}
	blobSvc := client.GetBlobService()

	container := blobSvc.GetContainerReference(vhdContainerName)
	blob := container.GetBlobReference(blobName)
	return blob.Delete(nil)
}
40000
func (sp *SignedSnapshot) DeleteMeta(role RoleName) {
	if _, ok := sp.Signed.Meta[role.String()]; ok {
		delete(sp.Signed.Meta, role.String())
		sp.Dirty = true
	}
}
557354
func (v *DeviceMapperVolume) RemoveSnapshot(label string) error {
	glog.V(2).Infof("RemoveSnapshot() (%s) START", v.name)
	defer glog.V(2).Infof("RemoveSnapshot() (%s) END", v.name)
	if !v.snapshotExists(label) {
		return volume.ErrSnapshotDoesNotExist
	}
	rawLabel := v.rawSnapshotLabel(label)
	v.Lock()
	defer v.Unlock()
	deviceHash, err := v.Metadata.LookupSnapshotDevice(rawLabel)
	if err != nil {
		glog.Errorf("Error removing snapshot: %v", err)
		return volume.ErrRemovingSnapshot
	}

	// Delete the device itself first, so we retain our internal snapshot entry
	// (metadata.json) in the event of a failure on this step
	glog.V(2).Infof("Deactivating snapshot device %s", deviceHash)
	v.driver.DeviceSet.Lock()
	if err := v.driver.DeactivateDevice(deviceHash); err != nil {
		glog.V(2).Infof("Error deactivating device (%s): %s", deviceHash, err)
	}
	v.driver.DeviceSet.Unlock()
	if err := v.driver.deleteDevice(deviceHash, false); err != nil {
		glog.Errorf("Error removing snapshot: %v", err)
		return volume.ErrRemovingSnapshot
	}

	// Remove the snapshot info from the volume metadata
	if err := v.Metadata.RemoveSnapshot(rawLabel); err != nil {
		glog.Errorf("Error removing snapshot: %v", err)
		return volume.ErrRemovingSnapshot
	}
	// Remove the snapshot-specific metadata directory
	if err := os.RemoveAll(filepath.Join(v.driver.MetadataDir(), rawLabel)); err != nil {
		return err
	}
	return nil
}
1308541
func (s *VPCService) DeleteVPC(p *DeleteVPCParams) (*DeleteVPCResponse, error) {
	resp, err := s.cs.newRequest("deleteVPC", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r DeleteVPCResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
1370863
func (v *BtrfsVolume) RemoveSnapshot(label string) error {
	if exists, err := v.snapshotExists(label); err != nil || !exists {
		if err != nil {
			return err
		} else {
			return volume.ErrSnapshotDoesNotExist
		}
	}

	v.Lock()
	defer v.Unlock()
	_, err := volume.RunBtrFSCmd(v.sudoer, "subvolume", "delete", v.snapshotPath(label))
	if err != nil {
		glog.Errorf("could not remove snapshot: %s", err)
		return volume.ErrRemovingSnapshot
	}
	return nil
}
747412
func (u *FakeAPIUtil) DeletePV(pvName string) error {
	if u.shouldFail {
		return fmt.Errorf("API failed")
	}

	pv, exists := u.cache.GetPV(pvName)
	if exists {
		u.deletedPVs[pvName] = pv
		delete(u.createdPVs, pvName)
		u.cache.DeletePV(pvName)
		return nil
	}
	return errors.NewNotFound(v1.Resource("persistentvolumes"), pvName)
}
687785
func (util *GCEDiskUtil) DeleteVolume(d *gcePersistentDiskDeleter) error {
	cloud, err := getCloudProvider(d.gcePersistentDisk.plugin.host.GetCloudProvider())
	if err != nil {
		return err
	}

	if err = cloud.DeleteDisk(d.pdName); err != nil {
		klog.V(2).Infof("Error deleting GCE PD volume %s: %v", d.pdName, err)
		// GCE cloud provider returns volume.deletedVolumeInUseError when
		// necessary, no handling needed here.
		return err
	}
	klog.V(2).Infof("Successfully deleted GCE PD volume %s", d.pdName)
	return nil
}
379535
func (cache *VolumeCache) DeletePV(pvName string) {
	cache.mutex.Lock()
	defer cache.mutex.Unlock()

	delete(cache.pvs, pvName)
	glog.Infof("Deleted pv %q from cache", pvName)
}
1237245
func (client *Client) DeleteSnapshot(snapshotId string) error {
	args := DeleteSnapshotArgs{SnapshotId: snapshotId}
	response := DeleteSnapshotResponse{}

	return client.Invoke("DeleteSnapshot", &args, &response)
}
1016814
func (c *cinderPlugin) SnapshotDelete(src *crdv1.VolumeSnapshotDataSource, _ *v1.PersistentVolume) error {
	if src == nil || src.CinderSnapshot == nil {
		return fmt.Errorf("invalid VolumeSnapshotDataSource: %v", src)
	}
	snapshotID := src.CinderSnapshot.SnapshotID
	err := c.cloud.DeleteSnapshot(snapshotID)
	if err != nil {
		return err
	}
	return nil
}
404744
func (v VirtualMachine) RemoveSnapshot(ctx context.Context, name string, removeChildren bool, consolidate *bool) (*Task, error) {
	snapshot, err := v.FindSnapshot(ctx, name)
	if err != nil {
		return nil, err
	}

	req := types.RemoveSnapshot_Task{
		This:           snapshot.Reference(),
		RemoveChildren: removeChildren,
		Consolidate:    consolidate,
	}

	res, err := methods.RemoveSnapshot_Task(ctx, v.c, &req)
	if err != nil {
		return nil, err
	}

	return NewTask(v.c, res.Returnval), nil
}
503882
func (s *SnapshotService) GetVMSnapshotID(name string, opts ...OptionFunc) (string, int, error) {
	p := &ListVMSnapshotParams{}
	p.p = make(map[string]interface{})

	p.p["name"] = name

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return "", -1, err
		}
	}

	l, err := s.ListVMSnapshot(p)
	if err != nil {
		return "", -1, err
	}

	if l.Count == 0 {
		return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
	}

	if l.Count == 1 {
		return l.VMSnapshot[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.VMSnapshot {
			if v.Name == name {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
}
419821
func deleteSnapshotInfo(c context.Context) error {
	c = ds.WithoutTransaction(c)
	return ds.Delete(c, ds.KeyForObj(c, &SnapshotInfo{}))
}
364805
func (util *VsphereDiskUtil) DeleteVolume(vd *vsphereVolumeDeleter) error {
	cloud, err := getCloudProvider(vd.plugin.host.GetCloudProvider())
	if err != nil {
		return err
	}

	if err = cloud.DeleteVolume(vd.volPath); err != nil {
		klog.V(2).Infof("Error deleting vsphere volume %s: %v", vd.volPath, err)
		return err
	}
	klog.V(2).Infof("Successfully deleted vsphere volume %s", vd.volPath)
	return nil
}
132339
func (s *UsersService) DeletePhoto() *UsersDeletePhotoCall {
	var call UsersDeletePhotoCall
	call.service = s
	return &call
}