def _add_interface(self, interface_id, **kw):
        """
        Create a tunnel interface. Kw argument list is as follows
        """
        base_interface = ElementCache()

        base_interface.update(
            interface_id=str(interface_id),
            interfaces=[])
        
        if 'zone_ref' in kw:
            zone_ref = kw.pop('zone_ref')
            base_interface.update(zone_ref=zone_helper(zone_ref) if zone_ref else None)
                
        if 'comment' in kw:
            base_interface.update(comment=kw.pop('comment'))
            
        self.data = base_interface
                          
        interfaces = kw.pop('interfaces', [])
        if interfaces:
            for interface in interfaces:
                if interface.get('cluster_virtual', None) or \
                    len(interface.get('nodes', [])) > 1:    # Cluster
                    
                    kw.update(interface_id=interface_id, interfaces=interfaces)
                    cvi = ClusterPhysicalInterface(**kw)
                    cvi.data.pop('vlanInterfaces', None)
                    self.data.update(cvi.data)
                else:
                    # Single interface FW
                    for node in interface.get('nodes', []):
                        node.update(nodeid=1)
                        sni = SingleNodeInterface.create(interface_id, **node)
                        base_interface.setdefault('interfaces', []).append(
                            {sni.typeof: sni.data})
def _add_interface ( self , interface_id , ** kw ) : base_interface = ElementCache ( ) base_interface . update ( interface_id = str ( interface_id ) , interfaces = [ ] ) if 'zone_ref' in kw : zone_ref = kw . pop ( 'zone_ref' ) base_interface . update ( zone_ref = zone_helper ( zone_ref ) if zone_ref else None ) if 'comment' in kw : base_interface . update ( comment = kw . pop ( 'comment' ) ) self . data = base_interface interfaces = kw . pop ( 'interfaces' , [ ] ) if interfaces : for interface in interfaces : if interface . get ( 'cluster_virtual' , None ) or len ( interface . get ( 'nodes' , [ ] ) ) > 1 : kw . update ( interface_id = interface_id , interfaces = interfaces ) cvi = ClusterPhysicalInterface ( ** kw ) cvi . data . pop ( 'vlanInterfaces' , None ) self . data . update ( cvi . data ) else : for node in interface . get ( 'nodes' , [ ] ) : node . update ( nodeid = 1 ) sni = SingleNodeInterface . create ( interface_id , ** node ) base_interface . setdefault ( 'interfaces' , [ ] ) . append ( { sni . typeof : sni . data } )
Create a tunnel interface. Kw argument list is as follows