本文整理汇总了Golang中github.com/juju/juju/cmd/jujud/agent.MachineAgentFactoryFn函数的典型用法代码示例。如果您正苦于以下问题:Golang MachineAgentFactoryFn函数的具体用法?Golang MachineAgentFactoryFn怎么用?Golang MachineAgentFactoryFn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MachineAgentFactoryFn函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: jujuDMain
// Main registers subcommands for the jujud executable, and hands over control
// to the cmd package.
func jujuDMain(args []string, ctx *cmd.Context) (code int, err error) {
// Assuming an average of 200 bytes per log message, use up to
// 200MB for the log buffer.
logCh, err := logsender.InstallBufferedLogWriter(1048576)
if err != nil {
return 1, errors.Trace(err)
}
jujud := jujucmd.NewSuperCommand(cmd.SuperCommandParams{
Name: "jujud",
Doc: jujudDoc,
})
jujud.Log.Factory = &writerFactory{}
jujud.Register(NewBootstrapCommand())
// TODO(katco-): AgentConf type is doing too much. The
// MachineAgent type has called out the separate concerns; the
// AgentConf should be split up to follow suit.
agentConf := agentcmd.NewAgentConf("")
machineAgentFactory := agentcmd.MachineAgentFactoryFn(
agentConf, logCh, looputil.NewLoopDeviceManager(),
)
jujud.Register(agentcmd.NewMachineAgentCmd(ctx, machineAgentFactory, agentConf, agentConf))
jujud.Register(agentcmd.NewUnitAgent(ctx, logCh))
code = cmd.Main(jujud, ctx, args[1:])
return code, nil
}
开发者ID:kakamessi99,项目名称:juju,代码行数:31,代码来源:main.go
示例2: TestLogRecordForwarded
func (s *syslogSuite) TestLogRecordForwarded(c *gc.C) {
// Create a machine and an agent for it.
m, password := s.Factory.MakeMachineReturningPassword(c, &factory.MachineParams{
Nonce: agent.BootstrapNonce,
Jobs: []state.MachineJob{state.JobManageModel},
})
s.PrimeAgent(c, m.Tag(), password)
agentConf := agentcmd.NewAgentConf(s.DataDir())
agentConf.ReadConfig(m.Tag().String())
machineAgentFactory := agentcmd.MachineAgentFactoryFn(agentConf, s.logsCh, c.MkDir())
a := machineAgentFactory(m.Id())
// Ensure there's no logs to begin with.
// Start the agent.
go func() { c.Check(a.Run(nil), jc.ErrorIsNil) }()
defer a.Stop()
err := s.State.UpdateModelConfig(map[string]interface{}{
"logforward-enabled": true,
}, nil, nil)
c.Assert(err, jc.ErrorIsNil)
s.assertLogRecordForwarded(c, s.received)
}
开发者ID:bac,项目名称:juju,代码行数:26,代码来源:syslog_test.go
示例3: TestConfigChange
func (s *syslogSuite) TestConfigChange(c *gc.C) {
// Create a machine and an agent for it.
m, password := s.Factory.MakeMachineReturningPassword(c, &factory.MachineParams{
Nonce: agent.BootstrapNonce,
Jobs: []state.MachineJob{state.JobManageModel},
})
s.PrimeAgent(c, m.Tag(), password)
agentConf := agentcmd.NewAgentConf(s.DataDir())
agentConf.ReadConfig(m.Tag().String())
machineAgentFactory := agentcmd.MachineAgentFactoryFn(agentConf, s.logsCh, c.MkDir())
a := machineAgentFactory(m.Id())
// Ensure there's no logs to begin with.
// Start the agent.
go func() { c.Check(a.Run(nil), jc.ErrorIsNil) }()
defer a.Stop()
done := make(chan struct{})
received := make(chan rfc5424test.Message)
addr := s.createSyslogServer(c, received, done)
err := s.State.UpdateModelConfig(map[string]interface{}{
"logforward-enabled": true,
"syslog-host": addr,
"syslog-ca-cert": coretesting.CACert,
"syslog-client-cert": coretesting.ServerCert,
"syslog-client-key": coretesting.ServerKey,
}, nil, nil)
c.Assert(err, jc.ErrorIsNil)
s.assertLogRecordForwarded(c, received)
}
开发者ID:bac,项目名称:juju,代码行数:33,代码来源:syslog_test.go
示例4: jujuDMain
// Main registers subcommands for the jujud executable, and hands over control
// to the cmd package.
func jujuDMain(args []string, ctx *cmd.Context) (code int, err error) {
// Assuming an average of 200 bytes per log message, use up to
// 200MB for the log buffer.
defer logger.Debugf("jujud complete, code %d, err %v", code, err)
logCh, err := logsender.InstallBufferedLogWriter(1048576)
if err != nil {
return 1, errors.Trace(err)
}
jujud := jujucmd.NewSuperCommand(cmd.SuperCommandParams{
Name: "jujud",
Doc: jujudDoc,
})
jujud.Log.NewWriter = func(target io.Writer) loggo.Writer {
return &jujudWriter{target: target}
}
jujud.Register(NewBootstrapCommand())
// TODO(katco-): AgentConf type is doing too much. The
// MachineAgent type has called out the separate concerns; the
// AgentConf should be split up to follow suit.
agentConf := agentcmd.NewAgentConf("")
machineAgentFactory := agentcmd.MachineAgentFactoryFn(agentConf, logCh, "")
jujud.Register(agentcmd.NewMachineAgentCmd(ctx, machineAgentFactory, agentConf, agentConf))
jujud.Register(agentcmd.NewUnitAgent(ctx, logCh))
jujud.Register(NewUpgradeMongoCommand())
code = cmd.Main(jujud, ctx, args[1:])
return code, nil
}
开发者ID:bac,项目名称:juju,代码行数:36,代码来源:main.go
示例5: jujuDMain
// Main registers subcommands for the jujud executable, and hands over control
// to the cmd package.
func jujuDMain(args []string, ctx *cmd.Context) (code int, err error) {
jujud := jujucmd.NewSuperCommand(cmd.SuperCommandParams{
Name: "jujud",
Doc: jujudDoc,
})
jujud.Log.Factory = &writerFactory{}
jujud.Register(NewBootstrapCommand())
// TODO(katco-): AgentConf type is doing too much. The
// MachineAgent type has called out the seperate concerns; the
// AgentConf should be split up to follow suite.
agentConf := agentcmd.NewAgentConf("")
machineAgentFactory := agentcmd.MachineAgentFactoryFn(agentConf, agentConf)
jujud.Register(agentcmd.NewMachineAgentCmd(ctx, machineAgentFactory, agentConf, agentConf))
jujud.Register(agentcmd.NewUnitAgent(ctx))
code = cmd.Main(jujud, ctx, args[1:])
return code, nil
}
开发者ID:Pankov404,项目名称:juju,代码行数:22,代码来源:main.go
示例6: runMachineAgentTest
func (s *dblogSuite) runMachineAgentTest(c *gc.C) bool {
// Create a machine and an agent for it.
m, password := s.Factory.MakeMachineReturningPassword(c, &factory.MachineParams{
Nonce: agent.BootstrapNonce,
})
s.PrimeAgent(c, m.Tag(), password, version.Current)
agentConf := agentcmd.NewAgentConf(s.DataDir())
agentConf.ReadConfig(m.Tag().String())
logsCh, err := logsender.InstallBufferedLogWriter(1000)
c.Assert(err, jc.ErrorIsNil)
machineAgentFactory := agentcmd.MachineAgentFactoryFn(agentConf, agentConf, logsCh, nil)
a := machineAgentFactory(m.Id())
// Ensure there's no logs to begin with.
c.Assert(s.getLogCount(c, m.Tag()), gc.Equals, 0)
// Start the agent.
go func() { c.Check(a.Run(nil), jc.ErrorIsNil) }()
defer a.Stop()
return s.waitForLogs(c, m.Tag())
}
开发者ID:vonwenm,项目名称:juju,代码行数:23,代码来源:dblog_test.go
示例7: newAgent
// TODO(mjs) - the following should maybe be part of AgentSuite
func (s *upgradeSuite) newAgent(c *gc.C, m *state.Machine) *agentcmd.MachineAgent {
agentConf := agentcmd.NewAgentConf(s.DataDir())
agentConf.ReadConfig(m.Tag().String())
machineAgentFactory := agentcmd.MachineAgentFactoryFn(agentConf, nil, c.MkDir())
return machineAgentFactory(m.Id())
}
开发者ID:kat-co,项目名称:juju,代码行数:7,代码来源:upgrade_test.go
示例8: SetUpTest
func (s *leadershipSuite) SetUpTest(c *gc.C) {
s.AgentSuite.SetUpTest(c)
leaseManager, err := lease.NewLeaseManager(s.State)
c.Assert(err, jc.ErrorIsNil)
s.AddCleanup(func(c *gc.C) {
leaseManager.Kill()
c.Assert(leaseManager.Wait(), jc.ErrorIsNil)
})
file, _ := ioutil.TempFile("", "juju-run")
defer file.Close()
s.AgentSuite.PatchValue(&agentcmd.JujuRun, file.Name())
agenttesting.InstallFakeEnsureMongo(s)
s.PatchValue(&agentcmd.ProductionMongoWriteConcern, false)
// Create a machine to manage the environment.
stateServer, password := s.Factory.MakeMachineReturningPassword(c, &factory.MachineParams{
InstanceId: "id-1",
Nonce: agent.BootstrapNonce,
Jobs: []state.MachineJob{state.JobManageEnviron},
})
c.Assert(stateServer.PasswordValid(password), gc.Equals, true)
c.Assert(stateServer.SetMongoPassword(password), jc.ErrorIsNil)
// Create a machine to host some units.
unitHostMachine := s.Factory.MakeMachine(c, &factory.MachineParams{
Nonce: agent.BootstrapNonce,
Password: password,
})
// Create a service and an instance of that service so that we can
// create a client.
service := s.Factory.MakeService(c, &factory.ServiceParams{})
s.serviceId = service.Tag().Id()
unit := s.Factory.MakeUnit(c, &factory.UnitParams{Machine: unitHostMachine, Service: service})
s.unitId = unit.UnitTag().Id()
c.Assert(unit.SetPassword(password), jc.ErrorIsNil)
s.apiState = s.OpenAPIAs(c, unit.Tag(), password)
// Tweak and write out the config file for the state server.
writeStateAgentConfig(
c,
s.MongoInfo(c),
s.DataDir(),
stateServer.Tag(),
s.State.EnvironTag(),
password,
version.Current,
)
// Create & start a machine agent so the tests have something to call into.
agentConf := agentcmd.NewAgentConf(s.DataDir())
machineAgentFactory := agentcmd.MachineAgentFactoryFn(agentConf, agentConf, nil, nil)
s.machineAgent = machineAgentFactory(stateServer.Id())
// See comment in createMockJujudExecutable
if runtime.GOOS == "windows" {
dirToRemove := createMockJujudExecutable(c, s.DataDir(), s.machineAgent.Tag().String())
s.AddCleanup(func(*gc.C) { os.RemoveAll(dirToRemove) })
}
c.Log("Starting machine agent...")
go func() {
err := s.machineAgent.Run(coretesting.Context(c))
c.Assert(err, jc.ErrorIsNil)
}()
}
开发者ID:frankban,项目名称:juju-tmp,代码行数:71,代码来源:leadership_test.go
注:本文中的github.com/juju/juju/cmd/jujud/agent.MachineAgentFactoryFn函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论