Class: Fog::Vsphere::Compute::Volumes
- Inherits:
-
Collection
- Object
- Collection
- Fog::Vsphere::Compute::Volumes
- Defined in:
- lib/fog/vsphere/models/compute/volumes.rb
Instance Method Summary collapse
- #all(_filters = {}) ⇒ Object
- #get(id) ⇒ Object
- #new(attributes = {}) ⇒ Object
- #server ⇒ Object
- #server=(new_server) ⇒ Object
Instance Method Details
#all(_filters = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fog/vsphere/models/compute/volumes.rb', line 9 def all(_filters = {}) requires :server_id case server when Fog::Vsphere::Compute::Server load service.list_vm_volumes(server.id) when Fog::Vsphere::Compute::Template load service.list_template_volumes(server.id) else raise 'volumes should have vm or template' end each { |volume| volume.server = server } self end |
#get(id) ⇒ Object
25 26 27 |
# File 'lib/fog/vsphere/models/compute/volumes.rb', line 25 def get(id) new service.get_volume(id) end |
#new(attributes = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/vsphere/models/compute/volumes.rb', line 29 def new(attributes = {}) if server_id # Default to the root volume datastore if one is not configured. datastore = !attributes.key?(:datastore) && any? ? first.datastore : nil super({ server_id: server_id, datastore: datastore }.merge!(attributes)) else super end end |
#server ⇒ Object
40 41 42 43 |
# File 'lib/fog/vsphere/models/compute/volumes.rb', line 40 def server return nil if server_id.nil? service.servers.get(server_id) end |
#server=(new_server) ⇒ Object
45 46 47 |
# File 'lib/fog/vsphere/models/compute/volumes.rb', line 45 def server=(new_server) server_id = new_server.id end |