2012-04-27 08:25:40 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Serverlove
|
|
|
|
|
2012-04-29 12:36:16 -04:00
|
|
|
class Image < Fog::Model
|
2012-04-27 08:25:40 -04:00
|
|
|
|
2012-04-29 12:36:16 -04:00
|
|
|
identity :id, :aliases => 'drive'
|
2012-04-27 08:25:40 -04:00
|
|
|
|
2012-12-22 18:23:47 -05:00
|
|
|
attribute :name
|
2012-04-27 08:25:40 -04:00
|
|
|
attribute :user
|
|
|
|
attribute :size
|
2012-04-27 09:01:42 -04:00
|
|
|
attribute :claimed
|
|
|
|
attribute :status
|
2012-06-22 11:26:11 -04:00
|
|
|
attribute :imaging
|
2012-04-27 09:55:06 -04:00
|
|
|
attribute :encryption_cipher, :aliases => 'encryption:cipher'
|
2012-12-22 18:23:47 -05:00
|
|
|
|
2012-04-27 08:25:40 -04:00
|
|
|
def save
|
2012-04-29 12:00:13 -04:00
|
|
|
attributes = {}
|
2012-12-22 18:23:47 -05:00
|
|
|
|
2012-04-29 12:00:13 -04:00
|
|
|
if(identity)
|
2012-12-22 18:23:47 -05:00
|
|
|
attributes = service.update_image(identity, allowed_attributes).body
|
2012-04-29 12:00:13 -04:00
|
|
|
else
|
|
|
|
requires :name
|
|
|
|
requires :size
|
2012-12-22 18:23:47 -05:00
|
|
|
attributes = service.create_image(allowed_attributes).body
|
2012-04-29 12:00:13 -04:00
|
|
|
end
|
2012-12-22 18:23:47 -05:00
|
|
|
|
2012-04-29 12:00:13 -04:00
|
|
|
merge_attributes(attributes)
|
2012-04-29 12:11:19 -04:00
|
|
|
self
|
2012-04-27 16:53:39 -04:00
|
|
|
end
|
2012-12-22 18:23:47 -05:00
|
|
|
|
Added loading of standard image.
Currently not working:
Expected(204) <=> Actual(404 Not Found)
request => {:connect_timeout=>60, :headers=>{"Authorization"=>"Basic YWE4ZWIxYzktYzc4OC00MDlmLWJmZjQtYjAyMjVjMDE0MDQ1OkFkZ1hYSGVUTmY3TTJHR1l2NEI3WkpnWE1ISkJMY1E2dlJBejRZUUg=", "Accept"=>"application/json", "Host"=>"api.z1-man.serverlove.com:443", "Content-Length"=>0}, :instrumentor_name=>"excon", :mock=>false, :read_timeout=>60, :retry_limit=>4, :ssl_ca_file=>"/Users/seanhandley/.rvm/gems/ruby-1.9.3-p125@fog_gem/gems/excon-0.14.1/data/cacert.pem", :ssl_verify_peer=>true, :write_timeout=>60, :host=>"api.z1-man.serverlove.com", :path=>"/drives/aea15650-5001-4cb8-8146-8c9835f5b880/image/679f5f44-0be7-4745-a658-cccd4334c1aa", :port=>"443", :query=>nil, :scheme=>"https", :method=>"post", :expects=>204}
response => #<Excon::Response:0x007ff661811848 @body="Operation failed: drive not found\n", @headers={"Server"=>"BaseHTTP/0.3 Python/2.6.6", "Date"=>"Fri, 22 Jun 2012 15:03:50 GMT", "X-Elastic-Error"=>"missing drive", "Connection"=>"close", "Content-Type"=>"text/plain"}, @status=404> (Excon::Errors::NotFound)
2012-06-22 11:09:17 -04:00
|
|
|
def load_standard_image(standard_image_uuid)
|
|
|
|
requires :identity
|
2012-12-22 18:23:47 -05:00
|
|
|
service.load_standard_image(identity, standard_image_uuid)
|
Added loading of standard image.
Currently not working:
Expected(204) <=> Actual(404 Not Found)
request => {:connect_timeout=>60, :headers=>{"Authorization"=>"Basic YWE4ZWIxYzktYzc4OC00MDlmLWJmZjQtYjAyMjVjMDE0MDQ1OkFkZ1hYSGVUTmY3TTJHR1l2NEI3WkpnWE1ISkJMY1E2dlJBejRZUUg=", "Accept"=>"application/json", "Host"=>"api.z1-man.serverlove.com:443", "Content-Length"=>0}, :instrumentor_name=>"excon", :mock=>false, :read_timeout=>60, :retry_limit=>4, :ssl_ca_file=>"/Users/seanhandley/.rvm/gems/ruby-1.9.3-p125@fog_gem/gems/excon-0.14.1/data/cacert.pem", :ssl_verify_peer=>true, :write_timeout=>60, :host=>"api.z1-man.serverlove.com", :path=>"/drives/aea15650-5001-4cb8-8146-8c9835f5b880/image/679f5f44-0be7-4745-a658-cccd4334c1aa", :port=>"443", :query=>nil, :scheme=>"https", :method=>"post", :expects=>204}
response => #<Excon::Response:0x007ff661811848 @body="Operation failed: drive not found\n", @headers={"Server"=>"BaseHTTP/0.3 Python/2.6.6", "Date"=>"Fri, 22 Jun 2012 15:03:50 GMT", "X-Elastic-Error"=>"missing drive", "Connection"=>"close", "Content-Type"=>"text/plain"}, @status=404> (Excon::Errors::NotFound)
2012-06-22 11:09:17 -04:00
|
|
|
end
|
2012-12-22 18:23:47 -05:00
|
|
|
|
2012-04-29 12:36:16 -04:00
|
|
|
def ready?
|
|
|
|
status.upcase == 'ACTIVE'
|
|
|
|
end
|
2012-04-27 16:53:39 -04:00
|
|
|
|
2012-04-27 08:25:40 -04:00
|
|
|
def destroy
|
|
|
|
requires :identity
|
2012-12-22 18:23:47 -05:00
|
|
|
service.destroy_image(identity)
|
2012-04-29 12:11:19 -04:00
|
|
|
self
|
2012-04-29 09:14:17 -04:00
|
|
|
end
|
2012-12-22 18:23:47 -05:00
|
|
|
|
2012-04-29 09:14:17 -04:00
|
|
|
def allowed_attributes
|
|
|
|
allowed = [:name, :size]
|
|
|
|
attributes.select {|k,v| allowed.include? k}
|
|
|
|
end
|
|
|
|
|
2012-04-27 08:25:40 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|