Sha256: b143277da37961a877f97a21378003914713f11554c6d05f5318815c998c3c31

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

require 'vagrant-conoha/command/openstack_command'

module VagrantPlugins
  module ConoHa
    module Command
      class FloatingIpList < OpenstackCommand
        def self.synopsis
          I18n.t('vagrant_openstack.command.flaotingip_list_synopsis')
        end

        def cmd(name, argv, env)
          fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0

          floating_ip_pools = env[:openstack_client].nova.get_floating_ip_pools(env)
          floating_ips = env[:openstack_client].nova.get_floating_ips(env)

          rows = []
          floating_ip_pools.each do |floating_ip_pool|
            rows << [floating_ip_pool['name']]
          end
          display_table(env, ['Floating IP pools'], rows)

          rows = []
          floating_ips.each do |floating_ip|
            rows << [floating_ip['id'], floating_ip['ip'], floating_ip['pool'], floating_ip['instance_id']]
          end
          display_table(env, ['ID', 'IP', 'Pool', 'Instance ID'], rows)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vagrant-conoha-0.1.10 lib/vagrant-conoha/command/floatingip_list.rb
vagrant-conoha-0.1.9 lib/vagrant-conoha/command/floatingip_list.rb
vagrant-conoha-0.1.8 lib/vagrant-conoha/command/floatingip_list.rb
vagrant-conoha-0.1.7 lib/vagrant-conoha/command/floatingip_list.rb
vagrant-conoha-0.1.6 lib/vagrant-conoha/command/floatingip_list.rb