Search code examples
rubyapiibm-cloud-infrastructure

create a virtual server under a specific subnet


I am using softlayer's ruby API, and i am trying to create a virtual server under a specific subnet in a VLAN and i couldnt find a way of doing it. At the moment i am using the following json:

 creation_hash = {
    'complexType' => 'SoftLayer_Virtual_Guest',
    'hostname' => XXX,
    'domain' => XXXX
    'datacenter' => { 'name' => @datacenter },
    'startCpus' => sl_machine_type(@params['instance_type'])['cpu'],
    'maxMemory' => sl_machine_type(@params['instance_type'])['memory'],
    'hourlyBillingFlag' => true,
    'blockDeviceTemplateGroup' => { 'globalIdentifier' => @params['image_id'] },
    'localDiskFlag' => false,
    'dedicatedAccountHostOnlyFlag' => true,
    'primaryBackendNetworkComponent' => {
      'networkVlan' => {
        'id' => @private_vlan['id']
      }
    },
    'networkComponents' => [{ 'maxSpeed' => 1000 }],
    'privateNetworkOnlyFlag' => true
  }

so when i choose a VLAN, it chooses a random subnet under that VLAN. how can i specify a subnet ? i didnt find this option in the documentation.


Solution

  • Unfortunately it is not possible to specify which subnet a server should be provisioned into.

    The provisioning system will choose an IP from the VLAN's primary subnet.

    The wording is a bit vague in this article, but it states that IPs are automatically assigned. I will get it updated to state that it is not possible to request a specific block of IPs for the primary.

    Adding an IP to the server from a secondary subnet directly after provisioning could be a possible work around. This could be done with a post install script or config manager(salt, chef, etc), if automation is needed. It would also allow you to control specifically which IPs are used for each server.