Class: SoftLayer::Datacenter

Inherits:
ModelBase show all
Defined in:
lib/softlayer/Datacenter.rb

Overview

A Data Center in the SoftLayer network

This class corresponds to the SoftLayer_Location++ data type:

sldn.softlayer.com/reference/datatypes/SoftLayer_Location

Although in this context it is used to represent a data center and not the more general class of locations that that data type can represent.

Constant Summary collapse

@@data_centers =

Return a list of all the datacenters

If the client parameter is not provided, the routine will try to use Client::default_client. If no client can be found, the routine will raise an exception

This routine will only retrieve the list of datacenters from the network once and keep it in memory unless you pass in force_reload as true.

nil

Instance Attribute Summary

Attributes inherited from ModelBase

#softlayer_client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ModelBase

#[], #has_sl_property?, #initialize, #refresh_details, #service, sl_attr, #to_ary

Constructor Details

This class inherits a constructor from SoftLayer::ModelBase

Class Method Details

.datacenter_named(name, client = nil) ⇒ Object

Return the datacenter with the given name (‘sng01’ or ‘dal05’)



33
34
35
# File 'lib/softlayer/Datacenter.rb', line 33

def self.datacenter_named(name, client = nil)
  datacenters(client).find{ | datacenter | datacenter.name == name.to_s.downcase }
end

.datacenters(client = nil, force_reload = false) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/softlayer/Datacenter.rb', line 49

def self.datacenters(client = nil, force_reload = false)
  softlayer_client = client || Client.default_client
  raise "Datacenter.datacenters requires a client to call the network API" if !softlayer_client

  if(!@@data_centers || force_reload)
    datacenters_data = softlayer_client[:Location].getDatacenters
    @@data_centers = datacenters_data.collect { | datacenter_data | self.new(softlayer_client, datacenter_data) }
  end

  @@data_centers
end

Instance Method Details

#long_nameObject

:attr_reader: long_name A longer location description



29
# File 'lib/softlayer/Datacenter.rb', line 29

sl_attr :long_name, "longName"

#nameObject

:attr_reader: A short location description



24
# File 'lib/softlayer/Datacenter.rb', line 24

sl_attr :name