Sha256: 809273c4b32c135a95bec6dba5f3ce98b75c2758d2999e6264d446f47a23743f

Contents?: true

Size: 1.61 KB

Versions: 21

Compression:

Stored size: 1.61 KB

Contents

module Fog
  module Compute
    class Cloudstack

      class Real
        # Disables static rule for given ip address
        #
        # {CloudStack API Reference}[http://cloudstack.apache.org/docs/api/apidocs-4.4/root_admin/disableStaticNat.html]
        def disable_static_nat(*args)
          options = {}
          if args[0].is_a? Hash
            options = args[0]
            options.merge!('command' => 'disableStaticNat') 
          else
            options.merge!('command' => 'disableStaticNat', 
            'ipaddressid' => args[0])
          end
          request(options)
        end
      end

      class Mock
        def disable_static_nat(*args)
          ip_address_id = args[0].is_a?(Hash) ? args[0]['ipaddressid'] : args[0]

          address = self.data[:public_ip_addresses][ip_address_id]

          unless address
            raise Fog::Compute::Cloudstack::BadRequest.new(
"Unable to execute API command disablestaticnat due to invalid value. \
Invalid parameter ipaddressid value=#{ip_address_id} due to incorrect long value format, \
or entity does not exist or due to incorrect parameter annotation for the field in api cmd class.")
          end

          if address['virtualmachineid'].nil?
            raise Fog::Compute::Cloudstack::BadRequest.new(
"Specified IP address id is not associated with any vm Id")
          end

          address.merge!(
            'virtualmachineid'          => nil,
            'virtualmachinname'         => nil,
            'virtualmachinedisplayname' => nil
          )
          {'enablestaticnatresponse' => {'success' => 'true'}}
        end
      end
    end
  end
end

Version data entries

21 entries across 19 versions & 3 rubygems

Version Path
fog-2.1.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/cloudstack/requests/compute/disable_static_nat.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/cloudstack/requests/compute/disable_static_nat.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.42.1 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-2.0.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.42.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.41.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.40.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.39.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.38.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.37.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.36.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.35.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-2.0.0.pre.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.34.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.33.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.32.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb
fog-1.31.0 lib/fog/cloudstack/requests/compute/disable_static_nat.rb