Resource group to share resources between intents
Change-Id: I5bf7d4261197449924d07dabac841cf8ccbe9389
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java
index 9b131ae..a3af158 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java
@@ -57,6 +57,7 @@
import org.onosproject.net.intent.IntentService;
import org.onosproject.net.intent.OpticalCircuitIntent;
import org.onosproject.net.intent.OpticalConnectivityIntent;
+import org.onosproject.net.intent.PathIntent;
import org.onosproject.net.optical.OchPort;
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.intent.IntentSetMultimap;
@@ -252,6 +253,7 @@
.dst(dstCP)
.signalType(ochPorts.getLeft().signalType())
.bidirectional(intent.isBidirectional())
+ .resourceGroup(intent.resourceGroup())
.build();
if (!supportsMultiplexing) {
@@ -328,7 +330,10 @@
rules.add(connectPorts(higherIntent.getDst(), lowerIntent.getDst(), higherIntent.priority(), slots));
}
- return new FlowRuleIntent(appId, higherIntent.key(), rules, higherIntent.resources());
+ return new FlowRuleIntent(appId, higherIntent.key(), rules,
+ higherIntent.resources(),
+ PathIntent.ProtectionType.PRIMARY,
+ higherIntent.resourceGroup());
}
/**
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
index de25fda..f361e99 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
@@ -197,6 +197,7 @@
.lambda(lambda)
.signalType(signalType)
.bidirectional(parentIntent.isBidirectional())
+ .resourceGroup(parentIntent.resourceGroup())
.build();
}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
index 1d60875..b01603f 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
@@ -47,6 +47,7 @@
import org.onosproject.net.intent.IntentCompiler;
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.OpticalOduIntent;
+import org.onosproject.net.intent.PathIntent;
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.OtuPort;
import org.onosproject.net.resource.Resource;
@@ -175,8 +176,13 @@
rules.addAll(createRules(intent, intent.getDst(), intent.getSrc(), path, slotsMap, true));
}
- return Collections.singletonList(new FlowRuleIntent(appId, intent.key(),
- rules, ImmutableSet.copyOf(path.links())));
+ return Collections.singletonList(
+ new FlowRuleIntent(appId,
+ intent.key(),
+ rules,
+ ImmutableSet.copyOf(path.links()),
+ PathIntent.ProtectionType.PRIMARY,
+ intent.resourceGroup()));
}
throw new OpticalIntentCompilationException("Unable to find suitable lightpath for intent " + intent);
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompiler.java
index 26196b7..9066032 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalPathIntentCompiler.java
@@ -38,6 +38,7 @@
import org.onosproject.net.intent.IntentCompiler;
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.OpticalPathIntent;
+import org.onosproject.net.intent.PathIntent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -79,10 +80,15 @@
rules.addAll(createReverseRules(intent));
}
- return Collections.singletonList(new FlowRuleIntent(appId,
- intent.key(),
- rules,
- intent.resources()));
+ return Collections.singletonList(
+ new FlowRuleIntent(appId,
+ intent.key(),
+ rules,
+ intent.resources(),
+ PathIntent.ProtectionType.PRIMARY,
+ intent.resourceGroup()
+ )
+ );
}
/**
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
index 67dbd76..1f33c46 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
@@ -61,6 +61,7 @@
.treatment(treatment)
.constraints(constraints)
.priority(priority())
+ .resourceGroup(resourceGroup())
.build();
service.submit(intent);
print("Host to Host intent submitted:\n%s", intent.toString());
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java
index 6c1a0e9..bf9558c 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java
@@ -72,6 +72,7 @@
.egressPoint(egress)
.constraints(constraints)
.priority(priority())
+ .resourceGroup(resourceGroup())
.build();
service.submit(intent);
print("Multipoint to single point intent submitted:\n%s", intent.toString());
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
index f1944ce..3b48374 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
@@ -96,6 +96,7 @@
.egressPoint(egress)
.constraints(constraints)
.priority(priority())
+ .resourceGroup(resourceGroup())
.build();
service.submit(intent);
print("Point to point intent submitted:\n%s", intent.toString());
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
index 87ede2b..52c8dfc 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
@@ -71,6 +71,7 @@
.egressPoints(egressPoints)
.constraints(constraints)
.priority(priority())
+ .resourceGroup(resourceGroup())
.build();
service.submit(intent);
print("Single point to multipoint intent submitted:\n%s", intent.toString());
diff --git a/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
index 5d5d18b..7ebc3be 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
@@ -28,6 +28,7 @@
import org.onosproject.core.CoreService;
import org.onosproject.net.EncapsulationType;
import org.onosproject.net.PortNumber;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
@@ -181,6 +182,11 @@
required = false, multiValued = false)
private boolean hashedPathSelection = false;
+ // Resource Group
+ @Option(name = "-r", aliases = "--resourceGroup", description = "Resource Group Id",
+ required = false, multiValued = false)
+ private String resourceGroupId = null;
+
/**
* Constructs a traffic selector based on the command line arguments
@@ -409,6 +415,18 @@
return appIdForIntent;
}
+ protected ResourceGroup resourceGroup() {
+ if (resourceGroupId != null) {
+ if (resourceGroupId.toLowerCase().startsWith("0x")) {
+ return ResourceGroup.of(Long.parseUnsignedLong(resourceGroupId.substring(2), 16));
+ } else {
+ return ResourceGroup.of(Long.parseUnsignedLong(resourceGroupId));
+ }
+ } else {
+ return null;
+ }
+ }
+
/**
* Creates a key for an intent based on command line arguments. If a key
* has been specified, it is returned. If no key is specified, null
diff --git a/core/api/src/main/java/org/onosproject/net/ResourceGroup.java b/core/api/src/main/java/org/onosproject/net/ResourceGroup.java
new file mode 100644
index 0000000..8eb3e7a
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/ResourceGroup.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2014-present Open Networking Laboratory
+ *
+ * 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;
+
+import com.google.common.annotations.Beta;
+import com.google.common.hash.HashFunction;
+import com.google.common.hash.Hashing;
+import org.onlab.util.Identifier;
+import org.onosproject.net.resource.ResourceConsumer;
+import org.onosproject.net.resource.ResourceConsumerId;
+
+import java.nio.charset.StandardCharsets;
+
+/**
+ * Intent identifier suitable as an external key.
+ * <p>This class is immutable.</p>
+ */
+@Beta
+public final class ResourceGroup extends Identifier<Long> implements ResourceConsumer {
+
+ private static final String HEX_PREFIX = "0x";
+ private static final HashFunction HASH_FN = Hashing.md5();
+
+ /**
+ * Creates a resource group identifier from the specified long
+ * representation.
+ *
+ * @param value long value
+ * @return resource group identifier
+ */
+ public static ResourceGroup of(long value) {
+ return new ResourceGroup(value);
+ }
+
+ /**
+ * Creates a resource group identifier from the specified string
+ * representation.
+ * Warning: it is caller responsibility to make sure the hashed value of
+ * {@code value} is unique.
+ *
+ * @param value string value
+ * @return resource group identifier
+ */
+ public static ResourceGroup of(String value) {
+ return new ResourceGroup(HASH_FN.newHasher()
+ .putString(value, StandardCharsets.UTF_8)
+ .hash()
+ .asLong());
+ }
+
+ /**
+ * Constructor for serializer.
+ */
+ protected ResourceGroup() {
+ super(0L);
+ }
+
+ /**
+ * Constructs the ID corresponding to a given long value.
+ *
+ * @param value the underlying value of this ID
+ */
+ protected ResourceGroup(long value) {
+ super(value);
+ }
+
+ /**
+ * Returns the backing value.
+ *
+ * @return the value
+ */
+ public long fingerprint() {
+ return identifier;
+ }
+
+ @Override
+ public String toString() {
+ return HEX_PREFIX + Long.toHexString(identifier);
+ }
+
+ @Override
+ public ResourceConsumerId consumerId() {
+ return ResourceConsumerId.of(this);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+ final ResourceGroup other = (ResourceGroup) obj;
+ if (this.fingerprint() != other.fingerprint()) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java b/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java
index 113845d..827a042 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/ConnectivityIntent.java
@@ -21,6 +21,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.Link;
import org.onosproject.net.NetworkResource;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
@@ -64,7 +65,9 @@
* @param constraints optional prioritized list of constraints
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if the selector or treatment is null
+ * @deprecated 1.9.1
*/
+ @Deprecated
protected ConnectivityIntent(ApplicationId appId,
Key key,
Collection<NetworkResource> resources,
@@ -79,6 +82,37 @@
}
/**
+ * Creates a connectivity intent that matches on the specified selector
+ * and applies the specified treatment.
+ * <p>
+ * Path will be optimized based on the first constraint if one is given.
+ * </p>
+ *
+ * @param appId application identifier
+ * @param key explicit key to use for intent
+ * @param resources required network resources (optional)
+ * @param selector traffic selector
+ * @param treatment treatment
+ * @param constraints optional prioritized list of constraints
+ * @param priority priority to use for flows generated by this intent
+ * @param resourceGroup resource group for this intent
+ * @throws NullPointerException if the selector or treatment is null
+ */
+ protected ConnectivityIntent(ApplicationId appId,
+ Key key,
+ Collection<NetworkResource> resources,
+ TrafficSelector selector,
+ TrafficTreatment treatment,
+ List<Constraint> constraints,
+ int priority,
+ ResourceGroup resourceGroup) {
+ super(appId, key, resources, priority, resourceGroup);
+ this.selector = checkNotNull(selector);
+ this.treatment = checkNotNull(treatment);
+ this.constraints = checkNotNull(constraints);
+ }
+
+ /**
* Constructor for serializer.
*/
protected ConnectivityIntent() {
diff --git a/core/api/src/main/java/org/onosproject/net/intent/FlowObjectiveIntent.java b/core/api/src/main/java/org/onosproject/net/intent/FlowObjectiveIntent.java
index b22a7ae..e1529e3 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/FlowObjectiveIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/FlowObjectiveIntent.java
@@ -21,6 +21,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.NetworkResource;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flowobjective.Objective;
import java.util.Collection;
@@ -54,12 +55,14 @@
* @param devices list of target devices; in same order as the objectives
* @param objectives backing flow objectives
* @param resources backing network resources
+ * @deprecated 1.9.1
*/
+ @Deprecated
public FlowObjectiveIntent(ApplicationId appId,
List<DeviceId> devices,
List<Objective> objectives,
Collection<NetworkResource> resources) {
- this(appId, null, devices, objectives, resources);
+ this(appId, null, devices, objectives, resources, null);
}
/**
@@ -71,13 +74,35 @@
* @param devices list of target devices; in same order as the objectives
* @param objectives backing flow objectives
* @param resources backing network resources
+ * @deprecated 1.9.1
*/
+ @Deprecated
public FlowObjectiveIntent(ApplicationId appId,
Key key,
List<DeviceId> devices,
List<Objective> objectives,
Collection<NetworkResource> resources) {
- super(appId, key, resources, DEFAULT_INTENT_PRIORITY);
+ this(appId, key, devices, objectives, resources, null);
+ }
+
+ /**
+ * Creates a flow objective intent with the specified objectives and
+ * resources.
+ *
+ * @param appId application id
+ * @param key intent key
+ * @param devices list of target devices; in same order as the objectives
+ * @param objectives backing flow objectives
+ * @param resources backing network resources
+ * @param resourceGroup resource goup for this intent
+ */
+ public FlowObjectiveIntent(ApplicationId appId,
+ Key key,
+ List<DeviceId> devices,
+ List<Objective> objectives,
+ Collection<NetworkResource> resources,
+ ResourceGroup resourceGroup) {
+ super(appId, key, resources, DEFAULT_INTENT_PRIORITY, resourceGroup);
checkArgument(devices.size() == objectives.size(),
"Number of devices and objectives does not match");
this.objectives = ImmutableList.copyOf(objectives);
@@ -117,6 +142,7 @@
.add("resources", resources())
.add("device", devices())
.add("objectives", objectives())
+ .add("resourceGroup", resourceGroup())
.toString();
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/FlowRuleIntent.java b/core/api/src/main/java/org/onosproject/net/intent/FlowRuleIntent.java
index 0bffaaa..9f4b9b9 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/FlowRuleIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/FlowRuleIntent.java
@@ -20,6 +20,7 @@
import com.google.common.collect.ImmutableList;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.NetworkResource;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.FlowRule;
import java.util.Collection;
@@ -43,7 +44,9 @@
* @param appId application id
* @param flowRules flow rules to be set
* @param resources network resource to be set
+ * @deprecated 1.9.1
*/
+ @Deprecated
public FlowRuleIntent(ApplicationId appId, List<FlowRule> flowRules, Collection<NetworkResource> resources) {
this(appId, null, flowRules, resources);
}
@@ -55,10 +58,12 @@
* @param flowRules flow rules to be set
* @param resources network resource to be set
* @param type protection type
+ * @deprecated 1.9.1
*/
+ @Deprecated
public FlowRuleIntent(ApplicationId appId, List<FlowRule> flowRules, Collection<NetworkResource> resources,
PathIntent.ProtectionType type) {
- this(appId, null, flowRules, resources, type);
+ this(appId, null, flowRules, resources, type, null);
}
/**
@@ -69,10 +74,13 @@
* @param key key
* @param flowRules flow rules
* @param resources network resources
+ * @deprecated 1.9.1
*/
+ @Deprecated
public FlowRuleIntent(ApplicationId appId, Key key, Collection<FlowRule> flowRules,
Collection<NetworkResource> resources) {
- this(appId, key, flowRules, resources, PathIntent.ProtectionType.PRIMARY);
+ this(appId, key, flowRules, resources,
+ PathIntent.ProtectionType.PRIMARY, null);
}
/**
@@ -84,10 +92,32 @@
* @param flowRules flow rules
* @param resources network resources
* @param primary primary protection type
+ * @deprecated 1.9.1
+ */
+ @Deprecated
+ public FlowRuleIntent(ApplicationId appId,
+ Key key,
+ Collection<FlowRule> flowRules,
+ Collection<NetworkResource> resources,
+ PathIntent.ProtectionType primary) {
+ this(appId, key, flowRules, resources, primary, null);
+ }
+
+ /**
+ * Creates a flow rule intent with the specified key, flow rules to be set, and
+ * required network resources.
+ *
+ * @param appId application id
+ * @param key key
+ * @param flowRules flow rules
+ * @param resources network resources
+ * @param primary primary protection type
+ * @param resourceGroup resource group for this intent
*/
public FlowRuleIntent(ApplicationId appId, Key key, Collection<FlowRule> flowRules,
- Collection<NetworkResource> resources, PathIntent.ProtectionType primary) {
- super(appId, key, resources, DEFAULT_INTENT_PRIORITY);
+ Collection<NetworkResource> resources, PathIntent.ProtectionType primary,
+ ResourceGroup resourceGroup) {
+ super(appId, key, resources, DEFAULT_INTENT_PRIORITY, resourceGroup);
this.flowRules = ImmutableList.copyOf(checkNotNull(flowRules));
this.type = primary;
}
@@ -101,7 +131,7 @@
*/
public FlowRuleIntent(FlowRuleIntent intent, PathIntent.ProtectionType type) {
this(intent.appId(), intent.key(), intent.flowRules(),
- intent.resources(), type);
+ intent.resources(), type, intent.resourceGroup());
}
/**
@@ -139,6 +169,7 @@
.add("appId", appId())
.add("resources", resources())
.add("flowRule", flowRules)
+ .add("resourceGroup", resourceGroup())
.toString();
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java b/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
index 92dd83b..a7505ae 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
@@ -23,6 +23,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.HostId;
import org.onosproject.net.Link;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.intent.constraint.LinkTypeConstraint;
@@ -92,6 +93,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the first host of the intent that will be built.
*
@@ -114,8 +120,6 @@
return this;
}
-
-
/**
* Builds a host to host intent from the accumulated parameters.
*
@@ -140,12 +144,12 @@
selector,
treatment,
theConstraints,
- priority
+ priority,
+ resourceGroup
);
}
}
-
/**
* Creates a new host-to-host intent with the supplied host pair.
*
@@ -157,21 +161,22 @@
* @param treatment ingress port
* @param constraints optional prioritized list of path selection constraints
* @param priority priority to use for flows generated by this intent
+ * @param resourceGroup resource group for this intent
* @throws NullPointerException if {@code one} or {@code two} is null.
*/
private HostToHostIntent(ApplicationId appId, Key key,
- HostId one, HostId two,
- TrafficSelector selector,
- TrafficTreatment treatment,
- List<Constraint> constraints,
- int priority) {
+ HostId one, HostId two,
+ TrafficSelector selector,
+ TrafficTreatment treatment,
+ List<Constraint> constraints,
+ int priority,
+ ResourceGroup resourceGroup) {
super(appId, key, ImmutableSet.of(one, two), selector, treatment,
- constraints, priority);
+ constraints, priority, resourceGroup);
// TODO: consider whether the case one and two are same is allowed
this.one = checkNotNull(one);
this.two = checkNotNull(two);
-
}
/**
@@ -203,6 +208,7 @@
.add("selector", selector())
.add("treatment", treatment())
.add("constraints", constraints())
+ .add("resourceGroup", resourceGroup())
.add("one", one)
.add("two", two)
.toString();
diff --git a/core/api/src/main/java/org/onosproject/net/intent/Intent.java b/core/api/src/main/java/org/onosproject/net/intent/Intent.java
index 4df13a6..12dad21 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/Intent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/Intent.java
@@ -19,6 +19,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.core.IdGenerator;
import org.onosproject.net.NetworkResource;
+import org.onosproject.net.ResourceGroup;
import java.util.Collection;
import java.util.Objects;
@@ -47,6 +48,7 @@
public static final int MIN_PRIORITY = 1;
private final Collection<NetworkResource> resources;
+ private final ResourceGroup resourceGroup;
private static IdGenerator idGenerator;
@@ -59,16 +61,18 @@
this.key = null;
this.resources = null;
this.priority = DEFAULT_INTENT_PRIORITY;
+ this.resourceGroup = null;
}
/**
* Creates a new intent.
- *
* @param appId application identifier
* @param key optional key
* @param resources required network resources (optional)
* @param priority flow rule priority
+ * @deprecated 1.9.1
*/
+ @Deprecated
protected Intent(ApplicationId appId,
Key key,
Collection<NetworkResource> resources,
@@ -80,6 +84,30 @@
this.key = (key != null) ? key : Key.of(id.fingerprint(), appId);
this.priority = priority;
this.resources = checkNotNull(resources);
+ this.resourceGroup = null;
+ }
+
+ /**
+ * Creates a new intent.
+ * @param appId application identifier
+ * @param key optional key
+ * @param resources required network resources (optional)
+ * @param priority flow rule priority
+ * @param resourceGroup the resource group for intent
+ */
+ protected Intent(ApplicationId appId,
+ Key key,
+ Collection<NetworkResource> resources,
+ int priority,
+ ResourceGroup resourceGroup) {
+ checkState(idGenerator != null, "Id generator is not bound.");
+ checkArgument(priority <= MAX_PRIORITY && priority >= MIN_PRIORITY);
+ this.id = IntentId.valueOf(idGenerator.getNewId());
+ this.appId = checkNotNull(appId, "Application ID cannot be null");
+ this.key = (key != null) ? key : Key.of(id.fingerprint(), appId);
+ this.priority = priority;
+ this.resources = checkNotNull(resources);
+ this.resourceGroup = resourceGroup;
}
/**
@@ -90,6 +118,7 @@
protected Key key;
protected int priority = Intent.DEFAULT_INTENT_PRIORITY;
protected Collection<NetworkResource> resources;
+ protected ResourceGroup resourceGroup;
/**
* Creates a new empty builder.
@@ -106,7 +135,8 @@
protected Builder(Intent intent) {
this.appId(intent.appId())
.key(intent.key())
- .priority(intent.priority());
+ .priority(intent.priority())
+ .resourceGroup(intent.resourceGroup());
}
/**
@@ -152,6 +182,17 @@
this.resources = resources;
return this;
}
+
+ /**
+ * Sets the resource group for this intent.
+ *
+ * @param resourceGroup the resource group
+ * @return this builder
+ */
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ this.resourceGroup = resourceGroup;
+ return this;
+ }
}
/**
@@ -191,6 +232,15 @@
}
/**
+ * Returns the resource group for this intent.
+ *
+ * @return the resource group; may be null
+ */
+ public ResourceGroup resourceGroup() {
+ return resourceGroup;
+ }
+
+ /**
* Indicates whether or not the intent is installable.
*
* @return true if installable
diff --git a/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java b/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java
index 2b5d663..0361e98 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/LinkCollectionIntent.java
@@ -27,6 +27,7 @@
import org.onosproject.net.FilteredConnectPoint;
import org.onosproject.net.Link;
import org.onosproject.net.NetworkResource;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
@@ -67,6 +68,7 @@
* @param priority priority to use for the flows generated by this intent
* @param egressTreatment true if treatment should be applied by the egress device
* @param cost the cost of the links
+ * @param resourceGroup resource group for this intent
* @throws NullPointerException {@code path} is null
*/
private LinkCollectionIntent(ApplicationId appId,
@@ -80,8 +82,9 @@
List<Constraint> constraints,
int priority,
boolean egressTreatment,
- double cost) {
- super(appId, key, resources(resources, links), selector, treatment, constraints, priority);
+ double cost,
+ ResourceGroup resourceGroup) {
+ super(appId, key, resources(resources, links), selector, treatment, constraints, priority, resourceGroup);
this.links = links;
this.ingressPoints = ingressPoints;
this.egressPoints = egressPoints;
@@ -163,6 +166,11 @@
return (Builder) super.resources(resources);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the ingress point of the single point to multi point intent
* that will be built.
@@ -280,7 +288,8 @@
constraints,
priority,
egressTreatmentFlag,
- cost
+ cost,
+ resourceGroup
);
}
}
@@ -372,7 +381,8 @@
.add("links", links())
.add("ingress", ingressPoints())
.add("egress", egressPoints())
- .add("treatementOnEgress", applyTreatmentOnEgress())
+ .add("treatmentOnEgress", applyTreatmentOnEgress())
+ .add("resourceGroup", resourceGroup())
.add("cost", cost())
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/MultiPointToSinglePointIntent.java b/core/api/src/main/java/org/onosproject/net/intent/MultiPointToSinglePointIntent.java
index 3048aac..2b0e7a8 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/MultiPointToSinglePointIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/MultiPointToSinglePointIntent.java
@@ -21,6 +21,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.FilteredConnectPoint;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.slf4j.Logger;
@@ -66,10 +67,10 @@
Set<FilteredConnectPoint> ingressPoints,
FilteredConnectPoint egressPoint,
List<Constraint> constraints,
- int priority
- ) {
+ int priority,
+ ResourceGroup resourceGroup) {
super(appId, key, ImmutableSet.of(), selector, treatment, constraints,
- priority);
+ priority, resourceGroup);
checkNotNull(ingressPoints);
checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty");
@@ -169,6 +170,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the ingress point of the single point to multi point intent
* that will be built.
@@ -245,7 +251,8 @@
ingressPoints,
egressPoint,
constraints,
- priority
+ priority,
+ resourceGroup
);
}
}
@@ -307,6 +314,7 @@
.add("filteredIngressCPs", filteredIngressPoints())
.add("filteredEgressCP", filteredEgressPoint())
.add("constraints", constraints())
+ .add("resourceGroup", resourceGroup())
.toString();
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java
index 3bc9db6..afe95bc 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java
@@ -20,6 +20,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.ResourceGroup;
import java.util.Collections;
@@ -47,10 +48,35 @@
* @param signalType ODU signal type
* @param isBidirectional indicate if intent is bidirectional
* @param priority priority to use for flows from this intent
+ * @deprecated 1.9.1
*/
+ @Deprecated
protected OpticalCircuitIntent(ApplicationId appId, Key key, ConnectPoint src, ConnectPoint dst,
CltSignalType signalType, boolean isBidirectional, int priority) {
- super(appId, key, Collections.emptyList(), priority);
+ super(appId, key, Collections.emptyList(), priority, null);
+ this.src = checkNotNull(src);
+ this.dst = checkNotNull(dst);
+ this.signalType = checkNotNull(signalType);
+ this.isBidirectional = isBidirectional;
+ }
+
+ /**
+ * Creates an optical circuit intent between the specified
+ * connection points.
+ *
+ * @param appId application identification
+ * @param key intent key
+ * @param src the source transponder port
+ * @param dst the destination transponder port
+ * @param signalType ODU signal type
+ * @param isBidirectional indicate if intent is bidirectional
+ * @param priority priority to use for flows from this intent
+ * @param resourceGroup resource group for this intent
+ */
+ protected OpticalCircuitIntent(ApplicationId appId, Key key, ConnectPoint src, ConnectPoint dst,
+ CltSignalType signalType, boolean isBidirectional, int priority,
+ ResourceGroup resourceGroup) {
+ super(appId, key, Collections.emptyList(), priority, resourceGroup);
this.src = checkNotNull(src);
this.dst = checkNotNull(dst);
this.signalType = checkNotNull(signalType);
@@ -91,6 +117,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the source for the intent that will be built.
*
@@ -149,7 +180,8 @@
dst,
signalType,
isBidirectional,
- priority
+ priority,
+ resourceGroup
);
}
}
@@ -213,6 +245,7 @@
.add("dst", dst)
.add("signalType", signalType)
.add("isBidirectional", isBidirectional)
+ .add("resourceGroup", resourceGroup())
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java
index 651ba02..05efb15 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java
@@ -20,6 +20,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.OduSignalType;
+import org.onosproject.net.ResourceGroup;
import java.util.Collections;
@@ -47,7 +48,9 @@
* @param signalType signal type
* @param isBidirectional indicates if intent is unidirectional
* @param priority priority to use for flows from this intent
+ * @deprecated 1.9.1
*/
+ @Deprecated
protected OpticalConnectivityIntent(ApplicationId appId,
Key key,
ConnectPoint src,
@@ -55,7 +58,35 @@
OduSignalType signalType,
boolean isBidirectional,
int priority) {
- super(appId, key, Collections.emptyList(), priority);
+ super(appId, key, Collections.emptyList(), priority, null);
+ this.src = checkNotNull(src);
+ this.dst = checkNotNull(dst);
+ this.signalType = checkNotNull(signalType);
+ this.isBidirectional = isBidirectional;
+ }
+
+ /**
+ * Creates an optical connectivity intent between the specified
+ * connection points.
+ *
+ * @param appId application identification
+ * @param key intent key
+ * @param src the source transponder port
+ * @param dst the destination transponder port
+ * @param signalType signal type
+ * @param isBidirectional indicates if intent is unidirectional
+ * @param priority priority to use for flows from this intent
+ * @param resourceGroup resource group of this intent
+ */
+ protected OpticalConnectivityIntent(ApplicationId appId,
+ Key key,
+ ConnectPoint src,
+ ConnectPoint dst,
+ OduSignalType signalType,
+ boolean isBidirectional,
+ int priority,
+ ResourceGroup resourceGroup) {
+ super(appId, key, Collections.emptyList(), priority, resourceGroup);
this.src = checkNotNull(src);
this.dst = checkNotNull(dst);
this.signalType = checkNotNull(signalType);
@@ -96,6 +127,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the source for the intent that will be built.
*
@@ -154,7 +190,8 @@
dst,
signalType,
isBidirectional,
- priority
+ priority,
+ resourceGroup
);
}
}
@@ -218,6 +255,7 @@
.add("dst", dst)
.add("signalType", signalType)
.add("isBidirectional", isBidirectional)
+ .add("resourceGroup", resourceGroup())
.toString();
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalOduIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalOduIntent.java
index 36c4dde..ec88542 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/OpticalOduIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalOduIntent.java
@@ -20,6 +20,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.ResourceGroup;
import java.util.Collections;
@@ -46,15 +47,44 @@
* @param signalType CltSignalType signal type
* @param isBidirectional indicate if intent is bidirectional
* @param priority priority to use for flows from this intent
+ * @deprecated 1.9.1
+ */
+ @Deprecated
+ protected OpticalOduIntent(ApplicationId appId,
+ Key key,
+ ConnectPoint src,
+ ConnectPoint dst,
+ CltSignalType signalType,
+ boolean isBidirectional,
+ int priority) {
+ super(appId, key, Collections.emptyList(), priority, null);
+ this.src = checkNotNull(src);
+ this.dst = checkNotNull(dst);
+ this.signalType = checkNotNull(signalType);
+ this.isBidirectional = isBidirectional;
+ }
+
+ /**
+ * Creates an optical ODU intent between the specified connection points.
+ *
+ * @param appId application identification
+ * @param key intent key
+ * @param src the source transponder port
+ * @param dst the destination transponder port
+ * @param signalType CltSignalType signal type
+ * @param isBidirectional indicate if intent is bidirectional
+ * @param priority priority to use for flows from this intent
+ * @param resourceGroup resource group for this intent
*/
protected OpticalOduIntent(ApplicationId appId,
- Key key,
- ConnectPoint src,
- ConnectPoint dst,
- CltSignalType signalType,
- boolean isBidirectional,
- int priority) {
- super(appId, key, Collections.emptyList(), priority);
+ Key key,
+ ConnectPoint src,
+ ConnectPoint dst,
+ CltSignalType signalType,
+ boolean isBidirectional,
+ int priority,
+ ResourceGroup resourceGroup) {
+ super(appId, key, Collections.emptyList(), priority, resourceGroup);
this.src = checkNotNull(src);
this.dst = checkNotNull(dst);
this.signalType = checkNotNull(signalType);
@@ -95,6 +125,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the source for the intent that will be built.
*
@@ -153,7 +188,8 @@
dst,
signalType,
isBidirectional,
- priority
+ priority,
+ resourceGroup
);
}
}
@@ -217,6 +253,7 @@
.add("dst", dst)
.add("signalType", signalType)
.add("isBidirectional", isBidirectional)
+ .add("resourceGroup", resourceGroup())
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java
index 1a6ee30..d42ce99 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java
@@ -24,6 +24,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableSet;
+import org.onosproject.net.ResourceGroup;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -48,8 +49,9 @@
OchSignal lambda,
OchSignalType signalType,
boolean isBidirectional,
- int priority) {
- super(appId, key, ImmutableSet.copyOf(path.links()), priority);
+ int priority,
+ ResourceGroup resourceGroup) {
+ super(appId, key, ImmutableSet.copyOf(path.links()), priority, resourceGroup);
this.src = checkNotNull(src);
this.dst = checkNotNull(dst);
this.path = checkNotNull(path);
@@ -104,6 +106,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the source for the intent that will be built.
*
@@ -186,7 +193,8 @@
lambda,
signalType,
isBidirectional,
- priority
+ priority,
+ resourceGroup
);
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java b/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
index 94a05b2..3c386cc 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
@@ -21,6 +21,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
@@ -50,7 +51,9 @@
* @param constraints optional list of constraints
* @param priority priority to use for the generated flows
* @throws NullPointerException {@code path} is null
+ * @deprecated 1.9.1
*/
+ @Deprecated
protected PathIntent(ApplicationId appId,
Key key,
TrafficSelector selector,
@@ -59,7 +62,7 @@
List<Constraint> constraints,
int priority) {
this(appId, key, selector, treatment, path, constraints, priority,
- ProtectionType.PRIMARY);
+ ProtectionType.PRIMARY, null);
}
/**
@@ -75,6 +78,7 @@
* @param constraints optional list of constraints
* @param priority priority to use for the generated flows
* @param type PRIMARY or BACKUP
+ * @param resourceGroup resource group for this intent
* @throws NullPointerException {@code path} is null
*/
protected PathIntent(ApplicationId appId,
@@ -84,9 +88,10 @@
Path path,
List<Constraint> constraints,
int priority,
- ProtectionType type) {
+ ProtectionType type,
+ ResourceGroup resourceGroup) {
super(appId, key, resources(path.links()), selector, treatment, constraints,
- priority);
+ priority, resourceGroup);
PathIntent.validate(path.links());
this.path = path;
this.type = type;
@@ -151,6 +156,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the path of the intent that will be built.
*
@@ -182,7 +192,8 @@
path,
constraints,
priority,
- type == null ? ProtectionType.PRIMARY : type
+ type == null ? ProtectionType.PRIMARY : type,
+ resourceGroup
);
}
}
@@ -237,6 +248,7 @@
.add("constraints", constraints())
.add("path", path)
.add("type", type)
+ .add("resourceGroup", resourceGroup())
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java b/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java
index ba3b2c2..77b4556 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/PointToPointIntent.java
@@ -22,6 +22,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.FilteredConnectPoint;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
@@ -92,6 +93,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the ingress point of the point to point intent that will be built.
*
@@ -140,7 +146,6 @@
return this;
}
-
/**
* Builds a point to point intent from the accumulated parameters.
*
@@ -156,7 +161,8 @@
ingressPoint,
egressPoint,
constraints,
- priority
+ priority,
+ resourceGroup
);
}
}
@@ -179,15 +185,16 @@
* {@code egressPoints} or {@code appId} is null.
*/
private PointToPointIntent(ApplicationId appId,
- Key key,
- TrafficSelector selector,
- TrafficTreatment treatment,
- FilteredConnectPoint ingressPoint,
- FilteredConnectPoint egressPoint,
- List<Constraint> constraints,
- int priority) {
+ Key key,
+ TrafficSelector selector,
+ TrafficTreatment treatment,
+ FilteredConnectPoint ingressPoint,
+ FilteredConnectPoint egressPoint,
+ List<Constraint> constraints,
+ int priority,
+ ResourceGroup resourceGroup) {
super(appId, key, Collections.emptyList(), selector, treatment, constraints,
- priority);
+ priority, resourceGroup);
checkArgument(!ingressPoint.equals(egressPoint),
"ingress and egress should be different (ingress: %s, egress: %s)", ingressPoint, egressPoint);
@@ -258,6 +265,7 @@
.add("ingress", filteredIngressPoint())
.add("egress", filteredEgressPoint())
.add("constraints", constraints())
+ .add("resourceGroup", resourceGroup())
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/ProtectedTransportIntent.java b/core/api/src/main/java/org/onosproject/net/intent/ProtectedTransportIntent.java
index 0ef0809..afc82e5 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/ProtectedTransportIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/ProtectedTransportIntent.java
@@ -24,6 +24,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.NetworkResource;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
@@ -65,9 +66,10 @@
TrafficSelector selector,
TrafficTreatment treatment,
List<Constraint> constraints,
- int priority) {
+ int priority,
+ ResourceGroup resourceGroup) {
super(appId, key, resources, selector, treatment, constraints,
- priority);
+ priority, resourceGroup);
this.one = checkNotNull(one, "one cannot be null");
this.two = checkNotNull(two, "two cannot be null");
@@ -143,6 +145,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the transport endpoint device one.
*
@@ -181,7 +188,8 @@
selector,
treatment,
constraints,
- priority
+ priority,
+ resourceGroup
);
}
@@ -199,6 +207,7 @@
.add("one", one())
.add("two", two())
.add("constraints", constraints())
+ .add("resourceGroup", resourceGroup())
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/ProtectionEndpointIntent.java b/core/api/src/main/java/org/onosproject/net/intent/ProtectionEndpointIntent.java
index 518db0b..e78e893 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/ProtectionEndpointIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/ProtectionEndpointIntent.java
@@ -23,6 +23,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.NetworkResource;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription;
import com.google.common.annotations.Beta;
@@ -39,13 +40,47 @@
private final DeviceId deviceId;
private final ProtectedTransportEndpointDescription description;
-
+ /**
+ * Creates a ProtectionEndpointIntent by specific resource and description.
+ *
+ * @param appId application identification
+ * @param key intent key
+ * @param resources network resource to be set
+ * @param priority priority to use for flows from this intent
+ * @param deviceId target device id
+ * @param description protected transport endpoint description of the intent
+ * @deprecated 1.9.1
+ */
+ @Deprecated
protected ProtectionEndpointIntent(ApplicationId appId, Key key,
- Collection<NetworkResource> resources,
- int priority,
- DeviceId deviceId,
- ProtectedTransportEndpointDescription description) {
- super(appId, key, resources, priority);
+ Collection<NetworkResource> resources,
+ int priority,
+ DeviceId deviceId,
+ ProtectedTransportEndpointDescription description) {
+ super(appId, key, resources, priority, null);
+
+ this.deviceId = checkNotNull(deviceId);
+ this.description = checkNotNull(description);
+ }
+
+ /**
+ * Creates a ProtectionEndpointIntent by specific resource and description.
+ *
+ * @param appId application identification
+ * @param key intent key
+ * @param resources network resource to be set
+ * @param priority priority to use for flows from this intent
+ * @param deviceId target device id
+ * @param description protected transport endpoint description of the intent
+ * @param resourceGroup resource group for this intent
+ */
+ protected ProtectionEndpointIntent(ApplicationId appId, Key key,
+ Collection<NetworkResource> resources,
+ int priority,
+ DeviceId deviceId,
+ ProtectedTransportEndpointDescription description,
+ ResourceGroup resourceGroup) {
+ super(appId, key, resources, priority, resourceGroup);
this.deviceId = checkNotNull(deviceId);
this.description = checkNotNull(description);
@@ -146,6 +181,11 @@
return this;
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
public Builder deviceId(DeviceId deviceId) {
this.deviceId = deviceId;
return this;
@@ -163,7 +203,8 @@
resources,
priority,
deviceId,
- description);
+ description,
+ resourceGroup);
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/SinglePointToMultiPointIntent.java b/core/api/src/main/java/org/onosproject/net/intent/SinglePointToMultiPointIntent.java
index 8431a0a..2583b8a 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/SinglePointToMultiPointIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/SinglePointToMultiPointIntent.java
@@ -24,6 +24,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.FilteredConnectPoint;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.slf4j.Logger;
@@ -67,9 +68,10 @@
FilteredConnectPoint ingressPoint,
Set<FilteredConnectPoint> egressPoints,
List<Constraint> constraints,
- int priority) {
+ int priority,
+ ResourceGroup resourceGroup) {
super(appId, key, ImmutableList.of(), selector, treatment, constraints,
- priority);
+ priority, resourceGroup);
checkNotNull(egressPoints);
checkNotNull(ingressPoint);
checkArgument(!egressPoints.isEmpty(), "Egress point set cannot be empty");
@@ -159,6 +161,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the ingress point of the single point to multi point intent
* that will be built.
@@ -221,7 +228,6 @@
return this;
}
-
/**
* Builds a single point to multi point intent from the
* accumulated parameters.
@@ -238,7 +244,8 @@
ingressPoint,
egressPoints,
constraints,
- priority
+ priority,
+ resourceGroup
);
}
}
@@ -308,6 +315,7 @@
.add("filteredIngressCPs", filteredIngressPoint())
.add("filteredEgressCP", filteredEgressPoints())
.add("constraints", constraints())
+ .add("resourceGroup", resourceGroup())
.toString();
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java b/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java
index 2a47891..cc023a4 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/TwoWayP2PIntent.java
@@ -21,6 +21,7 @@
import com.google.common.annotations.Beta;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
@@ -49,16 +50,18 @@
* @param treatment ingress port
* @param constraints optional prioritized list of path selection constraints
* @param priority priority to use for flows generated by this intent
+ * @param resourceGroup resource group for this intent
* @throws NullPointerException if {@code one} or {@code two} is null.
*/
private TwoWayP2PIntent(ApplicationId appId, Key key,
- ConnectPoint one, ConnectPoint two,
- TrafficSelector selector,
- TrafficTreatment treatment,
- List<Constraint> constraints,
- int priority) {
+ ConnectPoint one, ConnectPoint two,
+ TrafficSelector selector,
+ TrafficTreatment treatment,
+ List<Constraint> constraints,
+ int priority,
+ ResourceGroup resourceGroup) {
super(appId, key, Collections.emptyList(), selector, treatment, constraints,
- priority);
+ priority, resourceGroup);
// TODO: consider whether the case one and two are same is allowed
this.one = checkNotNull(one);
@@ -116,6 +119,11 @@
return (Builder) super.priority(priority);
}
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
+ }
+
/**
* Sets the first connection point of the two way intent that will be built.
*
@@ -153,7 +161,8 @@
selector,
treatment,
constraints,
- priority
+ priority,
+ resourceGroup
);
}
}
@@ -187,6 +196,7 @@
.add("selector", selector())
.add("treatment", treatment())
.add("constraints", constraints())
+ .add("resourceGroup", resourceGroup())
.add("one", one)
.add("two", two)
.toString();
diff --git a/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
index bab715f..3ac5a62 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
@@ -26,6 +26,7 @@
import org.onosproject.net.DeviceId;
import org.onosproject.net.FilteredConnectPoint;
import org.onosproject.net.PortNumber;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
@@ -65,6 +66,8 @@
public static final Set<FilteredConnectPoint> FPS1 = itemSet(new FilteredConnectPoint[]{FP1, FP3});
public static final Set<FilteredConnectPoint> FPS2 = itemSet(new FilteredConnectPoint[]{FP2, FP3});
+ public static final ResourceGroup RESOURCE_GROUP = ResourceGroup.of(0L);
+
public static final Map<ConnectPoint, TrafficSelector> VLANMATCHES = Maps.newHashMap();
static {
VLANMATCHES.put(P1, VLANMATCH1);
diff --git a/core/api/src/test/java/org/onosproject/net/intent/FlowObjectiveIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/FlowObjectiveIntentTest.java
index 69418a9..0b72e34 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/FlowObjectiveIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/FlowObjectiveIntentTest.java
@@ -24,6 +24,7 @@
import org.onosproject.core.DefaultApplicationId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.NetworkResource;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.criteria.Criteria;
@@ -59,6 +60,7 @@
private static final List<Objective> OBJECTIVES = ImmutableList.of(FO1, FO2);
private static final Collection<NetworkResource> RESOURCES = ImmutableSet.of();
private static final List<DeviceId> DEVICE = ImmutableList.of(DeviceId.NONE, DeviceId.NONE);
+ private static final ResourceGroup RESOURCE_GROUP = ResourceGroup.of(0L);
/**
* Tests basics of construction and getters.
@@ -66,11 +68,12 @@
@Test
public void basics() {
FlowObjectiveIntent intent =
- new FlowObjectiveIntent(APP_ID, KEY, DEVICE, OBJECTIVES, RESOURCES);
+ new FlowObjectiveIntent(APP_ID, KEY, DEVICE, OBJECTIVES, RESOURCES, RESOURCE_GROUP);
assertEquals("incorrect app id", APP_ID, intent.appId());
assertEquals("incorrect key", KEY, intent.key());
assertEquals("incorrect objectives", OBJECTIVES, intent.objectives());
assertEquals("incorrect resources", RESOURCES, intent.resources());
+ assertEquals("incorrect resource group", RESOURCE_GROUP, intent.resourceGroup());
assertTrue("should be installable", intent.isInstallable());
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java
index 0f373ff..3aba876 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/HostToHostIntentTest.java
@@ -20,6 +20,7 @@
import org.onosproject.TestApplicationId;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.HostId;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
import com.google.common.collect.ImmutableList;
@@ -41,6 +42,7 @@
private final HostId id1 = hid("12:34:56:78:91:ab/1");
private final HostId id2 = hid("12:34:56:78:92:ab/1");
private final HostId id3 = hid("12:34:56:78:93:ab/1");
+ private final ResourceGroup resourceGrouop = ResourceGroup.of(0L);
private static final ApplicationId APPID = new TestApplicationId("foo");
@@ -154,6 +156,18 @@
}
+ @Test
+ public void testResourceGroup() {
+ final HostToHostIntent intent = (HostToHostIntent) createWithResourceGroup();
+ assertThat("incorrect app id", intent.appId(), is(APPID));
+ assertThat("incorrect host one", intent.one(), is(id1));
+ assertThat("incorrect host two", intent.two(), is(id3));
+ assertThat("incorrect selector", intent.selector(), is(selector));
+ assertThat("incorrect treatment", intent.treatment(), is(treatment));
+ assertThat("incorrect resource group", intent.resourceGroup(), is(resourceGrouop));
+
+ }
+
@Override
protected Intent createOne() {
return HostToHostIntent.builder()
@@ -175,4 +189,15 @@
.treatment(treatment)
.build();
}
+
+ protected Intent createWithResourceGroup() {
+ return HostToHostIntent.builder()
+ .appId(APPID)
+ .one(id1)
+ .two(id3)
+ .selector(selector)
+ .treatment(treatment)
+ .resourceGroup(resourceGrouop)
+ .build();
+ }
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
index cb25b3c..9f45582 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/LinkCollectionIntentTest.java
@@ -27,6 +27,7 @@
import org.onosproject.net.FilteredConnectPoint;
import org.onosproject.net.Link;
import org.onosproject.net.NetTestTools;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import com.google.common.collect.ImmutableSet;
@@ -53,6 +54,7 @@
final IntentTestsMocks.MockTreatment treatment = new IntentTestsMocks.MockTreatment();
final FilteredConnectPoint filteredIngress = new FilteredConnectPoint(ingress);
final FilteredConnectPoint filteredEgress = new FilteredConnectPoint(egress);
+ final ResourceGroup resourceGroup = ResourceGroup.of(0L);
/**
* Checks that the LinkCollectionIntent class is immutable.
@@ -78,6 +80,7 @@
.links(links1)
.ingressPoints(ImmutableSet.of(ingress))
.egressPoints(ImmutableSet.of(egress))
+ .resourceGroup(resourceGroup)
.build();
final HashSet<Link> links2 = new HashSet<>();
@@ -90,6 +93,7 @@
.links(links2)
.ingressPoints(ImmutableSet.of(ingress))
.egressPoints(ImmutableSet.of(egress))
+ .resourceGroup(resourceGroup)
.build();
new EqualsTester()
@@ -113,6 +117,7 @@
.links(links1)
.ingressPoints(ImmutableSet.of(ingress))
.egressPoints(ImmutableSet.of(egress))
+ .resourceGroup(resourceGroup)
.build();
final Set<Link> createdLinks = collectionIntent.links();
@@ -122,6 +127,7 @@
assertThat(collectionIntent.selector(), is(selector));
assertThat(collectionIntent.ingressPoints(), is(ImmutableSet.of(ingress)));
assertThat(collectionIntent.egressPoints(), is(ImmutableSet.of(egress)));
+ assertThat(collectionIntent.resourceGroup(), is(resourceGroup));
assertThat(collectionIntent.resources(), hasSize(1));
final List<Constraint> createdConstraints = collectionIntent.constraints();
assertThat(createdConstraints, hasSize(0));
diff --git a/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java
index a41214b..5fcd8d4 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java
@@ -56,6 +56,14 @@
assertEquals("incorrect match", VLANMATCH1, intent.selector());
assertEquals("incorrect ingress", PS1, intent.ingressPoints());
assertEquals("incorrect egress", P2, intent.egressPoint());
+
+ intent = createWithResourceGroup();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", MATCH, intent.selector());
+ assertEquals("incorrect ingress", PS1, intent.ingressPoints());
+ assertEquals("incorrect egress", P2, intent.egressPoint());
+ assertEquals("incorrect resource group", RESOURCE_GROUP, intent.resourceGroup());
+
}
/**
@@ -109,6 +117,17 @@
.build();
}
+ protected MultiPointToSinglePointIntent createWithResourceGroup() {
+ return MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .ingressPoints(PS1)
+ .egressPoint(P2)
+ .resourceGroup(RESOURCE_GROUP)
+ .build();
+ }
+
protected MultiPointToSinglePointIntent createFilteredOne() {
return MultiPointToSinglePointIntent.builder()
diff --git a/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java
index e388468..da13af0 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java
@@ -73,6 +73,21 @@
assertEquals("incorrect action", NOP, intent.treatment());
assertEquals("incorrect path", PATH1, intent.path());
assertEquals("incorrect key", KEY, intent.key());
+
+ intent = createAnother();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", MATCH, intent.selector());
+ assertEquals("incorrect action", NOP, intent.treatment());
+ assertEquals("incorrect path", PATH2, intent.path());
+ assertEquals("incorrect key", KEY, intent.key());
+
+ intent = createWithResourceGroup();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", MATCH, intent.selector());
+ assertEquals("incorrect action", NOP, intent.treatment());
+ assertEquals("incorrect path", PATH2, intent.path());
+ assertEquals("incorrect key", KEY, intent.key());
+ assertEquals("incorrect resource group", RESOURCE_GROUP, intent.resourceGroup());
}
@Override
@@ -90,12 +105,24 @@
protected PathIntent createAnother() {
return PathIntent.builder()
.appId(APPID)
+ .key(KEY)
.selector(MATCH)
.treatment(NOP)
.path(PATH2)
.build();
}
+ protected PathIntent createWithResourceGroup() {
+ return PathIntent.builder()
+ .appId(APPID)
+ .key(KEY)
+ .selector(MATCH)
+ .treatment(NOP)
+ .path(PATH2)
+ .resourceGroup(RESOURCE_GROUP)
+ .build();
+ }
+
/**
* Tests the constructor raises IllegalArgumentException when the same device is specified in
* source and destination of a link.
diff --git a/core/api/src/test/java/org/onosproject/net/intent/PointToPointIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/PointToPointIntentTest.java
index 7f83850..8d0f900 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/PointToPointIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/PointToPointIntentTest.java
@@ -40,6 +40,13 @@
assertEquals("incorrect match", MATCH, intent.selector());
assertEquals("incorrect ingress", P1, intent.ingressPoint());
assertEquals("incorrect egress", P2, intent.egressPoint());
+
+ intent = createWithResourceGroup();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", MATCH, intent.selector());
+ assertEquals("incorrect ingress", P1, intent.ingressPoint());
+ assertEquals("incorrect egress", P2, intent.egressPoint());
+ assertEquals("incorrect resource group", RESOURCE_GROUP, intent.resourceGroup());
}
@Test
@@ -62,6 +69,17 @@
.build();
}
+ protected PointToPointIntent createWithResourceGroup() {
+ return PointToPointIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .ingressPoint(P1)
+ .egressPoint(P2)
+ .resourceGroup(RESOURCE_GROUP)
+ .build();
+ }
+
@Override
protected PointToPointIntent createAnother() {
return PointToPointIntent.builder()
diff --git a/core/api/src/test/java/org/onosproject/net/intent/SinglePointToMultiPointIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/SinglePointToMultiPointIntentTest.java
index 76aaa85..1aef3bb 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/SinglePointToMultiPointIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/SinglePointToMultiPointIntentTest.java
@@ -46,6 +46,13 @@
assertEquals("incorrect match", MATCH, intent.selector());
assertEquals("incorrect ingress", P2, intent.ingressPoint());
assertEquals("incorrect egress", PS1, intent.egressPoints());
+
+ intent = createWithResourceGroup();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", MATCH, intent.selector());
+ assertEquals("incorrect ingress", P2, intent.ingressPoint());
+ assertEquals("incorrect egress", PS1, intent.egressPoints());
+ assertEquals("incorrect resource group", RESOURCE_GROUP, intent.resourceGroup());
}
@Test
@@ -61,7 +68,6 @@
assertEquals("incorrect match", MATCH, intent.selector());
assertEquals("incorrect filtered ingress", FP1, intent.filteredIngressPoint());
assertEquals("incorrect filtered egress", FPS2, intent.filteredEgressPoints());
-
}
@Override
@@ -86,6 +92,17 @@
.build();
}
+ protected SinglePointToMultiPointIntent createWithResourceGroup() {
+ return SinglePointToMultiPointIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .ingressPoint(P2)
+ .egressPoints(PS1)
+ .resourceGroup(RESOURCE_GROUP)
+ .build();
+ }
+
protected SinglePointToMultiPointIntent createFilteredOne() {
return SinglePointToMultiPointIntent.builder()
.appId(APPID)
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/IntentCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/IntentCodec.java
index 11429d4..7686a55 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/IntentCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/IntentCodec.java
@@ -19,6 +19,7 @@
import org.onosproject.codec.JsonCodec;
import org.onosproject.core.CoreService;
import org.onosproject.net.NetworkResource;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentService;
@@ -45,6 +46,7 @@
protected static final String STATE = "state";
protected static final String PRIORITY = "priority";
protected static final String RESOURCES = "resources";
+ protected static final String RESOURCE_GROUP = "resourceGroup";
protected static final String MISSING_MEMBER_MESSAGE =
" member is required in Intent";
private static final String E_APP_ID_NOT_FOUND =
@@ -59,6 +61,9 @@
.put(ID, intent.id().toString())
.put(APP_ID, UrlEscapers.urlPathSegmentEscaper()
.escape(intent.appId().name()));
+ if (intent.resourceGroup() != null) {
+ result.put(RESOURCE_GROUP, intent.resourceGroup().toString());
+ }
final ArrayNode jsonResources = result.putArray(RESOURCES);
@@ -113,5 +118,13 @@
if (priorityJson != null) {
builder.priority(priorityJson.asInt());
}
+
+ JsonNode resourceGroup = json.get(IntentCodec.RESOURCE_GROUP);
+ if (resourceGroup != null) {
+ String resourceGroupId = resourceGroup.asText();
+ builder.resourceGroup(ResourceGroup.of(
+ Long.parseUnsignedLong(resourceGroupId.substring(2), 16)
+ ));
+ }
}
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
index f0f0046..f2283a0 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/HostToHostIntentCompiler.java
@@ -182,6 +182,7 @@
.applyTreatmentOnEgress(true)
.constraints(intent.constraints())
.priority(intent.priority())
+ .resourceGroup(intent.resourceGroup())
.build();
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentFlowObjectiveCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentFlowObjectiveCompiler.java
index 6a0081f..0aa4e87 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentFlowObjectiveCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentFlowObjectiveCompiler.java
@@ -119,7 +119,10 @@
});
}
return Collections.singletonList(
- new FlowObjectiveIntent(appId, intent.key(), devices, objectives, intent.resources()));
+ new FlowObjectiveIntent(appId, intent.key(), devices,
+ objectives,
+ intent.resources(),
+ intent.resourceGroup()));
}
@Override
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
index 758c21b5..3b4dca9 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
@@ -122,6 +122,7 @@
.filteredEgressPoints(ImmutableSet.of(intent.filteredEgressPoint()))
.priority(intent.priority())
.constraints(intent.constraints())
+ .resourceGroup(intent.resourceGroup())
.build();
return Collections.singletonList(result);
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
index a2c26dd..0b0569a 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java
@@ -88,7 +88,9 @@
intent.key(),
rules,
intent.resources(),
- intent.type()));
+ intent.type(),
+ intent.resourceGroup()
+ ));
}
@Override
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java
index 521d6fc..7c466285 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentFlowObjectiveCompiler.java
@@ -93,7 +93,9 @@
intent.key(),
devices,
objectives,
- intent.resources()));
+ intent.resources(),
+ intent.resourceGroup()
+ ));
}
@Override
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
index c3fc348..94fe6ed 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompiler.java
@@ -259,7 +259,8 @@
intent.key(),
createFailoverFlowRules(intent),
asList(ingressPoint.deviceId()),
- PathIntent.ProtectionType.FAILOVER);
+ PathIntent.ProtectionType.FAILOVER,
+ intent.resourceGroup());
intentList.add(frIntent);
} else {
updateFailoverGroup(intent, links);
@@ -320,6 +321,7 @@
.constraints(intent.constraints())
.priority(intent.priority())
.setType(type)
+ .resourceGroup(intent.resourceGroup())
.build();
}
@@ -353,6 +355,7 @@
.constraints(intent.constraints())
.priority(intent.priority())
.cost(cost)
+ .resourceGroup(intent.resourceGroup())
.build();
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java
index a3f7c49..504e4f3 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java
@@ -101,6 +101,7 @@
.priority(intent.priority())
.applyTreatmentOnEgress(true)
.constraints(intent.constraints())
+ .resourceGroup(intent.resourceGroup())
.build();
return Collections.singletonList(result);
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
index 6deba8f..862a845 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/TwoWayP2PIntentCompiler.java
@@ -54,6 +54,7 @@
.egressPoint(intent.two())
.constraints(intent.constraints())
.priority(intent.priority())
+ .resourceGroup(intent.resourceGroup())
.build(),
PointToPointIntent.builder()
.appId(intent.appId())
@@ -64,6 +65,7 @@
.egressPoint(intent.one())
.constraints(intent.constraints())
.priority(intent.priority())
+ .resourceGroup(intent.resourceGroup())
.build());
}
}
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/VirtualNetworkIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/VirtualNetworkIntentCompiler.java
index 5eac0d4..2222b50 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/VirtualNetworkIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/VirtualNetworkIntentCompiler.java
@@ -180,6 +180,7 @@
.constraints(intent.constraints())
.selector(intent.selector())
.treatment(intent.treatment())
+ .resourceGroup(intent.resourceGroup())
.build();
log.debug("Submitting physical intent: " + physicalIntent);
intentService.submit(physicalIntent);
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
index 1ea18a0..4db7a11 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
@@ -86,6 +86,7 @@
import org.onosproject.net.OtuSignalType;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.TributarySlot;
import org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription;
import org.onosproject.net.device.DefaultDeviceDescription;
@@ -469,6 +470,7 @@
ContinuousResourceId.class,
ResourceAllocation.class,
ResourceConsumerId.class,
+ ResourceGroup.class,
// Constraints
BandwidthConstraint.class,
LinkTypeConstraint.class,
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkIntent.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkIntent.java
index acdbe44..789353c 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkIntent.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkIntent.java
@@ -20,6 +20,7 @@
import com.google.common.base.MoreObjects;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.ResourceGroup;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.intent.ConnectivityIntent;
@@ -72,33 +73,38 @@
}
@Override
- public VirtualNetworkIntent.Builder appId(ApplicationId appId) {
- return (VirtualNetworkIntent.Builder) super.appId(appId);
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
}
@Override
- public VirtualNetworkIntent.Builder key(Key key) {
- return (VirtualNetworkIntent.Builder) super.key(key);
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
}
@Override
- public VirtualNetworkIntent.Builder selector(TrafficSelector selector) {
- return (VirtualNetworkIntent.Builder) super.selector(selector);
+ public Builder selector(TrafficSelector selector) {
+ return (Builder) super.selector(selector);
}
@Override
- public VirtualNetworkIntent.Builder treatment(TrafficTreatment treatment) {
- return (VirtualNetworkIntent.Builder) super.treatment(treatment);
+ public Builder treatment(TrafficTreatment treatment) {
+ return (Builder) super.treatment(treatment);
}
@Override
- public VirtualNetworkIntent.Builder constraints(List<Constraint> constraints) {
- return (VirtualNetworkIntent.Builder) super.constraints(constraints);
+ public Builder constraints(List<Constraint> constraints) {
+ return (Builder) super.constraints(constraints);
}
@Override
- public VirtualNetworkIntent.Builder priority(int priority) {
- return (VirtualNetworkIntent.Builder) super.priority(priority);
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ @Override
+ public Builder resourceGroup(ResourceGroup resourceGroup) {
+ return (Builder) super.resourceGroup(resourceGroup);
}
/**
@@ -150,7 +156,8 @@
ingressPoint,
egressPoint,
constraints,
- priority
+ priority,
+ resourceGroup
);
}
}
@@ -180,9 +187,10 @@
ConnectPoint ingressPoint,
ConnectPoint egressPoint,
List<Constraint> constraints,
- int priority) {
+ int priority,
+ ResourceGroup resourceGroup) {
super(appId, key, Collections.emptyList(), selector, treatment, constraints,
- priority);
+ priority, resourceGroup);
checkNotNull(networkId, NETWORK_ID_NULL);
checkArgument(!ingressPoint.equals(egressPoint),
@@ -245,6 +253,7 @@
.add("ingress", ingressPoint)
.add("egress", egressPoint)
.add("constraints", constraints())
+ .add("resourceGroup", resourceGroup())
.toString();
}