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



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

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

#preferred_kernel=(args) ⇒ Object



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

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

#reloadObject



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

def reload
  requires :name

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

  self.merge_attributes(data)
  self
end

#resource_urlObject



73
74
75
# File 'lib/fog/google/models/compute/image.rb', line 73

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

#saveObject



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

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