class Bosh::OpenStackCloud::VipNetwork
Represents OpenStack vip network: where users sets VM's IP (floating IP's in OpenStack)
Public Class Methods
new(name, spec)
click to toggle source
Creates a new vip network
@param [String] name Network
name @param [Hash] spec Raw network spec
Calls superclass method
Bosh::OpenStackCloud::Network::new
# File lib/cloud/openstack/vip_network.rb, line 15 def initialize(name, spec) super end
Public Instance Methods
configure(openstack, server)
click to toggle source
Configures OpenStack vip network
@param [Fog::Compute::OpenStack] openstack Fog OpenStack Compute client @param [Fog::Compute::OpenStack::Server] server OpenStack server to
configure
# File lib/cloud/openstack/vip_network.rb, line 25 def configure(openstack, server) if @ip.nil? cloud_error("No IP provided for vip network `#{@name}'") end # Check if the OpenStack floating IP is allocated. If true, disassociate # it from any server before associating it to the new server with_openstack do address = openstack.addresses.find { |a| a.ip == @ip } if address unless address.instance_id.nil? @logger.info("Disassociating floating IP `#{@ip}' " \ "from server `#{address.instance_id}'") address.server = nil end @logger.info("Associating server `#{server.id}' " \ "with floating IP `#{@ip}'") address.server = server else cloud_error("Floating IP #{@ip} not allocated") end end end