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) }
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 }
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 }
func (s *SyslogConfigSuite) TestAccumulateConfigRender(c *C) { syslogConfigRenderer := syslog.NewAccumulateConfig("some-machine") s.assertRsyslogConfigContents(c, syslogConfigRenderer, expectedAccumulateSyslogConf) }