1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
"github.com/juju/errors"
11
"github.com/lxc/lxd/shared"
14
type rawServerConfigClient interface {
15
SetServerConfig(key string, value string) (*lxd.Response, error)
17
WaitForSuccess(waitURL string) error
18
ServerStatus() (*shared.ServerState, error)
21
type serverConfigClient struct {
22
raw rawServerConfigClient
25
// SetConfig sets the given value in the server's config.
26
func (c serverConfigClient) SetConfig(key, value string) error {
27
resp, err := c.raw.SetServerConfig(key, value)
29
return errors.Trace(err)
32
if resp.Operation != "" {
33
if err := c.raw.WaitForSuccess(resp.Operation); err != nil {
34
// TODO(ericsnow) Handle different failures (from the async
35
// operation) differently?
36
return errors.Trace(err)
43
func (c serverConfigClient) ServerStatus() (*shared.ServerState, error) {
44
return c.raw.ServerStatus()