本文整理汇总了Golang中github.com/juju/juju/state/api.State类的典型用法代码示例。如果您正苦于以下问题:Golang State类的具体用法?Golang State怎么用?Golang State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了State类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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.State, 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, gc.IsNil)
worker, err := rsyslog.NewRsyslogConfigWorker(st.Rsyslog(), rsyslog.RsyslogModeForwarding, tag, namespace, []string{"0.1.2.3"})
c.Assert(err, gc.IsNil)
defer func() { c.Assert(worker.Wait(), gc.IsNil) }()
defer worker.Kill()
// change the API HostPorts to trigger an rsyslog restart
newHostPorts := network.AddressesWithPort(network.NewAddresses("127.0.0.1"), 6541)
err = s.State.SetAPIHostPorts([][]network.HostPort{newHostPorts})
c.Assert(err, gc.IsNil)
// 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.
waitForFile(c, filepath.Join(expectedLogDir, "ca-cert.pem"))
dir, err := os.Open(*rsyslog.RsyslogConfDir)
c.Assert(err, gc.IsNil)
names, err := dir.Readdirnames(-1)
dir.Close()
c.Assert(err, gc.IsNil)
c.Assert(names, gc.HasLen, 1)
c.Assert(names[0], gc.Equals, expectedFilename)
}
开发者ID:,项目名称:,代码行数:37,代码来源:
示例2: opClientServiceSetCharm
func opClientServiceSetCharm(c *gc.C, st *api.State, mst *state.State) (func(), error) {
err := st.Client().ServiceSetCharm("nosuch", "local:quantal/wordpress", false)
if params.IsCodeNotFound(err) {
err = nil
}
return func() {}, err
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:perm_test.go
示例3: opClientAddServiceUnits
func opClientAddServiceUnits(c *gc.C, st *api.State, mst *state.State) (func(), error) {
_, err := st.Client().AddServiceUnits("nosuch", 1, "")
if params.IsCodeNotFound(err) {
err = nil
}
return func() {}, err
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:perm_test.go
示例4: opClientServiceUnexpose
func opClientServiceUnexpose(c *gc.C, st *api.State, mst *state.State) (func(), error) {
err := st.Client().ServiceUnexpose("wordpress")
if err != nil {
return func() {}, err
}
return func() {}, nil
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:perm_test.go
示例5: opClientDestroyServiceUnits
func opClientDestroyServiceUnits(c *gc.C, st *api.State, mst *state.State) (func(), error) {
err := st.Client().DestroyServiceUnits("wordpress/99")
if err != nil && strings.HasPrefix(err.Error(), "no units were destroyed") {
err = nil
}
return func() {}, err
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:perm_test.go
示例6: opClientServiceSetYAML
func opClientServiceSetYAML(c *gc.C, st *api.State, mst *state.State) (func(), error) {
err := st.Client().ServiceSetYAML("wordpress", `"wordpress": {"blog-title": "foo"}`)
if err != nil {
return func() {}, err
}
return resetBlogTitle(c, st), nil
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:perm_test.go
示例7: opClientServiceDestroy
func opClientServiceDestroy(c *gc.C, st *api.State, mst *state.State) (func(), error) {
err := st.Client().ServiceDestroy("non-existent")
if params.IsCodeNotFound(err) {
err = nil
}
return func() {}, err
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:perm_test.go
示例8: opClientDestroyRelation
func opClientDestroyRelation(c *gc.C, st *api.State, mst *state.State) (func(), error) {
err := st.Client().DestroyRelation("nosuch1", "nosuch2")
if params.IsCodeNotFound(err) {
err = nil
}
return func() {}, err
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:perm_test.go
示例9: opClientEnvironmentGet
func opClientEnvironmentGet(c *gc.C, st *api.State, mst *state.State) (func(), error) {
_, err := st.Client().EnvironmentGet()
if err != nil {
return func() {}, err
}
return func() {}, nil
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:perm_test.go
示例10: opClientWatchAll
func opClientWatchAll(c *gc.C, st *api.State, mst *state.State) (func(), error) {
watcher, err := st.Client().WatchAll()
if err == nil {
watcher.Stop()
}
return func() {}, err
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:perm_test.go
示例11: opClientServiceDeployWithNetworks
func opClientServiceDeployWithNetworks(c *gc.C, st *api.State, mst *state.State) (func(), error) {
err := st.Client().ServiceDeployWithNetworks("mad:bad/url-1", "x", 1, "", constraints.Value{}, "", nil)
if err.Error() == `charm URL has invalid schema: "mad:bad/url-1"` {
err = nil
}
return func() {}, err
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:perm_test.go
示例12: restoreBootstrapMachine
func restoreBootstrapMachine(st *api.State, backupFile string, agentConf agentConfig) (addr string, err error) {
client := st.Client()
addr, err = client.PublicAddress("0")
if err != nil {
return "", fmt.Errorf("cannot get public address of bootstrap machine: %v", err)
}
paddr, err := client.PrivateAddress("0")
if err != nil {
return "", fmt.Errorf("cannot get private address of bootstrap machine: %v", err)
}
status, err := client.Status(nil)
if err != nil {
return "", fmt.Errorf("cannot get environment status: %v", err)
}
info, ok := status.Machines["0"]
if !ok {
return "", fmt.Errorf("cannot find bootstrap machine in status")
}
newInstId := instance.Id(info.InstanceId)
progress("copying backup file to bootstrap host")
if err := sendViaScp(backupFile, addr, "~/juju-backup.tgz"); err != nil {
return "", fmt.Errorf("cannot copy backup file to bootstrap instance: %v", err)
}
progress("updating bootstrap machine")
if err := runViaSsh(addr, updateBootstrapMachineScript(newInstId, agentConf, addr, paddr)); err != nil {
return "", fmt.Errorf("update script failed: %v", err)
}
return addr, nil
}
开发者ID:jiasir,项目名称:juju,代码行数:30,代码来源:restore.go
示例13: opClientGetAnnotations
func opClientGetAnnotations(c *gc.C, st *api.State, mst *state.State) (func(), error) {
ann, err := st.Client().GetAnnotations("service-wordpress")
if err != nil {
return func() {}, err
}
c.Assert(ann, gc.DeepEquals, make(map[string]string))
return func() {}, nil
}
开发者ID:klyachin,项目名称:juju,代码行数:8,代码来源:perm_test.go
示例14: resetBlogTitle
func resetBlogTitle(c *gc.C, st *api.State) func() {
return func() {
err := st.Client().ServiceSet("wordpress", map[string]string{
"blog-title": "",
})
c.Assert(err, gc.IsNil)
}
}
开发者ID:klyachin,项目名称:juju,代码行数:8,代码来源:perm_test.go
示例15: SetUpTest
func (s *loggerSuite) SetUpTest(c *gc.C) {
s.JujuConnSuite.SetUpTest(c)
var stateAPI *api.State
stateAPI, s.rawMachine = s.OpenAPIAsNewMachine(c)
// Create the logger facade.
s.logger = stateAPI.Logger()
c.Assert(s.logger, gc.NotNil)
}
开发者ID:rogpeppe,项目名称:juju,代码行数:8,代码来源:logger_test.go
示例16: SetUpTest
func (s *keyupdaterSuite) SetUpTest(c *gc.C) {
s.JujuConnSuite.SetUpTest(c)
var stateAPI *api.State
stateAPI, s.rawMachine = s.OpenAPIAsNewMachine(c)
c.Assert(stateAPI, gc.NotNil)
s.keyupdater = stateAPI.KeyUpdater()
c.Assert(s.keyupdater, gc.NotNil)
}
开发者ID:rogpeppe,项目名称:juju,代码行数:8,代码来源:authorisedkeys_test.go
示例17: opClientSetServiceConstraints
func opClientSetServiceConstraints(c *gc.C, st *api.State, mst *state.State) (func(), error) {
nullConstraints := constraints.Value{}
err := st.Client().SetServiceConstraints("wordpress", nullConstraints)
if err != nil {
return func() {}, err
}
return func() {}, nil
}
开发者ID:klyachin,项目名称:juju,代码行数:8,代码来源:perm_test.go
示例18: opClientSetEnvironmentConstraints
func opClientSetEnvironmentConstraints(c *gc.C, st *api.State, mst *state.State) (func(), error) {
nullConstraints := constraints.Value{}
err := st.Client().SetEnvironmentConstraints(nullConstraints)
if err != nil {
return func() {}, err
}
return func() {}, nil
}
开发者ID:klyachin,项目名称:juju,代码行数:8,代码来源:perm_test.go
示例19: opClientStatus
func opClientStatus(c *gc.C, st *api.State, mst *state.State) (func(), error) {
status, err := st.Client().Status(nil)
if err != nil {
c.Check(status, gc.IsNil)
return func() {}, err
}
c.Assert(status, jc.DeepEquals, scenarioStatus)
return func() {}, nil
}
开发者ID:klyachin,项目名称:juju,代码行数:9,代码来源:perm_test.go
示例20: opClientServiceSet
func opClientServiceSet(c *gc.C, st *api.State, mst *state.State) (func(), error) {
err := st.Client().ServiceSet("wordpress", map[string]string{
"blog-title": "foo",
})
if err != nil {
return func() {}, err
}
return resetBlogTitle(c, st), nil
}
开发者ID:klyachin,项目名称:juju,代码行数:9,代码来源:perm_test.go
注:本文中的github.com/juju/juju/state/api.State类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论