// Destroy deletes the VM on Azure.
511160
func (vm *VM) Destroy() error {
	// Set up the authorizer
	tok, err := getServicePrincipalToken(&vm.Creds, azure.PublicCloud.ResourceManagerEndpoint)
	if err != nil {
		return err
	}
	authorizer := autorest.NewBearerAuthorizer(tok)

	// Delete the VM
	virtualMachinesClient := compute.NewVirtualMachinesClient(vm.Creds.SubscriptionID)
	virtualMachinesClient.Authorizer = authorizer

	_, errc := virtualMachinesClient.Delete(vm.ResourceGroup, vm.Name, nil)
	if err := <-errc; err != nil {
		return err
	}

	// Make sure VM is deleted
	deleted := false
	for i := 0; i < actionTimeout; i++ {
		_, err := vm.GetState()
		if err != nil {
			if strings.Contains(err.Error(), `Code="ResourceNotFound"`) ||
				strings.Contains(err.Error(), `Code="NotFound"`) {
				deleted = true
				break
			}
			return err
		}

		time.Sleep(1 * time.Second)
	}

	if !deleted {
		return ErrActionTimeout
	}

	var errors []error
	// Delete the files of this VM
	err = vm.deleteVMFiles(authorizer)
	if err != nil {
		errors = append(errors, err)
	}

	// Delete the network interface of this VM
	err = vm.deleteNic(authorizer)
	if err != nil {
		errors = append(errors, err)
	} else {
		// Delete the public IP of this VM
		err = vm.deletePublicIP(authorizer)
		if err != nil {
			errors = append(errors, err)
		}
	}

	// Delete the deployed arm template
	err = vm.deleteDeployment(authorizer)
	if err != nil {
		errors = append(errors, err)
	}

	// Return all the errors
	var returnedErr error
	if len(errors) > 0 {
		for i, err := range errors {
			if i == 0 {
				returnedErr = err
				continue
			}

			returnedErr = fmt.Errorf("%s, %s", returnedErr, err)
		}
	}

	return returnedErr
}
1177069
func (n *NodeDevice) Destroy() error {
	var err C.virError
	result := C.virNodeDeviceDestroyWrapper(n.ptr, &err)
	if result == -1 {
		return makeError(&err)
	}
	return nil
}
274580
func (dfs *DistributedFilesystem) Destroy(tenantID string) error {
	vol, err := dfs.disk.Get(tenantID)
	if err != nil {
		glog.Errorf("Error destroying DFS:  Could not get volume for tenant %s: %s", tenantID, err)
	} else {
		// Remove all the stuff we need a volume object for
		snapshots, err := vol.Snapshots()
		if err != nil {
			glog.Errorf("Could not get snapshots for tenant %s: %s", tenantID, err)
		} else {
			for _, snapshot := range snapshots {
				if err := dfs.Delete(snapshot); err != nil {
					glog.Errorf("Could not remove snapshot %s for tenant %s: %s", snapshot, tenantID, err)
				}
			}
		}

		if err := dfs.unexport(vol.Path()); err != nil {
			glog.Errorf("Could not unexport path %s: %s", vol.Path(), err)
		}
	}

	if err := dfs.deleteImages(tenantID, docker.Latest); err != nil {
		glog.Errorf("Could not delete images for tenant %s: %s", tenantID, err)
	}

	if err := dfs.disk.Remove(tenantID); err != nil {
		glog.Errorf("Could not remove application data for tenant %s: %s", tenantID, err)
		return err
	}

	return nil
}
507576
func (vrsConnection *VRSConnection) DestroyEntityByVMName(vm_name string) error {

	condition := []string{ovsdb.NuageVMTableColumnVMName, "==", vm_name}
	if err := vrsConnection.vmTable.DeleteRow(vrsConnection.ovsdbClient, condition); err != nil {
		return fmt.Errorf("Unable to delete the entity from VRS %v", err)
	}

	return nil
}
713572
func (checkpoint *Checkpoint) Destroy() {
	C.rocksdb_checkpoint_object_destroy(checkpoint.c)
	checkpoint.c = nil
}
586885
func (_class VLANClass) Destroy(sessionID SessionRef, self VLANRef) (_err error) {
	_method := "VLAN.destroy"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertVLANRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_, _err =  _class.client.APICall(_method, _sessionIDArg, _selfArg)
	return
}
1167581
func (n *NomadAgent) Destroy() error {
	if err := n.Stop(); err != nil {
		return err
	}
	return os.RemoveAll(n.DataDir)
}
341057
func (s *appsService) Destroy(ctx context.Context, db *gorm.DB, app *App) error {
	if err := appsDestroy(db, app); err != nil {
		return err
	}

	return s.Scheduler.Remove(ctx, app.ID)
}
225076
func (d *Domain) Destroy() error {
	var err C.virError
	result := C.virDomainDestroyWrapper(d.ptr, &err)
	if result == -1 {
		return makeError(&err)
	}
	return nil
}
217044
func (s *Secret) Destroy() {
	defer s.buffer.Destroy()
	s.guard.remove(s)
}
763700
func (s *Sessions) Destroy(w http.ResponseWriter, r *http.Request) {
	cookieValue := GetCookie(r, s.config.Cookie)
	s.destroy(cookieValue)
	RemoveCookie(w, r, s.config)
}
1266352
func (vpcApi *VpcApi) Destroy(id string) (bool, error) {
	_, err := vpcApi.entityService.Delete(id, []byte{}, map[string]string{})
	return err == nil, err
}
562509
func (e *Environ) Destroy(ctx envcontext.ProviderCallContext) error {
	return common.Destroy(e, ctx)
}
65843
func (opts *EnvOptions) Destroy() {
	C.rocksdb_envoptions_destroy(opts.c)
	opts.c = nil
}
1195401
func (m *Manager) Destroy(s *Session) error {
	return m.config.Store.Del(s.id, makeStoreOption(m, s))
}
712231
func (a *AzureBackend) Delete(ctx context.Context, key string) error {
	defer metrics.MeasureSince([]string{"azure", "delete"}, time.Now())

	blob := &storage.Blob{
		Container: a.container,
		Name:      key,
	}

	a.permitPool.Acquire()
	defer a.permitPool.Release()

	_, err := blob.DeleteIfExists(nil)
	return err
}
534742
func (_class NetworkSriovClass) Destroy(sessionID SessionRef, self NetworkSriovRef) (_err error) {
	_method := "network_sriov.destroy"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertNetworkSriovRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_, _err =  _class.client.APICall(_method, _sessionIDArg, _selfArg)
	return
}