コード例 #1
0
ファイル: test_providers.py プロジェクト: igable/opennsa
    def setUp(self):
        from twisted.web import resource, server
        from twisted.application import internet
        from opennsa.protocols import nsi2
        from opennsa.protocols.shared import resource as soapresource
        from opennsa.protocols.nsi2 import requesterservice, requesterclient, requester

        tcf = os.path.expanduser('~/.opennsa-test.json')
        tc = json.load( open(tcf) )
        database.setupDatabase( tc['database'], tc['database-user'], tc['database-password'])

        self.requester = common.DUDRequester()

        self.clock = task.Clock()

        aruba_topo, pm = nrmparser.parseTopologySpec(StringIO.StringIO(topology.ARUBA_TOPOLOGY), self.network)

        self.backend = dud.DUDNSIBackend(self.network, aruba_topo, None, pm, {}) # we set the parent later
        self.backend.scheduler.clock = self.clock

        self.topology = nml.Topology()
        self.topology.addNetwork(aruba_topo, self.provider_agent)

        pr = provreg.ProviderRegistry( { self.provider_agent.urn() : self.backend }, {} )
        self.aggregator = aggregator.Aggregator(self.network, self.provider_agent, self.topology, None, pr) # we set the parent later

        self.backend.parent_requester = self.aggregator

        # provider protocol
        http_top_resource = resource.Resource()

        cs2_prov = nsi2.setupProvider(self.aggregator, http_top_resource)
        self.aggregator.parent_requester = cs2_prov

        provider_factory = server.Site(http_top_resource)
        self.provider_service = internet.TCPServer(self.PROVIDER_PORT, provider_factory)

        # requester protocol

        requester_top_resource = resource.Resource()
        soap_resource = soapresource.setupSOAPResource(requester_top_resource, 'RequesterService2')

        self.provider = requesterclient.RequesterClient(self.provider_agent.endpoint, self.requester_agent.endpoint)

        requester_service = requesterservice.RequesterService(soap_resource, self.requester) # this is the important part
        requester_factory = server.Site(requester_top_resource, logPath='/dev/null')

        # start engines!
        self.backend.startService()
        self.provider_service.startService()
        self.requester_iport = reactor.listenTCP(self.REQUESTER_PORT, requester_factory)

        # request stuff
        self.start_time = datetime.datetime.utcnow() + datetime.timedelta(seconds=2)
        self.end_time   = datetime.datetime.utcnow() + datetime.timedelta(seconds=10)

        self.schedule = nsa.Schedule(self.start_time, self.end_time)
        self.sd = nsa.Point2PointService(self.source_stp, self.dest_stp, self.bandwidth, None, None)
        self.criteria = nsa.Criteria(0, self.schedule, self.sd)
コード例 #2
0
ファイル: __init__.py プロジェクト: igable/opennsa
def setupRequesterPair(top_resource, host, port, service_endpoint, nsi_requester, resource_name=None, tls=False, ctx_factory=None):

    resource_name = resource_name or 'RequesterService2'

    requester_client = setupRequesterClient(top_resource, host, port, service_endpoint, resource_name=resource_name, tls=tls, ctx_factory=ctx_factory)

    soap_resource = soapresource.setupSOAPResource(top_resource, resource_name)
    requesterservice.RequesterService(soap_resource, nsi_requester)

    return requester_client
コード例 #3
0
def setupRequesterPair(top_resource, host, port, service_endpoint, nsi_requester, resource_name=None, tls=False, ctx_factory=None):

    resource_name = resource_name or 'RequesterService2'

    requester_client = setupRequesterClient(top_resource, host, port, service_endpoint, resource_name=resource_name, tls=tls, ctx_factory=ctx_factory)

    soap_resource = soapresource.setupSOAPResource(top_resource, resource_name)
    requesterservice.RequesterService(soap_resource, nsi_requester)

    return requester_client
コード例 #4
0
ファイル: __init__.py プロジェクト: igable/opennsa
def setupProvider(child_provider, top_resource, tls=False, ctx_factory=None):

    soap_resource = soapresource.setupSOAPResource(top_resource, 'CS2')

    provider_client = providerclient.ProviderClient(ctx_factory)

    nsi2_provider = provider.Provider(child_provider, provider_client)

    providerservice.ProviderService(soap_resource, nsi2_provider)

    return nsi2_provider
