Sha256: fd5acfb783e84edf1eea0c30aca746ca14ba487305a82cff8152500b626f92a8

Contents?: true

Size: 1.34 KB

Versions: 10

Compression:

Stored size: 1.34 KB

Contents

module Fog
  module Compute
    class Ecloud
      class Real
        include Shared

        def trusted_network_groups_edit(data)
          validate_data([:name], data)
          unless (data[:hosts] || data[:networks])
            raise ArgumentError.new("Required data missing: Either hosts or networks must be present")
          end

          request(
            :body => generate_edit_trusted_network_groups_request(data),
            :expects => 202,
            :method => "PUT",
            :headers => {},
            :uri => data[:uri],
            :parse => true
          )
        end

        private

        def generate_edit_trusted_network_groups_request(data)
          xml = Builder::XmlMarkup.new
          xml.TrustedNetworkGroup(:name => data[:name]) do
            if data[:hosts]
              xml.Hosts do
                data[:hosts].each do |ip|
                  xml.IpAddress ip
                end
              end
            end
            if data[:networks]
              xml.Networks do
                data[:networks].each do |network|
                  address, subnet = network.split("/")
                  xml.Network do
                    xml.Address address
                    xml.Size subnet
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 8 versions & 3 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb
fog-ecloud-0.3.0 lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb
fog-ecloud-0.2.0 lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb
fog-ecloud-0.1.3 lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb
fog-ecloud-0.1.2 lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb
fog-ecloud-0.1.1 lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb
fog-ecloud-0.1.0 lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb