本文整理汇总了Java中org.onosproject.net.PortNumber类的典型用法代码示例。如果您正苦于以下问题:Java PortNumber类的具体用法?Java PortNumber怎么用?Java PortNumber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PortNumber类属于org.onosproject.net包,在下文中一共展示了PortNumber类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.onosproject.net.PortNumber; //导入依赖的package包/类
@Override
protected void execute() {
DeviceService deviceService = get(DeviceService.class);
DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
Device dev = deviceService.getDevice(DeviceId.deviceId(uri));
if (dev == null) {
print(" %s", "Device does not exist");
return;
}
PortNumber pnum = PortNumber.portNumber(portNumber);
Port p = deviceService.getPort(dev.id(), pnum);
if (p == null) {
print(" %s", "Port does not exist");
return;
}
if (portState.equals("enable")) {
deviceAdminService.changePortState(dev.id(), pnum, true);
} else if (portState.equals("disable")) {
deviceAdminService.changePortState(dev.id(), pnum, false);
} else {
print(" %s", "State must be enable or disable");
}
}
示例2: getConnectPointInfrastructure
import org.onosproject.net.PortNumber; //导入依赖的package包/类
/**
* Tests if a connect point is infrastructure or edge.
*
* @param connectPointString deviceid:portnumber
* @return 200 OK with JSON representation of true if the connect point is broadcast,
* false otherwise
* @onos.rsModel TopologyInfrastructure
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("infrastructure/{connectPoint}")
public Response getConnectPointInfrastructure(@PathParam("connectPoint") String connectPointString) {
Topology topology = get(TopologyService.class).currentTopology();
DeviceId deviceId = DeviceId.deviceId(getDeviceId(connectPointString));
PortNumber portNumber = PortNumber.portNumber(getPortNumber(connectPointString));
ConnectPoint connectPoint = new ConnectPoint(deviceId, portNumber);
boolean isInfrastructure = get(TopologyService.class).isInfrastructure(topology, connectPoint);
return ok(mapper().createObjectNode()
.put("infrastructure", isInfrastructure))
.build();
}
示例3: execute
import org.onosproject.net.PortNumber; //导入依赖的package包/类
@Override
protected void execute() {
resourceService = get(ResourceService.class);
DeviceId did = DeviceId.deviceId(deviceIdStr);
PortNumber portNum = PortNumber.fromString(portNumberStr);
ResourceConsumer consumer = IntentId.valueOf(nIntendId);
Resource resource = Resources.discrete(did, portNum,
createLambda(Integer.parseInt(lambda))).resource();
Optional<ResourceAllocation> allocate = resourceService.allocate(consumer, resource);
if (allocate.isPresent()) {
print("Allocated: %s", allocate.get());
} else {
print("Failed to allocate %s for %s", resource, consumer);
}
}
示例4: modifyNextObjective
import org.onosproject.net.PortNumber; //导入依赖的package包/类
/**
* Setup expectations on flowObjectiveService.next for NextObjective.
*
**/
private int modifyNextObjective(DeviceId deviceId, PortNumber portNumber, VlanId vlanId, boolean popVlan,
boolean modifyFlag) {
NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder().withId(1)
.withType(NextObjective.Type.SIMPLE).fromApp(APPID);
TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
if (popVlan) {
ttBuilder.popVlan();
}
ttBuilder.setOutput(portNumber);
TrafficSelector.Builder metabuilder = DefaultTrafficSelector.builder();
metabuilder.matchVlanId(vlanId);
nextObjBuilder.withMeta(metabuilder.build());
nextObjBuilder.addTreatment(ttBuilder.build());
if (modifyFlag) {
flowObjectiveService.next(deviceId, nextObjBuilder.add());
expectLastCall().once();
} else {
flowObjectiveService.next(deviceId, nextObjBuilder.remove());
expectLastCall().once();
}
return 1;
}
示例5: removePort
import org.onosproject.net.PortNumber; //导入依赖的package包/类
@Override
public void removePort(NetworkId networkId, DeviceId deviceId, PortNumber portNumber) {
checkState(networkExists(networkId), "The network has not been added.");
Set<VirtualPort> virtualPortSet = new HashSet<>();
networkIdVirtualPortSetMap.get(networkId).forEach(port -> {
if (port.element().id().equals(deviceId) && port.number().equals(portNumber)) {
virtualPortSet.add(port);
}
});
if (virtualPortSet != null) {
networkIdVirtualPortSetMap.compute(networkId, (id, existingVirtualPorts) -> {
if (existingVirtualPorts == null || existingVirtualPorts.isEmpty()) {
return new HashSet<>();
} else {
return new HashSet<>(Sets.difference(existingVirtualPorts, virtualPortSet));
}
});
}
}
示例6: getPortNextObjectiveId
import org.onosproject.net.PortNumber; //导入依赖的package包/类
/**
* Returns the next objective of type simple associated with the port on the
* device, given the treatment. Different treatments to the same port result
* in different next objectives. If no such objective exists, this method
* creates one and returns the id. Optionally metadata can be passed in for
* the creation of the objective.
*
* @param portNum the port number for the simple next objective
* @param treatment the actions to apply on the packets (should include outport)
* @param meta optional metadata passed into the creation of the next objective
* @return int if found or created, -1 if there are errors during the
* creation of the next objective.
*/
public int getPortNextObjectiveId(PortNumber portNum, TrafficTreatment treatment,
TrafficSelector meta) {
Integer nextId = portNextObjStore
.get(new PortNextObjectiveStoreKey(deviceId, portNum, treatment));
if (nextId == null) {
log.trace("getPortNextObjectiveId in device{}: Next objective id "
+ "not found for {} and {} creating", deviceId, portNum);
createGroupFromPort(portNum, treatment, meta);
nextId = portNextObjStore.get(
new PortNextObjectiveStoreKey(deviceId, portNum, treatment));
if (nextId == null) {
log.warn("getPortNextObjectiveId: unable to create next obj"
+ "for dev:{} port:{}", deviceId, portNum);
return -1;
}
}
return nextId;
}
示例7: testEquality
import org.onosproject.net.PortNumber; //导入依赖的package包/类
@Test
public void testEquality() {
DefaultVirtualDevice device1 =
new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue1));
DefaultVirtualDevice device2 =
new DefaultVirtualDevice(NetworkId.networkId(0), DeviceId.deviceId(deviceIdValue2));
Port portA = new DefaultPort(device1, PortNumber.portNumber(1), true);
Port portB = new DefaultPort(device1, PortNumber.portNumber(2), true);
Port portC = new DefaultPort(device2, PortNumber.portNumber(2), true);
DefaultVirtualPort port1 =
new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(1), portA);
DefaultVirtualPort port2 =
new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(1), portA);
DefaultVirtualPort port3 =
new DefaultVirtualPort(NetworkId.networkId(0), device1, PortNumber.portNumber(2), portB);
DefaultVirtualPort port4 =
new DefaultVirtualPort(NetworkId.networkId(1), device2, PortNumber.portNumber(2), portC);
new EqualsTester().addEqualityGroup(port1, port2).addEqualityGroup(port3)
.addEqualityGroup(port4).testEquals();
}
示例8: programArpClassifierRules
import org.onosproject.net.PortNumber; //导入依赖的package包/类
@Override
public void programArpClassifierRules(DeviceId deviceId, PortNumber inPort,
IpAddress dstIp,
SegmentationId actionVni,
Objective.Operation type) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(inPort).matchEthType(ETH_TYPE.ethType().toShort())
.matchArpTpa(Ip4Address.valueOf(dstIp.toString())).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.setTunnelId(Long.parseLong(actionVni.segmentationId()))
.build();
ForwardingObjective.Builder objective = DefaultForwardingObjective
.builder().withTreatment(treatment).withSelector(selector)
.fromApp(appId).withFlag(Flag.SPECIFIC)
.withPriority(ARP_CLASSIFIER_PRIORITY);
if (type.equals(Objective.Operation.ADD)) {
log.debug("ArpClassifierRules-->ADD");
flowObjectiveService.forward(deviceId, objective.add());
} else {
log.debug("ArpClassifierRules-->REMOVE");
flowObjectiveService.forward(deviceId, objective.remove());
}
}
示例9: getAddDropPort
import org.onosproject.net.PortNumber; //导入依赖的package包/类
private PortNumber getAddDropPort(int channel, boolean isAddPort) {
OID oid = new OID(CTRL_CHANNEL_ADD_DROP_PORT_INDEX + (isAddPort ? "1" : "2"));
for (TreeEvent event : snmp.get(oid)) {
if (event == null) {
return null;
}
VariableBinding[] varBindings = event.getVariableBindings();
for (VariableBinding varBinding : varBindings) {
if (varBinding.getOid().last() == channel) {
int port = varBinding.getVariable().toInt();
if (!isAddPort) {
port += DROP_PORT_OFFSET;
}
return PortNumber.portNumber(port);
}
}
}
return null;
}
示例10: createIntent
import org.onosproject.net.PortNumber; //导入依赖的package包/类
private Intent createIntent(Key key, long mac, NodeId node, Multimap<NodeId, Device> devices) {
// choose a random device for which this node is master
List<Device> deviceList = devices.get(node).stream().collect(Collectors.toList());
Device device = deviceList.get(RandomUtils.nextInt(deviceList.size()));
//FIXME we currently ignore the path length and always use the same device
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(MacAddress.valueOf(mac)).build();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
ConnectPoint ingress = new ConnectPoint(device.id(), PortNumber.portNumber(1));
ConnectPoint egress = new ConnectPoint(device.id(), PortNumber.portNumber(2));
return PointToPointIntent.builder()
.appId(appId)
.key(key)
.selector(selector)
.treatment(treatment)
.ingressPoint(ingress)
.egressPoint(egress)
.build();
}
示例11: testRemoveInterface
import org.onosproject.net.PortNumber; //导入依赖的package包/类
@Test
public void testRemoveInterface() {
ConnectPoint sw1eth4 = new ConnectPoint(DEVICE_ID, PortNumber.portNumber(4));
Set<InterfaceIpAddress> interfaceIpAddresses4 = Sets.newHashSet();
interfaceIpAddresses4
.add(new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24")));
Interface sw1Eth4 = new Interface(sw1eth4.deviceId().toString(), sw1eth4, interfaceIpAddresses4,
MacAddress.valueOf("00:00:00:00:00:04"), VlanId.NONE);
EasyMock.reset(flowObjectiveService);
expect(flowObjectiveService.allocateNextId()).andReturn(1).anyTimes();
setUpInterfaceConfiguration(sw1Eth4, false);
replay(flowObjectiveService);
interfaceListener.event(new InterfaceEvent(InterfaceEvent.Type.INTERFACE_REMOVED, sw1Eth4, 500L));
verify(flowObjectiveService);
}
示例12: nextBatch
import org.onosproject.net.PortNumber; //导入依赖的package包/类
private List<FlowRule> nextBatch(int size) {
List<FlowRule> rules = Lists.newArrayList();
for (int i = 0; i < size; ++i) {
Device device = devices.next();
long srcMac = macIndex.incrementAndGet();
long dstMac = srcMac + 1;
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthSrc(MacAddress.valueOf(srcMac))
.matchEthDst(MacAddress.valueOf(dstMac))
.matchInPort(PortNumber.portNumber(2))
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.add(Instructions.createOutput(PortNumber.portNumber(3))).build();
FlowRule rule = new DefaultFlowRule(device.id(),
selector,
treatment,
100,
appId,
50000,
true,
null);
rules.add(rule);
}
return rules;
}
示例13: populateNext
import org.onosproject.net.PortNumber; //导入依赖的package包/类
/**
* Populates next objectives for given XConnect.
*
* @param key XConnect store key
* @param ports XConnect ports
*/
private NextObjective populateNext(XConnectStoreKey key, Set<PortNumber> ports) {
NextObjective nextObj = null;
if (xConnectNextObjStore.containsKey(key)) {
nextObj = xConnectNextObjStore.get(key).value();
log.debug("NextObj for {} found, id={}", key, nextObj.id());
} else {
NextObjective.Builder nextObjBuilder = nextObjBuilder(key, ports);
ObjectiveContext nextContext = new NextObjContext(Objective.Operation.ADD, key);
nextObj = nextObjBuilder.add(nextContext);
srManager.flowObjectiveService.next(key.deviceId(), nextObj);
xConnectNextObjStore.put(key, nextObj);
log.debug("NextObj for {} not found. Creating new NextObj with id={}", key, nextObj.id());
}
return nextObj;
}
示例14: createSouthboundGroupEntry
import org.onosproject.net.PortNumber; //导入依赖的package包/类
private Group createSouthboundGroupEntry(GroupId gId,
List<PortNumber> ports,
long referenceCount, DeviceId deviceId) {
List<PortNumber> outPorts = new ArrayList<>();
outPorts.addAll(ports);
List<GroupBucket> buckets = new ArrayList<>();
for (PortNumber portNumber : outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber)
.setEthDst(MacAddress.valueOf("00:00:00:00:00:02"))
.setEthSrc(MacAddress.valueOf("00:00:00:00:00:01"))
.pushMpls()
.setMpls(MplsLabel.mplsLabel(106));
buckets.add(DefaultGroupBucket.createSelectGroupBucket(
tBuilder.build()));
}
GroupBuckets groupBuckets = new GroupBuckets(buckets);
StoredGroupEntry group = new DefaultGroup(
gId, deviceId, Group.Type.SELECT, groupBuckets);
group.setReferenceCount(referenceCount);
return group;
}
示例15: createLinks
import org.onosproject.net.PortNumber; //导入依赖的package包/类
/**
* Creates the links for the fake topology.
* NB: Only unidirectional links are created, as for this purpose all we
* need is to occupy the ports with some link.
*/
private void createLinks(int numDevices) {
List<Link> links = new ArrayList<>();
for (int i = 1; i <= numDevices; i++) {
ConnectPoint src = new ConnectPoint(
getDeviceId(i),
PortNumber.portNumber(2));
ConnectPoint dst = new ConnectPoint(
getDeviceId((i + 1 > numDevices) ? 1 : i + 1),
PortNumber.portNumber(3));
Link link = createMock(Link.class);
expect(link.src()).andReturn(src).anyTimes();
expect(link.dst()).andReturn(dst).anyTimes();
replay(link);
links.add(link);
}
expect(linkService.getLinks()).andReturn(links).anyTimes();
replay(linkService);
}