Skip to content

Commit

Permalink
Merge 2737746 into 3e842c7
Browse files Browse the repository at this point in the history
  • Loading branch information
dpetzel committed Sep 17, 2015
2 parents 3e842c7 + 2737746 commit d305cc0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/kitchen/driver/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,24 @@ class Openstack < Kitchen::Driver::Base # rubocop:disable Metrics/ClassLength, M
end
end

# Set the proper server name in the config
def config_server_name
return if config[:server_name]

if config[:server_name_prefix]
config[:server_name] = server_name_prefix(
config[:server_name_prefix]
)
else
config[:server_name] = default_name
end
end

def create(state)
unless config[:server_name]
if config[:server_name_prefix]
config[:server_name] = server_name_prefix(
config[:server_name_prefix]
)
else
config[:server_name] = default_name
end
config_server_name
if state[:server_id]
info "#{config[:server_name]} (#{state[:server_id]}) already exists."
return
end
disable_ssl_validation if config[:disable_ssl_validation]
server = create_server
Expand Down
8 changes: 8 additions & 0 deletions spec/kitchen/driver/openstack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@
driver.create(state)
end
end

context 'when a server is already created' do
it 'does not create a new instance' do
state[:server_id] = '123'
expect(driver).not_to receive(:create_server)
driver.create(state)
end
end
end

describe '#destroy' do
Expand Down

0 comments on commit d305cc0

Please sign in to comment.