Class: Kitchen::Driver::Openstack
- Inherits:
-
Base
- Object
- Base
- Kitchen::Driver::Openstack
- Defined in:
- lib/kitchen/driver/openstack.rb,
lib/kitchen/driver/openstack/volume.rb
Overview
This takes from the Base Class and creates the OpenStack driver.
Defined Under Namespace
Classes: Volume
Constant Summary collapse
- @@ip_pool_lock =
rubocop:disable Metrics/ClassLength, Metrics/LineLength
Mutex.new
Instance Method Summary collapse
-
#config_server_name ⇒ Object
Set the proper server name in the config.
- #create(state) ⇒ Object
- #destroy(state) ⇒ Object
Instance Method Details
#config_server_name ⇒ Object
Set the proper server name in the config
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/kitchen/driver/openstack.rb', line 77 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 |
#create(state) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/kitchen/driver/openstack.rb', line 89 def create(state) 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 state[:server_id] = server.id info "OpenStack instance with ID of <#{state[:server_id]}> is ready." # rubocop:disable Metrics/LineLength sleep 30 if config[:floating_ip] attach_ip(server, config[:floating_ip]) elsif config[:floating_ip_pool] attach_ip_from_pool(server, config[:floating_ip_pool]) end wait_for_server(state) setup_ssh(server, state) if bourne_shell? add_ohai_hint(state) rescue Fog::Errors::Error, Excon::Errors::Error => ex raise ActionFailed, ex. end |
#destroy(state) ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/kitchen/driver/openstack.rb', line 112 def destroy(state) return if state[:server_id].nil? disable_ssl_validation if config[:disable_ssl_validation] server = compute.servers.get(state[:server_id]) server.destroy unless server.nil? info "OpenStack instance <#{state[:server_id]}> destroyed." state.delete(:server_id) state.delete(:hostname) end |