blob: c811ac185ca54bfdbafc45338ed930b345de9f4a [file] [log] [blame]
Thomas Vachuska7d693f52014-10-21 19:17:57 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Thomas Vachuska7d693f52014-10-21 19:17:57 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thomas Vachuska7d693f52014-10-21 19:17:57 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska7d693f52014-10-21 19:17:57 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.cli.net;
Ray Milkey9fdf1ea2014-10-21 09:48:02 -070017
18import org.apache.karaf.shell.commands.Option;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +080019import org.onlab.packet.Ip6Address;
20import org.onlab.packet.IpAddress;
Hyunsun Mooncf732fb2015-08-22 21:04:23 -070021import org.onlab.packet.IpPrefix;
22import org.onlab.packet.MacAddress;
23import org.onlab.packet.TpPort;
Dusan Pajin6b887c92015-07-01 18:32:49 +020024import org.onlab.packet.VlanId;
Sho SHIMIZU6d01d3d2015-05-08 14:08:36 -070025import org.onlab.util.Bandwidth;
Brian O'Connorabafb502014-12-02 22:26:20 -080026import org.onosproject.cli.AbstractShellCommand;
Ray Milkey95c50872015-04-14 14:32:31 -070027import org.onosproject.core.ApplicationId;
28import org.onosproject.core.CoreService;
Brian O'Connorabafb502014-12-02 22:26:20 -080029import org.onosproject.net.Link;
Steffen Gebertba2d3b72015-10-22 11:14:31 +020030import org.onosproject.net.PortNumber;
Brian O'Connorabafb502014-12-02 22:26:20 -080031import org.onosproject.net.flow.DefaultTrafficSelector;
Brian O'Connor11ff8702015-04-29 19:37:15 -070032import org.onosproject.net.flow.DefaultTrafficTreatment;
Brian O'Connorabafb502014-12-02 22:26:20 -080033import org.onosproject.net.flow.TrafficSelector;
34import org.onosproject.net.flow.TrafficTreatment;
35import org.onosproject.net.intent.Constraint;
Ray Milkeyc24cde32015-03-10 18:20:18 -070036import org.onosproject.net.intent.Intent;
Ray Milkey5b3717e2015-02-05 11:44:08 -080037import org.onosproject.net.intent.Key;
Brian O'Connorabafb502014-12-02 22:26:20 -080038import org.onosproject.net.intent.constraint.BandwidthConstraint;
39import org.onosproject.net.intent.constraint.LambdaConstraint;
40import org.onosproject.net.intent.constraint.LinkTypeConstraint;
Jonathan Hart96c5a4a2015-07-31 14:23:33 -070041import org.onosproject.net.intent.constraint.PartialFailureConstraint;
Ray Milkey9fdf1ea2014-10-21 09:48:02 -070042
Jonathan Hartd9df7bd2015-11-10 17:10:25 -080043import java.util.LinkedList;
44import java.util.List;
45
46import static com.google.common.base.Strings.isNullOrEmpty;
47import static org.onosproject.net.flow.DefaultTrafficTreatment.builder;
48
Ray Milkey9fdf1ea2014-10-21 09:48:02 -070049/**
50 * Base class for command line operations for connectivity based intents.
51 */
52public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
53
Jonathan Hart2c25e362014-11-17 18:14:19 -080054 // Selectors
Ray Milkey9fdf1ea2014-10-21 09:48:02 -070055 @Option(name = "-s", aliases = "--ethSrc", description = "Source MAC Address",
56 required = false, multiValued = false)
57 private String srcMacString = null;
58
59 @Option(name = "-d", aliases = "--ethDst", description = "Destination MAC Address",
60 required = false, multiValued = false)
61 private String dstMacString = null;
62
63 @Option(name = "-t", aliases = "--ethType", description = "Ethernet Type",
64 required = false, multiValued = false)
Ray Milkey04c78322015-01-21 14:57:58 -080065 private String ethTypeString = null;
Ray Milkey9fdf1ea2014-10-21 09:48:02 -070066
Dusan Pajin6b887c92015-07-01 18:32:49 +020067 @Option(name = "-v", aliases = "--vlan", description = "VLAN ID",
68 required = false, multiValued = false)
69 private String vlanString = null;
70
Jonathan Hart5f7097e2014-11-11 11:50:28 -080071 @Option(name = "--ipProto", description = "IP Protocol",
72 required = false, multiValued = false)
73 private String ipProtoString = null;
74
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -070075 @Option(name = "--ipSrc", description = "Source IP Prefix",
Jonathan Hart5f7097e2014-11-11 11:50:28 -080076 required = false, multiValued = false)
77 private String srcIpString = null;
78
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -070079 @Option(name = "--ipDst", description = "Destination IP Prefix",
Jonathan Hart5f7097e2014-11-11 11:50:28 -080080 required = false, multiValued = false)
81 private String dstIpString = null;
82
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +080083 @Option(name = "--fLabel", description = "IPv6 Flow Label",
84 required = false, multiValued = false)
85 private String fLabelString = null;
86
87 @Option(name = "--icmp6Type", description = "ICMPv6 Type",
88 required = false, multiValued = false)
89 private String icmp6TypeString = null;
90
91 @Option(name = "--icmp6Code", description = "ICMPv6 Code",
92 required = false, multiValued = false)
93 private String icmp6CodeString = null;
94
95 @Option(name = "--ndTarget", description = "IPv6 Neighbor Discovery Target Address",
96 required = false, multiValued = false)
97 private String ndTargetString = null;
98
99 @Option(name = "--ndSLL", description = "IPv6 Neighbor Discovery Source Link-Layer",
100 required = false, multiValued = false)
Jonathan Hartd9df7bd2015-11-10 17:10:25 -0800101 private String ndSllString = null;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800102
103 @Option(name = "--ndTLL", description = "IPv6 Neighbor Discovery Target Link-Layer",
104 required = false, multiValued = false)
Jonathan Hartd9df7bd2015-11-10 17:10:25 -0800105 private String ndTllString = null;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800106
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800107 @Option(name = "--tcpSrc", description = "Source TCP Port",
108 required = false, multiValued = false)
109 private String srcTcpString = null;
110
111 @Option(name = "--tcpDst", description = "Destination TCP Port",
112 required = false, multiValued = false)
113 private String dstTcpString = null;
114
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800115 @Option(name = "--extHdr", description = "IPv6 Extension Header Pseudo-field",
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800116 required = false, multiValued = true)
117 private List<String> extHdrStringList = null;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800118
Ray Milkey460f4022014-11-05 15:41:43 -0800119 @Option(name = "-b", aliases = "--bandwidth", description = "Bandwidth",
120 required = false, multiValued = false)
Ray Milkey04c78322015-01-21 14:57:58 -0800121 private String bandwidthString = null;
Ray Milkey460f4022014-11-05 15:41:43 -0800122
123 @Option(name = "-l", aliases = "--lambda", description = "Lambda",
124 required = false, multiValued = false)
Sho SHIMIZU792c26b2015-06-08 19:08:32 -0700125 private boolean lambda = false;
Ray Milkey460f4022014-11-05 15:41:43 -0800126
Ray Milkey95c50872015-04-14 14:32:31 -0700127 @Option(name = "-a", aliases = "--appId", description = "Application Id",
128 required = false, multiValued = false)
129 private String appId = null;
130
Ray Milkey5b3717e2015-02-05 11:44:08 -0800131 @Option(name = "-k", aliases = "--key", description = "Intent Key",
132 required = false, multiValued = false)
133 private String intentKey = null;
134
Jonathan Hart96c5a4a2015-07-31 14:23:33 -0700135 @Option(name = "--partial", description = "Allow partial installation",
136 required = false, multiValued = false)
137 private boolean partial = false;
138
Jonathan Hart2c25e362014-11-17 18:14:19 -0800139
140 // Treatments
141 @Option(name = "--setEthSrc", description = "Rewrite Source MAC Address",
142 required = false, multiValued = false)
143 private String setEthSrcString = null;
144
145 @Option(name = "--setEthDst", description = "Rewrite Destination MAC Address",
146 required = false, multiValued = false)
147 private String setEthDstString = null;
148
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800149 @Option(name = "--setIpSrc", description = "Rewrite Source IP Address",
150 required = false, multiValued = false)
151 private String setIpSrcString = null;
152
153 @Option(name = "--setIpDst", description = "Rewrite Destination IP Address",
154 required = false, multiValued = false)
155 private String setIpDstString = null;
156
Dusan Pajin6b887c92015-07-01 18:32:49 +0200157 @Option(name = "--setVlan", description = "Rewrite VLAN ID",
158 required = false, multiValued = false)
159 private String setVlan = null;
160
161 @Option(name = "--popVlan", description = "Pop VLAN Tag",
162 required = false, multiValued = false)
163 private boolean popVlan = false;
164
165 @Option(name = "--pushVlan", description = "Push VLAN ID",
166 required = false, multiValued = false)
167 private String pushVlan = null;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800168
Steffen Gebertba2d3b72015-10-22 11:14:31 +0200169 @Option(name = "--setQueue", description = "Set Queue ID (for OpenFlow 1.0, " +
170 "also the port has to be specified, i.e., <port>/<queue>",
Steffen Gebertbbfdaaa2015-09-29 11:01:46 +0200171 required = false, multiValued = false)
172 private String setQueue = null;
173
Ray Milkeyc24cde32015-03-10 18:20:18 -0700174 // Priorities
175 @Option(name = "-p", aliases = "--priority", description = "Priority",
176 required = false, multiValued = false)
177 private int priority = Intent.DEFAULT_INTENT_PRIORITY;
178
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700179 /**
180 * Constructs a traffic selector based on the command line arguments
181 * presented to the command.
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800182 * @return traffic selector
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700183 */
184 protected TrafficSelector buildTrafficSelector() {
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -0700185 IpPrefix srcIpPrefix = null;
186 IpPrefix dstIpPrefix = null;
Ray Milkeycaa450b2014-10-29 15:54:24 -0700187
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -0700188 TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
189
190 if (!isNullOrEmpty(srcIpString)) {
191 srcIpPrefix = IpPrefix.valueOf(srcIpString);
192 if (srcIpPrefix.isIp4()) {
193 selectorBuilder.matchIPSrc(srcIpPrefix);
194 } else {
195 selectorBuilder.matchIPv6Src(srcIpPrefix);
196 }
197 }
198
199 if (!isNullOrEmpty(dstIpString)) {
200 dstIpPrefix = IpPrefix.valueOf(dstIpString);
201 if (dstIpPrefix.isIp4()) {
202 selectorBuilder.matchIPDst(dstIpPrefix);
203 } else {
204 selectorBuilder.matchIPv6Dst(dstIpPrefix);
205 }
206 }
207
208 if ((srcIpPrefix != null) && (dstIpPrefix != null) &&
209 (srcIpPrefix.version() != dstIpPrefix.version())) {
210 // ERROR: IP src/dst version mismatch
211 throw new IllegalArgumentException(
212 "IP source and destination version mismatch");
213 }
214
215 //
216 // Set the default EthType based on the IP version if the matching
217 // source or destination IP prefixes.
218 //
Ayaka Koshibe8117f362015-06-02 13:44:01 -0700219 Short ethType = null;
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -0700220 if ((srcIpPrefix != null) && srcIpPrefix.isIp6()) {
221 ethType = EthType.IPV6.value();
222 }
223 if ((dstIpPrefix != null) && dstIpPrefix.isIp6()) {
224 ethType = EthType.IPV6.value();
225 }
Ray Milkey460f4022014-11-05 15:41:43 -0800226 if (!isNullOrEmpty(ethTypeString)) {
Jonathan Hart6e948282014-11-17 22:50:42 -0800227 ethType = EthType.parseFromString(ethTypeString);
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700228 }
Ayaka Koshibe8117f362015-06-02 13:44:01 -0700229 if (ethType != null) {
230 selectorBuilder.matchEthType(ethType);
231 }
Dusan Pajin6b887c92015-07-01 18:32:49 +0200232 if (!isNullOrEmpty(vlanString)) {
233 selectorBuilder.matchVlanId(VlanId.vlanId(Short.parseShort(vlanString)));
234 }
Ray Milkey460f4022014-11-05 15:41:43 -0800235 if (!isNullOrEmpty(srcMacString)) {
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700236 selectorBuilder.matchEthSrc(MacAddress.valueOf(srcMacString));
237 }
238
Ray Milkey460f4022014-11-05 15:41:43 -0800239 if (!isNullOrEmpty(dstMacString)) {
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700240 selectorBuilder.matchEthDst(MacAddress.valueOf(dstMacString));
241 }
242
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800243 if (!isNullOrEmpty(ipProtoString)) {
Jonathan Hart6e948282014-11-17 22:50:42 -0800244 short ipProtoShort = IpProtocol.parseFromString(ipProtoString);
245 selectorBuilder.matchIPProtocol((byte) ipProtoShort);
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800246 }
247
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800248 if (!isNullOrEmpty(fLabelString)) {
249 selectorBuilder.matchIPv6FlowLabel(Integer.parseInt(fLabelString));
250 }
251
252 if (!isNullOrEmpty(icmp6TypeString)) {
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800253 byte icmp6Type = Icmp6Type.parseFromString(icmp6TypeString);
254 selectorBuilder.matchIcmpv6Type(icmp6Type);
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800255 }
256
257 if (!isNullOrEmpty(icmp6CodeString)) {
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800258 byte icmp6Code = Icmp6Code.parseFromString(icmp6CodeString);
259 selectorBuilder.matchIcmpv6Code(icmp6Code);
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800260 }
261
262 if (!isNullOrEmpty(ndTargetString)) {
263 selectorBuilder.matchIPv6NDTargetAddress(Ip6Address.valueOf(ndTargetString));
264 }
265
Jonathan Hartd9df7bd2015-11-10 17:10:25 -0800266 if (!isNullOrEmpty(ndSllString)) {
267 selectorBuilder.matchIPv6NDSourceLinkLayerAddress(MacAddress.valueOf(ndSllString));
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800268 }
269
Jonathan Hartd9df7bd2015-11-10 17:10:25 -0800270 if (!isNullOrEmpty(ndTllString)) {
271 selectorBuilder.matchIPv6NDTargetLinkLayerAddress(MacAddress.valueOf(ndTllString));
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800272 }
273
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800274 if (!isNullOrEmpty(srcTcpString)) {
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700275 selectorBuilder.matchTcpSrc(TpPort.tpPort(Integer.parseInt(srcTcpString)));
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800276 }
277
278 if (!isNullOrEmpty(dstTcpString)) {
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700279 selectorBuilder.matchTcpDst(TpPort.tpPort(Integer.parseInt(dstTcpString)));
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800280 }
281
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800282 if (extHdrStringList != null) {
283 short extHdr = 0;
284 for (String extHdrString : extHdrStringList) {
285 extHdr = (short) (extHdr | ExtHeader.parseFromString(extHdrString));
286 }
287 selectorBuilder.matchIPv6ExthdrFlags(extHdr);
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800288 }
289
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700290 return selectorBuilder.build();
291 }
292
Ray Milkey460f4022014-11-05 15:41:43 -0800293 /**
Jonathan Hart2c25e362014-11-17 18:14:19 -0800294 * Generates a traffic treatment for this intent based on command line
295 * arguments presented to the command.
296 *
297 * @return traffic treatment
298 */
299 protected TrafficTreatment buildTrafficTreatment() {
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800300 final TrafficTreatment.Builder treatmentBuilder = builder();
Brian O'Connor11ff8702015-04-29 19:37:15 -0700301 boolean emptyTreatment = true;
Jonathan Hart2c25e362014-11-17 18:14:19 -0800302
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800303 if (!isNullOrEmpty(setEthSrcString)) {
304 treatmentBuilder.setEthSrc(MacAddress.valueOf(setEthSrcString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700305 emptyTreatment = false;
Brian O'Connor4f5a98a2015-03-14 19:50:09 -0700306 }
307
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800308 if (!isNullOrEmpty(setEthDstString)) {
309 treatmentBuilder.setEthDst(MacAddress.valueOf(setEthDstString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700310 emptyTreatment = false;
Jonathan Hart2c25e362014-11-17 18:14:19 -0800311 }
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800312
313 if (!isNullOrEmpty(setIpSrcString)) {
314 treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpSrcString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700315 emptyTreatment = false;
Jonathan Hart2c25e362014-11-17 18:14:19 -0800316 }
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800317
318 if (!isNullOrEmpty(setIpDstString)) {
319 treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpDstString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700320 emptyTreatment = false;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800321 }
Dusan Pajin6b887c92015-07-01 18:32:49 +0200322 if (!isNullOrEmpty(setVlan)) {
323 treatmentBuilder.setVlanId(VlanId.vlanId(Short.parseShort(setVlan)));
324 emptyTreatment = false;
325 }
326 if (popVlan) {
327 treatmentBuilder.popVlan();
328 emptyTreatment = false;
329 }
330 if (!isNullOrEmpty(pushVlan)) {
331 treatmentBuilder.pushVlan();
332 treatmentBuilder.setVlanId(VlanId.vlanId(Short.parseShort(pushVlan)));
333 emptyTreatment = false;
334 }
Steffen Gebertbbfdaaa2015-09-29 11:01:46 +0200335 if (!isNullOrEmpty(setQueue)) {
Steffen Gebertba2d3b72015-10-22 11:14:31 +0200336 // OpenFlow 1.0 notation (for ENQUEUE): <port>/<queue>
337 if (setQueue.contains("/")) {
338 String[] queueConfig = setQueue.split("/");
339 PortNumber port = PortNumber.portNumber(Long.parseLong(queueConfig[0]));
340 long queueId = Long.parseLong(queueConfig[1]);
341 treatmentBuilder.setQueue(queueId, port);
342 } else {
343 treatmentBuilder.setQueue(Long.parseLong(setQueue));
344 }
Steffen Gebertbbfdaaa2015-09-29 11:01:46 +0200345 emptyTreatment = false;
346 }
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800347
Brian O'Connor11ff8702015-04-29 19:37:15 -0700348 if (emptyTreatment) {
349 return DefaultTrafficTreatment.emptyTreatment();
350 } else {
351 return treatmentBuilder.build();
352 }
Jonathan Hart2c25e362014-11-17 18:14:19 -0800353 }
354
355 /**
Ray Milkey460f4022014-11-05 15:41:43 -0800356 * Builds the constraint list for this command based on the command line
357 * parameters.
358 *
359 * @return List of constraint objects describing the constraints requested
360 */
361 protected List<Constraint> buildConstraints() {
362 final List<Constraint> constraints = new LinkedList<>();
363
364 // Check for a bandwidth specification
365 if (!isNullOrEmpty(bandwidthString)) {
Sho SHIMIZU6d01d3d2015-05-08 14:08:36 -0700366 final Bandwidth bandwidth = Bandwidth.bps(Double.parseDouble(bandwidthString));
Sho SHIMIZUa88db492015-11-23 13:21:04 -0800367 constraints.add(new BandwidthConstraint(bandwidth));
Ray Milkey460f4022014-11-05 15:41:43 -0800368 }
369
370 // Check for a lambda specification
Sho SHIMIZU792c26b2015-06-08 19:08:32 -0700371 if (lambda) {
372 constraints.add(new LambdaConstraint(null));
Ray Milkey460f4022014-11-05 15:41:43 -0800373 }
Sho SHIMIZU792c26b2015-06-08 19:08:32 -0700374 constraints.add(new LinkTypeConstraint(lambda, Link.Type.OPTICAL));
375
Jonathan Hart96c5a4a2015-07-31 14:23:33 -0700376 if (partial) {
377 constraints.add(new PartialFailureConstraint());
378 }
379
Ray Milkey460f4022014-11-05 15:41:43 -0800380 return constraints;
381 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800382
Ray Milkey95c50872015-04-14 14:32:31 -0700383 @Override
384 protected ApplicationId appId() {
385 ApplicationId appIdForIntent;
386 if (appId == null) {
387 appIdForIntent = super.appId();
388 } else {
389 CoreService service = get(CoreService.class);
390 appIdForIntent = service.getAppId(appId);
391 }
392 return appIdForIntent;
393 }
394
Ray Milkey5b3717e2015-02-05 11:44:08 -0800395 /**
396 * Creates a key for an intent based on command line arguments. If a key
397 * has been specified, it is returned. If no key is specified, null
398 * is returned.
399 *
400 * @return intent key if specified, null otherwise
401 */
402 protected Key key() {
403 Key key = null;
Ray Milkey95c50872015-04-14 14:32:31 -0700404 ApplicationId appIdForIntent;
405
Ray Milkey5b3717e2015-02-05 11:44:08 -0800406 if (intentKey != null) {
407 key = Key.of(intentKey, appId());
408 }
409 return key;
410 }
Ray Milkeyc24cde32015-03-10 18:20:18 -0700411
412 /**
413 * Gets the priority to use for the intent.
414 *
415 * @return priority
416 */
417 protected int priority() {
418 return priority;
419 }
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700420}