Class: Fog::Compute::Softlayer::Servers
- Inherits:
-
Fog::Collection
- Object
- Fog::Collection
- Fog::Compute::Softlayer::Servers
- Defined in:
- lib/fog/softlayer/models/compute/servers.rb
Instance Method Summary collapse
- #all ⇒ Object
- #bootstrap(options = {}) ⇒ Object
-
#get(identifier) ⇒ Object
Get a SoftLayer server.
- #get_bm_create_options ⇒ Object
-
#get_by_ip(ip) ⇒ Object
Get a SoftLayer server by ip.
- #get_vm_create_options ⇒ Object
- #tagged_with(tags) ⇒ Object
Instance Method Details
#all ⇒ Object
18 19 20 21 |
# File 'lib/fog/softlayer/models/compute/servers.rb', line 18 def all data = service.list_servers load(data) end |
#bootstrap(options = {}) ⇒ Object
58 59 60 61 62 |
# File 'lib/fog/softlayer/models/compute/servers.rb', line 58 def bootstrap(={}) server = service.create() server.wait_for { ready? } server end |
#get(identifier) ⇒ Object
Get a SoftLayer server.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/softlayer/models/compute/servers.rb', line 26 def get(identifier) return nil if identifier.nil? || identifier == "" response = service.get_vm(identifier) = false if response.status == 404 # we didn't find it as a VM, look for a BMC server response = service.(identifier) = true end data = response.body data['bare_metal'] = new.merge_attributes(data) rescue Excon::Errors::NotFound nil end |
#get_bm_create_options ⇒ Object
74 75 76 |
# File 'lib/fog/softlayer/models/compute/servers.rb', line 74 def service..body end |
#get_by_ip(ip) ⇒ Object
Get a SoftLayer server by ip.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fog/softlayer/models/compute/servers.rb', line 43 def get_by_ip(ip) return nil if ip.blank? response = service.get_virtual_guest_by_ip(ip) = false if response.status == 404 # we didn't find it as a VM, look for a BMC server response = service.(ip) = true end data = response.body data['bare_metal'] = new.merge_attributes(data) rescue Excon::Errors::NotFound nil end |
#get_vm_create_options ⇒ Object
78 79 80 |
# File 'lib/fog/softlayer/models/compute/servers.rb', line 78 def service..body end |
#tagged_with(tags) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/fog/softlayer/models/compute/servers.rb', line 64 def tagged_with() raise ArgumentError, "Tags argument for #{self.class.name}##{__method__} must be Array." unless .is_a?(Array) ids = service.get_references_by_tag_name(.join(',')).body.map do |tag| tag['references'].map do |ref| ref['resourceTableId'] end end.flatten.uniq ids.map { |id| get(id) } end |