本文整理汇总了Golang中github.com/juju/juju/worker/authenticationworker.NewWorker函数的典型用法代码示例。如果您正苦于以下问题:Golang NewWorker函数的具体用法?Golang NewWorker怎么用?Golang NewWorker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewWorker函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestKeyUpdateRetainsExisting
func (s *workerSuite) TestKeyUpdateRetainsExisting(c *gc.C) {
authWorker := authenticationworker.NewWorker(s.keyupdaterApi, agentConfig(c, s.machine.Tag().(names.MachineTag)))
defer stop(c, authWorker)
newKey := sshtesting.ValidKeyThree.Key + " [email protected]"
s.setAuthorisedKeys(c, newKey)
newKeyWithCommentPrefix := sshtesting.ValidKeyThree.Key + " Juju:[email protected]"
s.waitSSHKeys(c, append(s.existingKeys, newKeyWithCommentPrefix))
}
开发者ID:kapilt,项目名称:juju,代码行数:9,代码来源:worker_test.go
示例2: TestWorkerRestart
func (s *workerSuite) TestWorkerRestart(c *gc.C) {
authWorker := authenticationworker.NewWorker(s.keyupdaterApi, agentConfig(c, s.machine.Tag().(names.MachineTag)))
defer stop(c, authWorker)
s.waitSSHKeys(c, append(s.existingKeys, s.existingEnvKey))
// Stop the worker and delete and add keys from the environment while it is down.
// added: key 3
// deleted: key 1 (existing env key)
stop(c, authWorker)
s.setAuthorisedKeys(c, sshtesting.ValidKeyThree.Key+" [email protected]")
// Restart the worker and check that the ssh auth keys are as expected.
authWorker = authenticationworker.NewWorker(s.keyupdaterApi, agentConfig(c, s.machine.Tag().(names.MachineTag)))
defer stop(c, authWorker)
yetAnotherKeyWithCommentPrefix := sshtesting.ValidKeyThree.Key + " Juju:[email protected]"
s.waitSSHKeys(c, append(s.existingKeys, yetAnotherKeyWithCommentPrefix))
}
开发者ID:kapilt,项目名称:juju,代码行数:18,代码来源:worker_test.go
示例3: TestNewKeysInJujuAreSavedOnStartup
func (s *workerSuite) TestNewKeysInJujuAreSavedOnStartup(c *gc.C) {
newKey := sshtesting.ValidKeyThree.Key + " [email protected]"
s.setAuthorisedKeys(c, newKey)
authWorker := authenticationworker.NewWorker(s.keyupdaterApi, agentConfig(c, s.machine.Tag()))
defer stop(c, authWorker)
newKeyWithCommentPrefix := sshtesting.ValidKeyThree.Key + " Juju:[email protected]"
s.waitSSHKeys(c, append(s.existingKeys, newKeyWithCommentPrefix))
}
开发者ID:rogpeppe,项目名称:juju,代码行数:10,代码来源:worker_test.go
示例4: TestMultipleChanges
func (s *workerSuite) TestMultipleChanges(c *gc.C) {
authWorker := authenticationworker.NewWorker(s.keyupdaterApi, agentConfig(c, s.machine.Tag().(names.MachineTag)))
defer stop(c, authWorker)
s.waitSSHKeys(c, append(s.existingKeys, s.existingEnvKey))
// Perform a set to add a key and delete a key.
// added: key 3
// deleted: key 1 (existing env key)
s.setAuthorisedKeys(c, sshtesting.ValidKeyThree.Key+" [email protected]")
yetAnotherKeyWithComment := sshtesting.ValidKeyThree.Key + " Juju:[email protected]"
s.waitSSHKeys(c, append(s.existingKeys, yetAnotherKeyWithComment))
}
开发者ID:kapilt,项目名称:juju,代码行数:12,代码来源:worker_test.go
示例5: TestDeleteKey
func (s *workerSuite) TestDeleteKey(c *gc.C) {
authWorker := authenticationworker.NewWorker(s.keyupdaterApi, agentConfig(c, s.machine.Tag().(names.MachineTag)))
defer stop(c, authWorker)
// Add another key
anotherKey := sshtesting.ValidKeyThree.Key + " [email protected]"
s.setAuthorisedKeys(c, s.existingEnvKey, anotherKey)
anotherKeyWithCommentPrefix := sshtesting.ValidKeyThree.Key + " Juju:[email protected]"
s.waitSSHKeys(c, append(s.existingKeys, s.existingEnvKey, anotherKeyWithCommentPrefix))
// Delete the original key and check anotherKey plus the existing keys remain.
s.setAuthorisedKeys(c, anotherKey)
s.waitSSHKeys(c, append(s.existingKeys, anotherKeyWithCommentPrefix))
}
开发者ID:kapilt,项目名称:juju,代码行数:14,代码来源:worker_test.go
示例6: APIWorker
//.........这里部分代码省略.........
// Before starting any workers, ensure we record the Juju version this machine
// agent is running.
currentTools := &coretools.Tools{Version: version.Current}
if err := st.Upgrader().SetVersion(agentConfig.Tag().String(), currentTools.Version); err != nil {
return nil, errors.Annotate(err, "cannot set machine agent version")
}
providerType := agentConfig.Value(agent.ProviderType)
// Run the upgrader and the upgrade-steps worker without waiting for
// the upgrade steps to complete.
runner.StartWorker("upgrader", func() (worker.Worker, error) {
return upgrader.NewUpgrader(
st.Upgrader(),
agentConfig,
a.previousAgentVersion,
a.upgradeWorkerContext.IsUpgradeRunning,
), nil
})
runner.StartWorker("upgrade-steps", func() (worker.Worker, error) {
return a.upgradeWorkerContext.Worker(a, st, entity.Jobs()), nil
})
// All other workers must wait for the upgrade steps to complete
// before starting.
a.startWorkerAfterUpgrade(runner, "machiner", func() (worker.Worker, error) {
return machiner.NewMachiner(st.Machiner(), agentConfig), nil
})
a.startWorkerAfterUpgrade(runner, "apiaddressupdater", func() (worker.Worker, error) {
return apiaddressupdater.NewAPIAddressUpdater(st.Machiner(), a), nil
})
a.startWorkerAfterUpgrade(runner, "logger", func() (worker.Worker, error) {
return workerlogger.NewLogger(st.Logger(), agentConfig), nil
})
a.startWorkerAfterUpgrade(runner, "machineenvironmentworker", func() (worker.Worker, error) {
return machineenvironmentworker.NewMachineEnvironmentWorker(st.Environment(), agentConfig), nil
})
a.startWorkerAfterUpgrade(runner, "rsyslog", func() (worker.Worker, error) {
return newRsyslogConfigWorker(st.Rsyslog(), agentConfig, rsyslogMode)
})
// TODO (mfoord 8/8/2014) improve the way we detect networking capabilities. Bug lp:1354365
writeNetworkConfig := providerType == "maas"
if disableNetworkManagement || !writeNetworkConfig {
a.startWorkerAfterUpgrade(runner, "networker", func() (worker.Worker, error) {
return newSafeNetworker(st.Networker(), agentConfig, networker.DefaultConfigDir)
})
} else if !disableNetworkManagement && writeNetworkConfig {
a.startWorkerAfterUpgrade(runner, "networker", func() (worker.Worker, error) {
return newNetworker(st.Networker(), agentConfig, networker.DefaultConfigDir)
})
}
// If not a local provider bootstrap machine, start the worker to
// manage SSH keys.
if providerType != provider.Local || a.MachineId != bootstrapMachineId {
a.startWorkerAfterUpgrade(runner, "authenticationworker", func() (worker.Worker, error) {
return authenticationworker.NewWorker(st.KeyUpdater(), agentConfig), nil
})
}
// Perform the operations needed to set up hosting for containers.
if err := a.setupContainerSupport(runner, st, entity, agentConfig); err != nil {
cause := errors.Cause(err)
if params.IsCodeDead(cause) || cause == worker.ErrTerminateAgent {
return nil, worker.ErrTerminateAgent
}
return nil, fmt.Errorf("setting up container support: %v", err)
}
for _, job := range entity.Jobs() {
switch job {
case params.JobHostUnits:
a.startWorkerAfterUpgrade(runner, "deployer", func() (worker.Worker, error) {
apiDeployer := st.Deployer()
context := newDeployContext(apiDeployer, agentConfig)
return deployer.NewDeployer(apiDeployer, context), nil
})
case params.JobManageEnviron:
a.startWorkerAfterUpgrade(singularRunner, "environ-provisioner", func() (worker.Worker, error) {
return provisioner.NewEnvironProvisioner(st.Provisioner(), agentConfig), nil
})
// TODO(axw) 2013-09-24 bug #1229506
// Make another job to enable the firewaller. Not all
// environments are capable of managing ports
// centrally.
a.startWorkerAfterUpgrade(singularRunner, "firewaller", func() (worker.Worker, error) {
return firewaller.NewFirewaller(st.Firewaller())
})
a.startWorkerAfterUpgrade(singularRunner, "charm-revision-updater", func() (worker.Worker, error) {
return charmrevisionworker.NewRevisionUpdateWorker(st.CharmRevisionUpdater()), nil
})
case params.JobManageStateDeprecated:
// Legacy environments may set this, but we ignore it.
default:
// TODO(dimitern): Once all workers moved over to using
// the API, report "unknown job type" here.
}
}
return newCloseWorker(runner, st), nil // Note: a worker.Runner is itself a worker.Worker.
}
开发者ID:zhouqt,项目名称:juju,代码行数:101,代码来源:machine.go
注:本文中的github.com/juju/juju/worker/authenticationworker.NewWorker函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论