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


Golang Service.AllUnits方法代碼示例

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


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

示例1: assertForceMachine

// assertForceMachine ensures that the result of assigning a unit with --to
// is as expected.
func (s *AddUnitSuite) assertForceMachine(c *C, svc *state.Service, expectedNumMachines, unitNum int, machineId string) {
	units, err := svc.AllUnits()
	c.Assert(err, IsNil)
	c.Assert(units, HasLen, expectedNumMachines)
	mid, err := units[unitNum].AssignedMachineId()
	c.Assert(err, IsNil)
	c.Assert(mid, Equals, machineId)
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:10,代碼來源:addunit_test.go

示例2: removeAllUnits

func removeAllUnits(c *C, s *state.Service) {
	us, err := s.AllUnits()
	c.Assert(err, IsNil)
	for _, u := range us {
		err = u.EnsureDead()
		c.Assert(err, IsNil)
		err = u.Remove()
		c.Assert(err, IsNil)
	}
}
開發者ID:hivetech,項目名稱:judo.legacy,代碼行數:10,代碼來源:service_test.go

示例3: removeServiceAndUnits

func removeServiceAndUnits(c *C, service *state.Service) {
	// Destroy all units for the service.
	units, err := service.AllUnits()
	c.Assert(err, IsNil)
	for _, unit := range units {
		err = unit.EnsureDead()
		c.Assert(err, IsNil)
		err = unit.Remove()
		c.Assert(err, IsNil)
	}
	err = service.Destroy()
	c.Assert(err, IsNil)

	err = service.Refresh()
	c.Assert(err, checkers.Satisfies, errors.IsNotFoundError)
}
開發者ID:hivetech,項目名稱:judo.legacy,代碼行數:16,代碼來源:api_test.go

示例4: assertMachines

func (s *DeployLocalSuite) assertMachines(c *C, service *state.Service, expectCons constraints.Value, expectIds ...string) {
	units, err := service.AllUnits()
	c.Assert(err, IsNil)
	c.Assert(units, HasLen, len(expectIds))
	unseenIds := set.NewStrings(expectIds...)
	for _, unit := range units {
		id, err := unit.AssignedMachineId()
		c.Assert(err, IsNil)
		unseenIds.Remove(id)
		machine, err := s.State.Machine(id)
		c.Assert(err, IsNil)
		cons, err := machine.Constraints()
		c.Assert(err, IsNil)
		c.Assert(cons, DeepEquals, expectCons)
	}
	c.Assert(unseenIds, DeepEquals, set.NewStrings())
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:17,代碼來源:conn_test.go

示例5: addRU

func addRU(c *C, svc *state.Service, rel *state.Relation, principal *state.Unit) (*state.Unit, *state.RelationUnit) {
	// Given the service svc in the relation rel, add a unit of svc and create
	// a RelationUnit with rel. If principal is supplied, svc is assumed to be
	// subordinate and the unit will be created by temporarily entering the
	// relation's scope as the principal.
	var u *state.Unit
	if principal == nil {
		unit, err := svc.AddUnit()
		c.Assert(err, IsNil)
		u = unit
	} else {
		origUnits, err := svc.AllUnits()
		c.Assert(err, IsNil)
		pru, err := rel.Unit(principal)
		c.Assert(err, IsNil)
		err = pru.EnterScope(nil) // to create the subordinate
		c.Assert(err, IsNil)
		err = pru.LeaveScope() // to reset to initial expected state
		c.Assert(err, IsNil)
		newUnits, err := svc.AllUnits()
		c.Assert(err, IsNil)
		for _, unit := range newUnits {
			found := false
			for _, old := range origUnits {
				if unit.Name() == old.Name() {
					found = true
					break
				}
			}
			if !found {
				u = unit
				break
			}
		}
		c.Assert(u, NotNil)
	}
	preventUnitDestroyRemove(c, u)
	ru, err := rel.Unit(u)
	c.Assert(err, IsNil)
	return u, ru
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:41,代碼來源:relationunit_test.go

示例6: processService

func processService(service *state.Service) (map[string]interface{}, error) {
	r := m()
	ch, _, err := service.Charm()
	if err != nil {
		return nil, err
	}
	r["charm"] = ch.String()
	r["exposed"] = service.IsExposed()

	// TODO(dfc) service.IsSubordinate() ?

	units, err := service.AllUnits()
	if err != nil {
		return nil, err
	}

	u := checkError(processUnits(units))
	if len(u) > 0 {
		r["units"] = u
	}

	// TODO(dfc) process relations
	return r, nil
}
開發者ID:prabhakhar,項目名稱:juju-core,代碼行數:24,代碼來源:status.go

示例7: assertAllUnits

func assertAllUnits(c *C, service *state.Service, expected int) {
	units, err := service.AllUnits()
	c.Assert(err, IsNil)
	c.Assert(units, HasLen, expected)
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:5,代碼來源:minimumunits_test.go


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