Class: Profitbricks::Storage
Class Method Summary (collapse)
-
+ (Storage) create(options = {})
Creates a virtual storage within an existing virtual data center.
-
+ (Storage) find(options = {})
Finds a storage device.
Instance Method Summary (collapse)
-
- (Boolean) connect(options = {})
Connects a virtual storage device to an existing server.
-
- (Boolean) delete
Deletes an existing virtual storage device.
-
- (Boolean) disconnect(options = {})
Disconnects a virtual storage device from a connected server.
-
- (Boolean) update(options = {})
Updates parameters of an existing virtual storage device.
Methods inherited from Model
#attributes, belongs_to, has_many, #initialize, #reload
Constructor Details
This class inherits a constructor from Profitbricks::Model
Class Method Details
+ (Storage) create(options = {})
Creates a virtual storage within an existing virtual data center. Additional parameters can be specified, e.g. for assigning a HDD image to the storage.
60 61 62 63 64 65 |
# File 'lib/profitbricks/storage.rb', line 60 def create( = {}) raise ArgumentError.new("You must provide a :data_center_id") if [:data_center_id].nil? [:storage_name] = .delete :name if [:name] response = Profitbricks.request :create_storage, self.find(:id => response[:storage_id]) end |
+ (Storage) find(options = {})
Finds a storage device
72 73 74 75 76 |
# File 'lib/profitbricks/storage.rb', line 72 def find( = {}) raise "Unable to locate the storage named '#{[:name]}'" unless [:id] response = Profitbricks.request :get_storage, storage_id: [:id] Profitbricks::Storage.new(response) end |
Instance Method Details
- (Boolean) connect(options = {})
Connects a virtual storage device to an existing server.
19 20 21 22 23 24 |
# File 'lib/profitbricks/storage.rb', line 19 def connect( = {}) raise ArgumentError.new(":bus_type has to be either 'IDE' or 'VIRTIO'") if [:bus_type] and !['IDE', 'VIRTIO'].include? [:bus_type] response = Profitbricks.request :connect_storage_to_server, .merge(:storage_id => self.id) update_attributes_from_hash return true end |
- (Boolean) delete
Deletes an existing virtual storage device.
7 8 9 10 |
# File 'lib/profitbricks/storage.rb', line 7 def delete Profitbricks.request :delete_storage, storage_id: self.id return true end |
- (Boolean) disconnect(options = {})
Disconnects a virtual storage device from a connected server.
31 32 33 34 |
# File 'lib/profitbricks/storage.rb', line 31 def disconnect( = {}) Profitbricks.request :disconnect_storage_from_server, storage_id: self.id, server_id: [:server_id] return true end |
- (Boolean) update(options = {})
Updates parameters of an existing virtual storage device.
43 44 45 46 47 48 |
# File 'lib/profitbricks/storage.rb', line 43 def update( = {}) update_attributes_from_hash [:storage_name] = .delete :name if [:name] Profitbricks.request :update_storage, .merge(:storage_id => self.id) return true end |