Sha256: 4c76ea9980f41b186acbce024cd0ce15547c8fb953b3fc5ba1e4a8188418ee4e

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

require 'log4r'
require 'restclient'
require 'json'

require 'vagrant-openstack-provider/client/utils'

module VagrantPlugins
  module Openstack
    class NeutronClient
      include Singleton
      include VagrantPlugins::Openstack::Utils

      def initialize
        @logger = Log4r::Logger.new('vagrant_openstack::neutron')
        @session = VagrantPlugins::Openstack.session
      end

      def get_private_networks(env)
        authenticated(env) do
          networks_json = RestClient.get("#{@session.endpoints[:network]}/networks",
                                         'X-Auth-Token' => @session.token,
                                         :accept => :json) { |res| handle_response(res) }
          networks = []
          JSON.parse(networks_json)['networks'].each do |n|
            networks << { id: n['id'], name: n['name'] } if n['tenant_id'].eql? @session.project_id
          end
          networks
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-openstack-provider-0.2.0 lib/vagrant-openstack-provider/client/neutron.rb