Thanks Laine,

I've wrote patch v2 and help to review ;-)

*Leno Hou*
E-mail :  leno...@gmail.com


On Thu, Dec 1, 2016 at 6:43 AM, Laine Stump <la...@laine.org> wrote:

> On 11/30/2016 02:41 AM, Leno Hou wrote:
>
> Hi Laine,
>
> Could you give this requirement that support define vlan interface with
> non-default name in detail ?
>
> Thanks.
>
>
> Your current patch will report an existing vlan interface with a name
> other than the default $phys.$vlan (i.e. it turns the ifcfg file into XML).
> We need to be able to define a new interface with non-default name (i.e.
> turn the XML into an ifcfg file). That is done with netcf's ncf_define()
> function, which is aided by the transforms in redhat-get.xsl.
>
> With this half implemented, someone could define an interface like this:
>
>
>       <interface type='vlan' name='vlan1292'>
>         <start mode='onboot'/>
>         <protocol family='ipv4'>
>           <ip address='10.254.5.254' prefix='24'/>
>         </protocol>
>         <vlan tag='1292'>
>           <interface name='eth0'/>
>         </vlan>
>      </interface>
>
> and netcf would produce the file /etc/sysconfig/network-scripts/ifcfg-vlan1292
> that would contain this:
>
>     DEVICE="vlan1292"
>     PHYSDEV="eth0"
>     VLAN="yes"
>     ONBOOT="yes"
>     BOOTPROTO="none"
>     IPADDR="10.254.5.254"
>     NETMASK="255.255.255.0"
>
> Right now when you do that, it *says* that it has been defined, but no
> file is created in /etc/sysconfig/network-scripts.
>
> (Once you figure out why it's not creating the file ifcfg-vlan1292 ,I
> *think* the only addition that will be necessary in the file is the line
> PHYSDEV="eth0")
>
>
> On Wed, Nov 30, 2016 at 3:06 AM, Laine Stump <la...@laine.org> wrote:
>
>> Thanks for taking the time to dig into the code! That's very helpful.
>>
>> We need to also support going in the other direction (defining a vlan
>> interface with a non-default name and having the XML properly created. This
>> would mostly be handled in redhat-get.xsl, but might also need some
>> supporting stuff in the C part of the code (I haven't looked).
>>
>>
>>
>> On 11/25/2016 12:31 PM, Leno Hou wrote:
>>
>>> This patch fixes the problem as shown below.
>>> * virsh dumpxml failed with vlan1292 in inactive status
>>> * virt-manager failed to view vlan1292 interface details.
>>>
>>> Following is steps to reproduce in virsh.
>>> 1) setup 802.1q vlan tagging using ifcfg-files
>>>      #cat > /etc/sysconfig/network-scripts/ifcfg-vlan1292 < EOF
>>>        VLAN=yes
>>>        VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD
>>>        DEVICE=vlan1292
>>>        PHYSDEV=eth0
>>>        ONBOOT=yes
>>>        BOOTPROTO=static
>>>        IPADDR=10.254.5.254
>>>        NETMASK=255.255.255.0
>>>        TYPE=Ethernet
>>>        NM_CONTROLLED=no
>>>        EOF
>>>
>>> 2) active vlan interface and dumpxml
>>>     #ifup vlan1292
>>>     #virsh iface-dumpxml vlan1292
>>>       <interface type='vlan' name='vlan1292'>
>>>         <protocol family='ipv4'>
>>>           <ip address='10.254.5.254' prefix='24'/>
>>>         </protocol>
>>>         <protocol family='ipv6'>
>>>           <ip address='fe80::4:21ff:fe00:b300' prefix='64'/>
>>>         </protocol>
>>>         <link speed='1000' state='up'/>
>>>         <vlan tag='1292'>
>>>           <interface name='eth0'/>
>>>         </vlan>
>>>      </interface>
>>>
>>> 3) deactive vlan interface and dumpxml
>>>     #ifdown vlan1292
>>>     #virsh iface-dumpxml vlan1292
>>>          error: XML error: vlan interface misses the tag attribute
>>>
>>> Once applied this patch, it's will be successfully return the results:
>>>     #virsh iface-dumpxml vlan1292
>>>       <interface type='vlan' name='vlan1292'>
>>>         <start mode='onboot'/>
>>>         <protocol family='ipv4'>
>>>           <ip address='10.254.5.254' prefix='24'/>
>>>         </protocol>
>>>         <vlan tag='1292'>
>>>           <interface name='eth0'/>
>>>         </vlan>
>>>      </interface>
>>>
>>> Signed-off-by: Leno Hou <leno...@gmail.com>
>>> ---
>>>   data/xml/redhat-put.xsl | 21 ++++++++++++++++-----
>>>   1 file changed, 16 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/data/xml/redhat-put.xsl b/data/xml/redhat-put.xsl
>>> index ed56c66..0a370fe 100644
>>> --- a/data/xml/redhat-put.xsl
>>> +++ b/data/xml/redhat-put.xsl
>>> @@ -56,11 +56,22 @@
>>>       <xsl:template name="vlan-device">
>>>       <xsl:variable name="name" select="node[@label = 'DEVICE']/@value"/>
>>> -    <xsl:variable name="device" select="substring-before($name, '.')"/>
>>> -    <xsl:variable name="tag" select="substring-after($name, '.')"/>
>>> -    <vlan tag="{$tag}">
>>> -      <interface name="{$device}"/>
>>> -    </vlan>
>>> +    <xsl:choose>
>>> +      <xsl:when test="contains($name, '.')">
>>> +        <xsl:variable name="device" select="substring-before($name,
>>> '.')"/>
>>> +        <xsl:variable name="tag" select="substring-after($name, '.')"/>
>>> +        <vlan tag="{$tag}">
>>> +          <interface name="{$device}"/>
>>> +        </vlan>
>>> +      </xsl:when>
>>> +      <xsl:otherwise>
>>> +        <xsl:variable name="device" select="node[@label =
>>> 'PHYSDEV']/@value"/>
>>> +        <xsl:variable name="tag" select="translate($name,
>>> translate($name, '0123456789', ''), '')"/>
>>> +        <vlan tag="{$tag}">
>>> +          <interface name="{$device}"/>
>>> +        </vlan>
>>> +      </xsl:otherwise>
>>> +      </xsl:choose>
>>>     </xsl:template>
>>>       <!--
>>>
>>
>>
>>
>
>
_______________________________________________
netcf-devel mailing list -- netcf-devel@lists.fedorahosted.org
To unsubscribe send an email to netcf-devel-le...@lists.fedorahosted.org

Reply via email to