API: create VNET with VLAN_ID_AUTOMATIC

Hello,

We are creating networks through the API but we can’t find which parameter we must pass to have VLAN_ID_AUTOMATIC=1. This parameter is not explained in the documentation, only that:

The VLAN id will be the same for every interface in a given network, calculated automatically by OpenNebula. It may also be forced by specifying an VLAN_ID parameter in the Virtual Network template.

NAME="test-dad"
VN_MAD="ovswitch"
BRIDGE = "nebula"

This results in:

<VNET>
  <ID>5</ID>
  <UID>0</UID>
  <GID>0</GID>
  <UNAME>oneadmin</UNAME>
  <GNAME>oneadmin</GNAME>
  <NAME>test-dad</NAME>
  <PERMISSIONS>
    <OWNER_U>1</OWNER_U>
    <OWNER_M>1</OWNER_M>
    <OWNER_A>0</OWNER_A>
    <GROUP_U>0</GROUP_U>
    <GROUP_M>0</GROUP_M>
    <GROUP_A>0</GROUP_A>
    <OTHER_U>0</OTHER_U>
    <OTHER_M>0</OTHER_M>
    <OTHER_A>0</OTHER_A>
  </PERMISSIONS>
  <CLUSTERS>
    <ID>0</ID>
  </CLUSTERS>
  <BRIDGE><![CDATA[vswitch]]></BRIDGE>
  <PARENT_NETWORK_ID/>
  <VN_MAD><![CDATA[ovswitch]]></VN_MAD>
  <PHYDEV/>
  <VLAN_ID/>
  <VLAN_ID_AUTOMATIC>0</VLAN_ID_AUTOMATIC>
  <USED_LEASES>0</USED_LEASES>
  <VROUTERS/>
  <TEMPLATE>
    <BRIDGE><![CDATA[vswitch]]></BRIDGE>
    <PHYDEV><![CDATA[]]></PHYDEV>
    <SECURITY_GROUPS><![CDATA[0]]></SECURITY_GROUPS>
    <VN_MAD><![CDATA[ovswitch]]></VN_MAD>
  </TEMPLATE>
  <AR_POOL/>
</VNET>

I tested on 5.0.2 and 5.2.1, it looks like a bug, can you confirm before I open one?

Regards.

Hi there!
I haven’t tried with the Openvswitch driver but with a 802.1Q network if you want OpenNebula to generate a VLAN_ID automatically, I’d try to add AUTOMATIC_VLAN_ID=“YES” to your virtual network template. If you want to use 1 as the VLAN_ID I would pass VLAN_ID=1 to the API while AUTOMATIC_VLAN_ID would not used in this case.

If that works I’ll create a PR to add that info to the Openvswitch doc section.

Cheers!

Interesting, the final attribute is <VLAN_ID_AUTOMATIC>1</VLAN_ID_AUTOMATIC>, the names do not match.

Thanks a lot, I’ll open a bug for the documentation.

Unfortunately this is not usable to “fix” already wrongly defined networks.

I tried to add AUTOMATIC_VLAN_ID="YES" with onevnet update and it does not works :-/

Regards.

I finally opened the bug #4989, I’ll let the developers decide if it should go in Documentation instead of Drivers - Network, because the documentation looks clear:

  • Attribute: VLAN_ID
  • Value: The VLAN ID, will be generated if not defined
  • Mandatory: NO

Regards.