<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>So far I have come up with a workaround - again not very elegant - but at least it starts up the container so that it gets a DHCP IP address from my tagged VLAN 10.  I just use this little script to start it up - instead of using "lxc start lxdora7a" I use
 my script "lxdora7a.start" which contains this:</p>
<p><br>
</p>
<p></p>
<div>lxc start lxdora7a<br>
sudo ovs-vsctl set port lxdora7a tag=10<br>
sleep 2<br>
lxc list<br>
<br>
which reliably starts up the container and gets it an IP address.<br>
<br>
What I'm looking for is a way to tag the created port "lxdora7a" within the config file so that I dont' have to start the containers with these scripts.<br>
<br>
<code>devices: </code><br>
<code><span style="color:rgb(255,0,0)"><b>eth0: </b></span></code><span style="color:rgb(255,0,0)"><b><br>
<code><span style="color:rgb(255,0,0)">host_name: lxdora7a </span></code><-- need to tell this to have "TAG=10" somehow...or maybe another parameter is added to this stanza?<br>
<span style="color:rgb(255,0,0)"><code><span style="color:rgb(255,0,0)">name: eth0
</span></code><br>
<span style="color:rgb(255,0,0)"><code><span style="color:rgb(255,0,0)">nictype: bridged
</span></code><br>
<span style="color:rgb(255,0,0)"><code><span style="color:rgb(255,0,0)">parent: sw1
</span></code><br>
<span style="color:rgb(255,0,0)"><code><span style="color:rgb(255,0,0)">type: nic
</span></code></span></span></span></span></b></span><br>
</div>
<br>
<p></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Gilbert Standen <gilstanden@hotmail.com><br>
<b>Sent:</b> Friday, September 23, 2016 6:58:28 PM<br>
<b>To:</b> lxc-devel@lists.linuxcontainers.org<br>
<b>Subject:</b> Putting a VLAN on an LXD LXC container config - help</font>
<div> </div>
</div>
<div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p></p>
<div class="sites-codeblock sites-codesnippet-block"><code>help <br>
<br>
oracle@g70:~ lxc config show lxdora7a<br>
<br>
name: lxdora7a </code><br>
<code>profiles: </code><br>
<code>- default </code><br>
<code>config: </code><br>
<code>volatile.base_image: ad1d975af5bee4ef947ecca36084dbe2934277ed62e6a02c1fa60f1c902d2280
</code><br>
<code>volatile.eth0.hwaddr: 00:16:3e:da:03:3e </code><br>
<code>volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":231072,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":231072,"Nsid":0,"Maprange":65536}]'
</code><br>
<code>devices: </code><br>
<code><span style="color:rgb(255,0,0)"><b>eth0: </b></span></code><span style="color:rgb(255,0,0)"><b><br>
<code><span style="color:rgb(255,0,0)">host_name: lxdora7a </span></code><br>
<span style="color:rgb(255,0,0)"><code><span style="color:rgb(255,0,0)">name: eth0
</span></code><br>
<span style="color:rgb(255,0,0)"><code><span style="color:rgb(255,0,0)">nictype: bridged
</span></code><br>
<span style="color:rgb(255,0,0)"><code><span style="color:rgb(255,0,0)">parent: sw1
</span></code><br>
<span style="color:rgb(255,0,0)"><code><span style="color:rgb(255,0,0)">type: nic
</span></code></span></span></span></span></b></span><br>
<code>root: </code><br>
<code>path: / </code><br>
<code>type: disk </code><br>
<code>ephemeral: false </code><br>
<br>
<code>oracle@g70:~$<br>
<br>
How do I put a VLAN TAG=10 on the above so that the lxdora7a port on my sw1 switch gets created with a TAG=10?<br>
<br>
</code></div>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3">I could not find a reference for how to add VLAN tagging in the lxc config file above, but I was able to manually put the VLAN tag on the port that the LXD container
 automatically creates when it boots using the following command after it had already booted.  At that point, eth0 is still unconfigured even though onboot is set to YES in the ifcfg-eth0 because the VLAN 10 is not passing the traffic from the LXD container
 lxdora7a because of the VLAN'g.</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3"><br>
</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3">So I ran this command to put a VLAN 10 on the port after the lxdora7a container had already booted:<br>
</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3"><br>
</font></span></span></code></p>
<div class="sites-codeblock sites-codesnippet-block"><font size="3"><font size="4"><code>sudo ovs-vsctl set port lxdora7a tag=10<br>
<br>
</code></font></font></div>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3">Then I logged into the container using:</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3"><br>
</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3">lxc exec lxdora7a /bin/sh
<br>
</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3"><br>
</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3">command and ran "ifup eth0" which brought up the network interface, got a dhcp address from my isc-dhcp-server and updated my DNS dynamically with the DNS IP info. 
 Again, not an elegant solution, but at least it gets me in business.  I'd like to have the lxdora7a port on sw1 created automatically with a vlan tag on it.</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3"><br>
</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3">In LXC I do this by using a script - can the same be done with this LXD LXC container config ?  Here's how I do that with LXC:</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3"><br>
</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3"></p>
<div>lxc.network.script.up = /etc/network/if-up.d/openvswitch/ora72c10-pub-ifup-sw1<br>
lxc.network.script.down = /etc/network/if-down.d/openvswitch/ora72c10-pub-ifdown-sw1<br>
</div>
<br>
</font></span></span></code>
<p></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3">and then the up script looks like this:</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3"><br>
</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3"></p>
<div>root@g70:/var/lib/lxc/ora72c10# cat /etc/network/if-up.d/openvswitch/ora72c10-pub-ifup-sw1<br>
#!/bin/bash<br>
ovsBr='sw1'<br>
ovs-vsctl add-port ${ovsBr} $5<br>
ovs-vsctl set port $5 tag=10<br>
root@g70:/var/lib/lxc/ora72c10# <br>
</div>
<br>
</font></span></span></code>
<p></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3">Thanks,</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3"><br>
</font></span></span></code></p>
<p><code><span style="font-family:arial,sans-serif"><span style="color:rgb(0,0,0)"><font size="3">Gilbert<br>
</font></span></span></code><br>
<br>
</p>
<br>
<p></p>
</div>
</div>
</body>
</html>