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 b'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
def setUp(self): from twisted.web import resource, server from twisted.application import internet from opennsa.protocols import nsi2 from opennsa.protocols.shared import 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_map = StringIO.StringIO(topology.ARUBA_TOPOLOGY) nrm_ports, nml_network, link_vector = setup.setupTopology(nrm_map, self.network, 'aruba.net') self.backend = dud.DUDNSIBackend(self.network, nrm_ports, None, {}) # we set the parent later self.backend.scheduler.clock = self.clock 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, nml_network, link_vector, 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)
def setUp(self): from twisted.web import resource, server from twisted.application import internet from opennsa.protocols import nsi2 from opennsa.protocols.shared import soapresource from opennsa.protocols.nsi2 import requesterservice, requesterclient db.setupDatabase() self.requester = common.DUDRequester() self.clock = task.Clock() nrm_map = StringIO.StringIO(topology.ARUBA_TOPOLOGY) nrm_ports, nml_network, link_vector = setup.setupTopology(nrm_map, self.network, 'aruba.net') self.backend = dud.DUDNSIBackend(self.network, nrm_ports, None, {}) # we set the parent later self.backend.scheduler.clock = self.clock 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, nml_network, link_vector, 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)
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
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
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