# API: create VNET with VLAN\_ID\_AUTOMATIC

**URL:** <https://forum.opennebula.io/t/api-create-vnet-with-vlan-id-automatic/3603>\
**Category:** Product Support\
**Created:** [January 18, 2017, 2:58pm UTC](https://forum.opennebula.io/t/api-create-vnet-with-vlan-id-automatic/3603 "2017-01-18T14:58:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaD](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/dad/32/8466_2.png) [@DaD](https://forum.opennebula.io/u/DaD)\
**Post date:** [January 18, 2017, 2:58pm UTC](https://forum.opennebula.io/t/api-create-vnet-with-vlan-id-automatic/3603/1 "2017-01-18T14:58:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mcabrerizo](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/mcabrerizo/32/4829_2.png) [@mcabrerizo](https://forum.opennebula.io/u/mcabrerizo)\
**Post date:** [January 18, 2017, 3:35pm UTC](https://forum.opennebula.io/t/api-create-vnet-with-vlan-id-automatic/3603/2 "2017-01-18T15:35:48Z")

</div>

Hi there!  
I haven’t tried with the Openvswitch driver but with a [802.1Q network](http://docs.opennebula.org/5.2/deployment/open_cloud_networking_setup/hm-vlan.html#defining-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!

---

<div class="post-metadata">

**Author:** ![DaD](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/dad/32/8466_2.png) [@DaD](https://forum.opennebula.io/u/DaD)\
**Post date:** [January 18, 2017, 3:38pm UTC](https://forum.opennebula.io/t/api-create-vnet-with-vlan-id-automatic/3603/3 "2017-01-18T15:38:20Z")

</div>

> [@mcabrerizo](#):
>
> AUTOMATIC\_VLAN\_ID=“YES”

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.

---

<div class="post-metadata">

**Author:** ![DaD](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/dad/32/8466_2.png) [@DaD](https://forum.opennebula.io/u/DaD)\
**Post date:** [January 18, 2017, 4:31pm UTC](https://forum.opennebula.io/t/api-create-vnet-with-vlan-id-automatic/3603/4 "2017-01-18T16:31:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DaD](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/dad/32/8466_2.png) [@DaD](https://forum.opennebula.io/u/DaD)\
**Post date:** [January 20, 2017, 2:28pm UTC](https://forum.opennebula.io/t/api-create-vnet-with-vlan-id-automatic/3603/5 "2017-01-20T14:28:43Z")

</div>

> [@DaD](#):
>
> Thanks a lot, I’ll open a bug for the documentation.

I finally opened [the bug #4989](https://dev.opennebula.org/issues/4989), I’ll let the developers decide if it should go in `Documentation` instead of `Drivers - Network`, because [the documentation](http://docs.opennebula.org/5.2/deployment/open_cloud_networking_setup/openvswitch.html#defining-an-open-vswitch-network) looks clear:

- Attribute: VLAN\_ID
- Value: The VLAN ID, will be generated if not defined
- Mandatory: NO

Regards.
