Sha256: d9bac63da63cc7096e727862733df655ed46fa2c5a178c0da9ad17dfe77f55dd

Contents?: true

Size: 1.98 KB

Versions: 27

Compression:

Stored size: 1.98 KB

Contents

module Fog
  module Compute
    class Linode
      class Real
        def avail_stackscripts(options={})
          result = request(
            :expects  => 200,
            :method   => 'GET',
            :query    => { :api_action => 'avail.stackscripts' }.merge!(options)
          )
          result.body['DATA'].each { |r| r['DISTRIBUTIONIDLIST'] = r['DISTRIBUTIONIDLIST'].to_s }
          result
        end
      end

      class Mock
        def avail_stackscripts(stackscript_id=nil)
          response = Excon::Response.new
          response.status = 200

          body = {
            "ERRORARRAY" => [],
            "ACTION" => "avail.stackscripts"
          }
          if stackscript_id
            mock_stackscript = create_mock_stackscript(stackscript_id)
            response.body = body.merge("DATA" => [mock_stackscript])
          else
            mock_stackscripts = []
            10.times do
              stackscript_id = rand(1..200)
              mock_stackscripts << create_mock_stackscript(stackscript_id)
            end
            response.body = body.merge("DATA" => mock_stackscripts)
          end
          response
        end

        private

        def create_mock_stackscript(stackscript_id)
          {
            "CREATE_DT"          => "2011-10-07 00:28:13.0",
            "DEPLOYMENTSACTIVE"  => 0,
            "DEPLOYMENTSTOTAL"   => 1,
            "DESCRIPTION"        => "Prints 'foobar' to the screen. Magic!",
            "DISTRIBUTIONIDLIST" => "77,78,64,65,82,83,50,51,73,74,41,42",
            "ISPUBLIC"           => 1,
            "LABEL"              => "foobar",
            "LATESTREV"          => 15149,
            "REV_DT"             => "2011-10-07 00:33:58.0",
            "REV_NOTE"           => "Updated update_rubygems_install function.",
            "SCRIPT"             => "#!/bin/bash\n#\n#\n\necho \"foobar\"",
            "STACKSCRIPTID"      => stackscript_id,
            "USERID"             => 1
          }
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 4 rubygems

Version Path
fog-1.35.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-2.0.0.pre.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.34.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.33.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.32.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.31.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.30.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.29.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.28.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.27.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.26.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.25.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
nsidc-fog-1.24.1 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.24.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
ns-fog-1.22.11 lib/fog/linode/requests/compute/avail_stackscripts.rb
ns-fog-1.22.10 lib/fog/linode/requests/compute/avail_stackscripts.rb
ns-fog-1.22.9 lib/fog/linode/requests/compute/avail_stackscripts.rb
ns-fog-1.22.8 lib/fog/linode/requests/compute/avail_stackscripts.rb