コード例 #5
0
def setupProvider(child_provider, top_resource, tls=False, ctx_factory=None, allowed_hosts=None):

    soap_resource = soapresource.setupSOAPResource(top_resource, 'CS2', allowed_hosts=allowed_hosts)

    provider_client = providerclient.ProviderClient(ctx_factory)

    nsi2_provider = provider.Provider(child_provider, provider_client)

    providerservice.ProviderService(soap_resource, nsi2_provider)

    return nsi2_provider
コード例 #6
0
ファイル: __init__.py プロジェクト: igable/opennsa
def createRequester(host, port, service_endpoint, resource_name=None, tls=False, ctx_factory=None, authz_header=None, callback_timeout=None):

    resource_name = resource_name or 'RequesterService2'

    top_resource = resource.Resource()

    requester_client = setupRequesterClient(top_resource, host, port, service_endpoint, resource_name=resource_name, tls=tls, ctx_factory=ctx_factory, authz_header=authz_header)

    nsi_requester = requester.Requester(requester_client, callback_timeout=callback_timeout)

    soap_resource = soapresource.setupSOAPResource(top_resource, resource_name)
    requesterservice.RequesterService(soap_resource, nsi_requester)

    site = server.Site(top_resource, logPath='/dev/null')
    return nsi_requester, site
コード例 #7
0
def createRequester(host, port, service_endpoint, resource_name=None, tls=False, ctx_factory=None, authz_header=None, callback_timeout=None):

    resource_name = resource_name or 'RequesterService2'

    top_resource = resource.Resource()

    requester_client = setupRequesterClient(top_resource, host, port, service_endpoint, resource_name=resource_name, tls=tls, ctx_factory=ctx_factory, authz_header=authz_header)

    nsi_requester = requester.Requester(requester_client, callback_timeout=callback_timeout)

    soap_resource = soapresource.setupSOAPResource(top_resource, resource_name)
    requesterservice.RequesterService(soap_resource, nsi_requester)

    site = server.Site(top_resource, logPath='/dev/null')
    return nsi_requester, site
コード例 #8
0
ファイル: test_providers.py プロジェクト: b0urn3/opennsa
    def setUp(self):
        from twisted.web import resource, server
        from twisted.application import internet
        from opennsa.protocols import nsi2
        from opennsa.protocols.shared import resource as soapresource
        from opennsa.protocols.nsi2 import requesterservice, requesterclient

        tcf = os.path.expanduser('~/.opennsa-test.json')
        tc = json.load(open(tcf))
        database.setupDatabase(tc['database'], tc['database-user'],
                               tc['database-password'])

        self.requester = common.DUDRequester()

        self.clock = task.Clock()

        nrm_ports = nrm.parsePortSpec(
            StringIO.StringIO(topology.ARUBA_TOPOLOGY))
        network_topology = nml.createNMLNetwork(nrm_ports, self.network,
                                                self.network)

        self.backend = dud.DUDNSIBackend(self.network, nrm_ports, None,
                                         {})  # we set the parent later
        self.backend.scheduler.clock = self.clock

        route_vectors = gns.RouteVectors([cnt.URN_OGF_PREFIX + self.network])
        route_vectors.updateVector(self.provider_agent.identity, 0,
                                   [self.network], {})

        pl = plugin.BasePlugin()
        pl.init({config.NETWORK_NAME: self.network}, None)

        pr = provreg.ProviderRegistry(
            {self.provider_agent.urn(): self.backend}, {})
        self.aggregator = aggregator.Aggregator(self.network,
                                                self.provider_agent,
                                                network_topology,
                                                route_vectors, None, pr, [],
                                                pl)  # we set the parent later

        self.backend.parent_requester = self.aggregator

        # provider protocol
        http_top_resource = resource.Resource()

        cs2_prov = nsi2.setupProvider(self.aggregator, http_top_resource)
        self.aggregator.parent_requester = cs2_prov

        provider_factory = server.Site(http_top_resource)
        self.provider_service = internet.TCPServer(self.PROVIDER_PORT,
                                                   provider_factory)

        # requester protocol

        requester_top_resource = resource.Resource()
        soap_resource = soapresource.setupSOAPResource(requester_top_resource,
                                                       'RequesterService2')

        self.provider = requesterclient.RequesterClient(
            self.provider_agent.endpoint, self.requester_agent.endpoint)

        requester_service = requesterservice.RequesterService(
            soap_resource, self.requester)  # this is the important part
        requester_factory = server.Site(requester_top_resource,
                                        logPath='/dev/null')

        # start engines!
        self.backend.startService()
        self.provider_service.startService()
        self.requester_iport = reactor.listenTCP(self.REQUESTER_PORT,
                                                 requester_factory)

        # request stuff
        self.start_time = datetime.datetime.utcnow() + datetime.timedelta(
            seconds=2)
        self.end_time = datetime.datetime.utcnow() + datetime.timedelta(
            seconds=10)

        self.schedule = nsa.Schedule(self.start_time, self.end_time)
        self.sd = nsa.Point2PointService(self.source_stp, self.dest_stp,
                                         self.bandwidth)
        self.criteria = nsa.Criteria(0, self.schedule, self.sd)
