15
15
"github.com/juju/juju/api/common"
16
16
"github.com/juju/juju/api/common/cloudspec"
17
17
"github.com/juju/juju/apiserver/params"
18
"github.com/juju/juju/core/description"
18
"github.com/juju/juju/environs"
19
"github.com/juju/juju/permission"
21
22
// Client provides methods that the Juju client command uses to interact
79
// HostedConfig contains the model config and the cloud spec for that
80
// model such that direct access to the provider can be used.
81
type HostedConfig struct {
84
Config map[string]interface{}
85
CloudSpec environs.CloudSpec
89
// HostedModelsConfig returns all model settings for the
91
func (c *Client) HostedModelConfigs() ([]HostedConfig, error) {
92
result := params.HostedModelConfigsResults{}
93
err := c.facade.FacadeCall("HostedModelConfigs", nil, &result)
95
return nil, errors.Trace(err)
97
// If we get to here, we have some values. Each value may or
98
// may not have an error, but it should at least have a name
100
hostedConfigs := make([]HostedConfig, len(result.Models))
101
for i, modelConfig := range result.Models {
102
hostedConfigs[i].Name = modelConfig.Name
103
tag, err := names.ParseUserTag(modelConfig.OwnerTag)
105
hostedConfigs[i].Error = errors.Trace(err)
108
hostedConfigs[i].Owner = tag
109
if modelConfig.Error != nil {
110
hostedConfigs[i].Error = errors.Trace(modelConfig.Error)
113
hostedConfigs[i].Config = modelConfig.Config
114
spec, err := c.MakeCloudSpec(modelConfig.CloudSpec)
116
hostedConfigs[i].Error = errors.Trace(err)
119
hostedConfigs[i].CloudSpec = spec
121
return hostedConfigs, err
78
124
// DestroyController puts the controller model into a "dying" state,
79
125
// and removes all non-manager machine instances. Underlying DestroyModel
80
126
// calls will fail if there are any manually-provisioned non-manager machines
138
184
results[i] = base.ModelStatus{
139
185
UUID: model.Id(),
186
Life: string(r.Life),
141
187
Owner: owner.Canonical(),
142
188
HostedMachineCount: r.HostedMachineCount,
143
189
ServiceCount: r.ApplicationCount,
199
245
// GetControllerAccess returns the access level the user has on the controller.
200
func (c *Client) GetControllerAccess(user string) (description.Access, error) {
246
func (c *Client) GetControllerAccess(user string) (permission.Access, error) {
201
247
if !names.IsValidUser(user) {
202
248
return "", errors.Errorf("invalid username: %q", user)
213
259
if err := results.Results[0].Error; err != nil {
214
260
return "", errors.Trace(err)
216
return description.Access(results.Results[0].Result.Access), nil
262
return permission.Access(results.Results[0].Result.Access), nil
219
265
// MigrationSpec holds the details required to start the migration of
220
266
// a single model.
221
267
type MigrationSpec struct {
224
269
TargetControllerUUID string
225
270
TargetAddrs []string
226
271
TargetCACert string
227
272
TargetUser string
228
273
TargetPassword string
229
274
TargetMacaroons []macaroon.Slice
276
SkipInitialPrechecks bool
232
279
// Validate performs sanity checks on the migration configuration it
273
320
Specs: []params.MigrationSpec{{
274
321
ModelTag: names.NewModelTag(spec.ModelUUID).String(),
275
322
TargetInfo: params.MigrationTargetInfo{
276
ControllerTag: names.NewModelTag(spec.TargetControllerUUID).String(),
323
ControllerTag: names.NewControllerTag(spec.TargetControllerUUID).String(),
277
324
Addrs: spec.TargetAddrs,
278
325
CACert: spec.TargetCACert,
279
326
AuthTag: names.NewUserTag(spec.TargetUser).String(),
280
327
Password: spec.TargetPassword,
281
328
Macaroons: string(macsJSON),
283
ExternalControl: spec.ExternalControl,
330
ExternalControl: spec.ExternalControl,
331
SkipInitialPrechecks: spec.SkipInitialPrechecks,
286
334
response := params.InitiateMigrationResults{}