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

#preferred_kernelObject



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

def preferred_kernel
  Fog::Logger.deprecation("preferred_kernel is no longer used [light_black](#{caller.first})[/]")
  nil
end

#preferred_kernel=(args) ⇒ Object



32
33
34
# File 'lib/fog/google/models/compute/image.rb', line 32

def preferred_kernel=(args)
  Fog::Logger.deprecation("preferred_kernel= is no longer used [light_black](#{caller.first})[/]")
end

#reloadObject



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

def reload
  requires :name

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

  self.merge_attributes(data)
  self
end

#resource_urlObject



71
72
73
# File 'lib/fog/google/models/compute/image.rb', line 71

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

#saveObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fog/google/models/compute/image.rb', line 49

def save
  requires :name
  requires :raw_disk

  options = {
    '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