Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b341744

Browse filesBrowse files
Merge pull request #3214 from gophercloud/bp-v2-2b109d7
[v2] [manila] add scheduler_hints to the shares CreateOpts
2 parents 75a970d + 9c67060 commit b341744
Copy full SHA for b341744

File tree

3 files changed

+38
-3
lines changed
Filter options

3 files changed

+38
-3
lines changed

‎openstack/sharedfilesystems/v2/shares/requests.go

Copy file name to clipboardExpand all lines: openstack/sharedfilesystems/v2/shares/requests.go
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ import (
77
"github.com/gophercloud/gophercloud/v2/pagination"
88
)
99

10+
// SchedulerHints contains options for providing scheduler hints when creating
11+
// a Share.
12+
type SchedulerHints struct {
13+
// DifferentHost will place the share on a different back-end that does not
14+
// host the given shares.
15+
DifferentHost string `json:"different_host,omitempty"`
16+
17+
// SameHost will place the share on a back-end that hosts the given shares.
18+
SameHost string `json:"same_host,omitempty"`
19+
20+
// OnlyHost value must be a manage-share service host in
21+
// host@backend#POOL format (admin only). Only available in and beyond
22+
// API version 2.67
23+
OnlyHost string `json:"only_host,omitempty"`
24+
}
25+
1026
// CreateOptsBuilder allows extensions to add additional parameters to the
1127
// Create request.
1228
type CreateOptsBuilder interface {
@@ -48,6 +64,9 @@ type CreateOpts struct {
4864
ConsistencyGroupID string `json:"consistency_group_id,omitempty"`
4965
// The availability zone of the share
5066
AvailabilityZone string `json:"availability_zone,omitempty"`
67+
// SchedulerHints are hints for the scheduler to select the share backend
68+
// Only available in and beyond API version 2.65
69+
SchedulerHints *SchedulerHints `json:"scheduler_hints,omitempty"`
5170
}
5271

5372
// ToShareCreateMap assembles a request body based on the contents of a

‎openstack/sharedfilesystems/v2/shares/testing/fixtures_test.go

Copy file name to clipboardExpand all lines: openstack/sharedfilesystems/v2/shares/testing/fixtures_test.go
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ var createRequest = `{
1818
"share": {
1919
"name": "my_test_share",
2020
"size": 1,
21-
"share_proto": "NFS"
21+
"share_proto": "NFS",
22+
"scheduler_hints": {
23+
"same_host": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef",
24+
"different_host": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef"
25+
}
2226
}
2327
}`
2428

@@ -61,7 +65,9 @@ var createResponse = `{
6165
"is_public": true,
6266
"metadata": {
6367
"project": "my_app",
64-
"aim": "doc"
68+
"aim": "doc",
69+
"__affinity_same_host": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef",
70+
"__affinity_different_host": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef"
6571
},
6672
"id": "011d21e2-fbc3-4e4a-9993-9ea223f73264",
6773
"description": "My custom share London"

‎openstack/sharedfilesystems/v2/shares/testing/request_test.go

Copy file name to clipboardExpand all lines: openstack/sharedfilesystems/v2/shares/testing/request_test.go
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,23 @@ func TestCreate(t *testing.T) {
1616

1717
MockCreateResponse(t)
1818

19-
options := &shares.CreateOpts{Size: 1, Name: "my_test_share", ShareProto: "NFS"}
19+
options := &shares.CreateOpts{
20+
Size: 1,
21+
Name: "my_test_share",
22+
ShareProto: "NFS",
23+
SchedulerHints: &shares.SchedulerHints{
24+
SameHost: "e268f4aa-d571-43dd-9ab3-f49ad06ffaef",
25+
DifferentHost: "e268f4aa-d571-43dd-9ab3-f49ad06ffaef",
26+
},
27+
}
2028
n, err := shares.Create(context.TODO(), client.ServiceClient(), options).Extract()
2129

2230
th.AssertNoErr(t, err)
2331
th.AssertEquals(t, n.Name, "my_test_share")
2432
th.AssertEquals(t, n.Size, 1)
2533
th.AssertEquals(t, n.ShareProto, "NFS")
34+
th.AssertEquals(t, n.Metadata["__affinity_same_host"], "e268f4aa-d571-43dd-9ab3-f49ad06ffaef")
35+
th.AssertEquals(t, n.Metadata["__affinity_different_host"], "e268f4aa-d571-43dd-9ab3-f49ad06ffaef")
2636
}
2737

2838
func TestUpdate(t *testing.T) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.