Skip to content

Commit 1b19697

Browse files
committed
Cleanup case usage of for VLAN and provision scripts URI.
v4-cleanup-required
1 parent 87d6f36 commit 1b19697

5 files changed

Lines changed: 64 additions & 12 deletions

File tree

lib/softlayer/Account.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,26 @@ def service
264264
# The IDs of the different segments can be helpful for ordering
265265
# firewalls.
266266
#
267+
def find_vlan_with_number(vlan_number)
268+
filter = SoftLayer::ObjectFilter.new() { |filter|
269+
filter.accept('networkVlans.vlanNumber').when_it is vlan_number
270+
}
271+
272+
vlan_data = self.service.object_mask("mask[id,vlanNumber,primaryRouter,networkSpace]").object_filter(filter).getNetworkVlans
273+
return vlan_data
274+
end
275+
276+
##
277+
# Searches the account's list of VLANs for the ones with the given
278+
# vlan number. This may return multiple results because a VLAN can
279+
# span different routers and you will get a separate segment for
280+
# each router.
281+
#
282+
# The IDs of the different segments can be helpful for ordering
283+
# firewalls.
284+
#
285+
# DEPRECATION WARNING: This method is deprecated in favor of find_vlan_with_number
286+
# and will be removed in the next major release.
267287
def find_VLAN_with_number(vlan_number)
268288
filter = SoftLayer::ObjectFilter.new() { |filter|
269289
filter.accept('networkVlans.vlanNumber').when_it is vlan_number

lib/softlayer/BareMetalServerOrder.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ class BareMetalServerOrder
7878
# Object responding to to_s and providing a valid URI, The URI of a post provisioning script to run on
7979
# this server once it is created.
8080
# Corresponds to +postInstallScriptUri+ in the +createObject+ documentation
81+
attr_accessor :provision_script_uri
82+
83+
# Object responding to to_s and providing a valid URI, The URI of a post provisioning script to run on
84+
# this server once it is created.
85+
# Corresponds to +postInstallScriptUri+ in the +createObject+ documentation
86+
#
87+
# DEPRECATION WARNING: This attribute is deprecated in favor of provision_script_uri
88+
# and will be removed in the next major release.
8189
attr_accessor :provision_script_URI
8290

8391
# Boolean, If true then the server will only have a private network interface (and no public network interface)
@@ -149,13 +157,14 @@ def hardware_instance_template
149157

150158
template['privateNetworkOnlyFlag'] = true if @private_network_only
151159

152-
template['datacenter'] = {"name" => @datacenter.name} if @datacenter
153-
template['userData'] = [{'value' => @user_metadata}] if @user_metadata
154-
template['networkComponents'] = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed
155-
template['postInstallScriptUri'] = @provision_script_URI.to_s if @provision_script_URI
156-
template['sshKeys'] = @ssh_key_ids.collect { |ssh_key| {'id'=> ssh_key.to_i } } if @ssh_key_ids
157-
template['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
160+
template['datacenter'] = {"name" => @datacenter.name} if @datacenter
161+
template['userData'] = [{'value' => @user_metadata}] if @user_metadata
162+
template['networkComponents'] = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed
163+
template['postInstallScriptUri'] = @provision_script_URI.to_s if @provision_script_URI
164+
template['postInstallScriptUri'] = @provision_script_uri.to_s if @provision_script_uri
165+
template['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
158166
template['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id
167+
template['sshKeys'] = @ssh_key_ids.collect { |ssh_key| {'id'=> ssh_key.to_i } } if @ssh_key_ids
159168

160169
if @disks && !@disks.empty?
161170
template['hardDrives'] = @disks.collect do |disk|

lib/softlayer/BareMetalServerOrder_Package.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ class BareMetalServerOrder_Package < Server
7575

7676
# The URI of a script to execute on the server after it has been provisioned. This may be
7777
# any object which accepts the to_s message. The resulting string will be passed to SoftLayer API.
78+
attr_accessor :provision_script_uri
79+
80+
# The URI of a script to execute on the server after it has been provisioned. This may be
81+
# any object which accepts the to_s message. The resulting string will be passed to SoftLayer API.
82+
#
83+
# DEPRECATION WARNING: This attribute is deprecated in favor of provision_script_uri
84+
# and will be removed in the next major release.
7885
attr_accessor :provision_script_URI
7986

8087
# An array of the ids of SSH keys to install on the server upon provisioning
@@ -151,6 +158,7 @@ def hardware_order
151158
product_order['imageTemplateGlobalIdentifier'] = @image_template.global_id if @image_template
152159
product_order['location'] = @datacenter.id if @datacenter
153160
product_order['provisionScripts'] = [@provision_script_URI.to_s] if @provision_script_URI
161+
product_order['provisionScripts'] = [@provision_script_uri.to_s] if @provision_script_uri
154162
product_order['sshKeys'] = [{ 'sshKeyIds' => @ssh_key_ids }] if @ssh_key_ids
155163
product_order['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
156164
product_order['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id

lib/softlayer/VirtualServerOrder.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ class VirtualServerOrder
8484
attr_accessor :private_vlan_id
8585

8686
# String, The URI of a post provisioning script to run on this server once it is created
87+
attr_accessor :provision_script_uri
88+
89+
# String, The URI of a post provisioning script to run on this server once it is created
90+
#
91+
# DEPRECATION WARNING: This attribute is deprecated in favor of provision_script_uri
92+
# and will be removed in the next major release.
8793
attr_accessor :provision_script_URI
8894

8995
# Integer, The id of the public VLAN this server should join
@@ -156,13 +162,14 @@ def virtual_guest_template
156162
template['dedicatedAccountHostOnlyFlag'] = true if @dedicated_host_only
157163
template['privateNetworkOnlyFlag'] = true if @private_network_only
158164

159-
template['datacenter'] = {"name" => @datacenter.name} if @datacenter
160-
template['userData'] = [{'value' => @user_metadata}] if @user_metadata
161-
template['networkComponents'] = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed
162-
template['postInstallScriptUri'] = @provision_script_URI.to_s if @provision_script_URI
163-
template['sshKeys'] = @ssh_key_ids.collect { |ssh_key_id| {'id'=> ssh_key_id.to_i } } if @ssh_key_ids
164-
template['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
165+
template['datacenter'] = {"name" => @datacenter.name} if @datacenter
166+
template['userData'] = [{'value' => @user_metadata}] if @user_metadata
167+
template['networkComponents'] = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed
168+
template['postInstallScriptUri'] = @provision_script_URI.to_s if @provision_script_URI
169+
template['postInstallScriptUri'] = @provision_script_uri.to_s if @provision_script_uri
170+
template['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
165171
template['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id
172+
template['sshKeys'] = @ssh_key_ids.collect { |ssh_key_id| {'id'=> ssh_key_id.to_i } } if @ssh_key_ids
166173

167174
if @image_template
168175
template['blockDeviceTemplateGroup'] = {"globalIdentifier" => @image_template.global_id}

lib/softlayer/VirtualServerOrder_Package.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ class VirtualServerOrder_Package < Server
7575

7676
# The URI of a script to execute on the server after it has been provisioned. This may be
7777
# any object which accepts the to_s message. The resulting string will be passed to SoftLayer API.
78+
attr_accessor :provision_script_uri
79+
80+
# The URI of a script to execute on the server after it has been provisioned. This may be
81+
# any object which accepts the to_s message. The resulting string will be passed to SoftLayer API.
82+
#
83+
# DEPRECATION WARNING: This attribute is deprecated in favor of provision_script_uri
84+
# and will be removed in the next major release.
7885
attr_accessor :provision_script_URI
7986

8087
# An array of the ids of SSH keys to install on the server upon provisioning
@@ -150,6 +157,7 @@ def virtual_server_order
150157
product_order['imageTemplateGlobalIdentifier'] = @image_template.global_id if @image_template
151158
product_order['location'] = @datacenter.id if @datacenter
152159
product_order['provisionScripts'] = [@provision_script_URI.to_s] if @provision_script_URI
160+
product_order['provisionScripts'] = [@provision_script_uri.to_s] if @provision_script_uri
153161
product_order['sshKeys'] = [{ 'sshKeyIds' => @ssh_key_ids }] if @ssh_key_ids
154162
product_order['virtualGuests'][0]['userData'] = @user_metadata if @user_metadata
155163
product_order['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id

0 commit comments

Comments
 (0)