// IPVSUpdateService updates the specified service in the IPVS table.
330133
func (ncc *SeesawNCC) IPVSUpdateService(svc *ipvs.Service, out *int) error {
	ipvsMutex.Lock()
	defer ipvsMutex.Unlock()
	return ipvs.UpdateService(*svc)
}
1346514
func (a *api) UpdateService(reader io.Reader) (*service.ServiceDetails, error) {
	// Unmarshal JSON from the reader
	var s service.Service
	if err := json.NewDecoder(reader).Decode(&s); err != nil {
		return nil, fmt.Errorf("could not unmarshal json: %s", err)
	}

	return a.UpdateServiceObj(s)
}
947921
func (ncc *SeesawNCC) IPVSAddService(svc *ipvs.Service, out *int) error {
	ipvsMutex.Lock()
	defer ipvsMutex.Unlock()
	return ipvs.AddService(*svc)
}
508896
func (p *NetPlugin) SvcProviderUpdate(servicename string, providers []string) {
	p.Lock()
	defer p.Unlock()
	p.NetworkDriver.SvcProviderUpdate(servicename, providers)
}
212163
func (s *Service) UpdateService(w http.ResponseWriter, r *http.Request) {
	id, err := paramID("kid", r)
	if err != nil {
		Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
		return
	}

	srcID, err := paramID("id", r)
	if err != nil {
		Error(w, http.StatusUnprocessableEntity, err.Error(), s.Logger)
		return
	}

	ctx := r.Context()
	srv, err := s.Store.Servers(ctx).Get(ctx, id)
	if err != nil || srv.SrcID != srcID || srv.Type == "" {
		notFound(w, id, s.Logger)
		return
	}

	var req patchServiceRequest
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		invalidJSON(w, s.Logger)
		return
	}

	if err := req.Valid(); err != nil {
		invalidData(w, err, s.Logger)
		return
	}

	if req.Name != nil {
		srv.Name = *req.Name
	}
	if req.Type != nil {
		srv.Type = *req.Type
	}
	if req.URL != nil {
		srv.URL = *req.URL
	}
	if req.Password != nil {
		srv.Password = *req.Password
	}
	if req.Username != nil {
		srv.Username = *req.Username
	}
	if req.InsecureSkipVerify != nil {
		srv.InsecureSkipVerify = *req.InsecureSkipVerify
	}
	if req.Metadata != nil {
		srv.Metadata = *req.Metadata
	}

	if srv.Type == "flux" {
		err := pingFlux(ctx, srv.URL, srv.InsecureSkipVerify)
		if err != nil {
			msg := fmt.Sprintf("Unable to reach flux %s: %v", srv.URL, err)
			Error(w, http.StatusGatewayTimeout, msg, s.Logger)
			return
		}
	}

	if err := s.Store.Servers(ctx).Update(ctx, srv); err != nil {
		msg := fmt.Sprintf("Error updating service ID %d", id)
		Error(w, http.StatusInternalServerError, msg, s.Logger)
		return
	}

	res := newService(srv)
	encodeJSON(w, http.StatusOK, res, s.Logger)
}
525949
func (*IPsTable) needsUpdate(row, cfg *IP) bool {
	return row.VLANId != cfg.VLANId
}
1244794
func (c *Client) UpdateIpAddress(p *UpdateIpAddressParameter) (*PublicIpAddress, error) {
	obj, err := c.Request("updateIpAddress", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*PublicIpAddress), err
}
1111521
func AddService(svc Service) error {
	ic := &ipvsCommand{Service: newIPVSService(&svc)}
	if err := netlink.SendMessageMarshalled(C.IPVS_CMD_NEW_SERVICE, family, 0, ic); err != nil {
		return err
	}
	for _, dst := range svc.Destinations {
		if err := AddDestination(svc, *dst); err != nil {
			return err
		}
	}
	return nil
}
1178688
func updateServiceLastReported(ds models.DeviceService, lr int64, w http.ResponseWriter) error {
	ds.LastReported = lr
	if err := dbClient.UpdateDeviceService(ds); err != nil {
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return err
	}

	return nil
}
847877
func (a *Application) UpdateCloudService(providerId string, addresses []network.Address) error {
	_, err := a.st.SaveCloudService(SaveCloudServiceArgs{
		Id:         a.Name(),
		ProviderId: providerId,
		Addresses:  addresses,
	})
	return errors.Trace(err)
}
212026
func (c *Client) UpdateApplicationService(arg params.UpdateApplicationServiceArg) error {
	var result params.ErrorResults
	args := params.UpdateApplicationServiceArgs{Args: []params.UpdateApplicationServiceArg{arg}}
	if err := c.facade.FacadeCall("UpdateApplicationsService", args, &result); err != nil {
		return errors.Trace(err)
	}
	if len(result.Results) != len(args.Args) {
		return errors.Errorf("expected %d result(s), got %d", len(args.Args), len(result.Results))
	}
	if result.Results[0].Error == nil {
		return nil
	}
	return maybeNotFound(result.Results[0].Error)
}
1223344
func (s *FusisStore) AddService(svc *types.Service) error {
	svcKey := s.key("services", svc.GetId())
	ipvsKey := s.key("ipvs-ids", "services", svc.IpvsId())
	// Validating service
	if err := s.validateService(svc); err != nil {
		return err
	}

	value, err := json.Marshal(svc)
	if err != nil {
		return errors.Wrapf(err, "[store] Error marshaling service: %v", svc)
	}

	svcCmp := notFound(svcKey)
	ipvsCmp := notFound(ipvsKey)

	svcPut := clientv3.OpPut(svcKey, string(value))
	ipvsPut := clientv3.OpPut(ipvsKey, "true")

	resp, err := s.kv.Txn(context.TODO()).
		If(svcCmp, ipvsCmp).
		Then(svcPut, ipvsPut).
		Commit()
	if err != nil {
		return errors.Wrapf(err, "[store] Error sending service to Etcd: %v", svc)
	}

	// resp.Succeeded means the compare clause was true
	if resp.Succeeded == false {
		return types.ErrValidation{Type: "service", Errors: map[string]string{"ipvs": "service must be unique"}}
	}

	return nil
}
670806
func UpdateServiceMap(serviceMap ServiceMap, changes *ServiceChangeTracker) (result UpdateServiceMapResult) {
	result.UDPStaleClusterIP = sets.NewString()
	serviceMap.apply(changes, result.UDPStaleClusterIP)

	// TODO: If this will appear to be computationally expensive, consider
	// computing this incrementally similarly to serviceMap.
	result.HCServiceNodePorts = make(map[types.NamespacedName]uint16)
	for svcPortName, info := range serviceMap {
		if info.GetHealthCheckNodePort() != 0 {
			result.HCServiceNodePorts[svcPortName.NamespacedName] = uint16(info.GetHealthCheckNodePort())
		}
	}

	return result
}
309471
func UpdateIP(conn client.Connection, req IPRequest, mutate func(*IP) bool) error {
	logger := plog.WithFields(log.Fields{
		"hostid":    req.HostID,
		"ipaddress": req.IPAddress,
	})

	basepth := "/"
	if req.PoolID != "" {
		basepth = path.Join("/pools", req.PoolID)
	}

	// Get the current pool ip
	ppth := path.Join(basepth, "/ips", req.IPID())
	pdat := &PoolIP{}
	if err := conn.Get(ppth, pdat); err != nil {
		logger.WithError(err).Debug("Could not look up virtual ip on resource pool")
		// TODO: error
		return err
	}

	// Get the current host ip
	hpth := path.Join(basepth, "/hosts", req.HostID, "ips", req.IPID())
	hdat := &HostIP{}
	if err := conn.Get(hpth, hdat); err != nil {
		logger.WithError(err).Debug("Could not look up virtual ip on host")
		// TODO: error
		return err
	}

	// mutate the state
	pver, hver := pdat.Version(), hdat.Version()
	ip := &IP{
		PoolIP:    *pdat,
		HostIP:    *hdat,
		HostID:    req.HostID,
		IPAddress: req.IPAddress,
	}

	// only commit the transaction if mutate returns true
	if !mutate(ip) {
		logger.Debug("Transaction aborted")
		return nil
	}

	// set the version object on the respective ips
	*pdat = ip.PoolIP
	pdat.SetVersion(pver)
	*hdat = ip.HostIP
	hdat.SetVersion(hver)

	if err := conn.NewTransaction().Set(ppth, pdat).Set(hpth, hdat).Commit(); err != nil {
		logger.WithError(err).Debug("Could not commit transaction")
		// TODO: error
		return err
	}
	logger.Debug("Updated ip")
	return nil
}
1009549
func (ncc *SeesawNCC) IPVSGetServices(in int, s *ncctypes.IPVSServices) error {
	ipvsMutex.Lock()
	defer ipvsMutex.Unlock()
	svcs, err := ipvs.GetServices()
	if err != nil {
		return err
	}
	s.Services = nil
	for _, svc := range svcs {
		s.Services = append(s.Services, svc)
	}
	return nil
}
1347923
func (s *VPCService) UpdateVPC(p *UpdateVPCParams) (*UpdateVPCResponse, error) {
	resp, err := s.cs.newRequest("updateVPC", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r UpdateVPCResponse
	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
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

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

	return &r, nil
}
649848
func (m *MockServiceAPIClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) {
	ret := m.ctrl.Call(m, "ServiceUpdate", ctx, serviceID, version, service, options)
	ret0, _ := ret[0].(types.ServiceUpdateResponse)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}