当前位置: 首页>>代码示例>>Golang>>正文


Golang serviced.ControlClient类代码示例

本文整理汇总了Golang中github.com/zenoss/serviced.ControlClient的典型用法代码示例。如果您正苦于以下问题:Golang ControlClient类的具体用法?Golang ControlClient怎么用?Golang ControlClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ControlClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: RestGetService

func RestGetService(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	var allServices []*dao.Service

	if err := client.GetServices(&empty, &allServices); err != nil {
		glog.Errorf("Could not get services: %v", err)
		RestServerError(w)
		return
	}

	sid, err := url.QueryUnescape(r.PathParam("serviceId"))
	if err != nil {
		RestBadRequest(w)
		return
	}

	for _, service := range allServices {
		if service.Id == sid {
			w.WriteJson(&service)
			return
		}
	}

	glog.Errorf("No such service [%v]", sid)
	RestServerError(w)
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:25,代码来源:resources.go

示例2: getNamedServices

func getNamedServices(client *serviced.ControlClient, nmregex string) ([]*dao.Service, error) {
	services := []*dao.Service{}
	if err := client.GetServices(&empty, &services); err != nil {
		glog.Errorf("Could not get named services: %v", err)
		return nil, err
	}

	return filterByNameRegex(nmregex, services)
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:9,代码来源:resources.go

示例3: RestGetPools

func RestGetPools(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	var poolsMap map[string]*dao.ResourcePool
	err := client.GetResourcePools(&empty, &poolsMap)
	if err != nil {
		glog.Error("Could not get resource pools: ", err)
		RestServerError(w)
		return
	}
	w.WriteJson(&poolsMap)
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:10,代码来源:resources.go

示例4: getServices

func getServices(client *serviced.ControlClient) ([]*dao.Service, error) {
	services := []*dao.Service{}
	if err := client.GetServices(&empty, &services); err != nil {
		glog.Errorf("Could not get services: %v", err)
		return nil, err
	}

	glog.V(2).Infof("Returning %d services", len(services))
	return services, nil
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:10,代码来源:resources.go

示例5: RestGetHosts

func RestGetHosts(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	var hosts map[string]*dao.Host
	err := client.GetHosts(&empty, &hosts)
	if err != nil {
		glog.Errorf("Could not get hosts: %v", err)
		RestServerError(w)
		return
	}
	glog.V(2).Infof("Returning %d hosts", len(hosts))
	w.WriteJson(&hosts)
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:11,代码来源:resources.go

示例6: RestGetServiceLogs

func RestGetServiceLogs(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	serviceId, err := url.QueryUnescape(r.PathParam("serviceId"))
	if err != nil {
		RestBadRequest(w)
		return
	}
	var logs string
	err = client.GetServiceLogs(serviceId, &logs)
	if err != nil {
		glog.Errorf("Unexpected error getting logs: %v", err)
		RestServerError(w)
	}
	w.WriteJson(&SimpleResponse{logs, serviceLinks(serviceId)})
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:14,代码来源:resources.go

示例7: getTaggedServices

func getTaggedServices(client *serviced.ControlClient, tags, nmregex string) ([]*dao.Service, error) {
	services := []*dao.Service{}
	var ts interface{}
	ts = strings.Split(tags, ",")
	if err := client.GetTaggedServices(&ts, &services); err != nil {
		glog.Errorf("Could not get tagged services: %v", err)
		return nil, err
	}

	if nmregex != "" {
		return filterByNameRegex(nmregex, services)
	}
	glog.V(2).Infof("Returning %d tagged services", len(services))
	return services, nil
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:15,代码来源:resources.go

示例8: RestGetAllRunning

func RestGetAllRunning(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	var services []*dao.RunningService
	err := client.GetRunningServices(&empty, &services)
	if err != nil {
		glog.Errorf("Could not get services: %v", err)
		RestServerError(w)
		return
	}
	if services == nil {
		glog.V(3).Info("Services was nil, returning empty list instead")
		services = []*dao.RunningService{}
	}
	glog.V(2).Infof("Return %d running services", len(services))
	w.WriteJson(&services)
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:15,代码来源:resources.go

示例9: RestRemovePool

func RestRemovePool(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	poolId, err := url.QueryUnescape(r.PathParam("poolId"))
	if err != nil {
		RestBadRequest(w)
		return
	}
	var unused int
	err = client.RemoveResourcePool(poolId, &unused)
	if err != nil {
		glog.Error("Could not remove resource pool: ", err)
		RestServerError(w)
		return
	}
	glog.V(0).Info("Removed pool ", poolId)
	w.WriteJson(&SimpleResponse{"Removed resource pool", poolsLinks()})
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:16,代码来源:resources.go

示例10: RestRemoveHost

func RestRemoveHost(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	var unused int
	hostId, err := url.QueryUnescape(r.PathParam("hostId"))
	if err != nil {
		RestBadRequest(w)
		return
	}
	err = client.RemoveHost(hostId, &unused)
	if err != nil {
		glog.Errorf("Could not remove host: %v", err)
		RestServerError(w)
		return
	}
	glog.V(0).Info("Removed host ", hostId)
	w.WriteJson(&SimpleResponse{"Removed host", hostsLinks()})
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:16,代码来源:resources.go

示例11: RestAddPool

func RestAddPool(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	var payload dao.ResourcePool
	var poolId string
	err := r.DecodeJsonPayload(&payload)
	if err != nil {
		glog.V(1).Info("Could not decode pool payload: ", err)
		RestBadRequest(w)
		return
	}
	err = client.AddResourcePool(payload, &poolId)
	if err != nil {
		glog.Error("Unable to add pool: ", err)
		RestServerError(w)
		return
	}
	glog.V(0).Info("Added pool ", poolId)
	w.WriteJson(&SimpleResponse{"Added resource pool", poolLinks(poolId)})
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:18,代码来源:resources.go

示例12: RestDeployAppTemplate

func RestDeployAppTemplate(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	var payload dao.ServiceTemplateDeploymentRequest
	err := r.DecodeJsonPayload(&payload)
	if err != nil {
		glog.V(1).Info("Could not decode deployment payload: ", err)
		RestBadRequest(w)
		return
	}
	var unused int
	err = client.DeployTemplate(payload, &unused)
	if err != nil {
		glog.Error("Could not deploy template: ", err)
		RestServerError(w)
		return
	}
	glog.V(0).Info("Deployed template ", payload)
	w.WriteJson(&SimpleResponse{"Deployed app template", servicesLinks()})
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:18,代码来源:resources.go

示例13: RestGetTopServices

func RestGetTopServices(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	var allServices []*dao.Service
	topServices := []*dao.Service{}

	err := client.GetServices(&empty, &allServices)
	if err != nil {
		glog.Errorf("Could not get services: %v", err)
		RestServerError(w)
		return
	}
	for _, service := range allServices {
		if len(service.ParentServiceId) == 0 {
			topServices = append(topServices, service)
		}
	}
	glog.V(2).Infof("Returning %d services as top services", len(topServices))
	w.WriteJson(&topServices)
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:18,代码来源:resources.go

示例14: RestGetRunningForService

func RestGetRunningForService(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	serviceId, err := url.QueryUnescape(r.PathParam("serviceId"))
	if err != nil {
		RestBadRequest(w)
		return
	}
	var services []*dao.RunningService
	err = client.GetRunningServicesForService(serviceId, &services)
	if err != nil {
		glog.Errorf("Could not get services: %v", err)
		RestServerError(w)
		return
	}
	if services == nil {
		glog.V(3).Info("Running services was nil, returning empty list instead")
		services = []*dao.RunningService{}
	}
	glog.V(2).Infof("Returning %d running services for service %s", len(services), serviceId)
	w.WriteJson(&services)
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:20,代码来源:resources.go

示例15: RestGetHostsForResourcePool

func RestGetHostsForResourcePool(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
	var poolHosts []*dao.PoolHost
	poolId, err := url.QueryUnescape(r.PathParam("poolId"))
	if err != nil {
		glog.V(1).Infof("Unable to acquire pool ID: %v", err)
		RestBadRequest(w)
		return
	}
	err = client.GetHostsForResourcePool(poolId, &poolHosts)
	if err != nil {
		glog.Errorf("Could not get hosts: %v", err)
		RestServerError(w)
		return
	}
	if poolHosts == nil {
		glog.V(3).Info("Pool hosts was nil, returning empty list instead")
		poolHosts = []*dao.PoolHost{}
	}
	glog.V(2).Infof("Returning %d hosts for pool %s", len(poolHosts), poolId)
	w.WriteJson(&poolHosts)
}
开发者ID:jhuie-zenoss,项目名称:serviced,代码行数:21,代码来源:resources.go


注:本文中的github.com/zenoss/serviced.ControlClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。