• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang mongo.ServiceName函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/juju/juju/mongo.ServiceName函数的典型用法代码示例。如果您正苦于以下问题:Golang ServiceName函数的具体用法?Golang ServiceName怎么用?Golang ServiceName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ServiceName函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: placeNewMongo

// placeNewMongo tries to use mongorestore to replace an existing
// mongo with the dump in newMongoDumpPath returns an error if its not possible.
func placeNewMongo(newMongoDumpPath string, ver version.Number) error {
	mongoRestore, err := restorePath()
	if err != nil {
		return errors.Annotate(err, "mongorestore not available")
	}

	mgoRestoreArgs, err := restoreArgsForVersion(ver, newMongoDumpPath)
	if err != nil {
		return errors.Errorf("cannot restore this backup version")
	}
	err = runCommand("initctl", "stop", mongo.ServiceName(""))
	if err != nil {
		return errors.Annotate(err, "failed to stop mongo")
	}

	err = runCommand(mongoRestore, mgoRestoreArgs...)

	if err != nil {
		return errors.Annotate(err, "failed to restore database dump")
	}

	err = runCommand("initctl", "start", mongo.ServiceName(""))
	if err != nil {
		return errors.Annotate(err, "failed to start mongo")
	}

	return nil
}
开发者ID:Pankov404,项目名称:juju,代码行数:30,代码来源:db.go


示例2: makeFakeInitScripts

func (s *localJujuTestSuite) makeFakeInitScripts(c *gc.C, env environs.Environ) (installable, installable) {
	s.MakeTool(c, "start", `echo "some-service start/running, process 123"`)
	namespace := env.Config().AllAttrs()["namespace"].(string)

	// Mongo first...
	mongoName := mongo.ServiceName(namespace)
	mongoConf := common.Conf{
		Desc:      "fake mongo",
		ExecStart: "echo FAKE",
	}
	mongoService := local.NewService(mongoName, mongoConf, s.svcData)
	s.svcData.SetStatus(mongoName, "installed")
	installed, err := mongoService.Installed()
	c.Assert(err, jc.ErrorIsNil)
	c.Check(installed, jc.IsTrue)

	// ...then the machine agent
	agentName := fmt.Sprintf("juju-agent-%s", namespace)
	agentConf := common.Conf{
		Desc:      "fake agent",
		ExecStart: "echo FAKE",
	}
	agentService := local.NewService(agentName, agentConf, s.svcData)
	s.svcData.SetStatus(agentName, "installed")
	installed, err = agentService.Installed()
	c.Assert(err, jc.ErrorIsNil)
	c.Check(installed, jc.IsTrue)

	return mongoService, agentService
}
开发者ID:pmatulis,项目名称:juju,代码行数:30,代码来源:environ_test.go


示例3: makeFakeUpstartScripts

func (s *localJujuTestSuite) makeFakeUpstartScripts(c *gc.C, env environs.Environ,
) (mongoService *upstart.Service, machineAgent *upstart.Service) {
	upstartDir := c.MkDir()
	s.PatchValue(&upstart.InitDir, upstartDir)
	s.MakeTool(c, "start", `echo "some-service start/running, process 123"`)

	namespace := env.Config().AllAttrs()["namespace"].(string)
	mongoConf := common.Conf{
		Desc: "fake mongo",
		Cmd:  "echo FAKE",
	}
	mongoService = upstart.NewService(mongo.ServiceName(namespace), mongoConf)
	err := mongoService.Install()
	c.Assert(err, gc.IsNil)
	c.Assert(mongoService.Installed(), jc.IsTrue)

	agentConf := common.Conf{
		Desc: "fake agent",
		Cmd:  "echo FAKE",
	}
	machineAgent = upstart.NewService(fmt.Sprintf("juju-agent-%s", namespace), agentConf)

	err = machineAgent.Install()
	c.Assert(err, gc.IsNil)
	c.Assert(machineAgent.Installed(), jc.IsTrue)

	return mongoService, machineAgent
}
开发者ID:kapilt,项目名称:juju,代码行数:28,代码来源:environ_test.go


