Skip to content

VirtualServerOrder_Package class doesn't define VLANs #111

Open

Description

@rubercuellar

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)

Activity

  1. renier commented on Sep 17, 2016

    @renier
    Contributor

    Why is this a softlayer-ruby issue?

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

  2. ArtsiomMusin commented on Nov 23, 2016

    @ArtsiomMusin
    Contributor

    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?

  3. renier commented on Nov 23, 2016

    @renier
    Contributor

    @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

  4. ArtsiomMusin commented on Nov 24, 2016

    @ArtsiomMusin
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions