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

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

Constant Summary collapse

READY_STATE =
"READY"

Instance Method Summary collapse

Instance Method Details

#destroy(async = true) ⇒ Object



50
51
52
53
54
55
56
57
# File 'lib/fog/google/models/compute/image.rb', line 50

def destroy(async=true)
  data = service.delete_image(name)
  operation = Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'])
  unless async
    operation.wait_for { ready? }
  end
  operation
end

#preferred_kernelObject



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

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

#preferred_kernel=(args) ⇒ Object



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

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

#ready?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/fog/google/models/compute/image.rb', line 46

def ready?
  self.status == READY_STATE
end

#reloadObject



59
60
61
62
63
64
65
66
67
# File 'lib/fog/google/models/compute/image.rb', line 59

def reload
  requires :name

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

  self.merge_attributes(data)
  self
end

#resource_urlObject



84
85
86
# File 'lib/fog/google/models/compute/image.rb', line 84

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

#saveObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fog/google/models/compute/image.rb', line 69

def save
  requires :name
  requires :raw_disk

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

  data = service.insert_image(name, options)
  operation = Fog::Compute::Google::Operations.new(:service => service).get(data.body['name'])
  operation.wait_for { !pending? }
  reload
end