Skip to content

Commit 8ddcaf3

Browse files
Benjamin MaisonnasLudovic Lamarche
authored andcommitted
octavia: add DomainName and HTTPVersion on monitors (added in 2.10)
1 parent 8a454d9 commit 8ddcaf3

File tree

8 files changed

+83
-20
lines changed

8 files changed

+83
-20
lines changed

acceptance/openstack/loadbalancer/v2/loadbalancer.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ func CreateLoadBalancerFullyPopulated(t *testing.T, client *gophercloud.ServiceC
176176
memberName := tools.RandomString("TESTACCT-", 8)
177177
memberPort := tools.RandomInt(100, 1000)
178178
memberWeight := tools.RandomInt(1, 10)
179+
monitorDomainName := tools.RandomString("example.com", 8)
179180

180181
t.Logf("Attempting to create fully populated loadbalancer %s on subnet %s which contains listener: %s, l7Policy: %s, pool %s, member %s",
181182
lbName, subnetID, listenerName, policyName, poolName, memberName)
@@ -204,9 +205,11 @@ func CreateLoadBalancerFullyPopulated(t *testing.T, client *gophercloud.ServiceC
204205
}},
205206
Monitor: &monitors.CreateOpts{
206207
Delay: 10,
208+
DomainName: monitorDomainName,
207209
Timeout: 5,
208210
MaxRetries: 5,
209211
MaxRetriesDown: 4,
212+
HTTPVersion: 1.1,
210213
Type: monitors.TypeHTTP,
211214
},
212215
},
@@ -266,6 +269,8 @@ func CreateLoadBalancerFullyPopulated(t *testing.T, client *gophercloud.ServiceC
266269
th.AssertEquals(t, lb.Pools[0].Members[0].ProtocolPort, memberPort)
267270
th.AssertEquals(t, lb.Pools[0].Members[0].Weight, memberWeight)
268271

272+
th.AssertEquals(t, lb.Pools[0].Monitor.DomainName, monitorDomainName)
273+
269274
if len(tags) > 0 {
270275
th.AssertDeepEquals(t, lb.Tags, tags)
271276
}
@@ -323,9 +328,11 @@ func CreateMonitor(t *testing.T, client *gophercloud.ServiceClient, lb *loadbala
323328
PoolID: pool.ID,
324329
Name: monitorName,
325330
Delay: 10,
331+
DomainName: "example.com",
326332
Timeout: 5,
327333
MaxRetries: 5,
328334
MaxRetriesDown: 4,
335+
HTTPVersion: 1.1,
329336
Type: monitors.TypePING,
330337
}
331338

@@ -343,9 +350,11 @@ func CreateMonitor(t *testing.T, client *gophercloud.ServiceClient, lb *loadbala
343350
th.AssertEquals(t, monitor.Name, monitorName)
344351
th.AssertEquals(t, monitor.Type, monitors.TypePING)
345352
th.AssertEquals(t, monitor.Delay, 10)
353+
th.AssertEquals(t, monitor.DomainName, "example.com")
346354
th.AssertEquals(t, monitor.Timeout, 5)
347355
th.AssertEquals(t, monitor.MaxRetries, 5)
348356
th.AssertEquals(t, monitor.MaxRetriesDown, 4)
357+
th.AssertEquals(t, monitor.HTTPVersion, 1.1)
349358

350359
return monitor, nil
351360
}

openstack/loadbalancer/v2/loadbalancers/testing/fixtures.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,11 @@ const PostFullyPopulatedLoadbalancerBody = `
159159
"admin_state_up": true,
160160
"project_id": "e3cd678b11784734bc366148aa37580e",
161161
"delay": 3,
162+
"domain_name": "example.com",
162163
"expected_codes": "200,201,202",
163164
"max_retries": 2,
164165
"http_method": "GET",
166+
"http_version": 1.1,
165167
"timeout": 1,
166168
"max_retries_down": 3,
167169
"url_path": "/index.html",
@@ -382,8 +384,10 @@ var (
382384
Timeout: 1,
383385
MaxRetries: 2,
384386
Delay: 3,
387+
DomainName: "example.com",
385388
MaxRetriesDown: 3,
386389
HTTPMethod: "GET",
390+
HTTPVersion: 1.1,
387391
URLPath: "/index.html",
388392
ExpectedCodes: "200,201,202",
389393
AdminStateUp: true,
@@ -465,13 +469,15 @@ func HandleFullyPopulatedLoadbalancerCreationSuccessfully(t *testing.T, response
465469
"default_pool": {
466470
"healthmonitor": {
467471
"delay": 3,
472+
"domain_name": "example.com",
468473
"expected_codes": "200",
469474
"http_method": "GET",
470475
"max_retries": 2,
471476
"max_retries_down": 3,
472477
"name": "db",
473478
"timeout": 1,
474479
"type": "HTTP",
480+
"http_version": 1.1,
475481
"url_path": "/index.html"
476482
},
477483
"lb_algorithm": "ROUND_ROBIN",

openstack/loadbalancer/v2/loadbalancers/testing/requests_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,11 @@ func TestCreateFullyPopulatedLoadbalancer(t *testing.T) {
121121
Name: "db",
122122
Type: "HTTP",
123123
Delay: 3,
124+
DomainName: "example.com",
124125
Timeout: 1,
125126
MaxRetries: 2,
126127
MaxRetriesDown: 3,
128+
HTTPVersion: 1.1,
127129
URLPath: "/index.html",
128130
HTTPMethod: "GET",
129131
ExpectedCodes: "200",

openstack/loadbalancer/v2/monitors/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Example to Create a Monitor
2929
Name: "db",
3030
PoolID: "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d",
3131
Delay: 20,
32+
DomainName: "example.com",
3233
Timeout: 10,
3334
MaxRetries: 5,
3435
MaxRetriesDown: 4,
@@ -48,6 +49,7 @@ Example to Update a Monitor
4849
updateOpts := monitors.UpdateOpts{
4950
Name: "NewHealthmonitorName",
5051
Delay: 3,
52+
DomainName: "www.example.com",
5153
Timeout: 20,
5254
MaxRetries: 10,
5355
MaxRetriesDown: 8,

openstack/loadbalancer/v2/monitors/requests.go

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,27 @@ type ListOptsBuilder interface {
1919
// sort by a particular Monitor attribute. SortDir sets the direction, and is
2020
// either `asc' or `desc'. Marker and Limit are used for pagination.
2121
type ListOpts struct {
22-
ID string `q:"id"`
23-
Name string `q:"name"`
24-
TenantID string `q:"tenant_id"`
25-
ProjectID string `q:"project_id"`
26-
PoolID string `q:"pool_id"`
27-
Type string `q:"type"`
28-
Delay int `q:"delay"`
29-
Timeout int `q:"timeout"`
30-
MaxRetries int `q:"max_retries"`
31-
MaxRetriesDown int `q:"max_retries_down"`
32-
HTTPMethod string `q:"http_method"`
33-
URLPath string `q:"url_path"`
34-
ExpectedCodes string `q:"expected_codes"`
35-
AdminStateUp *bool `q:"admin_state_up"`
36-
Status string `q:"status"`
37-
Limit int `q:"limit"`
38-
Marker string `q:"marker"`
39-
SortKey string `q:"sort_key"`
40-
SortDir string `q:"sort_dir"`
22+
ID string `q:"id"`
23+
Name string `q:"name"`
24+
TenantID string `q:"tenant_id"`
25+
ProjectID string `q:"project_id"`
26+
PoolID string `q:"pool_id"`
27+
Type string `q:"type"`
28+
Delay int `q:"delay"`
29+
DomainName string `q:"domain_name"`
30+
Timeout int `q:"timeout"`
31+
MaxRetries int `q:"max_retries"`
32+
MaxRetriesDown int `q:"max_retries_down"`
33+
HTTPMethod string `q:"http_method"`
34+
HTTPVersion float32 `q:"http_version"`
35+
URLPath string `q:"url_path"`
36+
ExpectedCodes string `q:"expected_codes"`
37+
AdminStateUp *bool `q:"admin_state_up"`
38+
Status string `q:"status"`
39+
Limit int `q:"limit"`
40+
Marker string `q:"marker"`
41+
SortKey string `q:"sort_key"`
42+
SortDir string `q:"sort_dir"`
4143
}
4244

4345
// ToMonitorListQuery formats a ListOpts into a query string.
@@ -103,6 +105,10 @@ type CreateOpts struct {
103105
// The time, in seconds, between sending probes to members.
104106
Delay int `json:"delay" required:"true"`
105107

108+
// The domain name, which be injected into the HTTP Host Header to
109+
// the backend server for HTTP health check. New in version 2.10.
110+
DomainName string `json:"domain_name"`
111+
106112
// Maximum number of seconds for a Monitor to wait for a ping reply
107113
// before it times out. The value must be less than the delay value.
108114
Timeout int `json:"timeout" required:"true"`
@@ -111,7 +117,7 @@ type CreateOpts struct {
111117
// status to INACTIVE. Must be a number between 1 and 10.
112118
MaxRetries int `json:"max_retries" required:"true"`
113119

114-
// Number of permissible ping failures befor changing the member's
120+
// Number of permissible ping failures before changing the member's
115121
// status to ERROR. Must be a number between 1 and 10.
116122
MaxRetriesDown int `json:"max_retries_down,omitempty"`
117123

@@ -122,6 +128,10 @@ type CreateOpts struct {
122128
// is not specified, it defaults to "GET". Required for HTTP(S) types.
123129
HTTPMethod string `json:"http_method,omitempty"`
124130

131+
// The HTTP version used for requests by the Monitor. If this attribute
132+
// is not specified, it defaults to 1.0". Required for HTTP(S) types.
133+
HTTPVersion float32 `json:"http_version,omitempty"`
134+
125135
// Expected HTTP codes for a passing HTTP(S) Monitor. You can either specify
126136
// a single status like "200", a range like "200-202", or a combination like
127137
// "200-202, 401".
@@ -193,6 +203,10 @@ type UpdateOpts struct {
193203
// The time, in seconds, between sending probes to members.
194204
Delay int `json:"delay,omitempty"`
195205

206+
// The domain name, which be injected into the HTTP Host Header to
207+
// the backend server for HTTP health check. New in version 2.10.
208+
DomainName string `json:"domain_name"`
209+
196210
// Maximum number of seconds for a Monitor to wait for a ping reply
197211
// before it times out. The value must be less than the delay value.
198212
Timeout int `json:"timeout,omitempty"`
@@ -213,6 +227,10 @@ type UpdateOpts struct {
213227
// is not specified, it defaults to "GET". Required for HTTP(S) types.
214228
HTTPMethod string `json:"http_method,omitempty"`
215229

230+
// The HTTP version used for requests by the Monitor. If this attribute
231+
// is not specified, it defaults to 1.0". Required for HTTP(S) types.
232+
HTTPVersion float32 `json:"http_version,omitempty"`
233+
216234
// Expected HTTP codes for a passing HTTP(S) Monitor. You can either specify
217235
// a single status like "200", or a range like "200-202". Required for HTTP(S)
218236
// types.

openstack/loadbalancer/v2/monitors/results.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ type Monitor struct {
4444
// The time, in seconds, between sending probes to members.
4545
Delay int `json:"delay"`
4646

47+
// The domain name, which be injected into the HTTP Host Header to
48+
// the backend server for HTTP health check. New in version 2.10.
49+
DomainName string `json:"domain_name"`
50+
4751
// The maximum number of seconds for a monitor to wait for a connection to be
4852
// established before it times out. This value must be less than the delay
4953
// value.
@@ -60,6 +64,10 @@ type Monitor struct {
6064
// The HTTP method that the monitor uses for requests.
6165
HTTPMethod string `json:"http_method"`
6266

67+
// The HTTP version. One of 1.0 or 1.1. The default is 1.0.
68+
// New in version 2.10
69+
HTTPVersion float32 `json:"http_version"`
70+
6371
// The HTTP path of the request sent by the monitor to test the health of a
6472
// member. Must be a string beginning with a forward slash (/).
6573
URLPath string `json:"url_path" `

openstack/loadbalancer/v2/monitors/testing/fixtures.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ const HealthmonitorsListBody = `
3030
"admin_state_up":true,
3131
"project_id":"83657cfcdfe44cd5920adaf26c48ceea",
3232
"delay":5,
33+
"domain_name": "example.com",
3334
"name":"db",
3435
"expected_codes":"200",
3536
"max_retries":2,
3637
"max_retries_down":4,
3738
"http_method":"GET",
39+
"http_version": 1.1,
3840
"timeout":2,
3941
"url_path":"/",
4042
"type":"HTTP",
@@ -52,11 +54,13 @@ const SingleHealthmonitorBody = `
5254
"admin_state_up":true,
5355
"project_id":"83657cfcdfe44cd5920adaf26c48ceea",
5456
"delay":5,
57+
"domain_name": "example.com",
5558
"name":"db",
5659
"expected_codes":"200",
5760
"max_retries":2,
5861
"max_retries_down":4,
5962
"http_method":"GET",
63+
"http_version": 1.1,
6064
"timeout":2,
6165
"url_path":"/",
6266
"type":"HTTP",
@@ -73,11 +77,13 @@ const PostUpdateHealthmonitorBody = `
7377
"admin_state_up":true,
7478
"project_id":"83657cfcdfe44cd5920adaf26c48ceea",
7579
"delay":3,
80+
"domain_name": "www.example.com",
7681
"name":"NewHealthmonitorName",
7782
"expected_codes":"301",
7883
"max_retries":10,
7984
"max_retries_down":8,
8085
"http_method":"GET",
86+
"http_version": 1.0,
8187
"timeout":20,
8288
"url_path":"/another_check",
8389
"type":"HTTP",
@@ -105,13 +111,15 @@ var (
105111
Name: "db",
106112
ProjectID: "83657cfcdfe44cd5920adaf26c48ceea",
107113
Delay: 5,
114+
DomainName: "example.com",
108115
ExpectedCodes: "200",
109116
MaxRetries: 2,
110117
MaxRetriesDown: 4,
111118
Timeout: 2,
112119
URLPath: "/",
113120
Type: "HTTP",
114121
HTTPMethod: "GET",
122+
HTTPVersion: 1.1,
115123
ID: "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
116124
Pools: []monitors.PoolID{{ID: "d459f7d8-c6ee-439d-8713-d3fc08aeed8d"}},
117125
}
@@ -120,13 +128,15 @@ var (
120128
Name: "NewHealthmonitorName",
121129
ProjectID: "83657cfcdfe44cd5920adaf26c48ceea",
122130
Delay: 3,
131+
DomainName: "www.example.com",
123132
ExpectedCodes: "301",
124133
MaxRetries: 10,
125134
MaxRetriesDown: 8,
126135
Timeout: 20,
127136
URLPath: "/another_check",
128137
Type: "HTTP",
129138
HTTPMethod: "GET",
139+
HTTPVersion: 1.0,
130140
ID: "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
131141
Pools: []monitors.PoolID{{ID: "d459f7d8-c6ee-439d-8713-d3fc08aeed8d"}},
132142
}
@@ -164,10 +174,12 @@ func HandleHealthmonitorCreationSuccessfully(t *testing.T, response string) {
164174
"pool_id":"84f1b61f-58c4-45bf-a8a9-2dafb9e5214d",
165175
"project_id":"453105b9-1754-413f-aab1-55f1af620750",
166176
"delay":20,
177+
"domain_name": "example.com",
167178
"name":"db",
168179
"timeout":10,
169180
"max_retries":5,
170181
"max_retries_down":4,
182+
"http_version": 1.1,
171183
"url_path":"/check",
172184
"expected_codes":"200-299"
173185
}
@@ -211,9 +223,11 @@ func HandleHealthmonitorUpdateSuccessfully(t *testing.T) {
211223
"healthmonitor": {
212224
"name": "NewHealthmonitorName",
213225
"delay": 3,
226+
"domain_name": "www.example.com",
214227
"timeout": 20,
215228
"max_retries": 10,
216229
"max_retries_down": 8,
230+
"http_version": 1.0,
217231
"url_path": "/another_check",
218232
"expected_codes": "301"
219233
}

openstack/loadbalancer/v2/monitors/testing/requests_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ func TestCreateHealthmonitor(t *testing.T) {
6363
PoolID: "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d",
6464
ProjectID: "453105b9-1754-413f-aab1-55f1af620750",
6565
Delay: 20,
66+
DomainName: "example.com",
6667
Timeout: 10,
6768
MaxRetries: 5,
6869
MaxRetriesDown: 4,
70+
HTTPVersion: 1.1,
6971
URLPath: "/check",
7072
ExpectedCodes: "200-299",
7173
}).Extract()
@@ -118,9 +120,11 @@ func TestUpdateHealthmonitor(t *testing.T) {
118120
actual, err := monitors.Update(client, "5d4b5228-33b0-4e60-b225-9b727c1a20e7", monitors.UpdateOpts{
119121
Name: &name,
120122
Delay: 3,
123+
DomainName: "www.example.com",
121124
Timeout: 20,
122125
MaxRetries: 10,
123126
MaxRetriesDown: 8,
127+
HTTPVersion: 1.0,
124128
URLPath: "/another_check",
125129
ExpectedCodes: "301",
126130
}).Extract()

0 commit comments

Comments
 (0)