Skip to content

Commit

Permalink
Implement support for passing scheduler hints
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Raits <i.gnatenko.brain@gmail.com>
  • Loading branch information
ignatenkobrain committed Oct 4, 2020
1 parent c27b941 commit 258798f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,20 @@ If your vms require config drive.
config_drive: true
```
### scheduler\_hints
If you wish to pass any scheduler hints.
```
scheduler_hints:
group: b0f6f534-3a02-4dfa-9165-605446799cc0
query: >-
["or",
["=", "$host", "cmp123.example.com"],
["=", "$host", "cmp456.example.com"]
]
```
### network\_ref
**Deprecated** A list of network names to create instances with.
Expand Down
6 changes: 6 additions & 0 deletions lib/kitchen/driver/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ def create_server
server_def[c] = optional_config(c) if config[c]
end

if config[:scheduler_hints]
server_def["os:scheduler_hints"] = optional_config(:scheduler_hints)
end

# Can't use the Fog bootstrap and/or setup methods here; they require a
# public IP address that can't be guaranteed to exist across all
# OpenStack deployments (e.g. TryStack ARM only has private IPs).
Expand All @@ -224,6 +228,8 @@ def optional_config(c)
config[c] if config[c].is_a?(Array)
when :user_data
File.open(config[c], &:read) if File.exist?(config[c])
when :scheduler_hints
config[c] if config[c].is_a?(Hash)
else
config[c]
end
Expand Down
29 changes: 29 additions & 0 deletions spec/kitchen/driver/openstack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,35 @@
end
end

context "scheduler_hints specified" do
let(:config) do
{
server_name: "hello",
image_ref: "111",
flavor_ref: "1",
scheduler_hints: {
group: "3df3519e-0e22-4d14-8c6a-afd8e4467b4b",
},
}
end
let(:data) do
{
group: "3df3519e-0e22-4d14-8c6a-afd8e4467b4b",
}
end

it "passes scheduler_hints contents" do
expect(servers).to receive(:create).with(
name: "hello",
image_ref: "111",
flavor_ref: "1",
availability_zone: nil,
"os:scheduler_hints" => data
)
driver.send(:create_server)
end
end

context "image_id specified" do
let(:config) do
{
Expand Down

0 comments on commit 258798f

Please sign in to comment.