Sha256: d91aafbcb7d8268b83f03a55ca5e8f5a58189ca5fda107e95e25043b1c6d747b

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require 'vagrant-openstack-provider/command/utils'
require 'vagrant-openstack-provider/command/abstract_command'

module VagrantPlugins
  module Openstack
    module Command
      class FloatingIpList < AbstractCommand
        include VagrantPlugins::Openstack::Command::Utils

        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 == 1

          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

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-openstack-provider-0.3.0 lib/vagrant-openstack-provider/command/floatingip_list.rb