March 9, 2012

Classes
Tags blog

The CCI VLAN Specification
<p>When ordering a CCI on our shopping cart you are currently unable to specify a VLAN. While there are exceptions in pl

When ordering a CCI on our shopping cart you are currently unable to specify a VLAN. While there are exceptions in place for things like VLAN-bound firewalls and load balancers, there are a number of situations outside of those in which a shared VLAN is preferable. Good news - when placing an order via the API this is something that can be accomplished!

When populating the virtualGuests property of a SoftLayer_Container_Product_Order_Virtual_Guest you need to create an array of SoftLayer_Virtual_Guest. Normally during this process you only need to provide a hostname and domain. However when placing an order with a specific VLAN in mind you will need to also include the VLAN id by defining primaryNetworkComponent->networkVlan->id or primaryBackendNetworkComponent->networkVlan->id .

virtualGuets = [
    {
        ‘hostname’ : ‘testhost’,
        ‘domain’ : ‘example.org’,
\t ‘primaryNetworkComponent: {
\t\t‘networkVlan’: {
\t\t\t‘id’: 1234
\t\t}
\t }
    }
]

I am going to assume that you, like myself do not carry around a little black book containing your VLAN information and suggest using an IP address which already exists on the target VLAN as a parameter to SoftLayer_Network_Vlan::getVlanForIpAddress.

You could even use an object mask and an existing server as a shortcut:

<?php
$client = SoftLayer_SoapClient::getClient(‘SoftLayer_Hardware_Server’, $serverId, $apiUsername,  $apiKey);
 
$mask = new SoftLayer_ObjectMask();
$mask->primaryNetworkComponent->primarySubnet->networkVlan;
$client->setObjectMask($mask);
 
try {
    $vlanId = $client->getObject()->primaryNetworkComponent->primarySubnet->networkVlan->id;
    print_r($vlanId);
} catch (Exception $e) {
    print $e->getMessage();
}


Feedback?

We would love to hear it
Open an issue