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



33
34
35
36
37
38
39
40
# File 'lib/fog/google/models/compute/image.rb', line 33

def reload
  requires :name

  data = service.get_image(name, self.project).body

  self.merge_attributes(data)
  self
end

#resource_urlObject



66
67
68
# File 'lib/fog/google/models/compute/image.rb', line 66

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

#saveObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fog/google/models/compute/image.rb', line 42

def save
  requires :name
  requires :preferred_kernel
  requires :raw_disk

  options = {
    'preferredKernel' => preferred_kernel,
    'rawDisk'         => raw_disk,
    'description'     => description,
  }

  service.insert_image(name, options)

  data = service.backoff_if_unfound {
    service.get_image(self.name).body
  }

  # Track the name of the project in which we insert the image
  data.merge!('project' => service.project)
  self.project = self.service.project

  service.images.merge_attributes(data)
end