Class: Profitbricks::Image
Class Method Summary collapse
-
.all ⇒ Array<Image>
Outputs a list of all HDD and/or CD-ROM/DVD images existing on or uploaded to the Profit-Bricks FTP server.
-
.find(options = {}) ⇒ Image
Returns information about a HDD or CD-ROM/DVD (ISO) image.
Instance Method Summary collapse
-
#set_os_type(type) ⇒ Image
(also: #os_type=)
Sets the OS Type of an individual HDD and/or CD-ROM/DVD image that has been uploaded on the ProfitBricks FTP server.
Methods inherited from Model
#attributes, belongs_to, has_many, #initialize, #reload
Constructor Details
This class inherits a constructor from Profitbricks::Model
Class Method Details
.all ⇒ Array<Image>
Outputs a list of all HDD and/or CD-ROM/DVD images existing on or uploaded to the Profit-Bricks FTP server.
37 38 39 40 41 42 |
# File 'lib/profitbricks/image.rb', line 37 def all resp = Profitbricks.request :get_all_images resp.collect do |dc| PB::Image.new(dc) end end |
.find(options = {}) ⇒ Image
Returns information about a HDD or CD-ROM/DVD (ISO) image.
24 25 26 27 28 29 30 31 32 |
# File 'lib/profitbricks/image.rb', line 24 def find( = {}) image = nil if [:name] image = PB::Image.all().select { |d| d.name == [:name] && ([:region] ? d.region == [:region] : true) }.first [:id] = image.id if image end raise "Unable to locate the image named '#{[:name]}'" unless [:id] image end |
Instance Method Details
#set_os_type(type) ⇒ Image Also known as: os_type=
Sets the OS Type of an individual HDD and/or CD-ROM/DVD image that has been uploaded on the ProfitBricks FTP server.
9 10 11 12 13 14 |
# File 'lib/profitbricks/image.rb', line 9 def set_os_type(type) raise ArgumentError.new(":os_type has to be either 'WINDOWS' or 'OTHER'") if !['WINDOWS', 'OTHER'].include? type response = Profitbricks.request :set_image_os_type, image_id: self.id, os_type: type @os_type = type self end |