Sha256: 9fc2dd36a0e55447a55269bf630c989849de3b2768bd57d8c7b7bc4ea2159948

Contents?: true

Size: 1.63 KB

Versions: 48

Compression:

Stored size: 1.63 KB

Contents

module Fog
  module Network
    class OpenStack
      class Real
        def update_vpn_service(vpn_service_id, options = {})
          data = {'vpnservice' => {}}

          vanilla_options = [:name, :description, :admin_state_up]
          vanilla_options.select { |o| options.key?(o) }.each do |key|
            data['vpnservice'][key] = options[key]
          end

          request(
            :body    => Fog::JSON.encode(data),
            :expects => 200,
            :method  => 'PUT',
            :path    => "vpn/vpnservices/#{vpn_service_id}"
          )
        end
      end

      class Mock
        def update_vpn_service(vpn_service_id, options = {})
          response = Excon::Response.new
          if vpn_service = list_vpn_services.body['vpnservices'].detect { |instance| instance['id'] == vpn_service_id }
            vpn_service['id']             = vpn_service_id
            vpn_service['subnet_id']      = options[:subnet_id]
            vpn_service['router_id']      = options[:router_id]
            vpn_service['name']           = options[:name]
            vpn_service['description']    = options[:description]
            vpn_service['status']         = 'ACTIVE'
            vpn_service['admin_state_up'] = options[:admin_state_up]
            vpn_service['tenant_id']      = options[:tenant_id]
            vpn_service['external_v4_ip'] = '1.2.3.4'
            vpn_service['external_v6_ip'] = '::1'
            response.body = {'vpnservice' => vpn_service}
            response.status = 200
            response
          else
            raise Fog::Network::OpenStack::NotFound
          end
        end
      end
    end
  end
end

Version data entries

48 entries across 46 versions & 3 rubygems

Version Path
fog-openstack-0.1.9 lib/fog/openstack/requests/network/update_vpn_service.rb
fog-openstack-0.1.8 lib/fog/openstack/requests/network/update_vpn_service.rb
fog-openstack-0.1.7 lib/fog/openstack/requests/network/update_vpn_service.rb
fog-openstack-0.1.6 lib/fog/openstack/requests/network/update_vpn_service.rb
fog-openstack-0.1.5 lib/fog/openstack/requests/network/update_vpn_service.rb
fog-openstack-0.1.4 lib/fog/openstack/requests/network/update_vpn_service.rb
fog-openstack-0.1.3 lib/fog/openstack/requests/network/update_vpn_service.rb
fog-openstack-0.1.2 lib/fog/openstack/requests/network/update_vpn_service.rb