本文整理汇总了Golang中github.com/juju/juju/api.Connection.Rsyslog方法的典型用法代码示例。如果您正苦于以下问题:Golang Connection.Rsyslog方法的具体用法?Golang Connection.Rsyslog怎么用?Golang Connection.Rsyslog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/api.Connection
的用法示例。
在下文中一共展示了Connection.Rsyslog方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testNamespace
// testNamespace starts a worker and ensures that
// the rsyslog config file has the expected filename,
// and the appropriate log dir is used.
func (s *RsyslogSuite) testNamespace(c *gc.C, st api.Connection, tag names.Tag, namespace, expectedFilename, expectedLogDir string) {
restarted := make(chan struct{}, 2) // once for create, once for teardown
s.PatchValue(rsyslog.RestartRsyslog, func() error {
restarted <- struct{}{}
return nil
})
err := os.MkdirAll(expectedLogDir, 0755)
c.Assert(err, jc.ErrorIsNil)
worker, err := rsyslog.NewRsyslogConfigWorker(st.Rsyslog(),
rsyslog.RsyslogModeAccumulate, tag, namespace, []string{"0.1.2.3"}, s.ConfDir())
c.Assert(err, jc.ErrorIsNil)
defer func() { c.Assert(worker.Wait(), gc.IsNil) }()
defer worker.Kill()
// change the API HostPorts to trigger an rsyslog restart
newHostPorts := network.NewHostPorts(6541, "127.0.0.1")
err = s.State.SetAPIHostPorts([][]network.HostPort{newHostPorts})
c.Assert(err, jc.ErrorIsNil)
// Wait for rsyslog to be restarted, so we can check to see
// what the name of the config file is.
waitForRestart(c, restarted)
// Ensure that ca-cert.pem gets written to the expected log dir.
dirname := filepath.Join(s.ConfDir(), "rsyslog")
waitForFile(c, filepath.Join(dirname, "ca-cert.pem"))
dir, err := os.Open(*rsyslog.RsyslogConfDir)
c.Assert(err, jc.ErrorIsNil)
names, err := dir.Readdirnames(-1)
dir.Close()
c.Assert(err, jc.ErrorIsNil)
c.Assert(names, gc.HasLen, 1)
c.Assert(names[0], gc.Equals, expectedFilename)
}