// RemoveResourcePool removes a resource pool
499158
func (f *Facade) RemoveResourcePool(ctx datastore.Context, id string) error {
	alog := f.auditLogger.
		Message(ctx, "Removing Resource Pool").
		Action(audit.Remove).ID(id).Type(pool.GetType())

	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.RemoveResourcePool"))
	glog.V(2).Infof("Facade.RemoveResourcePool: %s", id)
	if err := f.DFSLock(ctx).LockWithTimeout("remove resource pool", userLockTimeout); err != nil {
		glog.Warningf("Cannot remove resource pool: %s", err)
		return alog.Error(err)
	}
	defer f.DFSLock(ctx).Unlock()

	// CC-2024: do not delete the default resource pool
	if id == "default" {
		glog.Errorf("Cannot delete default resource pool")
		return alog.Error(ErrDefaultPool)
	}

	if hosts, err := f.FindHostsInPool(ctx, id); err != nil {
		return alog.Error(fmt.Errorf("could not verify hosts in pool %s: %s", id, err))
	} else if count := len(hosts); count > 0 {
		return alog.Error(fmt.Errorf("cannot delete pool %s: found %d hosts", id, count))
	}

	if svcs, err := f.GetServicesByPool(ctx, id); err != nil {
		return alog.Error(fmt.Errorf("could not verify services in pool %s: %s", id, err))
	} else if count := len(svcs); count > 0 {
		return alog.Error(fmt.Errorf("cannot delete pool %s: found %d services", id, count))
	}

	if err := f.delete(ctx, f.poolStore, pool.Key(id), beforePoolDelete, afterPoolDelete); err != nil {
		return alog.Error(err)
	}

	f.poolCache.SetDirty()

	return alog.Error(f.zzk.RemoveResourcePool(id))
}
754203
func (s *LoadBalancerService) RemoveFromLoadBalancerRule(p *RemoveFromLoadBalancerRuleParams) (*RemoveFromLoadBalancerRuleResponse, error) {
	resp, err := s.cs.newRequest("removeFromLoadBalancerRule", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r RemoveFromLoadBalancerRuleResponse
	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
}
140283
func (c *Client) RemoveFromLoadBalancerRule(p *RemoveFromLoadBalancerRuleParameter) (*Result, error) {
	obj, err := c.Request("removeFromLoadBalancerRule", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Result), err
}
1159032
func (r User_Permission_Group) RemoveBulkResourceObjects(resourceObjects []datatypes.Entity, resourceTypeKeyName *string) (resp bool, err error) {
	params := []interface{}{
		resourceObjects,
		resourceTypeKeyName,
	}
	err = r.Session.DoRequest("SoftLayer_User_Permission_Group", "removeBulkResourceObjects", params, &r.Options, &resp)
	return
}
30173
func (pdev podDevices) removeContainerAllocatedResources(podUID, contName string, allocatedResources map[string]sets.String) {
	containers, exists := pdev[podUID]
	if !exists {
		return
	}
	resources, exists := containers[contName]
	if !exists {
		return
	}
	for resource, devices := range resources {
		allocatedResources[resource] = allocatedResources[resource].Difference(devices.deviceIds)
	}
}
1337498
func (gce *Cloud) DeleteTargetPool(name string, hc *compute.HttpHealthCheck) error {
	region, err := GetGCERegion(gce.localZone)
	if err != nil {
		return err
	}
	return gce.deleteTargetPool(name, region, hc)
}
579141
func (_m *ClientInterface) GetResourcePool(poolID string) (*pool.ResourcePool, error) {
	ret := _m.Called(poolID)

	var r0 *pool.ResourcePool
	if rf, ok := ret.Get(0).(func(string) *pool.ResourcePool); ok {
		r0 = rf(poolID)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*pool.ResourcePool)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(poolID)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
111892
func (c *Client) RemovePool(pname string) error {
	if c.BestAPIVersion() < 5 {
		return errors.New("removing storage pools is not supported by this version of Juju")
	}
	var results params.ErrorResults
	args := params.StoragePoolDeleteArgs{
		Pools: []params.StoragePoolDeleteArg{{
			Name: pname,
		}},
	}
	if err := c.facade.FacadeCall("RemovePool", args, &results); err != nil {
		return errors.Trace(err)
	}
	return results.OneError()
}
983431
func (p ResourcePersistence) NewRemoveUnitResourcesOps(unitID string) ([]txn.Op, error) {
	docs, err := p.unitResources(unitID)
	if err != nil {
		return nil, errors.Trace(err)
	}

	ops := newRemoveResourcesOps(docs)
	// We do not remove the resource from the blob store here. That is
	// an application-level matter.
	return ops, nil
}
57544
func (rp *ResourcePool) Close() {
	if rp.idleTimer != nil {
		rp.idleTimer.Stop()
	}
	_ = rp.SetCapacity(0)
}
263106
func (c *aliCloudImplementation) RemoveTags(resourceId string, resourceType string, tags map[string]string) error {
	if len(tags) == 0 {
		return nil
	}
	if resourceId == "" {
		return errors.New("resourceId not provided to RemoveTags")
	}
	if resourceType == "" {
		return errors.New("resourceType not provided to RemoveTags")
	}

	request := &ecs.RemoveTagsArgs{
		ResourceId:   resourceId,
		ResourceType: ecs.TagResourceType(resourceType), //image, instance, snapshot or disk
		RegionId:     common.Region(c.Region()),
		Tag:          tags,
	}
	err := c.EcsClient().RemoveTags(request)
	if err != nil {
		return fmt.Errorf("error removing tags on %v: %v", resourceId, err)
	}

	return nil
}
830154
func (env *azureEnviron) Destroy(ctx context.ProviderCallContext) error {
	logger.Debugf("destroying model %q", env.envName)
	logger.Debugf("- deleting resource group %q", env.resourceGroup)
	sdkCtx := stdcontext.Background()
	if err := env.deleteResourceGroup(ctx, sdkCtx, env.resourceGroup); err != nil {
		return errors.Trace(err)
	}
	// Resource groups are self-contained and fully encompass
	// all environ resources. Once you delete the group, there
	// is nothing else to do.
	return nil
}
1265252
func (f *Facade) UpdateResourcePool(ctx datastore.Context, entity *pool.ResourcePool) error {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.UpdateResourcePool"))
	alog := f.auditLogger.Message(ctx, "Updating Resource Pool").
		Action(audit.Update).Entity(entity)
	if err := f.DFSLock(ctx).LockWithTimeout("update resource pool", userLockTimeout); err != nil {
		glog.Warningf("Cannot update resource pool: %s", err)
		return alog.Error(err)
	}
	defer f.DFSLock(ctx).Unlock()

	return alog.Error(f.updateResourcePool(ctx, entity))
}
1031083
func (p ResourcePersistence) RemovePendingAppResources(applicationID string, pendingIDs map[string]string) error {
	buildTxn := func(int) ([]txn.Op, error) {
		return p.NewRemovePendingAppResourcesOps(applicationID, pendingIDs)
	}
	return errors.Trace(p.base.Run(buildTxn))
}
1010823
func (g *Generator) RemoveLinuxResourcesDevice(allow bool, devType string, major, minor *int64, access string) {
	if g.Config == nil || g.Config.Linux == nil || g.Config.Linux.Resources == nil {
		return
	}
	for i, device := range g.Config.Linux.Resources.Devices {
		if device.Allow == allow &&
			(devType == device.Type || (devType != "" && device.Type != "" && devType == device.Type)) &&
			(access == device.Access || (access != "" && device.Access != "" && access == device.Access)) &&
			(major == device.Major || (major != nil && device.Major != nil && *major == *device.Major)) &&
			(minor == device.Minor || (minor != nil && device.Minor != nil && *minor == *device.Minor)) {

			g.Config.Linux.Resources.Devices = append(g.Config.Linux.Resources.Devices[:i], g.Config.Linux.Resources.Devices[i+1:]...)
			return
		}
	}
	return
}
1001667
func UpdateResourcePool(conn client.Connection, p pool.ResourcePool) error {
	pth := path.Join("/pools", p.ID)

	logger := plog.WithFields(log.Fields{
		"poolid": p.ID,
		"zkpath": pth,
	})

	// create the resource pool if it doesn't exist
	if err := conn.Create(pth, &PoolNode{ResourcePool: &p}); err == client.ErrNodeExists {

		// the node exists, so get it and update it
		node := &PoolNode{ResourcePool: &pool.ResourcePool{}}
		if err := conn.Get(pth, node); err != nil && err != client.ErrEmptyNode {

			logger.WithError(err).Debug("Could not get resource pool entry from zookeeper")
			return err
		}

		node.ResourcePool = &p
		if err := conn.Set(pth, node); err != nil {

			logger.WithError(err).Debug("Could not update resource pool entry in zookeeper")
			return err
		}

		logger.Debug("Updated entry for resource pool in zookeeper")
		return nil
	} else if err != nil {

		logger.WithError(err).Debug("Could not create resource pool entry in zookeeper")
		return err
	}

	logger.Debug("Created entry for resource pool in zookeeper")
	return nil
}
14466
func (ds *dockerService) RemoveContainer(_ context.Context, r *runtimeapi.RemoveContainerRequest) (*runtimeapi.RemoveContainerResponse, error) {
	ds.performPlatformSpecificContainerForContainer(r.ContainerId)

	// Ideally, log lifecycle should be independent of container lifecycle.
	// However, docker will remove container log after container is removed,
	// we can't prevent that now, so we also clean up the symlink here.
	err := ds.removeContainerLogSymlink(r.ContainerId)
	if err != nil {
		return nil, err
	}
	err = ds.client.RemoveContainer(r.ContainerId, dockertypes.ContainerRemoveOptions{RemoveVolumes: true, Force: true})
	if err != nil {
		return nil, fmt.Errorf("failed to remove container %q: %v", r.ContainerId, err)
	}
	return &runtimeapi.RemoveContainerResponse{}, nil
}