コード例 #9
0
ファイル: test_providers.py プロジェクト: ajragusa/opennsa
    def setUp(self):
        from twisted.web import resource, server
        from twisted.application import internet
        from opennsa.protocols import nsi2
        from opennsa.protocols.shared import resource as soapresource
        from opennsa.protocols.nsi2 import requesterservice, requesterclient

        tcf = os.path.expanduser('~/.opennsa-test.json')
        tc = json.load( open(tcf) )
        database.setupDatabase( tc['database'], tc['database-user'], tc['database-password'])

        self.requester = common.DUDRequester()

        self.clock = task.Clock()

        nrm_ports = nrm.parsePortSpec(StringIO.StringIO(topology.ARUBA_TOPOLOGY))
        network_topology = nml.createNMLNetwork(nrm_ports, self.network, self.network)

        self.backend = dud.DUDNSIBackend(self.network, nrm_ports, None, {}) # we set the parent later
        self.backend.scheduler.clock = self.clock

        route_vectors = gns.RouteVectors( [ cnt.URN_OGF_PREFIX + self.network ] )
        route_vectors.updateVector(self.provider_agent.identity, 0, [ self.network ], {})

        pl = plugin.BasePlugin()
        pl.init( { config.NETWORK_NAME: self.network }, None )

        pr = provreg.ProviderRegistry( { self.provider_agent.urn() : self.backend }, {} )
        self.aggregator = aggregator.Aggregator(self.network, self.provider_agent, network_topology, route_vectors, None, pr, [], pl) # we set the parent later

        self.backend.parent_requester = self.aggregator

        # provider protocol
        http_top_resource = resource.Resource()

        cs2_prov = nsi2.setupProvider(self.aggregator, http_top_resource)
        self.aggregator.parent_requester = cs2_prov

        provider_factory = server.Site(http_top_resource)
        self.provider_service = internet.TCPServer(self.PROVIDER_PORT, provider_factory)

        # requester protocol

        requester_top_resource = resource.Resource()
        soap_resource = soapresource.setupSOAPResource(requester_top_resource, 'RequesterService2')

        self.provider = requesterclient.RequesterClient(self.provider_agent.endpoint, self.requester_agent.endpoint)

        requester_service = requesterservice.RequesterService(soap_resource, self.requester) # this is the important part
        requester_factory = server.Site(requester_top_resource, logPath='/dev/null')

        # start engines!
        self.backend.startService()
        self.provider_service.startService()
        self.requester_iport = reactor.listenTCP(self.REQUESTER_PORT, requester_factory)

        # request stuff
        self.start_time = datetime.datetime.utcnow() + datetime.timedelta(seconds=2)
        self.end_time   = datetime.datetime.utcnow() + datetime.timedelta(seconds=10)

        self.schedule = nsa.Schedule(self.start_time, self.end_time)
        self.sd = nsa.Point2PointService(self.source_stp, self.dest_stp, self.bandwidth)
        self.criteria = nsa.Criteria(0, self.schedule, self.sd)