當前位置: 首頁>>代碼示例>>Golang>>正文


Golang State.Service方法代碼示例

本文整理匯總了Golang中launchpad/net/juju-core/state.State.Service方法的典型用法代碼示例。如果您正苦於以下問題:Golang State.Service方法的具體用法?Golang State.Service怎麽用?Golang State.Service使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在launchpad/net/juju-core/state.State的用法示例。


在下文中一共展示了State.Service方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ServiceGet

// ServiceGet returns the configuration for the named service.
func ServiceGet(st *state.State, p params.ServiceGet) (params.ServiceGetResults, error) {
	service, err := st.Service(p.ServiceName)
	if err != nil {
		return params.ServiceGetResults{}, err
	}
	settings, err := service.ConfigSettings()
	if err != nil {
		return params.ServiceGetResults{}, err
	}
	charm, _, err := service.Charm()
	if err != nil {
		return params.ServiceGetResults{}, err
	}
	configInfo := describe(settings, charm.Config())
	var constraints constraints.Value
	if service.IsPrincipal() {
		constraints, err = service.Constraints()
		if err != nil {
			return params.ServiceGetResults{}, err
		}
	}
	return params.ServiceGetResults{
		Service:     p.ServiceName,
		Charm:       charm.Meta().Name,
		Config:      configInfo,
		Constraints: constraints,
	}, nil
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:29,代碼來源:get.go

示例2: SetServiceConstraints

// SetServiceContstraints sets the constraints for a given service
func SetServiceConstraints(st *state.State, args params.SetServiceConstraints) error {
	svc, err := st.Service(args.ServiceName)
	if err != nil {
		return err
	}
	return svc.SetConstraints(args.Constraints)
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:8,代碼來源:setconstraints.go

示例3: GetServiceConstraints

// GetServiceConstraints returns the constraints for a given service
func GetServiceConstraints(st *state.State, args params.GetServiceConstraints) (params.GetServiceConstraintsResults, error) {
	svc, err := st.Service(args.ServiceName)
	if err != nil {
		return params.GetServiceConstraintsResults{constraints.Value{}}, err
	}
	constraints, err := svc.Constraints()
	return params.GetServiceConstraintsResults{constraints}, err
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:9,代碼來源:getconstraints.go

示例4: opClientServiceExpose

func opClientServiceExpose(c *C, st *api.State, mst *state.State) (func(), error) {
	err := st.Client().ServiceExpose("wordpress")
	if err != nil {
		return func() {}, err
	}
	return func() {
		svc, err := mst.Service("wordpress")
		c.Assert(err, IsNil)
		svc.ClearExposed()
	}, nil
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:11,代碼來源:perm_test.go

示例5: ServiceUnexpose

// ServiceUnexpose changes the juju-managed firewall to unexpose any ports that
// were also explicitly marked by units as open.
func ServiceUnexpose(state *state.State, args params.ServiceUnexpose) error {
	svc, err := state.Service(args.ServiceName)
	if err != nil {
		return err
	}
	return svc.ClearExposed()
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:9,代碼來源:unexpose.go

示例6: ServiceDestroy

// ServiceDestroy destroys a given service along with all its units and relations.
func ServiceDestroy(state *state.State, args params.ServiceDestroy) error {
	svc, err := state.Service(args.ServiceName)
	if err != nil {
		return err
	}

	return svc.Destroy()
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:9,代碼來源:destroyservice.go

示例7: AddServiceUnits

// AddServiceUnits adds a given number of units to a service.
func AddServiceUnits(state *state.State, args params.AddServiceUnits) ([]*state.Unit, error) {
	conn, err := juju.NewConnFromState(state)
	if err != nil {
		return nil, err
	}
	service, err := state.Service(args.ServiceName)
	if err != nil {
		return nil, err
	}
	if args.NumUnits < 1 {
		return nil, errors.New("must add at least one unit")
	}
	if args.NumUnits > 1 && args.ToMachineSpec != "" {
		return nil, errors.New("cannot use --num-units with --to")
	}
	return conn.AddUnits(service, args.NumUnits, args.ToMachineSpec)
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:18,代碼來源:addunit.go


注:本文中的launchpad/net/juju-core/state.State.Service方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。