0

background

I can get a vlan's subnet info by the flowing python script:

# Declare an Object Mask to get additional information
    object_mask = 'mask[primaryRouter,subnets[id,billingItem,cidr,version,addressSpace,subnetType,networkIdentifier,totalIpAddresses,usableIpAddressCount,ipAddresses[ipAddress, isReserved, virtualGuest, hardware]]]'
    # Declare an Object Filter to get information from specific vlan
    filter = {'networkVlans': {'id': {'operation': vlan_id}}}
    return self.sl_account.getNetworkVlans(mask=object_mask, filter=filter)[0]

And the result contains:

[... 'subnets': [{'cidr': 28,
              'id': 986245,
              'billingItem': {'allowCancellationFlag': 1,}
              orderItemId': 223126909,
              'ipAddresses': [{'ipAddress': '169.38.73.xxx', ...
               'subnetType': 'STATIC_IP_ROUTED',
             'totalIpAddresses': '8',
             'usableIpAddressCount': '5',
             'version': 4},
             ...]
            }
            ...
            ]]

question

The result of STATIC_IP_ROUTED subnet do not contain the virtualGuest item.

  1. Now I want to know which VSI has bind this subnet? Does any other mask can helps?

  2. Or, How can I get the secondary ip info of a vsi?

Lippman S
  • 15
  • 3

1 Answers1

1

You may add the subnets relational property to go deeper and display the VSI on which the subnet is binded through the property endpointIpAddress.

Please try your code with the mask previously mentioned:

# Declare an Object Mask to get additional information
object_mask = 'mask[primaryRouter,subnets[id,billingItem,cidr,version,addressSpace,subnetType,networkIdentifier,totalIpAddresses,usableIpAddressCount,ipAddresses[id, ipAddress, virtualGuest[id], hardware[id]]], subnets[endPointIpAddress[id,ipAddress,subnet[id, datacenter[longName,name]],hardware[id,fullyQualifiedDomainName],virtualGuest[id,fullyQualifiedDomainName]]]]'

# Declare an Object Filter to get information from specific vlan
filter = {'networkVlans': {'id': {'operation': vlan_id}}}

return self.sl_account.getNetworkVlans(mask=object_mask, filter=filter)[0]

Or you may use the SoftLayer_Account::getSubnets method.

# Declare an Object Mask to get additional subnet information
object_mask = 'mask[id, networkIdentifier, subnetType, totalIpAddresses, datacenter[longName, name], networkVlan[id, vlanNumber], endPointIpAddress[id,ipAddress,subnet[id, datacenter[longName,name]],hardware[id,fullyQualifiedDomainName],virtualGuest[id,fullyQualifiedDomainName]]]'

# Declare an Object Filter to get information from specific Subnet.
filter = {"subnets":{"id":{"operation":subnet_id}}}

subnetsResult = client ['Account'].getSubnets(filter = filter, mask = object_mask)

print(subnetsResult)

On both solutions you will see the VirtualGuest item information.

In order to retrieve the secondary ip Addresses of a VSI please refer to this post How to get secondary ip addresses.

Fernando Iquiza
  • 531
  • 3
  • 7