Class: Fog::Compute::Google::Image

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/google/models/compute/image.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#reloadObject

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/google/models/compute/image.rb', line 17

def reload
  requires :name

  data = {}

  # Try looking for the image in known projects
  [
    self.service.project,
    'google',
    'debian-cloud',
    'centos-cloud',
  ].each do |owner|
    begin
      data = service.get_image(name, owner).body
      data[:project] = owner
    rescue
    end
  end

  raise ArgumentError, 'Specified image was not found' if data.empty?

  self.merge_attributes(data)
  self
end

#resource_urlObject



48
49
50
# File 'lib/fog/google/models/compute/image.rb', line 48

def resource_url
  "#{self.project}/global/images/#{name}"
end

#saveObject



42
43
44
45
46
# File 'lib/fog/google/models/compute/image.rb', line 42

def save
  requires :name

  reload
end