// Return a pointer to netprofile from collection
507242
func FindNetprofile(key string) *Netprofile {
	collections.netprofileMutex.Lock()
	defer collections.netprofileMutex.Unlock()

	obj := collections.netprofiles[key]
	if obj == nil {
		return nil
	}

	return obj
}
970598
func (n *NetworkServerAPI) DeleteRoutingProfile(ctx context.Context, req *ns.DeleteRoutingProfileRequest) (*empty.Empty, error) {
	var rpID uuid.UUID
	copy(rpID[:], req.Id)

	if err := storage.DeleteRoutingProfile(storage.DB(), rpID); err != nil {
		return nil, errToRPCError(err)
	}

	return &empty.Empty{}, nil
}
1166174
func (rp RawProfile) TCPoolProfile() (TCPoolProfile, error) {
	var result TCPoolProfile
	c := rp.Context()
	if c != TCPoolSchema {
		return result, fmt.Errorf("incorrect JSON-LD @context for TCPoolProfile %s", c)
	}
	err := decodeProfile(rp, &result)
	return result, err
}
172382
func (ac *APIController) NetprofileDelete(netProfile *contivModel.Netprofile) error {
	log.Infof("Deleting Netprofile:%s", netProfile.ProfileName)

	// Find Tenant
	tenant := contivModel.FindTenant(netProfile.TenantName)
	if tenant == nil {
		return core.Errorf("Tenant %s not found", netProfile.TenantName)
	}
	// Check if any endpoint group is using the network policy
	if len(netProfile.LinkSets.EndpointGroups) != 0 {
		return core.Errorf("NetProfile is being used")
	}

	modeldb.RemoveLinkSet(&tenant.LinkSets.NetProfiles, netProfile)
	return nil
}
117098
func (c *ConsulAlertClient) GetProfileInfo(node, serviceID, checkID, status string) ProfileInfo {
	log.Println("Getting profile for node: ", node, " service: ", serviceID, " check: ", checkID)

	var profile string

	profile = c.getProfileForService(serviceID)
	if profile == "" {
		profile = c.getProfileForCheck(checkID)
	}
	if profile == "" {
		profile = c.getProfileForNode(node)
	}
	if profile == "" {
		profile = c.getProfileForStatus(status)
	}
	if profile == "" {
		profile = "default"
	}

	var checkProfile ProfileInfo
	key := fmt.Sprintf("consul-alerts/config/notif-profiles/%s", profile)
	log.Println("profile key: ", key)
	kvPair, _, _ := c.api.KV().Get(key, nil)
	if kvPair == nil {
		log.Println("profile key not found.")
		return checkProfile
	}

	if err := json.Unmarshal(kvPair.Value, &checkProfile); err != nil {
		log.Error("Profile unmarshalling error: ", err.Error())
	} else {
		log.Println("Interval: ", checkProfile.Interval, " List: ", checkProfile.NotifList)
	}

	return checkProfile
}
715209
func httpCreateNetprofile(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	log.Debugf("Received httpGetNetprofile: %+v", vars)

	var obj Netprofile
	key := vars["key"]

	// Get object from the request
	err := json.NewDecoder(r.Body).Decode(&obj)
	if err != nil {
		log.Errorf("Error decoding netprofile create request. Err %v", err)
		return nil, err
	}

	// set the key
	obj.Key = key

	// Create the object
	err = CreateNetprofile(&obj)
	if err != nil {
		log.Errorf("CreateNetprofile error for: %+v. Err: %v", obj, err)
		return nil, err
	}

	// Return the obj
	return obj, nil
}
139035
func (ac *APIController) NetprofileUpdate(profile, params *contivModel.Netprofile) error {
	log.Infof("Received NetprofileUpdate: %+v, params: %+v", profile, params)

	if params.Burst > 0 && params.Burst < 2 {
		return core.Errorf("Invalid Burst size. burst size must be > 1500 bytes")
	}
	profile.Bandwidth = params.Bandwidth
	profile.DSCP = params.DSCP
	profile.Burst = params.Burst

	for key := range profile.LinkSets.EndpointGroups {
		// Find the corresponding epg
		epg := contivModel.FindEndpointGroup(key)
		if epg == nil {
			return core.Errorf("EndpointGroups not found")
		}

		err := master.UpdateEndpointGroup(params.Bandwidth, epg.GroupName, epg.TenantName, params.DSCP, params.Burst)
		if err != nil {
			log.Errorf("Error updating the EndpointGroups: %s. Err: %v", epg.GroupName, err)
		}
	}
	return nil
}
912347
func (h *HandlerT) CpuProfile(file string, nsec uint) error {
	if err := h.StartCPUProfile(file); err != nil {
		return err
	}
	time.Sleep(time.Duration(nsec) * time.Second)
	h.StopCPUProfile()
	return nil
}
737177
func (api *Client) GetUserProfile(userID string, includeLabels bool) (*UserProfile, error) {
	return api.GetUserProfileContext(context.Background(), userID, includeLabels)
}
154650
func httpDeleteNetprofile(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	log.Debugf("Received httpDeleteNetprofile: %+v", vars)

	key := vars["key"]

	// Delete the object
	err := DeleteNetprofile(key)
	if err != nil {
		log.Errorf("DeleteNetprofile error for: %s. Err: %v", key, err)
		return nil, err
	}

	// Return the obj
	return key, nil
}
528610
func (r Layout_Profile_Containers) GetLayoutProfile() (resp datatypes.Layout_Profile, err error) {
	err = r.Session.DoRequest("SoftLayer_Layout_Profile_Containers", "getLayoutProfile", nil, &r.Options, &resp)
	return
}
159078
func (_m *DBClient) GetDeviceProfileByName(n string) (models.DeviceProfile, error) {
	ret := _m.Called(n)

	var r0 models.DeviceProfile
	if rf, ok := ret.Get(0).(func(string) models.DeviceProfile); ok {
		r0 = rf(n)
	} else {
		r0 = ret.Get(0).(models.DeviceProfile)
	}

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

	return r0, r1
}
295725
func (st *State) GetContainerProfileInfo(containerTag names.MachineTag) ([]*LXDProfileResult, error) {
	var result params.ContainerProfileResults
	args := params.Entities{
		Entities: []params.Entity{{Tag: containerTag.String()}},
	}
	if err := st.facade.FacadeCall("GetContainerProfileInfo", args, &result); err != nil {
		return nil, err
	}
	if len(result.Results) != 1 {
		return nil, errors.Errorf("expected 1 result, got %d", len(result.Results))
	}
	if err := result.Results[0].Error; err != nil {
		return nil, err
	}
	profiles := result.Results[0].LXDProfiles
	var res []*LXDProfileResult
	for _, p := range profiles {
		if p == nil {
			continue
		}
		res = append(res, &LXDProfileResult{
			Config:      p.Profile.Config,
			Description: p.Profile.Description,
			Devices:     p.Profile.Devices,
			Name:        p.Name,
		})
	}
	return res, nil
}
474534
func (o *OverlayManagementProfile) OverlayManagementSubnetProfiles(info *bambou.FetchingInfo) (OverlayManagementSubnetProfilesList, *bambou.Error) {

	var list OverlayManagementSubnetProfilesList
	err := bambou.CurrentSession().FetchChildren(o, OverlayManagementSubnetProfileIdentity, &list, info)
	return list, err
}
384280
func CreateNetprofile(obj *Netprofile) error {
	// Validate parameters
	err := ValidateNetprofile(obj)
	if err != nil {
		log.Errorf("ValidateNetprofile retruned error for: %+v. Err: %v", obj, err)
		return err
	}

	// Check if we handle this object
	if objCallbackHandler.NetprofileCb == nil {
		log.Errorf("No callback registered for netprofile object")
		return errors.New("Invalid object type")
	}

	saveObj := obj

	collections.netprofileMutex.Lock()
	key := collections.netprofiles[obj.Key]
	collections.netprofileMutex.Unlock()

	// Check if object already exists
	if key != nil {
		// Perform Update callback
		err = objCallbackHandler.NetprofileCb.NetprofileUpdate(collections.netprofiles[obj.Key], obj)
		if err != nil {
			log.Errorf("NetprofileUpdate retruned error for: %+v. Err: %v", obj, err)
			return err
		}

		// save the original object after update
		collections.netprofileMutex.Lock()
		saveObj = collections.netprofiles[obj.Key]
		collections.netprofileMutex.Unlock()
	} else {
		// save it in cache
		collections.netprofileMutex.Lock()
		collections.netprofiles[obj.Key] = obj
		collections.netprofileMutex.Unlock()

		// Perform Create callback
		err = objCallbackHandler.NetprofileCb.NetprofileCreate(obj)
		if err != nil {
			log.Errorf("NetprofileCreate retruned error for: %+v. Err: %v", obj, err)
			collections.netprofileMutex.Lock()
			delete(collections.netprofiles, obj.Key)
			collections.netprofileMutex.Unlock()
			return err
		}
	}

	// Write it to modeldb
	collections.netprofileMutex.Lock()
	err = saveObj.Write()
	collections.netprofileMutex.Unlock()
	if err != nil {
		log.Errorf("Error saving netprofile %s to db. Err: %v", saveObj.Key, err)
		return err
	}

	return nil
}
1056443
func (_m *DBClient) GetDeviceProfilesByModel(m string) ([]models.DeviceProfile, error) {
	ret := _m.Called(m)

	var r0 []models.DeviceProfile
	if rf, ok := ret.Get(0).(func(string) []models.DeviceProfile); ok {
		r0 = rf(m)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]models.DeviceProfile)
		}
	}

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

	return r0, r1
}
820701
func (o *Enterprise) CreateNetconfProfile(child *NetconfProfile) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}