class Inception::Providers::Clients::OpenStackProviderClient
Public Instance Methods
associate_ip_address_with_server(ip_address, server)
click to toggle source
# File lib/inception/providers/clients/openstack_provider_client.rb, line 17 def associate_ip_address_with_server(ip_address, server) address = fog_compute.addresses.find { |a| a.ip == ip_address } address.server = server end
create_and_attach_volume(name, disk_size, server, device)
click to toggle source
# File lib/inception/providers/clients/openstack_provider_client.rb, line 37 def create_and_attach_volume(name, disk_size, server, device) volume = fog_compute.volumes.create(:name => name, :description => "", :size => disk_size, :availability_zone => server.availability_zone) volume.wait_for { volume.status == 'available' } volume.attach(server.id, device) volume.wait_for { volume.status == 'in-use' } end
find_server_device(server, device)
click to toggle source
# File lib/inception/providers/clients/openstack_provider_client.rb, line 32 def find_server_device(server, device) va = fog_compute.get_server_volumes(server.id).body['volumeAttachments'] va.find { |v| v["device"] == device } end
fog_attributes(inception_server)
click to toggle source
# File lib/inception/providers/clients/openstack_provider_client.rb, line 59 def fog_attributes(inception_server) # :name => "Inception VM", # :key_name => key_name, # :private_key_path => inception_vm_private_key_path, # :flavor_ref => inception_flavor.id, # :image_ref => inception_image.id, # :security_groups => [settings["inception"]["security_group"]], # :username => username { name: inception_server.server_name, key_name: inception_server.key_name, private_key_path: inception_server.private_key_path, image_ref: inception_server.image_id, flavor_ref: flavor_id(inception_server.flavor), security_groups: inception_server.security_groups, public_key: inception_server.public_key, public_ip_address: inception_server.ip_address, bits: 64, username: "ubuntu", } end
image_id()
click to toggle source
# File lib/inception/providers/clients/openstack_provider_client.rb, line 47 def image_id raise "Not yet implemented" end
ip_permissions(sg)
click to toggle source
Hook method for FogProviderClient#create_security_group
# File lib/inception/providers/clients/openstack_provider_client.rb, line 23 def ip_permissions(sg) sg.rules end
openstack_constants()
click to toggle source
# File lib/inception/providers/clients/openstack_provider_client.rb, line 81 def openstack_constants Inception::Providers::Constants::OpenStackConstants end
provision_public_ip_address(options={})
click to toggle source
@return [String] provisions a new public IP address in target region TODO nil if none available
# File lib/inception/providers/clients/openstack_provider_client.rb, line 11 def provision_public_ip_address(options={}) address = fog_compute.addresses.create address.ip # TODO catch error and return nil end
setup_fog_connection()
click to toggle source
Construct a Fog::Compute object Uses attributes
which normally originates from settings.provider
# File lib/inception/providers/clients/openstack_provider_client.rb, line 53 def setup_fog_connection configuration = Fog.symbolize_credentials(attributes.credentials) configuration[:provider] = "OpenStack" @fog_compute = Fog::Compute.new(configuration) end