Exemple #1
0
def topologyGraph(topology_file, all_links=False):

    from opennsa.topology import gole

    topo, _ = gole.parseTopology([open(topology_file)])

    links = []

    for nw in topo.networks:
        for ep in nw.endpoints:
            if ep.dest_stp:
                nw1 = nw.name.replace('.ets', '').replace('-', '_')
                nw2 = ep.dest_stp.network.replace('.ets', '').replace('-', '_')

                l = [nw1, nw2]
                if all_links:
                    if nw1 < nw2:  # this prevents us from building double links
                        links.append(l)
                else:
                    l = sorted(l)
                    if not l in links:
                        links.append(l)

    log.msg('graph Network {')
    for l in sorted(links):
        log.msg('  %s -- %s;' % (l[0], l[1]))
    log.msg('}')
Exemple #2
0
    def setUp(self):

        self.iports = []

        HOST = 'localhost'
        WSDL_DIR = os.path.realpath(os.path.normpath(os.path.join(os.path.dirname(__file__), '../wsdl')))
        #WSDL_DIR = os.path.join(os.getcwd(), '..', 'wsdl')

        # service

        SERVICES = [ ('Aruba', 9080), ('Bonaire', 9081), ('Curacao',9082) ]

        for network, port in SERVICES:

            topo_source = StringIO.StringIO(testtopology.TEST_TOPOLOGY)
            backend = dud.DUDNSIBackend(network)
            topo, _ = gole.parseTopology( [ topo_source ] )

            factory = setup.createService(network, backend, topo, HOST, port, WSDL_DIR)

            iport = reactor.listenTCP(port, factory, interface='localhost')
            self.iports.append(iport)

        # client

        CLIENT_PORT = 7080

        self.client, client_factory  = setup.createClient(HOST, CLIENT_PORT, WSDL_DIR)
        self.client_nsa = nsa.NetworkServiceAgent('OpenNSA-Test-Client', 'http://localhost:%i/NSI/services/ConnectionService' % CLIENT_PORT)

        client_iport = reactor.listenTCP(CLIENT_PORT, client_factory)
        self.iports.append(client_iport)
Exemple #3
0
    def startService(self):
        """
        This sets up the OpenNSA service and ties together everything in the initialization.
        There are a lot of things going on, but none of it it particular deep.
        """
        log.msg('OpenNSA service initializing', system='opennsa.setup')

        vc = self.vc

        topology_sources = [ open(tf) for tf in vc[config.TOPOLOGY_FILE] ]

        topology, internal_topology = gole.parseTopology(topology_sources, open(vc[config.NRM_MAP_FILE]) if vc[config.NRM_MAP_FILE] else None )

        if vc[config.HOST] is None:
            import socket
            vc[config.HOST] = socket.getfqdn()

        ctx_factory = None
        if vc[config.TLS]:
            from opennsa import ctxfactory
            ctx_factory = ctxfactory.ContextFactory(vc[config.KEY], vc[config.CERTIFICATE], vc[config.CERTIFICATE_DIR], vc[config.VERIFY_CERT])

        backend = setupBackend(vc['backend'], vc[config.NETWORK_NAME], internal_topology)

        factory = createService(vc[config.NETWORK_NAME], backend, topology, vc[config.HOST], vc[config.PORT], vc[config.WSDL_DIRECTORY])

        if vc[config.TLS]:
            internet.SSLServer(vc[config.PORT], factory, ctx_factory).setServiceParent(self)
        else:
            internet.TCPServer(vc[config.PORT], factory).setServiceParent(self)

        # do not start sub-services until we have started this one
        twistedservice.MultiService.startService(self)

        log.msg('OpenNSA service started')
Exemple #4
0
def topology(topology_file):

    from opennsa.topology import gole

    topo, _ = gole.parseTopology([open(topology_file)])

    for nw in topo.networks:
        ns = '%s (%s)' % (nw.name, ','.join(
            sorted([ep.endpoint for ep in nw.endpoints])))
        log.msg(ns)
Exemple #5
0
def path(topology_file, source_stp, dest_stp):

    from opennsa.topology import gole

    topo, _ = gole.parseTopology([open(topology_file)])

    source_network, source_port = source_stp.split(':', 1)
    dest_network, dest_port = dest_stp.split(':', 1)

    r_source_stp = nsa.STP(source_network, source_port)
    r_dest_stp = nsa.STP(dest_network, dest_port)

    paths = topo.findPaths(r_source_stp, r_dest_stp)

    for p in sorted(paths, key=lambda p: len(p.network_links)):
        log.msg(str(p))
Exemple #6
0
    def setUp(self):

        self.iports = []

        HOST = 'localhost'
        WSDL_DIR = os.path.realpath(
            os.path.normpath(os.path.join(os.path.dirname(__file__),
                                          '../wsdl')))
        #WSDL_DIR = os.path.join(os.getcwd(), '..', 'wsdl')

        # service

        SERVICES = [('Aruba', 9080), ('Bonaire', 9081), ('Curacao', 9082)]

        for network, port in SERVICES:

            topo_source = StringIO.StringIO(testtopology.TEST_TOPOLOGY)
            backend = dud.DUDNSIBackend(network)
            topo, _ = gole.parseTopology([topo_source])

            factory = setup.createService(network, backend, topo, HOST, port,
                                          WSDL_DIR)

            iport = reactor.listenTCP(port, factory, interface='localhost')
            self.iports.append(iport)

        # client

        CLIENT_PORT = 7080

        self.client, client_factory = setup.createClient(
            HOST, CLIENT_PORT, WSDL_DIR)
        self.client_nsa = nsa.NetworkServiceAgent(
            'OpenNSA-Test-Client',
            'http://localhost:%i/NSI/services/ConnectionService' % CLIENT_PORT)

        client_iport = reactor.listenTCP(CLIENT_PORT, client_factory)
        self.iports.append(client_iport)
Exemple #7
0
 def setUp(self):
     f = StringIO.StringIO(testtopology.TEST_TOPOLOGY)
     self.topo, _ = gole.parseTopology([f])
 def setUp(self):
     f = StringIO.StringIO(testtopology.TEST_TOPOLOGY)
     self.topo, _ = gole.parseTopology( [f] )