~james-page/ubuntu/wily/juju-core/mir-fixes

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/state/apiserver/client/client.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-03-28 08:58:42 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20140328085842-cyzrgc120bdfxwj0
Tags: 1.17.7-0ubuntu1
* New upstream point release, including fixes for:
  - no debug log with all providers on Ubuntu 14.04 (LP: #1294776).
* d/control: Add cpu-checker dependency to juju-local (LP: #1297077).

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
        resources *common.Resources
39
39
        client    *Client
40
40
        dataDir   string
 
41
        // statusSetter provides common methods for updating an entity's provisioning status.
 
42
        statusSetter *common.StatusSetter
41
43
}
42
44
 
43
45
// Client serves client-specific API methods.
48
50
// NewAPI creates a new instance of the Client API.
49
51
func NewAPI(st *state.State, resources *common.Resources, authorizer common.Authorizer, datadir string) *API {
50
52
        r := &API{
51
 
                state:     st,
52
 
                auth:      authorizer,
53
 
                resources: resources,
54
 
                dataDir:   datadir,
 
53
                state:        st,
 
54
                auth:         authorizer,
 
55
                resources:    resources,
 
56
                dataDir:      datadir,
 
57
                statusSetter: common.NewStatusSetter(st, common.AuthAlways(true)),
55
58
        }
56
59
        r.client = &Client{
57
60
                api: r,
279
282
 
280
283
        _, err = juju.DeployService(c.api.state,
281
284
                juju.DeployServiceParams{
282
 
                        ServiceName:    args.ServiceName,
283
 
                        Charm:          ch,
284
 
                        NumUnits:       args.NumUnits,
285
 
                        ConfigSettings: settings,
286
 
                        Constraints:    args.Constraints,
287
 
                        ToMachineSpec:  args.ToMachineSpec,
 
285
                        ServiceName:     args.ServiceName,
 
286
                        Charm:           ch,
 
287
                        NumUnits:        args.NumUnits,
 
288
                        ConfigSettings:  settings,
 
289
                        Constraints:     args.Constraints,
 
290
                        ToMachineSpec:   args.ToMachineSpec,
 
291
                        IncludeNetworks: args.IncludeNetworks,
 
292
                        ExcludeNetworks: args.ExcludeNetworks,
288
293
                })
289
294
        return err
290
295
}
291
296
 
 
297
// ServiceDeployWithNetworks works exactly like ServiceDeploy, but
 
298
// allows specifying networks to include or exclude on the machine
 
299
// where the charm gets deployed.
 
300
func (c *Client) ServiceDeployWithNetworks(args params.ServiceDeploy) error {
 
301
        return c.ServiceDeploy(args)
 
302
}
 
303
 
292
304
// ServiceUpdate updates the service attributes, including charm URL,
293
305
// minimum number of units, settings and constraints.
294
306
// All parameters in params.ServiceUpdate except the service name are optional.
799
811
                }
800
812
                return nil
801
813
        }
802
 
 
803
814
        // TODO(waigani) 2014-3-11 #1167616
804
815
        // Add a txn retry loop to ensure that the settings on disk have not
805
816
        // changed underneath us.
806
 
 
807
817
        return c.api.state.UpdateEnvironConfig(args.Config, nil, checkAgentVersion)
 
818
}
808
819
 
 
820
// EnvironmentUnset implements the server-side part of the
 
821
// set-environment CLI command.
 
822
func (c *Client) EnvironmentUnset(args params.EnvironmentUnset) error {
 
823
        // TODO(waigani) 2014-3-11 #1167616
 
824
        // Add a txn retry loop to ensure that the settings on disk have not
 
825
        // changed underneath us.
 
826
        return c.api.state.UpdateEnvironConfig(nil, args.Keys, nil)
809
827
}
810
828
 
811
829
// SetEnvironAgentVersion sets the environment agent version.
947
965
        }
948
966
        return charm.Quote(fmt.Sprintf("%s-%d-%s", name, revision, uuid)), nil
949
967
}
 
968
 
 
969
// RetryProvisioning marks a provisioning error as transient on the machines.
 
970
func (c *Client) RetryProvisioning(p params.Entities) (params.ErrorResults, error) {
 
971
        entityStatus := make([]params.EntityStatus, len(p.Entities))
 
972
        for i, entity := range p.Entities {
 
973
                entityStatus[i] = params.EntityStatus{Tag: entity.Tag, Data: params.StatusData{"transient": true}}
 
974
        }
 
975
        return c.api.statusSetter.UpdateStatus(params.SetStatus{
 
976
                Entities: entityStatus,
 
977
        })
 
978
}