Giter Club home page Giter Club logo

Comments (3)

EtienneMILON avatar EtienneMILON commented on July 25, 2024

Hello,

I have also seen that I can retrieve VPN site configuration directly from the engine :

vpn_pb = {}
for one_vpn in PolicyVPN.objects.all():
    vpn_pb.update({
        one_vpn.name: one_vpn.key,
        one_vpn.key: one_vpn.name,
    })
engine = Engine("my_firewall")
engine_vpn = {}
for site in engine.vpn.sites:
    for ref in site.vpn_references:
        if ref["vpn_id"] in vpn_pb.keys():
            if vpn_pb.get(ref["vpn_id"]) not in engine_vpn.keys():
                engine_vpn[vpn_pb.get(ref["vpn_id"])] = {}
            engine_vpn[vpn_pb.get(ref["vpn_id"])].update({site.name: ref})

Is it possible to update these sites (enable/disable and mode) ?

from fp-ngfw-smc-python.

ad1rie1 avatar ad1rie1 commented on July 25, 2024

Salut Etienne !
Truc comme ca :

class ConnectionType(Element):
    typeof = 'connection_type'

class EndpointTunnel(SubElement):
    """
    A gateway tunnel represents the point to point connection
    between two IPSEC endpoints in a PolicyVPN configuration. 
    The tunnel arrangement is based on whether the nodes are placed
    as a central gateway or a satellite gateway. This provides access
    to see the point to point connections, whether the link is enabled,
    and setting the presharred key.
    """

    def enable_disable(self):
        """
        Enable or disable the tunnel link between endpoints.
        
        :raises UpdateElementFailed: failed with reason
        :return: None
        """
        if self.enabled:
            self.update(enabled=False)
        else:
            self.update(enabled=True)
    
    @property
    def enabled(self):
        """          
        Whether the VPN link between endpoints is enabled
        
        :rtype: bool
        """
        return self.data.get('enabled', False)
    
    
    @property
    def tunnel_side_a(self):
        """
        Return the gateway node for tunnel side A. This will
        be an instance of GatewayNode.
        
        :rtype: GatewayNode
        """
        return type('TunnelSideA', (InternalEndpoint,), {
            'href': self.data.get('endpoint_1')})()
    
    @property
    def tunnel_side_b(self):
        """
        Return the gateway node for tunnel side B. This will
        be an instance of GatewayNode.
        
        :rtype: GatewayNode
        """
        return type('TunnelSideB', (InternalEndpoint,), {
            'href': self.data.get('endpoint_2')})()
    @property
    def setVPNProfile(self,href):
        return self.data.get('vpn_profile', href)

    def __str__(self):
        return '{0}(tunnel_side_a={1},tunnel_side_b={2})'.format(
            self.__class__.__name__, self.tunnel_side_a.name, self.tunnel_side_b.name)

    def __repr__(self):
        return str(self)
 
 VPNPDV = PolicyVPN(name='VPN-PDV')
    VPNPDV.open()
    ###########MISE EN PLACE DE PROFILE VPN PERSONALISER SUR LES ENDPOINT#############
    for tunnel in VPNPDV.tunnels:
        tunnela = tunnel.tunnel_side_a
        tunnelb = tunnel.tunnel_side_b
        if(tunnel.enabled != ENABLE):
            if(tunnela.name.startswith("FWCENTRAL") and tunnelb.name.startswith("FWDistant") ):
                tunnel.update(enabled=ENABLE)
            

            VPNPDV.save()

from fp-ngfw-smc-python.

lilianValeroFp avatar lilianValeroFp commented on July 25, 2024

It is already available in 1.0.20.

from fp-ngfw-smc-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.