Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion kitchen-openstack.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

lib = File.expand_path("../lib", __FILE__)
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "kitchen/driver/openstack_version"

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