def reserve(self, srcNet, srcSTP, dstNet, dstSTP, start_time=None, length=None, gid=None, nsa=None, rid=None): srcNet = self.topo.getNetwork(srcNet) srcSTP = srcNet.getEndpoint(srcSTP) dstNet = self.topo.getNetwork(dstNet) dstSTP = dstNet.getEndpoint(dstSTP) if nsa: provider_nsa = getNSA(nsa) else: provider_nsa = srcNet.nsa print "Reserving (%s,%s) to (%s,%s) \n at %s (%s)" % (srcNet,srcSTP,dstNet,dstSTP, provider_nsa,provider_nsa.url()) # Setting some defaults for now, to fill in later start_time=None end_time=None description='CLI Test Connection' # Constructing the ServiceParamaters if not start_time: start_time = datetime.datetime.utcfromtimestamp(time.time() + 10 ) if length: end_time = start_time + datetime.timedelta(minutes=length) else: end_time = start_time + datetime.timedelta(minutes=999999) if gid: global_reservation_id = gid else: global_reservation_id = 'opennsa-cli:gid-%s' % random.randrange(1000,10000) connection_id = "urn:uuid:%s" % uuid.uuid1() bwp = opennsa.nsa.BandwidthParameters(20000) service_params = opennsa.nsa.ServiceParameters(start_time, end_time, srcSTP, dstSTP, bandwidth=bwp) # Send the reservation and wait for response r = yield self.client.reserve(self.client_nsa, provider_nsa, None, global_reservation_id, description, connection_id, service_params) print type(r) print r print "Reservation created.\nReservation ID: %s\nConnection ID: %s" % (global_reservation_id,connection_id) self.requests[rid]={ 'global_reservation_id' : global_reservation_id, 'connection_id' : connection_id}
def query(self, nsa, cid=None, gid=None, rid=None): nsa = getNSA(nsa) if cid and gid: print "cid and gid isn't good defaulting to cid" if cid: qr = yield self.client.query(self.client_nsa, nsa, None, "Summary", connection_ids=[cid]) elif gid: qr = yield self.client.query(self.client_nsa, nsa, None, "Details", connection_ids=[]) #qr = yield self.client.query(self.client_nsa, nsa, None, "Details", global_reservation_ids = [ gid ] ) else: qr = yield self.client.query(self.client_nsa, nsa, None, "Summary", connection_ids=[]) print qr self.requests[rid] = self._queryToList(qr)
def reserve(self, srcNet, srcSTP, dstNet, dstSTP, start_time=None, length=None, gid=None, nsa=None): srcNet = self.topo.getNetwork(srcNet) srcSTP = srcNet.getEndpoint(srcSTP) dstNet = self.topo.getNetwork(dstNet) dstSTP = dstNet.getEndpoint(dstSTP) if nsa: provider_nsa = getNSA(nsa) else: provider_nsa = srcNet.nsa print "Reserving (%s,%s) to (%s,%s) \n at %s (%s)" % (srcNet,srcSTP,dstNet,dstSTP, provider_nsa,provider_nsa.url()) # Setting some defaults for now, to fill in later start_time=None end_time=None description='CLI Test Connection' # Constructing the ServiceParamaters if not start_time: start_time = datetime.datetime.utcfromtimestamp(time.time() + 10 ) # two minutes from now if length: end_time = start_time + datetime.timedelta(minutes=length) # two minutes later else: end_time = start_time + datetime.timedelta(minutes=3) # two minutes later if gid: global_reservation_id = gid else: global_reservation_id = 'opennsa-cli:gid-%s' % random.randrange(1000,10000) connection_id = "urn:uuid:%s" % uuid.uuid1() bwp = opennsa.nsa.BandwidthParameters(200) service_params = opennsa.nsa.ServiceParameters(start_time, end_time, srcSTP, dstSTP, bandwidth=bwp) # Send the reservation and wait for response r = yield self.client.reserve(self.client_nsa, provider_nsa, None, global_reservation_id, description, connection_id, service_params) print "Reservation created.\nReservation ID: %s\nConnection ID: %s" % (global_reservation_id,connection_id) self.result={ 'global_reservation_id' : global_reservation_id, 'connection_id' : connection_id}
def provision(self, nsa, cid, rid=None): if not "http" in nsa: nsa = getNSA(nsa) print "Provisioning %s at %s" % (cid, nsa) qr = yield self.client.provision(self.client_nsa, nsa, None, connection_id=cid) self.requests[rid] = qr
def terminate(self, nsa, cid, rid=None): if not "http" in nsa: nsa = getNSA(nsa) print "Terminating %s at %s" % (cid, nsa) qr = yield self.client.terminate(self.client_nsa, nsa, None, connection_id=cid) self.requests[rid] = qr
def query (self, nsa, cid=None, gid=None): nsa = getNSA(nsa) if cid and gid: print "cid and gid isn't good defaulting to cid" if cid: qr = yield self.client.query(self.client_nsa, nsa, None, "Summary", connection_ids = [ cid ] ) elif gid: qr = yield self.client.query(self.client_nsa, nsa, None, "Summary", global_reservation_ids = [ gid ] ) else: qr = yield self.client.query(self.client_nsa, nsa, None, "Summary", connection_ids = [] ) self.result = qr
def query (self, nsa, cid=None, gid=None, rid=None): nsa = getNSA(nsa) if cid and gid: print "cid and gid isn't good defaulting to cid" if cid: qr = yield self.client.query(self.client_nsa, nsa, None, "Summary", connection_ids = [ cid ] ) elif gid: qr = yield self.client.query(self.client_nsa, nsa, None, "Details", connection_ids = [] ) #qr = yield self.client.query(self.client_nsa, nsa, None, "Details", global_reservation_ids = [ gid ] ) else: qr = yield self.client.query(self.client_nsa, nsa, None, "Summary", connection_ids = [] ) print qr self.requests[rid]=self._queryToList(qr)
def provision(self,nsa, cid, rid=None): if not "http" in nsa: nsa = getNSA(nsa) print "Provisioning %s at %s" % (cid, nsa) qr = yield self.client.provision(self.client_nsa, nsa, None , connection_id = cid ) self.requests[rid]=qr
def terminate(self,nsa, cid, rid=None): if not "http" in nsa: nsa = getNSA(nsa) print "Terminating %s at %s" % (cid, nsa) qr = yield self.client.terminate(self.client_nsa, nsa, None , connection_id = cid ) self.requests[rid]=qr