Exemple #1
0
func (*agentSuite) TestContainerAgentConf(c *gc.C) {
	dataDir := c.MkDir()
	logDir := c.MkDir()
	info := service.NewUnitAgentInfo("wordpress/0", dataDir, logDir)
	renderer, err := shell.NewRenderer("")
	c.Assert(err, jc.ErrorIsNil)
	conf := service.ContainerAgentConf(info, renderer, "cont")

	jujud := filepath.Join(dataDir, "tools", "unit-wordpress-0", "jujud"+cmdSuffix)
	cmd := strings.Join([]string{
		shquote(jujud),
		"unit",
		"--data-dir", shquote(dataDir),
		"--unit-name", "wordpress/0",
		"--debug",
	}, " ")
	serviceBinary := jujud
	serviceArgs := []string{
		"unit",
		"--data-dir", dataDir,
		"--unit-name", "wordpress/0",
		"--debug",
	}
	env := osenv.FeatureFlags()
	env[osenv.JujuContainerTypeEnvKey] = "cont"
	c.Check(conf, jc.DeepEquals, common.Conf{
		Desc:          "juju unit agent for wordpress/0",
		ExecStart:     cmd,
		Logfile:       filepath.Join(logDir, "unit-wordpress-0.log"),
		Env:           env,
		Timeout:       300,
		ServiceBinary: serviceBinary,
		ServiceArgs:   serviceArgs,
	})
}
Exemple #2
0
// service returns a service.Service corresponding to the specified
// unit.
func (ctx *SimpleContext) service(unitName string, renderer shell.Renderer) (deployerService, error) {
	tag := names.NewUnitTag(unitName).String()
	svcName := "jujud-" + tag

	info := service.NewAgentInfo(
		service.AgentKindUnit,
		unitName,
		ctx.agentConfig.DataDir(),
		ctx.agentConfig.LogDir(),
	)

	// TODO(thumper): 2013-09-02 bug 1219630
	// As much as I'd like to remove JujuContainerType now, it is still
	// needed as MAAS still needs it at this stage, and we can't fix
	// everything at once.
	containerType := ctx.agentConfig.Value(agent.ContainerType)

	conf := service.ContainerAgentConf(info, renderer, containerType)
	return ctx.discoverService(svcName, conf)
}