[ONOS-6935] ActionProfile supports in P4RuntimeClient
Change-Id: I9f0ac307985c03b7ed93e14e41ba468c481a4e4f
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java
index f023e05..1de4d61 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionGroup.java
@@ -47,11 +47,15 @@
private final PiActionGroupId id;
private final Type type;
private final ImmutableSet<PiActionGroupMember> members;
+ private final PiActionProfileId piActionProfileId;
- private PiActionGroup(PiActionGroupId id, Type type, ImmutableSet<PiActionGroupMember> members) {
+ private PiActionGroup(PiActionGroupId id, Type type,
+ ImmutableSet<PiActionGroupMember> members,
+ PiActionProfileId piActionProfileId) {
this.id = id;
this.type = type;
this.members = members;
+ this.piActionProfileId = piActionProfileId;
}
/**
@@ -81,18 +85,28 @@
return members;
}
+ /**
+ * Gets identifier of the action profile.
+ *
+ * @return action profile id
+ */
+ public PiActionProfileId actionProfileId() {
+ return piActionProfileId;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if (o == null || !(o instanceof PiActionGroup)) {
return false;
}
PiActionGroup that = (PiActionGroup) o;
- return id == that.id &&
+ return Objects.equal(id, that.id) &&
Objects.equal(type, that.type) &&
- Objects.equal(members, that.members);
+ Objects.equal(members, that.members) &&
+ Objects.equal(piActionProfileId, that.piActionProfileId);
}
@Override
@@ -106,6 +120,7 @@
.add("groupId", id)
.add("type", type)
.add("members", members)
+ .add("piActionProfileId", piActionProfileId)
.toString();
}
@@ -126,6 +141,7 @@
private PiActionGroupId id;
private Type type;
private Map<PiActionGroupMemberId, PiActionGroupMember> members = Maps.newHashMap();
+ private PiActionProfileId piActionProfileId;
private Builder() {
// hides constructor.
@@ -176,6 +192,17 @@
}
/**
+ * Sets the identifier of the action profile.
+ *
+ * @param piActionProfileId the identifier of the action profile
+ * @return this
+ */
+ public Builder withActionProfileId(PiActionProfileId piActionProfileId) {
+ this.piActionProfileId = piActionProfileId;
+ return this;
+ }
+
+ /**
* Creates a new action group.
*
* @return action group
@@ -183,8 +210,11 @@
public PiActionGroup build() {
checkNotNull(id);
checkNotNull(type);
- checkArgument(members.size() > 0, "Members cannot be empty");
- return new PiActionGroup(id, type, ImmutableSet.copyOf(members.values()));
+ checkArgument(!members.isEmpty(), "Members cannot be empty");
+ checkNotNull(piActionProfileId);
+ return new PiActionGroup(id, type,
+ ImmutableSet.copyOf(members.values()),
+ piActionProfileId);
}
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileId.java
new file mode 100644
index 0000000..e0158c9
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionProfileId.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.runtime;
+
+import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
+
+/**
+ * Identifier of an action profile of a protocol-independent pipeline.
+ */
+@Beta
+public final class PiActionProfileId extends Identifier<String> {
+
+ private PiActionProfileId(String actionProfileName) {
+ super(actionProfileName);
+ }
+
+ /**
+ * Returns action profile id with given action profile name.
+ *
+ * @param actionProfileName action profile name
+ * @return action profile id
+ */
+ public static PiActionProfileId of(String actionProfileName) {
+ return new PiActionProfileId(actionProfileName);
+ }
+}