本文整理汇总了Golang中github.com/juju/juju/apiserver/client.Status函数的典型用法代码示例。如果您正苦于以下问题:Golang Status函数的具体用法?Golang Status怎么用?Golang Status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Status函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestNoMeterStatusWhenNotRequired
func (s *statusUnitTestSuite) TestNoMeterStatusWhenNotRequired(c *gc.C) {
service := s.Factory.MakeApplication(c, nil)
units, err := service.AllUnits()
c.Assert(err, jc.ErrorIsNil)
c.Assert(units, gc.HasLen, 0)
for i, unit := range testUnits {
u, err := service.AddUnit()
testUnits[i].unitName = u.Name()
c.Assert(err, jc.ErrorIsNil)
if unit.setStatus != nil {
err := u.SetMeterStatus(unit.setStatus.Code.String(), unit.setStatus.Info)
c.Assert(err, jc.ErrorIsNil)
}
}
client := s.APIState.Client()
status, err := client.Status(nil)
c.Assert(err, jc.ErrorIsNil)
c.Assert(status, gc.NotNil)
serviceStatus, ok := status.Applications[service.Name()]
c.Assert(ok, gc.Equals, true)
c.Assert(serviceStatus.MeterStatuses, gc.HasLen, 0)
}
示例2: checkAppVersion
func (s *statusUnitTestSuite) checkAppVersion(c *gc.C, application *state.Application, expectedVersion string) params.ApplicationStatus {
client := s.APIState.Client()
status, err := client.Status(nil)
c.Assert(err, jc.ErrorIsNil)
appStatus, found := status.Applications[application.Name()]
c.Assert(found, jc.IsTrue)
c.Check(appStatus.WorkloadVersion, gc.Equals, expectedVersion)
return appStatus
}
示例3: TestUpdateRevisions
func (s *statusUpgradeUnitSuite) TestUpdateRevisions(c *gc.C) {
s.AddMachine(c, "0", state.JobManageModel)
s.SetupScenario(c)
client := s.APIState.Client()
status, _ := client.Status(nil)
serviceStatus, ok := status.Services["mysql"]
c.Assert(ok, gc.Equals, true)
c.Assert(serviceStatus.CanUpgradeTo, gc.Equals, "")
// Update to the latest available charm revision.
result, err := s.charmrevisionupdater.UpdateLatestRevisions()
c.Assert(err, jc.ErrorIsNil)
c.Assert(result.Error, gc.IsNil)
// Check if CanUpgradeTo suggest the latest revision.
status, _ = client.Status(nil)
serviceStatus, ok = status.Services["mysql"]
c.Assert(ok, gc.Equals, true)
c.Assert(serviceStatus.CanUpgradeTo, gc.Equals, "cs:quantal/mysql-23")
}
示例4: TestFullStatusUnitLeadership
func (s *statusSuite) TestFullStatusUnitLeadership(c *gc.C) {
u := s.Factory.MakeUnit(c, nil)
s.State.LeadershipClaimer().ClaimLeadership(u.ApplicationName(), u.Name(), time.Minute)
client := s.APIState.Client()
status, err := client.Status(nil)
c.Assert(err, jc.ErrorIsNil)
app, ok := status.Applications[u.ApplicationName()]
c.Assert(ok, jc.IsTrue)
unit, ok := app.Units[u.Name()]
c.Assert(ok, jc.IsTrue)
c.Assert(unit.Leader, jc.IsTrue)
}
示例5: TestFullStatus
func (s *statusSuite) TestFullStatus(c *gc.C) {
machine := s.addMachine(c)
client := s.APIState.Client()
status, err := client.Status(nil)
c.Assert(err, jc.ErrorIsNil)
c.Check(status.ModelName, gc.Equals, "admin")
c.Check(status.Services, gc.HasLen, 0)
c.Check(status.Machines, gc.HasLen, 1)
resultMachine, ok := status.Machines[machine.Id()]
if !ok {
c.Fatalf("Missing machine with id %q", machine.Id())
}
c.Check(resultMachine.Id, gc.Equals, machine.Id())
c.Check(resultMachine.Series, gc.Equals, machine.Series())
}
示例6: TestFullStatus
func (s *statusSuite) TestFullStatus(c *gc.C) {
machine := s.addMachine(c)
client := s.APIState.Client()
status, err := client.Status(nil)
c.Assert(err, jc.ErrorIsNil)
c.Check(status.Model.Name, gc.Equals, "controller")
c.Check(status.Model.CloudTag, gc.Equals, "cloud-dummy")
c.Check(status.Applications, gc.HasLen, 0)
c.Check(status.Machines, gc.HasLen, 1)
resultMachine, ok := status.Machines[machine.Id()]
if !ok {
c.Fatalf("Missing machine with id %q", machine.Id())
}
c.Check(resultMachine.Id, gc.Equals, machine.Id())
c.Check(resultMachine.Series, gc.Equals, machine.Series())
}
示例7: TestMigrationInProgress
func (s *statusUnitTestSuite) TestMigrationInProgress(c *gc.C) {
// Create a host model because controller models can't be migrated.
state2 := s.Factory.MakeModel(c, nil)
defer state2.Close()
// Get API connection to hosted model.
apiInfo := s.APIInfo(c)
apiInfo.ModelTag = state2.ModelTag()
conn, err := api.Open(apiInfo, api.DialOpts{})
c.Assert(err, jc.ErrorIsNil)
client := conn.Client()
checkMigStatus := func(expected string) {
status, err := client.Status(nil)
c.Assert(err, jc.ErrorIsNil)
c.Check(status.Model.Migration, gc.Equals, expected)
}
// Migration status should be empty when no migration is happening.
checkMigStatus("")
// Start it migrating.
mig, err := state2.CreateMigration(state.MigrationSpec{
InitiatedBy: names.NewUserTag("admin"),
TargetInfo: migration.TargetInfo{
ControllerTag: names.NewControllerTag(utils.MustNewUUID().String()),
Addrs: []string{"1.2.3.4:5555", "4.3.2.1:6666"},
CACert: "cert",
AuthTag: names.NewUserTag("user"),
Password: "password",
},
})
c.Assert(err, jc.ErrorIsNil)
// Check initial message.
checkMigStatus("starting")
// Check status is reported when set.
setAndCheckMigStatus := func(message string) {
err := mig.SetStatusMessage(message)
c.Assert(err, jc.ErrorIsNil)
checkMigStatus(message)
}
setAndCheckMigStatus("proceeding swimmingly")
setAndCheckMigStatus("oh noes")
}
示例8: TestMeterStatusWithCredentials
func (s *statusUnitTestSuite) TestMeterStatusWithCredentials(c *gc.C) {
service := s.Factory.MakeApplication(c, nil)
c.Assert(service.SetMetricCredentials([]byte("magic-ticket")), jc.ErrorIsNil)
units, err := service.AllUnits()
c.Assert(err, jc.ErrorIsNil)
c.Assert(units, gc.HasLen, 0)
for i, unit := range testUnits {
u, err := service.AddUnit()
testUnits[i].unitName = u.Name()
c.Assert(err, jc.ErrorIsNil)
if unit.setStatus != nil {
err := u.SetMeterStatus(unit.setStatus.Code.String(), unit.setStatus.Info)
c.Assert(err, jc.ErrorIsNil)
}
}
client := s.APIState.Client()
status, err := client.Status(nil)
c.Assert(err, jc.ErrorIsNil)
c.Assert(status, gc.NotNil)
serviceStatus, ok := status.Applications[service.Name()]
c.Assert(ok, gc.Equals, true)
c.Assert(serviceStatus.MeterStatuses, gc.HasLen, len(testUnits)-1)
for _, unit := range testUnits {
unitStatus, ok := serviceStatus.MeterStatuses[unit.unitName]
if unit.expectedStatus != nil {
c.Assert(ok, gc.Equals, true)
c.Assert(&unitStatus, gc.DeepEquals, unit.expectedStatus)
} else {
c.Assert(ok, gc.Equals, false)
}
}
}
示例9: TestMeterStatus
func (s *statusUnitTestSuite) TestMeterStatus(c *gc.C) {
meteredCharm := s.Factory.MakeCharm(c, &factory.CharmParams{Name: "metered", URL: "cs:quantal/metered"})
service := s.Factory.MakeApplication(c, &factory.ApplicationParams{Charm: meteredCharm})
units, err := service.AllUnits()
c.Assert(err, jc.ErrorIsNil)
c.Assert(units, gc.HasLen, 0)
for i, unit := range testUnits {
u, err := service.AddUnit()
testUnits[i].unitName = u.Name()
c.Assert(err, jc.ErrorIsNil)
if unit.setStatus != nil {
err := u.SetMeterStatus(unit.setStatus.Code.String(), unit.setStatus.Info)
c.Assert(err, jc.ErrorIsNil)
}
}
client := s.APIState.Client()
status, err := client.Status(nil)
c.Assert(err, jc.ErrorIsNil)
c.Assert(status, gc.NotNil)
serviceStatus, ok := status.Applications[service.Name()]
c.Assert(ok, gc.Equals, true)
c.Assert(serviceStatus.MeterStatuses, gc.HasLen, len(testUnits)-1)
for _, unit := range testUnits {
unitStatus, ok := serviceStatus.MeterStatuses[unit.unitName]
if unit.expectedStatus != nil {
c.Assert(ok, gc.Equals, true)
c.Assert(&unitStatus, gc.DeepEquals, unit.expectedStatus)
} else {
c.Assert(ok, gc.Equals, false)
}
}
}