Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VirtualServerOrder_Package class doesn't define VLANs #111

Open
rubercuellar opened this issue Apr 11, 2016 · 4 comments
Open

VirtualServerOrder_Package class doesn't define VLANs #111

rubercuellar opened this issue Apr 11, 2016 · 4 comments

Comments

@rubercuellar
Copy link

There is an issue at the moment to specify vlans:

 product_order['primaryNetworkComponent']        = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id
 product_order['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id

The vlans should be specified inside of "hardware" object. This could be a possible solution

  def virtual_server_order
      product_order = {
        'packageId'        => @package.id,
        'useHourlyPricing' => !!@hourly,
        'hardware'    => [{
                                 'domain'   => @domain,
                                 'hostname' => @hostname,
                                 'primaryNetworkComponent' => { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id,
                                 'primaryBackendNetworkComponent' => { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id
                               }]
      }

I replaced 'hardware' instead of 'virtualGuests', because it is not possible to set vlans using 'virtualGuests' object. (It seems an issue)

@renier
Copy link
Contributor

renier commented Sep 17, 2016

Why is this a softlayer-ruby issue?

It makes sense that the network components are specified per device, after all.

@ArtsiomMusin
Copy link
Contributor

ArtsiomMusin commented Nov 23, 2016

I faced the issue here when a private VLAN is not assigned correctly. Whenever I try to use any other VLAN, the server is created with a default VLAN which is auto-assigned when, for example, you don't specify a VLAN at all.

Playing around with changes suggested by @rubercuellar didn't help. I found a helpful solution in #92
Basically what I did for my workaround was to replace
{ "networkVlan" => {"id" => 123 } }
to
{ "networkVlanId" => 123 }

At the moment my final workaround, which works correctly, looks like that:
add_vlans = lambda { |order_template| order_template['primaryBackendNetworkComponent'] = { "networkVlanId" => private_vlan_id } order_template } server_order.verify(&add_vlans) server_order.place_order!(&add_vlans)

@renier, still not a softlayer-ruby issue?

@renier
Copy link
Contributor

renier commented Nov 23, 2016

@ArtsiomMusin could should show the whole code you are trying?, from when you get an instance of server order. and use '```' do delimit the code block

@ArtsiomMusin
Copy link
Contributor

sorry I cannot show the whole code... confidential stuff you know.
But here is the main calls we use to build the order:

server_order = ::SoftLayer::VirtualServerOrder_Package.new(@client)

vs_package = ::SoftLayer::ProductPackage.virtual_server_package(@client)
required_categories = vs_package.configuration.select(&:required?)
config_options = {}
required_categories.each { |required_category| config_options[required_category.categoryCode] = required_category.default_option }

server_order.datacenter = ::SoftLayer::Datacenter.datacenter_named dc_name, @client
server_order.image_template = ::SoftLayer::ImageTemplate.template_with_id(template_id, client: @client)

server_order.hostname = hostname
server_order.domain = domain
server_order.configuration_options = config_options

add_vlans = lambda do |order_template|
  order_template['primaryBackendNetworkComponent'] =
    { 'networkVlanId' => input[:private_vlan_id].to_i } unless input[:private_vlan_id].blank?
  order_template
end

server_order.verify(&add_vlans)
server_order.place_order!(&add_vlans)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants