14
14
"github.com/juju/juju/cmd/juju/controller"
15
15
"github.com/juju/juju/cmd/modelcmd"
16
"github.com/juju/juju/jujuclient"
16
17
"github.com/juju/juju/jujuclient/jujuclienttesting"
17
18
"github.com/juju/juju/testing"
26
27
func (s *ShowControllerSuite) TestShowOneControllerOneInStore(c *gc.C) {
27
28
s.controllersYaml = `controllers:
29
servers: [maas-1-05.cluster.mallards]
30
30
uuid: this-is-another-uuid
31
31
api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
32
32
ca-cert: this-is-another-ca-cert
36
36
s.expectedOutput = `
39
servers: [maas-1-05.cluster.mallards]
40
39
uuid: this-is-another-uuid
41
40
api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
42
41
ca-cert: this-is-another-ca-cert
62
61
func (s *ShowControllerSuite) TestShowControllerWithPasswords(c *gc.C) {
63
62
s.controllersYaml = `controllers:
65
servers: [maas-1-05.cluster.mallards]
66
64
uuid: this-is-another-uuid
67
65
api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
68
66
ca-cert: this-is-another-ca-cert
72
70
s.expectedOutput = `
75
servers: [maas-1-05.cluster.mallards]
76
73
uuid: this-is-another-uuid
77
74
api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
78
75
ca-cert: this-is-another-ca-cert
97
94
s.assertShowController(c, "local.mallards", "--show-passwords")
97
func (s *ShowControllerSuite) TestShowControllerWithBootstrapConfig(c *gc.C) {
98
s.controllersYaml = `controllers:
100
uuid: this-is-another-uuid
101
api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
102
ca-cert: this-is-another-ca-cert
104
store := s.createTestClientStore(c)
105
store.BootstrapConfig["local.mallards"] = jujuclient.BootstrapConfig{
106
Config: map[string]interface{}{
111
Credential: "my-credential",
113
CloudRegion: "mallards1",
114
CloudEndpoint: "http://mallards.local/MAAS",
120
uuid: this-is-another-uuid
121
api-endpoints: [this-is-another-of-many-api-endpoints, this-is-one-more-of-many-api-endpoints]
122
ca-cert: this-is-another-ca-cert
131
current-model: my-model
136
current-account: admin@local
143
endpoint: http://mallards.local/MAAS
144
credential: my-credential
147
s.assertShowController(c, "local.mallards")
100
150
func (s *ShowControllerSuite) TestShowOneControllerManyInStore(c *gc.C) {
101
151
s.createTestClientStore(c)
103
153
s.expectedOutput = `
106
servers: [instance-1-2-4.useast.aws.com]
107
156
uuid: this-is-the-aws-test-uuid
108
157
api-endpoints: [this-is-aws-test-of-many-api-endpoints]
109
158
ca-cert: this-is-aws-test-ca-cert
136
184
current-model: admin
137
185
local.mark-test-prodstack:
139
servers: [vm-23532.prodstack.canonical.com, great.test.server.hostname.co.nz]
140
187
uuid: this-is-a-uuid
141
188
api-endpoints: [this-is-one-of-many-api-endpoints]
142
189
ca-cert: this-is-a-ca-cert
152
199
s.createTestClientStore(c)
154
201
s.expectedOutput = `
155
{"local.aws-test":{"details":{"servers":["instance-1-2-4.useast.aws.com"],"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}}}
202
{"local.aws-test":{"details":{"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}}}
158
205
s.assertShowController(c, "--format", "json", "local.aws-test")
161
208
func (s *ShowControllerSuite) TestShowControllerJsonMany(c *gc.C) {
162
209
s.createTestClientStore(c)
163
210
s.expectedOutput = `
164
{"local.aws-test":{"details":{"servers":["instance-1-2-4.useast.aws.com"],"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}},"local.mark-test-prodstack":{"details":{"servers":["vm-23532.prodstack.canonical.com","great.test.server.hostname.co.nz"],"uuid":"this-is-a-uuid","api-endpoints":["this-is-one-of-many-api-endpoints"],"ca-cert":"this-is-a-ca-cert"},"accounts":{"admin@local":{"user":"admin@local"}}}}
211
{"local.aws-test":{"details":{"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}},"local.mark-test-prodstack":{"details":{"uuid":"this-is-a-uuid","api-endpoints":["this-is-one-of-many-api-endpoints"],"ca-cert":"this-is-a-ca-cert"},"accounts":{"admin@local":{"user":"admin@local"}}}}
166
213
s.assertShowController(c, "--format", "json", "local.aws-test", "local.mark-test-prodstack")
183
230
s.createTestClientStore(c)
185
232
s.expectedOutput = `
186
{"local.aws-test":{"details":{"servers":["instance-1-2-4.useast.aws.com"],"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}}}
233
{"local.aws-test":{"details":{"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"admin@local":{"user":"admin@local","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}}}
188
235
err := modelcmd.WriteCurrentController("local.aws-test")
189
236
c.Assert(err, jc.ErrorIsNil)