Merge lp:~axwalk/juju-core/apihostports-api into lp:~go-bot/juju-core/trunk

Proposed by Andrew Wilkins
Status: Merged
Approved by: Andrew Wilkins
Approved revision: no longer in the source branch.
Merged at revision: 2503
Proposed branch: lp:~axwalk/juju-core/apihostports-api
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 103 lines (+57/-7)
5 files modified
state/api/client.go (+9/-0)
state/api/params/internal.go (+0/-7)
state/api/params/params.go (+7/-0)
state/apiserver/client/client.go (+8/-0)
state/apiserver/client/client_test.go (+33/-0)
To merge this branch: bzr merge lp:~axwalk/juju-core/apihostports-api
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+213200@code.launchpad.net

Commit message

Introduce APIHostPorts client API

I've added a APIHostPorts client API,
to allow clients to discover addresses
for additional API servers. There already
existed an internal API of the same name,
so I moved the result struct from
internal.go and reused it.

https://codereview.appspot.com/81340045/

Description of the change

Introduce APIHostPorts client API

I've added a APIHostPorts client API,
to allow clients to discover addresses
for additional API servers. There already
existed an internal API of the same name,
so I moved the result struct from
internal.go and reused it.

https://codereview.appspot.com/81340045/

To post a comment you must log in.
Revision history for this message
Andrew Wilkins (axwalk) wrote :
Download full text (4.5 KiB)

Reviewers: mp+213200_code.launchpad.net,

Message:
Please take a look.

Description:
Introduce APIHostPorts client API

I've added a APIHostPorts client API,
to allow clients to discover addresses
for additional API servers. There already
existed an internal API of the same name,
so I moved the result struct from
internal.go and reused it.

https://code.launchpad.net/~axwalk/juju-core/apihostports-api/+merge/213200

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/81340045/

Affected files (+59, -7 lines):
   A [revision details]
   M state/api/client.go
   M state/api/params/internal.go
   M state/api/params/params.go
   M state/apiserver/client/client.go
   M state/apiserver/client/client_test.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20140327203820-qrgltgfsli0ff9ci
+New revision: <email address hidden>

Index: state/api/client.go
=== modified file 'state/api/client.go'
--- state/api/client.go 2014-03-26 17:19:35 +0000
+++ state/api/client.go 2014-03-28 05:59:48 +0000
@@ -666,3 +666,12 @@
   }
   return jsonResponse.Tools, nil
  }
+
+// APIHostPorts returns a slice of instance.HostPort for each API server.
+func (c *Client) APIHostPorts() ([][]instance.HostPort, error) {
+ var result params.APIHostPortsResult
+ if err := c.call("APIHostPorts", nil, &result); err != nil {
+ return nil, err
+ }
+ return result.Servers, nil
+}

Index: state/api/params/internal.go
=== modified file 'state/api/params/internal.go'
--- state/api/params/internal.go 2014-03-26 04:13:52 +0000
+++ state/api/params/internal.go 2014-03-28 05:59:48 +0000
@@ -532,10 +532,3 @@
  type RunResults struct {
   Results []RunResult
  }
-
-// APIHostPortsResult holds the result of an APIHostPorts
-// call. Each element in the top level slice holds
-// the addresses for one API server.
-type APIHostPortsResult struct {
- Servers [][]instance.HostPort
-}

Index: state/api/params/params.go
=== modified file 'state/api/params/params.go'
--- state/api/params/params.go 2014-03-27 12:53:54 +0000
+++ state/api/params/params.go 2014-03-28 05:59:48 +0000
@@ -632,3 +632,10 @@
  type SetRsyslogCertParams struct {
   CACert []byte
  }
+
+// APIHostPortsResult holds the result of an APIHostPorts
+// call. Each element in the top level slice holds
+// the addresses for one API server.
+type APIHostPortsResult struct {
+ Servers [][]instance.HostPort
+}

Index: state/apiserver/client/client.go
=== modified file 'state/apiserver/client/client.go'
--- state/apiserver/client/client.go 2014-03-26 13:40:28 +0000
+++ state/apiserver/client/client.go 2014-03-28 05:59:48 +0000
@@ -976,3 +976,11 @@
    Entities: entityStatus,
   })
  }
+
+// APIHostPOrts returns the API host/port addresses stored in state.
+func (c *Client) APIHostPorts() (result params.APIHostPortsResult, err
error) {
+ if result.Servers, err = c.api.state.APIHostPorts(); err != nil {
+ return params.APIHostPortsResult{}, err
+ }
+ return result, nil
+}

Index: state/apiserver/cli...

Read more...