示例4: Destroy

func (e *manualEnviron) Destroy() error {
	script := `
set -x
touch %s
pkill -%d jujud && exit
stop %s
rm -f /etc/init/juju*
rm -f /etc/rsyslog.d/*juju*
rm -fr %s %s
exit 0
`
	script = fmt.Sprintf(
		script,
		utils.ShQuote(path.Join(
			agent.DefaultPaths.DataDir,
			agent.UninstallAgentFile,
		)),
		terminationworker.TerminationSignal,
		mongo.ServiceName(""),
		utils.ShQuote(agent.DefaultPaths.DataDir),
		utils.ShQuote(agent.DefaultPaths.LogDir),
	)
	_, err := runSSHCommand(
		"[email protected]"+e.envConfig().bootstrapHost(),
		[]string{"sudo", "/bin/bash"}, script,
	)
	return err
}
开发者ID:snailwalker,项目名称:juju,代码行数:28,代码来源:environ.go


示例5: PatchServices

func PatchServices(patchValue func(interface{}, interface{}), data *svctesting.FakeServiceData) {
	patchValue(&mongoRemoveService, func(namespace string) error {
		data.AddCall("RemoveService", namespace)
		data.SetStatus(mongo.ServiceName(namespace), "")
		return data.NextErr()
	})
	patchValue(&discoverService, func(name string) (agentService, error) {
		return NewService(name, common.Conf{}, data), nil
	})
}
开发者ID:imoapps,项目名称:juju,代码行数:10,代码来源:export_test.go


示例6: TestIsServiceInstalledWhenInstalled

func (s *serviceSuite) TestIsServiceInstalledWhenInstalled(c *gc.C) {
	namespace := "some-namespace"
	svcName := mongo.ServiceName(namespace)
	svcData := svctesting.NewFakeServiceData(svcName)
	mongo.PatchService(s.PatchValue, svcData)

	isInstalled, err := mongo.IsServiceInstalled(namespace)

	c.Assert(err, jc.ErrorIsNil)
	c.Assert(isInstalled, jc.IsTrue)
}
开发者ID:imoapps,项目名称:juju,代码行数:11,代码来源:service_test.go


示例7: TestRemoveService

func (s *MongoSuite) TestRemoveService(c *gc.C) {
	namespace := "namespace"
	s.data.SetStatus(mongo.ServiceName(namespace), "running")

	err := mongo.RemoveService(namespace)
	c.Assert(err, jc.ErrorIsNil)

	removed := s.data.Removed()
	if !c.Check(removed, gc.HasLen, 1) {
		c.Check(removed[0].Name(), gc.Equals, "juju-db-namespace")
		c.Check(removed[0].Conf(), jc.DeepEquals, common.Conf{})
	}
	s.data.CheckCallNames(c, "Stop", "Remove")
}
开发者ID:Pankov404,项目名称:juju,代码行数:14,代码来源:mongo_test.go


示例8: TestEnsureServerServerExistsNotRunningIsStarted

func (s *MongoSuite) TestEnsureServerServerExistsNotRunningIsStarted(c *gc.C) {
	dataDir := c.MkDir()
	namespace := "namespace"

	mockShellCommand(c, &s.CleanupSuite, "apt-get")

	s.data.SetStatus(mongo.ServiceName(namespace), "installed")

	err := mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))
	c.Assert(err, jc.ErrorIsNil)

	c.Check(s.data.Installed(), gc.HasLen, 0)
	s.data.CheckCallNames(c, "Installed", "Exists", "Running", "Start")
}
开发者ID:Pankov404,项目名称:juju,代码行数:14,代码来源:mongo_test.go


示例9: TestEnsureServerServerExistsNotRunningStartError

func (s *MongoSuite) TestEnsureServerServerExistsNotRunningStartError(c *gc.C) {
	dataDir := c.MkDir()
	namespace := "namespace"

	mockShellCommand(c, &s.CleanupSuite, "apt-get")

	s.data.SetStatus(mongo.ServiceName(namespace), "installed")
	failure := errors.New("won't start")
	s.data.SetErrors(nil, nil, nil, failure) // Installed, Exists, Running, Running, Start

	err := mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))

	c.Check(errors.Cause(err), gc.Equals, failure)
	c.Check(s.data.Installed(), gc.HasLen, 0)
	s.data.CheckCallNames(c, "Installed", "Exists", "Running", "Start")
}
开发者ID:Pankov404,项目名称:juju,代码行数:16,代码来源:mongo_test.go


示例10: TestInstallMongodServiceExists

func (s *MongoSuite) TestInstallMongodServiceExists(c *gc.C) {
	output := mockShellCommand(c, &s.CleanupSuite, "apt-get")
	dataDir := c.MkDir()
	namespace := "namespace"

	s.data.SetStatus(mongo.ServiceName(namespace), "running")
	s.data.SetErrors(nil, nil, nil, errors.New("shouldn't be called"))

	err := mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))
	c.Assert(err, jc.ErrorIsNil)

	c.Check(s.data.Installed(), gc.HasLen, 0)
	s.data.CheckCallNames(c, "Installed", "Exists", "Running")

	// We still attempt to install mongodb, despite the service existing.
	cmds := getMockShellCalls(c, output)
	c.Check(cmds, gc.HasLen, 1)
}
开发者ID:Pankov404,项目名称:juju,代码行数:18,代码来源:mongo_test.go


示例11: TestEnsureServerServerExistsNotRunningStartError

func (s *MongoSuite) TestEnsureServerServerExistsNotRunningStartError(c *gc.C) {
	dataDir := c.MkDir()
	namespace := "namespace"

	pm, err := coretesting.GetPackageManager()
	c.Assert(err, jc.ErrorIsNil)
	testing.PatchExecutableAsEchoArgs(c, s, pm.PackageManager)

	s.data.SetStatus(mongo.ServiceName(namespace), "installed")
	failure := errors.New("won't start")
	s.data.SetErrors(nil, nil, nil, failure) // Installed, Exists, Running, Running, Start

	err = mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))

	c.Check(errors.Cause(err), gc.Equals, failure)
	c.Check(s.data.Installed(), gc.HasLen, 0)
	s.data.CheckCallNames(c, "Installed", "Exists", "Running", "Start")
}
开发者ID:imoapps,项目名称:juju,代码行数:18,代码来源:mongo_test.go


示例12: TestEnsureServerServerExistsNotRunningIsStarted

func (s *MongoSuite) TestEnsureServerServerExistsNotRunningIsStarted(c *gc.C) {
	dataDir := c.MkDir()
	namespace := "namespace"

	mockShellCommand(c, &s.CleanupSuite, "apt-get")

	s.data.SetStatus(mongo.ServiceName(namespace), "installed")

	err := mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))
	c.Assert(err, jc.ErrorIsNil)

	// These should still be written out even if the service was installed.
	s.assertSSLKeyFile(c, dataDir)
	s.assertSharedSecretFile(c, dataDir)
	s.assertMongoConfigFile(c)

	c.Check(s.data.Installed(), gc.HasLen, 0)
	s.data.CheckCallNames(c, "Installed", "Exists", "Running", "Start")
}
开发者ID:mhilton,项目名称:juju,代码行数:19,代码来源:mongo_test.go


示例13: TestInstallMongodServiceExists

