Sha256: a718a92d81348abdb3a34f5011e81855b1d457acdb06e2a5254af39abf1caa5a

Contents?: true

Size: 1.58 KB

Versions: 20

Compression:

Stored size: 1.58 KB

Contents

module Fog
  module OpenStack
    class Network
      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::OpenStack::Network::Real.update(options))
            response.body = {'network' => network}
            response.status = 200
            response
          else
            raise Fog::OpenStack::Network::NotFound
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
fog-openstack-1.1.3 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.1.2 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-fork-99 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.1.0 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.1.0.pre lib/fog/openstack/network/requests/update_network.rb
fog-openstack-apibank-1.0.102 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.11 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-apibank-1.0.101 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.10 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.9 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.8 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.7 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.6 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.5 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.4 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.3 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.2 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.1 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-1.0.0 lib/fog/openstack/network/requests/update_network.rb
fog-openstack-0.3.1 lib/fog/openstack/network/requests/update_network.rb