3737# a server.
3838def tl_dr_version
3939 client = SoftLayer ::Client . new (
40- # :username => "joecustomer" # enter your username here
40+ # :username => "joecustomer", # enter your username here
4141 # :api_key => "feeddeadbeefbadf00d..." # enter your api key here
4242 )
4343
4444 # Select a package
45- quad_intel_package = SoftLayer ::ProductPackage . package_with_id ( client , 32 )
45+ product_package = SoftLayer ::ProductPackage . package_with_id ( 251 , client )
4646
4747 # Find required Categories and fill config_options with defaults
4848 config_options = { }
49- required_categories = quad_intel_package . configuration . select { |category | category . required? }
49+ required_categories = product_package . configuration . select { |category | category . required? }
5050 required_categories . each { |required_category | config_options [ required_category . categoryCode ] = required_category . default_option }
5151
52- # Provide a value for missing config categories
53- config_options [ 'server' ] = 1417 # price id of Quad Processor Quad Core Intel 7420 - 2.13GHz (Dunnington) - 4 x 6MB / 8MB cache
52+ # Provide a value for missing config categories as they don't have defaults
53+ config_options [ 'server' ] = 50691 # Dual Intel Xeon E5-2620 v3 (12 Cores, 2.40 GHz)
54+ config_options [ 'ram' ] = 49427 # 64 GB RAM
55+ config_options [ 'disk0' ] = 49811 # 1.00 TB SATA
5456
5557 # With all the config options in place we can now construct the product order.
56- server_order = SoftLayer ::BareMetalServerOrder_Package . new ( quad_intel_package , client )
57- server_order . location = 'sng01'
58+ server_order = SoftLayer ::BareMetalServerOrder_Package . new ( product_package , client )
59+ server_order . datacenter = SoftLayer :: Datacenter . datacenter_named 'sng01' , client
5860 server_order . hostname = 'sample'
5961 server_order . domain = 'softlayerapi.org'
6062 server_order . configuration_options = config_options
@@ -69,7 +71,7 @@ def tl_dr_version
6971
7072begin
7173 client = SoftLayer ::Client . new (
72- # :username => "joecustomer" # enter your username here
74+ # :username => "joecustomer", # enter your username here
7375 # :api_key => "feeddeadbeefbadf00d..." # enter your api key here
7476 )
7577
@@ -80,14 +82,14 @@ def tl_dr_version
8082 packages . each { |package | puts "#{ package . id } \t #{ package . name } " }
8183
8284 # For this example, we'll assume that we've selected the a package
83- # with an id of 32 representing a "Quad Processor, Quad Core Intel "
84- quad_intel_package = SoftLayer ::ProductPackage . package_with_id ( 32 , client )
85+ # with an id of 251 representing a "Dual E5-2600 v3 Series (12 Drives) "
86+ product_package = SoftLayer ::ProductPackage . package_with_id ( 251 , client )
8587
8688 # Now we need to now what ProductItemCategories are required to
8789 # configure a server in that package. This code prints out a table
8890 # of the required category codes with a description of each
89- puts "\n Required Categories for '#{ quad_intel_package . name } ':"
90- required_categories = quad_intel_package . configuration . select { |category | category . required? }
91+ puts "\n Required Categories for '#{ product_package . name } ':"
92+ required_categories = product_package . configuration . select { |category | category . required? }
9193 max_code_length = required_categories . inject ( 0 ) { |max_code_length , category | [ category . categoryCode . length , max_code_length ] . max }
9294 printf "%#{ max_code_length } s\t Category Description\n " , "Category Code"
9395 printf "%#{ max_code_length } s\t --------------------\n " , "-------------"
@@ -96,7 +98,7 @@ def tl_dr_version
9698 # We will need to provide values for each of the required category codes in our
9799 # configuration_options. Let's see what configuration options are available for
98100 # just one of the categories... Say 'os'
99- os_category = quad_intel_package . category ( 'os' )
101+ os_category = product_package . category ( 'os' )
100102 config_options = os_category . configuration_options
101103 puts "\n Configuration options in the 'os' category:"
102104 config_options . each { |option | printf "%5s\t #{ option . description } \n " , option . price_id }
@@ -119,20 +121,25 @@ def tl_dr_version
119121 # Regardless of the default values... we know we want the os selection we discovered above:
120122 config_options [ 'os' ] = os_config_option
121123
124+ # Provide a value for missing config categories as they don't have defaults
125+ config_options [ 'server' ] = 50691 # Dual Intel Xeon E5-2620 v3 (12 Cores, 2.40 GHz)
126+ config_options [ 'ram' ] = 49427 # 64 GB RAM
127+ config_options [ 'disk0' ] = 49811 # 1.00 TB SATA
128+
122129 # And we can customize the default config by providing selections for any config categories
123130 # we are interested in
124131 config_options . merge! ( {
125- 'server ' => 1417 , # price id of Quad Processor Quad Core Intel 7420 - 2.13GHz (Dunnington) - 4 x 6MB / 8MB cache
126- 'port_speed ' => 274 # 1 Gbps Public & Private Network Uplinks
132+ 'port_speed ' => 37220 , # 1 Gbps Public & Private Network Uplinks (Unbonded)
133+ 'bandwidth ' => 50233 # 1000 GB Bandwidth
127134 } )
128135
129136 # We have a configuration for the server, we also need a location for the new server.
130137 # The package can give us a list of locations. Let's print out that list
131- puts "\n Data Centers for '#{ quad_intel_package . name } ':"
132- quad_intel_package . datacenter_options . each { |datacenter | puts "\t #{ datacenter . name } " }
138+ puts "\n Data Centers for '#{ product_package . name } ':"
139+ product_package . datacenter_options . each { |datacenter | puts "\t #{ datacenter . name } " }
133140
134141 # With all the config options in place we can now construct the product order.
135- server_order = SoftLayer ::BareMetalServerOrder_Package . new ( quad_intel_package , client )
142+ server_order = SoftLayer ::BareMetalServerOrder_Package . new ( product_package , client )
136143 server_order . datacenter = SoftLayer ::Datacenter . datacenter_named 'sng01' , client
137144 server_order . hostname = 'sample'
138145 server_order . domain = 'softlayerapi.org'
@@ -151,4 +158,3 @@ def tl_dr_version
151158rescue Exception => exception
152159 $stderr. puts "An exception occurred while trying to complete the SoftLayer API calls #{ exception } "
153160end
154-
0 commit comments