Sha256: 17123da42ab82fa136e0093684e6e46ca7a30170598c6c9107f7542a431df0b4

Contents?: true

Size: 927 Bytes

Versions: 2

Compression:

Stored size: 927 Bytes

Contents

require "fog/core/collection"
require "fog/azurerm/models/compute/server"

module Fog
  module Compute
    class AzureRM
      # This class is giving implementation of all/list, and get
      # for Server.
      class Servers < Fog::Collection
        attribute :resource_group
        model Fog::Compute::AzureRM::Server

        def all
          requires :resource_group
          virtual_machines = []
          service.list_virtual_machines(resource_group).each do |vm|
            virtual_machines << Fog::Compute::AzureRM::Server.parse(vm)
          end
          load(virtual_machines)
        end

        def get(resource_group, identity)
          all.find { |s| s.name == identity && s.resource_group == resource_group}
        end

        def get_from_remote(resource_group, name)
          service.get_virtual_machine(resource_group, name)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.1 lib/fog/azurerm/models/compute/servers.rb
fog-azure-rm-0.0.0 lib/fog/azurerm/models/compute/servers.rb