Sha256: 34e1f7d297f43626982a7c6caf1ccab01dc7f9b4bad77b68a74a82e6cd52bc33

Contents?: true

Size: 1.58 KB

Versions: 37

Compression:

Stored size: 1.58 KB

Contents

module Fog
  module Network
    class OpenStack
      class Real
        # Not all options can be updated
        UPDATE_OPTIONS = [
          :name,
          :shared,
          :admin_state_up,
          :qos_policy_id,
          :port_security_enabled
        ].freeze

        # Not all extra options can be updated
        UPDATE_EXTENTED_OPTIONS = [
          :router_external
        ].freeze

        def self.update(options)
          data = {}
          UPDATE_OPTIONS.select { |o| options.key?(o) }.each do |key|
            data[key.to_s] = options[key]
          end

          UPDATE_EXTENTED_OPTIONS.reject { |o| options[o].nil? }.each do |key|
            aliased_key = ALIASES[key] || key
            data[aliased_key] = options[key]
          end
          data
        end

        def update_network(network_id, options = {})
          data = {'network' => self.class.update(options)}
          request(
            :body    => Fog::JSON.encode(data),
            :expects => 200,
            :method  => 'PUT',
            :path    => "networks/#{network_id}.json"
          )
        end
      end

      class Mock
        def update_network(network_id, options = {})
          response = Excon::Response.new
          if network = list_networks.body['networks'].find { |_| _['id'] == network_id }
            network.merge!(Fog::Network::OpenStack::Real.update(options))
            response.body = {'network' => network}
            response.status = 200
            response
          else
            raise Fog::Network::OpenStack::NotFound
          end
        end
      end
    end
  end
end

Version data entries

37 entries across 35 versions & 3 rubygems

Version Path
fog-openstack-0.1.27 lib/fog/network/openstack/requests/update_network.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-openstack-0.1.26/lib/fog/network/openstack/requests/update_network.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-openstack-0.1.26/lib/fog/network/openstack/requests/update_network.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-openstack-0.1.26/lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.26 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.25 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.24 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.23 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.22 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.21 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.20 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.19 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.18 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.17 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.15 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.14 lib/fog/network/openstack/requests/update_network.rb
fog-openstack-0.1.13 lib/fog/network/openstack/requests/update_network.rb