Exemplo n.º 1
0
func (s *SyslogConfigSuite) TestAccumulateConfigWrite(c *C) {
	syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine")
	syslogConfigRenderer.ConfigDir = s.configDir
	syslogConfigRenderer.ConfigFileName = "rsyslog.conf"
	s.assertRsyslogConfigPath(c, syslogConfigRenderer)
	err := syslogConfigRenderer.Write()
	c.Assert(err, IsNil)
	syslogConfData, err := ioutil.ReadFile(syslogConfigRenderer.ConfigFilePath())
	c.Assert(err, IsNil)
	c.Assert(string(syslogConfData), Equals, expectedAccumulateSyslogConf)
}
Exemplo n.º 2
0
func (cfg *MachineConfig) addLogging(c *cloudinit.Config) error {
	var configRenderer syslog.SyslogConfigRenderer
	if cfg.StateServer {
		configRenderer = syslog.NewAccumulateConfig(
			names.MachineTag(cfg.MachineId))
	} else {
		configRenderer = syslog.NewForwardConfig(
			names.MachineTag(cfg.MachineId), cfg.stateHostAddrs())
	}
	content, err := configRenderer.Render()
	if err != nil {
		return err
	}
	c.AddFile("/etc/rsyslog.d/25-juju.conf", string(content), 0600)
	c.AddRunCmd("restart rsyslog")
	return nil
}
Exemplo n.º 3
0
func (cfg *MachineConfig) addLogging(c *cloudinit.Config) error {
	var configRenderer syslog.SyslogConfigRenderer
	if cfg.StateServer {
		configRenderer = syslog.NewAccumulateConfig(
			state.MachineTag(cfg.MachineId))
	} else {
		configRenderer = syslog.NewForwardConfig(
			state.MachineTag(cfg.MachineId), cfg.stateHostAddrs())
	}
	content, err := configRenderer.Render()
	if err != nil {
		return err
	}
	addScripts(c,
		fmt.Sprintf("cat > /etc/rsyslog.d/25-juju.conf << 'EOF'\n%sEOF\n", string(content)),
	)
	c.AddRunCmd("restart rsyslog")
	return nil
}
Exemplo n.º 4
0
func (s *SyslogConfigSuite) TestAccumulateConfigRender(c *C) {
	syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine")
	s.assertRsyslogConfigContents(c, syslogConfigRenderer, expectedAccumulateSyslogConf)
}