func (s *MongoSuite) TestInstallMongodServiceExists(c *gc.C) {
	pm, err := coretesting.GetPackageManager()
	c.Assert(err, jc.ErrorIsNil)
	testing.PatchExecutableAsEchoArgs(c, s, pm.PackageManager)
	if pm.PackageManager == "yum" {
		testing.PatchExecutableAsEchoArgs(c, s, "chcon")
		testing.PatchExecutableAsEchoArgs(c, s, "semanage")
	}

	dataDir := c.MkDir()
	namespace := "namespace"

	s.data.SetStatus(mongo.ServiceName(namespace), "running")
	s.data.SetErrors(nil, nil, nil, errors.New("shouldn't be called"))

	err = mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))
	c.Assert(err, jc.ErrorIsNil)

	c.Check(s.data.Installed(), gc.HasLen, 0)
	s.data.CheckCallNames(c, "Installed", "Exists", "Running")
}
开发者ID:imoapps,项目名称:juju,代码行数:21,代码来源:mongo_test.go


示例14: TestEnsureServerServerExistsNotRunningIsStarted

func (s *MongoSuite) TestEnsureServerServerExistsNotRunningIsStarted(c *gc.C) {
	dataDir := c.MkDir()
	namespace := "namespace"

	pm, err := coretesting.GetPackageManager()
	c.Assert(err, jc.ErrorIsNil)
	testing.PatchExecutableAsEchoArgs(c, s, pm.PackageManager)

	s.data.SetStatus(mongo.ServiceName(namespace), "installed")

	err = mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))
	c.Assert(err, jc.ErrorIsNil)

	// These should still be written out even if the service was installed.
	s.assertSSLKeyFile(c, dataDir)
	s.assertSharedSecretFile(c, dataDir)
	s.assertMongoConfigFile(c)

	c.Check(s.data.Installed(), gc.HasLen, 0)
	s.data.CheckCallNames(c, "Installed", "Exists", "Running", "Start")
}
开发者ID:imoapps,项目名称:juju,代码行数:21,代码来源:mongo_test.go


示例15: TestMongoAptGetFails

func (s *MongoSuite) TestMongoAptGetFails(c *gc.C) {
	s.PatchValue(&version.Current.Series, "trusty")

	// Any exit code from apt-get that isn't 0 or 100 will be treated
	// as unexpected, skipping the normal retry loop. failCmd causes
	// the command to exit with 1.
	binDir := c.MkDir()
	s.PatchEnvPathPrepend(binDir)
	failCmd(filepath.Join(binDir, "apt-get"))

	// Set the mongodb service as installed but not running.
	namespace := "namespace"
	s.data.SetStatus(mongo.ServiceName(namespace), "installed")

	var tw loggo.TestWriter
	c.Assert(loggo.RegisterWriter("test-writer", &tw, loggo.ERROR), jc.ErrorIsNil)
	defer loggo.RemoveWriter("test-writer")

	dataDir := c.MkDir()
	err := mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))

	// Even though apt-get failed, EnsureServer should continue and
	// not return the error - even though apt-get failed, the Juju
	// mongodb package is most likely already installed.
	// The error should be logged however.
	c.Assert(err, jc.ErrorIsNil)

	c.Check(tw.Log(), jc.LogMatches, []jc.SimpleMessage{
		{loggo.ERROR, `packaging command failed: .+`},
		{loggo.ERROR, `cannot install/upgrade mongod \(will proceed anyway\): packaging command failed`},
	})

	// Verify that EnsureServer continued and started the mongodb service.
	c.Check(s.data.Installed(), gc.HasLen, 0)
	s.data.CheckCallNames(c, "Installed", "Exists", "Running", "Start")
}
开发者ID:Pankov404,项目名称:juju,代码行数:36,代码来源:mongo_test.go


示例16: TestServiceName

func (s *MongoSuite) TestServiceName(c *gc.C) {
	name := mongo.ServiceName("foo")
	c.Assert(name, gc.Equals, "juju-db-foo")
	name = mongo.ServiceName("")
	c.Assert(name, gc.Equals, "juju-db")
}
开发者ID:kapilt,项目名称:juju,代码行数:6,代码来源:mongo_test.go



注:本文中的github.com/juju/juju/mongo.ServiceName函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang mongo.SetAdminMongoPassword函数代码示例发布时间:2022-05-23
下一篇:
Golang mongo.SelectPeerAddress函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap