deleting vlan members from interface-ranges via cfgTables

98 views
Skip to first unread message

Arne Van Theemsche

unread,
Jan 17, 2018, 5:12:35 AM1/17/18
to Junos Python EZ
Hi,

I am trying to delete a vlan member from an interface-range through cfg tables (but I think this issue also applies to more generic subjects as deleting an instance where multiple instances exists and no "name" key is present)

this is my table

InterfaceRangeCfTable:
  set: interfaces/interface-range
  key-field:
    - name
    - unit
  required_keys:
    interface_range: name
  view: InterfaceRangeConfigView

InterfaceRangeConfigView:
  fields:
    name: name
    member: member/name
    member_range: member-range/name
    unit: unit/name
    vlan: unit/family/ethernet-switching/vlan/members


this is an example situation

    <configuration junos:changed-seconds="1516183709" junos:changed-localtime="2018-01-17 11:08:29 CET">
            <interfaces>
                <interface-range>
                    <name>test</name>
                    <member>
                        <name>xe-0/0/0</name>
                    </member>
                    <unit>
                        <name>0</name>
                        <family>
                            <ethernet-switching>
                                <port-mode>trunk</port-mode>
                                <vlan>
                                    <members>vlan1</members>
                                    <members>vlan2</members>
                                </vlan>
                            </ethernet-switching>
                        </family>
                    </unit>
                </interface-range>
            </interfaces>
    </configuration>

so If I want to delete vlan1 I would make something like

    <configuration junos:changed-seconds="1516183709" junos:changed-localtime="2018-01-17 11:08:29 CET">
            <interfaces>
                <interface-range>
                    <name>test</name>
                    <unit>
                        <name>0</name>
                        <family>
                            <ethernet-switching>
                                <port-mode>trunk</port-mode>
                                <vlan>
                                    <members operation="delete">vlan1</members>
                                </vlan>
                            </ethernet-switching>
                        </family>
                    </unit>
                </interface-range>
            </interfaces>
    </configuration>

but the problem is I cannot set the vlan member in my table to both "vlan1" and {'operation' : 'delete'}

I know about fixing this with cu=Config and giving the set commands, but I would really like to keep working with cfTables

anybody an Idea?

kind regards
Arne

Nitin Kr (Automation)

unread,
Jan 17, 2018, 6:38:03 AM1/17/18
to Arne Van Theemsche, Junos Python EZ

Hi Arne,

 

As of today, we can only delete all tags of the list element by doing

 

obj.vlan = {'operation': 'delete'}

deleting single element from the list won’t be possible as of today. As a work around, we can use, get() API to fetch all vlans, then delete all using above command, remove vlan from the list. Then again assign to obj.vlan this will be quite complicated (and uses multiple RPC calls) then directly calling cu.load() with desired xml

 

Thanks

Nitin Kr

--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
junos-python-...@googlegroups.com.
Visit this group at
https://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit
https://groups.google.com/d/msgid/junos-python-ez/fcfc736c-c66b-4f9f-994e-86423dccca69%40googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages