Class: Chef::Knife::Cloud::OpenstackFloatingIpAssociate

Inherits:
Command
  • Object
show all
Includes:
OpenstackHelpers, OpenstackServiceOptions
Defined in:
lib/chef/knife/openstack_floating_ip_associate.rb

Instance Method Summary collapse

Methods included from OpenstackServiceOptions

included

Methods included from OpenstackHelpers

#create_service_instance, #instance_addresses, #primary_network_ip_address, #primary_private_ip_address, #primary_public_ip_address, #validate!

Instance Method Details

#execute_commandObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/chef/knife/openstack_floating_ip_associate.rb', line 38

def execute_command
  if @name_args[0]
    floating_ip = @name_args[0]
  else
    ui.error "Please provide Floating IP to associate with."
    exit 1
  end

  response = @service.associate_address(config[:instance_id], floating_ip)
  if response && response.status == 202
    ui.info "Floating IP #{floating_ip} associated with Instance #{config[:instance_id]}"
  end
end