Revision history for this message
Roger Peppe (rogpeppe) wrote :

On 2014/03/28 06:17:37, axw wrote:
> Please take a look.

LGTM

https://codereview.appspot.com/81340045/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'state/api/client.go'
2--- state/api/client.go 2014-03-26 17:19:35 +0000
3+++ state/api/client.go 2014-03-28 06:14:33 +0000
4@@ -666,3 +666,12 @@
5 }
6 return jsonResponse.Tools, nil
7 }
8+
9+// APIHostPorts returns a slice of instance.HostPort for each API server.
10+func (c *Client) APIHostPorts() ([][]instance.HostPort, error) {
11+ var result params.APIHostPortsResult
12+ if err := c.call("APIHostPorts", nil, &result); err != nil {
13+ return nil, err
14+ }
15+ return result.Servers, nil
16+}
17
18=== modified file 'state/api/params/internal.go'
19--- state/api/params/internal.go 2014-03-26 04:13:52 +0000
20+++ state/api/params/internal.go 2014-03-28 06:14:33 +0000
21@@ -532,10 +532,3 @@
22 type RunResults struct {
23 Results []RunResult
24 }
25-
26-// APIHostPortsResult holds the result of an APIHostPorts
27-// call. Each element in the top level slice holds
28-// the addresses for one API server.
29-type APIHostPortsResult struct {
30- Servers [][]instance.HostPort
31-}
32
33=== modified file 'state/api/params/params.go'
34--- state/api/params/params.go 2014-03-27 12:53:54 +0000
35+++ state/api/params/params.go 2014-03-28 06:14:33 +0000
36@@ -632,3 +632,10 @@
37 type SetRsyslogCertParams struct {
38 CACert []byte
39 }
40+
41+// APIHostPortsResult holds the result of an APIHostPorts
42+// call. Each element in the top level slice holds
43+// the addresses for one API server.
44+type APIHostPortsResult struct {
45+ Servers [][]instance.HostPort
46+}
47
48=== modified file 'state/apiserver/client/client.go'
49--- state/apiserver/client/client.go 2014-03-26 13:40:28 +0000
50+++ state/apiserver/client/client.go 2014-03-28 06:14:33 +0000
51@@ -976,3 +976,11 @@
52 Entities: entityStatus,
53 })
54 }
55+
56+// APIHostPOrts returns the API host/port addresses stored in state.
57+func (c *Client) APIHostPorts() (result params.APIHostPortsResult, err error) {
58+ if result.Servers, err = c.api.state.APIHostPorts(); err != nil {
59+ return params.APIHostPortsResult{}, err
60+ }
61+ return result, nil
62+}
63
64=== modified file 'state/apiserver/client/client_test.go'
65--- state/apiserver/client/client_test.go 2014-03-26 17:19:35 +0000
66+++ state/apiserver/client/client_test.go 2014-03-28 06:14:33 +0000
67@@ -2082,3 +2082,36 @@
68 c.Assert(info, gc.Equals, "error")
69 c.Assert(data["transient"], gc.Equals, true)
70 }
71+
72+func (s *clientSuite) TestAPIHostPorts(c *gc.C) {
73+ apiHostPorts, err := s.APIState.Client().APIHostPorts()
74+ c.Assert(err, gc.IsNil)
75+ c.Assert(apiHostPorts, gc.HasLen, 0)
76+
77+ server1Addresses := []instance.Address{{
78+ Value: "server-1",
79+ Type: instance.HostName,
80+ NetworkScope: instance.NetworkPublic,
81+ }, {
82+ Value: "10.0.0.1",
83+ Type: instance.Ipv4Address,
84+ NetworkName: "internal",
85+ NetworkScope: instance.NetworkCloudLocal,
86+ }}
87+ server2Addresses := []instance.Address{{
88+ Value: "::1",
89+ Type: instance.Ipv6Address,
90+ NetworkName: "loopback",
91+ NetworkScope: instance.NetworkMachineLocal,
92+ }}
93+ stateAPIHostPorts := [][]instance.HostPort{
94+ instance.AddressesWithPort(server1Addresses, 123),
95+ instance.AddressesWithPort(server2Addresses, 456),
96+ }
97+
98+ err = s.State.SetAPIHostPorts(stateAPIHostPorts)
99+ c.Assert(err, gc.IsNil)
100+ apiHostPorts, err = s.APIState.Client().APIHostPorts()
101+ c.Assert(err, gc.IsNil)
102+ c.Assert(apiHostPorts, gc.DeepEquals, stateAPIHostPorts)
103+}

Subscribers

People subscribed via source and target branches

to status/vote changes: