Sha256: 7e3924daecae2872ad474551da40a152ab5f462e9396aa083c743f9e0d137883

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require File.expand_path("../environment", __FILE__)

module Fog
  module Compute
    class Ecloud
      class Environments < Fog::Ecloud::Collection
        model Fog::Compute::Ecloud::Environment

        undef_method :create

        identity :href

        def all
          data = []
          raw_location = service.get_organization(href).body[:Locations][:Location]
          if raw_location.is_a?(Array)
            # If there's more than one location, the XML parser returns an
            # array.
            location = raw_location
          else
            # Otherwise it returns a hash.
            location = [raw_location]
          end

          location.each do |l|
            environments = l[:Environments]
            next unless environments
            if environments[:Environment].is_a?(Array)
              environments[:Environment].each { |e| data << e }
            else
              data << environments[:Environment]
            end
          end
          load(data)
        end

        def get(uri)
          if data = service.get_environment(uri)
            new(data.body)
          end
        rescue Fog::Errors::NotFound
          nil
        end

        Vdcs = Environments
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-ecloud-0.2.0 lib/fog/compute/ecloud/models/environments.rb
fog-ecloud-0.1.3 lib/fog/compute/ecloud/models/environments.rb
fog-ecloud-0.1.2 lib/fog/compute/ecloud/models/environments.rb