org.onosproject.net.group.GroupDescription Java Examples
The following examples show how to use
org.onosproject.net.group.GroupDescription.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: L2BridgingComponent.java From ngsdn-tutorial with Apache License 2.0 | 6 votes |
/** * Inserts an ALL group in the ONOS core to replicate packets on all host * facing ports. This group will be used to broadcast all ARP/NDP requests. * <p> * ALL groups in ONOS are equivalent to P4Runtime packet replication engine * (PRE) Multicast groups. * * @param deviceId the device where to install the group */ private void insertMulticastGroup(DeviceId deviceId) { // Replicate packets where we know hosts are attached. Set<PortNumber> ports = getHostFacingPorts(deviceId); if (ports.isEmpty()) { // Stop here. log.warn("Device {} has 0 host facing ports", deviceId); return; } log.info("Adding L2 multicast group with {} ports on {}...", ports.size(), deviceId); // Forge group object. final GroupDescription multicastGroup = Utils.buildMulticastGroup( appId, deviceId, DEFAULT_BROADCAST_GROUP_ID, ports); // Insert. groupService.addGroup(multicastGroup); }
Example #2
Source File: GroupModBuilder.java From onos with Apache License 2.0 | 6 votes |
private OFBucket.Builder ofBucketBuilder(GroupBucket bucket) { OFBucket.Builder bucketBuilder = factory.buildBucket(); List<OFAction> actions = buildActions(bucket.treatment()); bucketBuilder.setActions(actions); if (type == GroupDescription.Type.SELECT) { bucketBuilder.setWeight(bucket.weight()); } if (type == GroupDescription.Type.FAILOVER && bucket.watchPort() != null) { bucketBuilder.setWatchPort(OFPort.of((int) bucket.watchPort().toLong())); } else { bucketBuilder.setWatchPort(OFPort.ANY); } if (type == GroupDescription.Type.FAILOVER && bucket.watchGroup() != null) { bucketBuilder.setWatchGroup(OFGroup.of(bucket.watchGroup().id())); } else { bucketBuilder.setWatchGroup(OFGroup.ANY); } return bucketBuilder; }
Example #3
Source File: SimpleVirtualGroupStore.java From onos with Apache License 2.0 | 6 votes |
@Override public void storeGroupDescription(NetworkId networkId, GroupDescription groupDesc) { // Check if a group is existing with the same key if (getGroup(networkId, groupDesc.deviceId(), groupDesc.appCookie()) != null) { return; } if (deviceAuditStatus.get(networkId) == null || deviceAuditStatus.get(networkId).get(groupDesc.deviceId()) == null) { // Device group audit has not completed yet // Add this group description to pending group key table // Create a group entry object with Dummy Group ID StoredGroupEntry group = new DefaultGroup(dummyGroupId, groupDesc); group.setState(Group.GroupState.WAITING_AUDIT_COMPLETE); ConcurrentMap<GroupKey, StoredGroupEntry> pendingKeyTable = getPendingGroupKeyTable(networkId, groupDesc.deviceId()); pendingKeyTable.put(groupDesc.appCookie(), group); return; } storeGroupDescriptionInternal(networkId, groupDesc); }
Example #4
Source File: SimpleGroupStore.java From onos with Apache License 2.0 | 6 votes |
/** * Stores a new group entry using the information from group description. * * @param groupDesc group description to be used to create group entry */ @Override public void storeGroupDescription(GroupDescription groupDesc) { // Check if a group is existing with the same key if (getGroup(groupDesc.deviceId(), groupDesc.appCookie()) != null) { return; } if (deviceAuditStatus.get(groupDesc.deviceId()) == null) { // Device group audit has not completed yet // Add this group description to pending group key table // Create a group entry object with Dummy Group ID StoredGroupEntry group = new DefaultGroup(dummyGroupId, groupDesc); group.setState(GroupState.WAITING_AUDIT_COMPLETE); ConcurrentMap<GroupKey, StoredGroupEntry> pendingKeyTable = getPendingGroupKeyTable(groupDesc.deviceId()); pendingKeyTable.put(groupDesc.appCookie(), group); return; } storeGroupDescriptionInternal(groupDesc); }
Example #5
Source File: Utils.java From ngsdn-tutorial with Apache License 2.0 | 6 votes |
public static GroupDescription buildSelectGroup(DeviceId deviceId, String tableId, String actionProfileId, int groupId, Collection<PiAction> actions, ApplicationId appId) { final GroupKey groupKey = new PiGroupKey( PiTableId.of(tableId), PiActionProfileId.of(actionProfileId), groupId); final List<GroupBucket> buckets = actions.stream() .map(action -> DefaultTrafficTreatment.builder() .piTableAction(action).build()) .map(DefaultGroupBucket::createSelectGroupBucket) .collect(Collectors.toList()); return new DefaultGroupDescription( deviceId, GroupDescription.Type.SELECT, new GroupBuckets(buckets), groupKey, groupId, appId); }
Example #6
Source File: L2BridgingComponent.java From onos-p4-tutorial with Apache License 2.0 | 6 votes |
/** * Inserts an ALL group in the ONOS core to replicate packets on all host * facing ports. This group will be used to broadcast all ARP/NDP requests. * <p> * ALL groups in ONOS are equivalent to P4Runtime packet replication engine * (PRE) Multicast groups. * * @param deviceId the device where to install the group */ private void insertMulticastGroup(DeviceId deviceId) { // Replicate packets where we know hosts are attached. Set<PortNumber> ports = getHostFacingPorts(deviceId); if (ports.isEmpty()) { // Stop here. log.warn("Device {} has 0 host facing ports", deviceId); return; } log.info("Adding L2 multicast group with {} ports on {}...", ports.size(), deviceId); // Forge group object. final GroupDescription multicastGroup = Utils.buildMulticastGroup( appId, deviceId, DEFAULT_BROADCAST_GROUP_ID, ports); // Insert. groupService.addGroup(multicastGroup); }
Example #7
Source File: DefaultOFSwitch.java From onos with Apache License 2.0 | 6 votes |
private GroupDescription.Type getGroupType(OFGroupType type) { switch (type) { case ALL: return GroupDescription.Type.ALL; case INDIRECT: return GroupDescription.Type.INDIRECT; case SELECT: return GroupDescription.Type.SELECT; case FF: return GroupDescription.Type.FAILOVER; default: log.error("Unsupported OF group type : {}", type); break; } return null; }
Example #8
Source File: Ofdpa2GroupHandler.java From onos with Apache License 2.0 | 6 votes |
/** * Creates a simple L2 Interface Group. * @param nextObj the next Objective */ private void createL2InterfaceGroup(NextObjective nextObj) { VlanId assignedVlan = readVlanFromSelector(nextObj.meta()); if (assignedVlan == null) { log.warn("VLAN ID required by simple next obj is missing. Abort."); fail(nextObj, ObjectiveError.BADPARAMS); return; } List<GroupInfo> groupInfos = prepareL2InterfaceGroup(nextObj, assignedVlan); // There is only one L2 interface group in this case GroupDescription l2InterfaceGroupDesc = groupInfos.get(0).innerMostGroupDesc(); // Put all dependency information into allGroupKeys List<Deque<GroupKey>> allGroupKeys = Lists.newArrayList(); Deque<GroupKey> gkeyChain = new ArrayDeque<>(); gkeyChain.addFirst(l2InterfaceGroupDesc.appCookie()); allGroupKeys.add(gkeyChain); // Point the next objective to this group OfdpaNextGroup ofdpaGrp = new OfdpaNextGroup(allGroupKeys, nextObj); updatePendingNextObjective(l2InterfaceGroupDesc.appCookie(), ofdpaGrp); // Start installing the inner-most group groupService.addGroup(l2InterfaceGroupDesc); }
Example #9
Source File: Utils.java From onos-p4-tutorial with Apache License 2.0 | 6 votes |
public static GroupDescription buildSelectGroup(DeviceId deviceId, String tableId, String actionProfileId, int groupId, Collection<PiAction> actions, ApplicationId appId) { final GroupKey groupKey = new PiGroupKey( PiTableId.of(tableId), PiActionProfileId.of(actionProfileId), groupId); final List<GroupBucket> buckets = actions.stream() .map(action -> DefaultTrafficTreatment.builder() .piTableAction(action).build()) .map(DefaultGroupBucket::createSelectGroupBucket) .collect(Collectors.toList()); return new DefaultGroupDescription( deviceId, GroupDescription.Type.SELECT, new GroupBuckets(buckets), groupKey, groupId, appId); }
Example #10
Source File: L2BridgingComponent.java From onos-p4-tutorial with Apache License 2.0 | 6 votes |
/** * Inserts an ALL group in the ONOS core to replicate packets on all host * facing ports. This group will be used to broadcast all ARP/NDP requests. * <p> * ALL groups in ONOS are equivalent to P4Runtime packet replication engine * (PRE) Multicast groups. * * @param deviceId the device where to install the group */ private void insertMulticastGroup(DeviceId deviceId) { // Replicate packets where we know hosts are attached. Set<PortNumber> ports = getHostFacingPorts(deviceId); if (ports.isEmpty()) { // Stop here. log.warn("Device {} has 0 host facing ports", deviceId); return; } log.info("Adding L2 multicast group with {} ports on {}...", ports.size(), deviceId); // Forge group object. final GroupDescription multicastGroup = Utils.buildMulticastGroup( appId, deviceId, DEFAULT_BROADCAST_GROUP_ID, ports); // Insert. groupService.addGroup(multicastGroup); }
Example #11
Source File: OvsOfdpaPipeline.java From onos with Apache License 2.0 | 6 votes |
/** * Builds a indirect group contains pop_vlan and punt actions. * <p> * Using group instead of immediate action to ensure that * the copy of packet on the data plane is not affected by the pop vlan action. */ private void initPopVlanPuntGroup() { GroupKey groupKey = popVlanPuntGroupKey(); TrafficTreatment bucketTreatment = DefaultTrafficTreatment.builder() .popVlan().punt().build(); GroupBucket bucket = DefaultGroupBucket.createIndirectGroupBucket(bucketTreatment); GroupDescription groupDesc = new DefaultGroupDescription( deviceId, GroupDescription.Type.INDIRECT, new GroupBuckets(Collections.singletonList(bucket)), groupKey, POP_VLAN_PUNT_GROUP_ID, driverId); groupService.addGroup(groupDesc); log.info("Initialized pop vlan punt group on {}", deviceId); }
Example #12
Source File: OfdpaGroupHandlerUtility.java From onos with Apache License 2.0 | 6 votes |
static List<GroupBucket> createL3MulticastBucket(List<GroupInfo> groupInfos) { List<GroupBucket> l3McastBuckets = new ArrayList<>(); // For each inner group groupInfos.forEach(groupInfo -> { // Points to L3 interface group if there is one. // Otherwise points to L2 interface group directly. GroupDescription nextGroupDesc = (groupInfo.nextGroupDesc() != null) ? groupInfo.nextGroupDesc() : groupInfo.innerMostGroupDesc(); TrafficTreatment.Builder ttb = DefaultTrafficTreatment.builder(); ttb.group(new GroupId(nextGroupDesc.givenGroupId())); GroupBucket abucket = DefaultGroupBucket.createAllGroupBucket(ttb.build()); l3McastBuckets.add(abucket); }); // Done return the new list of buckets return l3McastBuckets; }
Example #13
Source File: Utils.java From onos-p4-tutorial with Apache License 2.0 | 6 votes |
public static GroupDescription buildSelectGroup(DeviceId deviceId, String tableId, String actionProfileId, int groupId, Collection<PiAction> actions, ApplicationId appId) { final GroupKey groupKey = new PiGroupKey( PiTableId.of(tableId), PiActionProfileId.of(actionProfileId), groupId); final List<GroupBucket> buckets = actions.stream() .map(action -> DefaultTrafficTreatment.builder() .piTableAction(action).build()) .map(DefaultGroupBucket::createSelectGroupBucket) .collect(Collectors.toList()); return new DefaultGroupDescription( deviceId, GroupDescription.Type.SELECT, new GroupBuckets(buckets), groupKey, groupId, appId); }
Example #14
Source File: GroupModBuilder.java From onos with Apache License 2.0 | 5 votes |
private GroupModBuilder(GroupBuckets buckets, GroupId groupId, GroupDescription.Type type, OFFactory factory, Optional<Long> xid) { this.buckets = buckets; this.groupId = groupId; this.type = type; this.factory = factory; this.xid = xid.orElse((long) 0); }
Example #15
Source File: GroupStoreMessage.java From onos with Apache License 2.0 | 5 votes |
public static GroupStoreMessage createGroupFailoverMsg(DeviceId deviceId, GroupDescription desc) { return new GroupStoreMessage(Type.FAILOVER, deviceId, desc.appCookie(), desc, null, null, desc.appCookie()); }
Example #16
Source File: SpringOpenTTP.java From onos with Apache License 2.0 | 5 votes |
private void removeBucketFromGroup(NextObjective nextObjective) { log.debug("removeBucketFromGroup in {}: for next objective id {}", deviceId, nextObjective.id()); NextGroup nextGroup = flowObjectiveStore.getNextGroup(nextObjective.id()); if (nextGroup != null) { Collection<TrafficTreatment> treatments = nextObjective.next(); TrafficTreatment treatment = treatments.iterator().next(); final GroupKey key = new DefaultGroupKey( appKryo.serialize(nextObjective .id())); Group group = groupService.getGroup(deviceId, key); if (group == null) { log.warn("Group is not found in {} for {}", deviceId, key); return; } GroupBucket bucket; if (group.type() == GroupDescription.Type.INDIRECT) { bucket = DefaultGroupBucket.createIndirectGroupBucket(treatment); } else if (group.type() == GroupDescription.Type.SELECT) { bucket = DefaultGroupBucket.createSelectGroupBucket(treatment); } else if (group.type() == GroupDescription.Type.ALL) { bucket = DefaultGroupBucket.createAllGroupBucket(treatment); } else { log.warn("Unsupported Group type {}", group.type()); return; } GroupBuckets removeBuckets = new GroupBuckets(Collections.singletonList(bucket)); log.debug("Removing buckets from group id {} of next objective id {} in device {}", group.id(), nextObjective.id(), deviceId); groupService.removeBucketsFromGroup(deviceId, key, removeBuckets, key, appId); } }
Example #17
Source File: AbstractCorsaPipeline.java From onos with Apache License 2.0 | 5 votes |
@Override public void next(NextObjective nextObjective) { switch (nextObjective.type()) { case SIMPLE: Collection<TrafficTreatment> treatments = nextObjective.next(); if (treatments.size() == 1) { TrafficTreatment treatment = treatments.iterator().next(); CorsaTrafficTreatment corsaTreatment = processNextTreatment(treatment); final GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id())); if (corsaTreatment.type() == CorsaTrafficTreatmentType.GROUP) { GroupBucket bucket = DefaultGroupBucket.createIndirectGroupBucket(corsaTreatment.treatment()); GroupBuckets buckets = new GroupBuckets(Collections.singletonList(bucket)); // group id == null, let group service determine group id GroupDescription groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, buckets, key, null, nextObjective.appId()); groupService.addGroup(groupDescription); pendingGroups.put(key, nextObjective); } else if (corsaTreatment.type() == CorsaTrafficTreatmentType.ACTIONS) { pendingNext.put(nextObjective.id(), nextObjective); flowObjectiveStore.putNextGroup(nextObjective.id(), new CorsaGroup(key)); nextObjective.context().ifPresent(context -> context.onSuccess(nextObjective)); } } break; case HASHED: case BROADCAST: case FAILOVER: fail(nextObjective, ObjectiveError.UNSUPPORTED); log.warn("Unsupported next objective type {}", nextObjective.type()); break; default: fail(nextObjective, ObjectiveError.UNKNOWN); log.warn("Unknown next objective type {}", nextObjective.type()); } }
Example #18
Source File: GroupModBuilder.java From onos with Apache License 2.0 | 5 votes |
private GroupModBuilder(GroupBuckets buckets, GroupId groupId, GroupDescription.Type type, OFFactory factory, Optional<Long> xid, Optional<DriverService> driverService) { this.buckets = buckets; this.groupId = groupId; this.type = type; this.factory = factory; this.xid = xid.orElse((long) 0); this.driverService = driverService; }
Example #19
Source File: DistributedGroupStoreTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests pushing group metrics. */ @Test public void testPushGroupMetrics() { groupStore.deviceInitialAuditCompleted(deviceId1, true); groupStore.deviceInitialAuditCompleted(deviceId2, true); GroupDescription groupDescription3 = new DefaultGroupDescription( deviceId1, ALL, allGroupBuckets, new DefaultGroupKey("aaa".getBytes()), null, APP_ID); groupStore.storeGroupDescription(groupDescription1); groupStore.storeGroupDescription(groupDescription2); groupStore.storeGroupDescription(groupDescription3); Group group1 = groupStore.getGroup(deviceId1, groupId1); assertThat(group1, instanceOf(DefaultGroup.class)); DefaultGroup defaultGroup1 = (DefaultGroup) group1; defaultGroup1.setPackets(55L); defaultGroup1.setBytes(66L); groupStore.pushGroupMetrics(deviceId1, ImmutableList.of(group1)); // Make sure the group was updated. Group requeryGroup1 = groupStore.getGroup(deviceId1, groupId1); assertThat(requeryGroup1.packets(), is(55L)); assertThat(requeryGroup1.bytes(), is(66L)); }
Example #20
Source File: SpringOpenTTP.java From onos with Apache License 2.0 | 5 votes |
private void addBucketToGroup(NextObjective nextObjective) { log.debug("addBucketToGroup in {}: for next objective id {}", deviceId, nextObjective.id()); Collection<TrafficTreatment> treatments = nextObjective.next(); TrafficTreatment treatment = treatments.iterator().next(); final GroupKey key = new DefaultGroupKey( appKryo.serialize(nextObjective .id())); Group group = groupService.getGroup(deviceId, key); if (group == null) { log.warn("Group is not found in {} for {}", deviceId, key); return; } GroupBucket bucket; if (group.type() == GroupDescription.Type.INDIRECT) { bucket = DefaultGroupBucket.createIndirectGroupBucket(treatment); } else if (group.type() == GroupDescription.Type.SELECT) { bucket = DefaultGroupBucket.createSelectGroupBucket(treatment); } else if (group.type() == GroupDescription.Type.ALL) { bucket = DefaultGroupBucket.createAllGroupBucket(treatment); } else { log.warn("Unsupported Group type {}", group.type()); return; } GroupBuckets bucketsToAdd = new GroupBuckets(Collections.singletonList(bucket)); log.debug("Adding buckets to group id {} of next objective id {} in device {}", group.id(), nextObjective.id(), deviceId); groupService.addBucketsToGroup(deviceId, key, bucketsToAdd, key, appId); }
Example #21
Source File: GroupModBuilderTest.java From onos with Apache License 2.0 | 5 votes |
private GroupDescription.Type getGroupType(OFGroupType type) { switch (type) { case ALL: return GroupDescription.Type.ALL; case INDIRECT: return GroupDescription.Type.INDIRECT; case SELECT: return GroupDescription.Type.SELECT; case FF: return GroupDescription.Type.FAILOVER; default: break; } return null; }
Example #22
Source File: Ofdpa3GroupHandler.java From onos with Apache License 2.0 | 5 votes |
/** * Helper method to create a mpls l2 vpn group. * * @param nextGroupId the next group in the chain * @param index the index of the group * @param instructions the instructions to push * @param applicationId the application id * @return the group description */ private GroupDescription createMplsL2VpnGroup(int nextGroupId, int index, List<Instruction> instructions, ApplicationId applicationId) { TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); // We add the extensions and the instructions. treatment.extension(new Ofdpa3PushL2Header(), deviceId); treatment.pushVlan(); instructions.forEach(treatment::add); treatment.extension(new Ofdpa3PushCw(), deviceId); // We point the group to the next group. treatment.group(new GroupId(nextGroupId)); GroupBucket groupBucket = DefaultGroupBucket .createIndirectGroupBucket(treatment.build()); // Finally we build the group description. int groupId = makeMplsLabelGroupId(OfdpaMplsGroupSubType.L2_VPN, index); GroupKey groupKey = new DefaultGroupKey( Ofdpa2Pipeline.appKryo.serialize(index) ); return new DefaultGroupDescription( deviceId, INDIRECT, new GroupBuckets(Collections.singletonList(groupBucket)), groupKey, groupId, applicationId ); }
Example #23
Source File: Ofdpa3GroupHandler.java From onos with Apache License 2.0 | 5 votes |
/** * Helper method to create a mpls tunnel label group. * * @param nextGroupId the next group in the chain * @param subtype the mpls tunnel label group subtype * @param index the index of the group * @param instructions the instructions to push * @param applicationId the application id * @return the group description */ private GroupDescription createMplsTunnelLabelGroup(int nextGroupId, OfdpaMplsGroupSubType subtype, int index, List<Instruction> instructions, ApplicationId applicationId) { TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); // We add all the instructions. instructions.forEach(treatment::add); // We point the group to the next group. treatment.group(new GroupId(nextGroupId)); GroupBucket groupBucket = DefaultGroupBucket .createIndirectGroupBucket(treatment.build()); // Finally we build the group description. int groupId = makeMplsLabelGroupId(subtype, index); GroupKey groupKey = new DefaultGroupKey( Ofdpa2Pipeline.appKryo.serialize(index) ); return new DefaultGroupDescription( deviceId, INDIRECT, new GroupBuckets(Collections.singletonList(groupBucket)), groupKey, groupId, applicationId ); }
Example #24
Source File: OpenFlowGroupProviderTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void addGroup() { GroupId groupId = new GroupId(1); List<GroupBucket> bucketList = Lists.newArrayList(); TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); builder.setOutput(PortNumber.portNumber(1)); GroupBucket bucket = DefaultGroupBucket.createSelectGroupBucket(builder.build()); bucketList.add(bucket); GroupBuckets buckets = new GroupBuckets(bucketList); List<GroupOperation> operationList = Lists.newArrayList(); GroupOperation operation = GroupOperation.createAddGroupOperation(groupId, GroupDescription.Type.SELECT, buckets); operationList.add(operation); GroupOperations operations = new GroupOperations(operationList); provider.performGroupOperation(deviceId, operations); final Dpid dpid = Dpid.dpid(deviceId.uri()); TestOpenFlowSwitch sw = (TestOpenFlowSwitch) controller.getSwitch(dpid); assertNotNull("Switch should not be nul", sw); assertNotNull("OFGroupMsg should not be null", sw.msg); }
Example #25
Source File: SimpleGroupStore.java From onos with Apache License 2.0 | 5 votes |
@Override public void deviceInitialAuditCompleted(DeviceId deviceId, boolean completed) { synchronized (deviceAuditStatus) { if (completed) { log.debug("deviceInitialAuditCompleted: AUDIT " + "completed for device {}", deviceId); deviceAuditStatus.put(deviceId, true); // Execute all pending group requests ConcurrentMap<GroupKey, StoredGroupEntry> pendingGroupRequests = getPendingGroupKeyTable(deviceId); for (Group group:pendingGroupRequests.values()) { GroupDescription tmp = new DefaultGroupDescription( group.deviceId(), group.type(), group.buckets(), group.appCookie(), group.givenGroupId(), group.appId()); storeGroupDescriptionInternal(tmp); } getPendingGroupKeyTable(deviceId).clear(); } else { if (deviceAuditStatus.getOrDefault(deviceId, false)) { log.debug("deviceInitialAuditCompleted: Clearing AUDIT " + "status for device {}", deviceId); deviceAuditStatus.put(deviceId, false); } } } }
Example #26
Source File: DefaultOFSwitch.java From onos with Apache License 2.0 | 5 votes |
private void processGroupMod(OFGroupMod groupMod) { log.debug("processing GROUP_MOD {} message", groupMod.getCommand()); ApplicationId appId = ofSwitchService.appId(); GroupKey appCookie = new DefaultGroupKey(networkId.toString().getBytes()); switch (groupMod.getCommand()) { case ADD: // TODO return OFGroupModFailedCode.GROUP_EXISTS if group already exists int groupId = groupMod.getGroup().getGroupNumber(); OFGroupAdd groupAdd = (OFGroupAdd) groupMod; GroupBuckets groupAddBuckets = new OFAgentVirtualGroupBucketEntryBuilder( Dpid.dpid(Dpid.uri(dpid().getLong())), groupAdd.getBuckets(), groupAdd.getGroupType(), driverService) .build(); GroupDescription groupDescription = new DefaultGroupDescription( deviceId, getGroupType(groupAdd.getGroupType()), groupAddBuckets, appCookie, groupId, appId); groupService.addGroup(groupDescription); break; case MODIFY: // TODO return OFGroupModFailedCode.INVALID_GROUP if group does not exist OFGroupModify groupModify = (OFGroupModify) groupMod; GroupBuckets groupModifyBuckets = new OFAgentVirtualGroupBucketEntryBuilder( Dpid.dpid(Dpid.uri(dpid().getLong())), groupModify.getBuckets(), groupModify.getGroupType(), driverService) .build(); groupService.setBucketsForGroup(deviceId, appCookie, groupModifyBuckets, appCookie, appId); break; case DELETE: groupService.removeGroup(deviceId, appCookie, appId); break; default: // INSERT_BUCKET, REMOVE_BUCKET are effective OF 1.5. OFAgent supports 1.3. log.warn("Unsupported GROUP_MOD {} message received for switch {}", groupMod.getCommand(), this); } }
Example #27
Source File: OfdpaGroupHandlerUtility.java From onos with Apache License 2.0 | 5 votes |
/** * Generates a list of group buckets from given list of group information * and group bucket type. * * @param groupInfos a list of group information * @param bucketType group bucket type * @return list of group bucket generate from group information */ static List<GroupBucket> generateNextGroupBuckets(List<GroupInfo> groupInfos, GroupDescription.Type bucketType) { List<GroupBucket> newBuckets = Lists.newArrayList(); groupInfos.forEach(groupInfo -> { GroupDescription groupDesc = groupInfo.nextGroupDesc(); TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder(); treatmentBuilder.group(new GroupId(groupDesc.givenGroupId())); GroupBucket newBucket = null; switch (bucketType) { case ALL: newBucket = DefaultGroupBucket.createAllGroupBucket(treatmentBuilder.build()); break; case INDIRECT: newBucket = DefaultGroupBucket.createIndirectGroupBucket(treatmentBuilder.build()); break; case SELECT: newBucket = DefaultGroupBucket.createSelectGroupBucket(treatmentBuilder.build()); break; case FAILOVER: // TODO: support failover bucket type default: log.warn("Unknown bucket type: {}", bucketType); break; } if (newBucket != null) { newBuckets.add(newBucket); } }); return ImmutableList.copyOf(newBuckets); }
Example #28
Source File: OpenstackGroupRuleManager.java From onos with Apache License 2.0 | 5 votes |
@Override public void setRule(ApplicationId appId, DeviceId deviceId, int groupId, GroupDescription.Type type, List<GroupBucket> buckets, boolean install) { if (install) { GroupDescription groupDesc = new DefaultGroupDescription(deviceId, type, new GroupBuckets(buckets), getGroupKey(groupId), groupId, appId); groupService.addGroup(groupDesc); log.info("Adding group rule {}", groupId); } else { groupService.removeGroup(deviceId, getGroupKey(groupId), appId); log.info("Removing group rule {}", groupId); } }
Example #29
Source File: ObjectiveTranslation.java From onos with Apache License 2.0 | 5 votes |
private ObjectiveTranslation(Map<FlowId, FlowRule> flowRules, Map<Integer, GroupDescription> groups, ObjectiveError error) { this.flowRules = ImmutableMap.copyOf(flowRules); this.groups = ImmutableMap.copyOf(groups); this.error = error; }
Example #30
Source File: GroupModBuilderTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void groupDel() { OFGroupMod groupMod = GroupModBuilder.builder(GROUP_BUCKETS, GROUP_ID, GroupDescription.Type.ALL, OFFactoryVer13.INSTANCE, Optional.of(Long.MAX_VALUE)).buildGroupDel(); assertThat(groupMod.getBuckets().size(), is(0)); assertThat(groupMod.getGroup().getGroupNumber(), is(GROUP_ID.id())); assertThat(getGroupType(groupMod.getGroupType()), is(GroupDescription.Type.ALL)); assertThat(groupMod.getXid(), is(Long.MAX_VALUE)); assertThat(groupMod.getCommand(), is(OFGroupModCommand.DELETE)); }