softlayer / softlayer-ruby

http://softlayer.github.io/softlayer-ruby/
MIT License
54 stars 35 forks source link

Order ESXi using SoftLayer::BareMetalServerOrder_Package using the wrong vlan #92

Closed bttong closed 9 years ago

bttong commented 9 years ago

Hello, I'm using SoftLayer::BareMetalServerOrder_Package to order ESXi and it works fine except I don't see the option to specify public and private vlans that I would like the server to join. I see the options to specify private_vlan_id and public_vlan_id in BareMetalServerOrder. Is it possible to do something similar for BareMetalServerOrder_Package? Thanks.

SLsthompson commented 9 years ago

It must be possible as the createObject mechanism used by BareMetalServerOrder just uses the same package-based mechanism in implementation. Let me do some research and I will get back with you.

bttong commented 9 years ago

Hi sthompson, I'm wondering if you have any update regarding this issue.

SLsthompson commented 9 years ago

I've not received word back from the email I sent. Let me track down the person and ask them directly.

SLsthompson commented 9 years ago

OK. I spoke with an engineer who was able to offer guidance. The technique is pretty straightforward.

When putting together the order that is sent to placeOrder you need to modify the hardware template provided so that it includes a reference to the id of the VLAN you want to set on the device.

It's going to look something like this:

{
    "hardware" =>  [{
        "primaryBackendNetworkComponent" =>  {
            "networkVlanId" => 12345
        },
        "primaryNetworkComponent" => {
            "networkVlanId" => 12345
        }
    }]
}

You can modify the order template by passing a block to verify or place_order!. That block will be handed the order template and should return a modified template so something like this may work (though realize this was typed into GitHub, and has not gone through Ruby yet:

bms_order = SoftLayer::BareMetalServerOrder_Package.new()
bms_order.package = # some product package
bms_order.hostname = # some host name
bms_order.domain = # some domain

add_lans = lambda { |order_template|
order_template['hardware'][0]['primaryBackendNetworkComponent'] = { "networkVlanId" => 12345 }
order_template
}

bms_order.verify(&add_lans)
bms_order.place_order!(&add_lans)
bttong commented 9 years ago

Thanks a lot. I will give it a try.

bttong commented 9 years ago

Thanks.

bttong commented 9 years ago

Thanks. I got it to work with your suggestion. I think it would be great to enhance the API to have vlan as SoftLayer::BareMetalServerOrder_Package attribute.

ju2wheels commented 9 years ago

@bttong ive added them to both the VirtualServer and BareMetalServer order package wrappers.