Esempio n. 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,
	})
}
Esempio n. 2
0
// AgentConf returns the data that defines an init service config
// for the identified agent.
func AgentConf(info AgentInfo, renderer shell.Renderer) common.Conf {
	conf := common.Conf{
		Desc:          fmt.Sprintf("juju agent for %s", info.name),
		ExecStart:     info.cmd(renderer),
		Logfile:       info.logFile(renderer),
		Env:           osenv.FeatureFlags(),
		Timeout:       agentServiceTimeout,
		ServiceBinary: info.jujud(renderer),
		ServiceArgs:   info.execArgs(renderer),
	}

	switch info.Kind {
	case AgentKindMachine:
		conf.Limit = map[string]int{
			"nofile": maxAgentFiles,
		}
	case AgentKindUnit:
		conf.Desc = "juju unit agent for " + info.ID
	}

	return conf
}
Esempio n. 3
0
func (*agentSuite) TestAgentConfMachineLocal(c *gc.C) {
	// We use two distinct directories to ensure the paths don't get
	// mixed up during the call.
	dataDir := c.MkDir()
	logDir := c.MkDir()
	info := service.NewMachineAgentInfo("0", dataDir, logDir)
	renderer, err := shell.NewRenderer("")
	c.Assert(err, jc.ErrorIsNil)
	conf := service.AgentConf(info, renderer)

	jujud := filepath.Join(dataDir, "tools", "machine-0", "jujud"+cmdSuffix)
	cmd := strings.Join([]string{
		shquote(jujud),
		"machine",
		"--data-dir", shquote(dataDir),
		"--machine-id", "0",
		"--debug",
	}, " ")
	serviceBinary := jujud
	serviceArgs := []string{
		"machine",
		"--data-dir", dataDir,
		"--machine-id", "0",
		"--debug",
	}
	c.Check(conf, jc.DeepEquals, common.Conf{
		Desc:      "juju agent for machine-0",
		ExecStart: cmd,
		Logfile:   filepath.Join(logDir, "machine-0.log"),
		Env:       osenv.FeatureFlags(),
		Limit: map[string]int{
			"nofile": 20000,
		},
		Timeout:       300,
		ServiceBinary: serviceBinary,
		ServiceArgs:   serviceArgs,
	})
}
Esempio n. 4
0
func (*agentSuite) TestAgentConfMachineUbuntu(c *gc.C) {
	dataDir := "/var/lib/juju"
	logDir := "/var/log/juju"
	info := service.NewMachineAgentInfo("0", dataDir, logDir)
	renderer, err := shell.NewRenderer("ubuntu")
	c.Assert(err, jc.ErrorIsNil)
	conf := service.AgentConf(info, renderer)

	jujud := dataDir + "/tools/machine-0/jujud"
	cmd := strings.Join([]string{
		shquote(dataDir + "/tools/machine-0/jujud"),
		"machine",
		"--data-dir", shquote(dataDir),
		"--machine-id", "0",
		"--debug",
	}, " ")
	serviceBinary := jujud
	serviceArgs := []string{
		"machine",
		"--data-dir", dataDir,
		"--machine-id", "0",
		"--debug",
	}
	c.Check(conf, jc.DeepEquals, common.Conf{
		Desc:      "juju agent for machine-0",
		ExecStart: cmd,
		Logfile:   logDir + "/machine-0.log",
		Env:       osenv.FeatureFlags(),
		Limit: map[string]int{
			"nofile": 20000,
		},
		Timeout:       300,
		ServiceBinary: serviceBinary,
		ServiceArgs:   serviceArgs,
	})
}
Esempio n. 5
0
func (*agentSuite) TestAgentConfMachineWindows(c *gc.C) {
	dataDir := `C:\Juju\lib\juju`
	logDir := `C:\Juju\logs\juju`
	info := service.NewMachineAgentInfo("0", dataDir, logDir)
	renderer, err := shell.NewRenderer("windows")
	c.Assert(err, jc.ErrorIsNil)
	conf := service.AgentConf(info, renderer)

	jujud := dataDir + `\tools\machine-0\jujud.exe`
	cmd := strings.Join([]string{
		shquote(jujud),
		"machine",
		"--data-dir", shquote(dataDir),
		"--machine-id", "0",
		"--debug",
	}, " ")
	serviceBinary := jujud
	serviceArgs := []string{
		"machine",
		"--data-dir", dataDir,
		"--machine-id", "0",
		"--debug",
	}
	c.Check(conf, jc.DeepEquals, common.Conf{
		Desc:      "juju agent for machine-0",
		ExecStart: cmd,
		Logfile:   logDir + `\machine-0.log`,
		Env:       osenv.FeatureFlags(),
		Limit: map[string]int{
			"nofile": 20000,
		},
		Timeout:       300,
		ServiceBinary: serviceBinary,
		ServiceArgs:   serviceArgs,
	})
}