Class: Fog::Vsphere::Compute::Interfaces
- Inherits:
-
Collection
- Object
- Collection
- Fog::Vsphere::Compute::Interfaces
- Defined in:
- lib/fog/vsphere/models/compute/interfaces.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/interfaces.rb', line 9 def all(_filters = {}) requires :server_id case server when Fog::Vsphere::Compute::Server load service.list_vm_interfaces(server.id) when Fog::Vsphere::Compute::Template load service.list_template_interfaces(server.id) else raise 'interfaces should have vm or template' end each { |interface| interface.server_id = server.id } self end |
#get(id) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fog/vsphere/models/compute/interfaces.rb', line 25 def get(id) requires :server_id case server when Fog::Vsphere::Compute::Server interface = service.get_vm_interface(server.id, key: id, mac: id, name: id, datacenter: server.datacenter) when Fog::Vsphere::Compute::Template interface = service.get_template_interfaces(server.id, key: id, mac: id, name: id) else raise 'interfaces should have vm or template' end if interface Fog::Vsphere::Compute::Interface.new(interface.merge(server_id: server.id, service: service)) end end |
#new(attributes = {}) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/fog/vsphere/models/compute/interfaces.rb', line 43 def new(attributes = {}) if server_id super({ server_id: server_id }.merge(attributes)) else super end end |
#server ⇒ Object
51 52 53 54 |
# File 'lib/fog/vsphere/models/compute/interfaces.rb', line 51 def server return nil if server_id.nil? service.servers.get(server_id) end |
#server=(new_server) ⇒ Object
56 57 58 |
# File 'lib/fog/vsphere/models/compute/interfaces.rb', line 56 def server=(new_server) server_id = new_server.id end |