blob: e9d975b2a1adc980dcd66205f399bfa86974cd63 [file] [log] [blame]
Thomas Vachuska7d693f52014-10-21 19:17:57 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present 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;
Michele Santuari05b882c2015-11-25 09:40:46 +010029import org.onosproject.net.EncapsulationType;
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;
Michele Santuari05b882c2015-11-25 09:40:46 +010039import org.onosproject.net.intent.constraint.EncapsulationConstraint;
Jonathan Hart96c5a4a2015-07-31 14:23:33 -070040import org.onosproject.net.intent.constraint.PartialFailureConstraint;
Ray Milkey9fdf1ea2014-10-21 09:48:02 -070041
Jonathan Hartd9df7bd2015-11-10 17:10:25 -080042import java.util.LinkedList;
43import java.util.List;
44
45import static com.google.common.base.Strings.isNullOrEmpty;
46import static org.onosproject.net.flow.DefaultTrafficTreatment.builder;
47
Ray Milkey9fdf1ea2014-10-21 09:48:02 -070048/**
49 * Base class for command line operations for connectivity based intents.
50 */
51public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
52
Jonathan Hart2c25e362014-11-17 18:14:19 -080053 // Selectors
Ray Milkey9fdf1ea2014-10-21 09:48:02 -070054 @Option(name = "-s", aliases = "--ethSrc", description = "Source MAC Address",
55 required = false, multiValued = false)
56 private String srcMacString = null;
57
58 @Option(name = "-d", aliases = "--ethDst", description = "Destination MAC Address",
59 required = false, multiValued = false)
60 private String dstMacString = null;
61
62 @Option(name = "-t", aliases = "--ethType", description = "Ethernet Type",
63 required = false, multiValued = false)
Ray Milkey04c78322015-01-21 14:57:58 -080064 private String ethTypeString = null;
Ray Milkey9fdf1ea2014-10-21 09:48:02 -070065
Dusan Pajin6b887c92015-07-01 18:32:49 +020066 @Option(name = "-v", aliases = "--vlan", description = "VLAN ID",
67 required = false, multiValued = false)
68 private String vlanString = null;
69
Jonathan Hart5f7097e2014-11-11 11:50:28 -080070 @Option(name = "--ipProto", description = "IP Protocol",
71 required = false, multiValued = false)
72 private String ipProtoString = null;
73
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -070074 @Option(name = "--ipSrc", description = "Source IP Prefix",
Jonathan Hart5f7097e2014-11-11 11:50:28 -080075 required = false, multiValued = false)
76 private String srcIpString = null;
77
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -070078 @Option(name = "--ipDst", description = "Destination IP Prefix",
Jonathan Hart5f7097e2014-11-11 11:50:28 -080079 required = false, multiValued = false)
80 private String dstIpString = null;
81
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +080082 @Option(name = "--fLabel", description = "IPv6 Flow Label",
83 required = false, multiValued = false)
84 private String fLabelString = null;
85
86 @Option(name = "--icmp6Type", description = "ICMPv6 Type",
87 required = false, multiValued = false)
88 private String icmp6TypeString = null;
89
90 @Option(name = "--icmp6Code", description = "ICMPv6 Code",
91 required = false, multiValued = false)
92 private String icmp6CodeString = null;
93
94 @Option(name = "--ndTarget", description = "IPv6 Neighbor Discovery Target Address",
95 required = false, multiValued = false)
96 private String ndTargetString = null;
97
98 @Option(name = "--ndSLL", description = "IPv6 Neighbor Discovery Source Link-Layer",
99 required = false, multiValued = false)
Jonathan Hartd9df7bd2015-11-10 17:10:25 -0800100 private String ndSllString = null;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800101
102 @Option(name = "--ndTLL", description = "IPv6 Neighbor Discovery Target Link-Layer",
103 required = false, multiValued = false)
Jonathan Hartd9df7bd2015-11-10 17:10:25 -0800104 private String ndTllString = null;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800105
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800106 @Option(name = "--tcpSrc", description = "Source TCP Port",
107 required = false, multiValued = false)
108 private String srcTcpString = null;
109
110 @Option(name = "--tcpDst", description = "Destination TCP Port",
111 required = false, multiValued = false)
112 private String dstTcpString = null;
113
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800114 @Option(name = "--extHdr", description = "IPv6 Extension Header Pseudo-field",
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800115 required = false, multiValued = true)
116 private List<String> extHdrStringList = null;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800117
Ray Milkey95c50872015-04-14 14:32:31 -0700118 @Option(name = "-a", aliases = "--appId", description = "Application Id",
119 required = false, multiValued = false)
120 private String appId = null;
121
Ray Milkey5b3717e2015-02-05 11:44:08 -0800122 @Option(name = "-k", aliases = "--key", description = "Intent Key",
123 required = false, multiValued = false)
124 private String intentKey = null;
125
Jonathan Hart2c25e362014-11-17 18:14:19 -0800126
127 // Treatments
128 @Option(name = "--setEthSrc", description = "Rewrite Source MAC Address",
129 required = false, multiValued = false)
130 private String setEthSrcString = null;
131
132 @Option(name = "--setEthDst", description = "Rewrite Destination MAC Address",
133 required = false, multiValued = false)
134 private String setEthDstString = null;
135
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800136 @Option(name = "--setIpSrc", description = "Rewrite Source IP Address",
137 required = false, multiValued = false)
138 private String setIpSrcString = null;
139
140 @Option(name = "--setIpDst", description = "Rewrite Destination IP Address",
141 required = false, multiValued = false)
142 private String setIpDstString = null;
143
Dusan Pajin6b887c92015-07-01 18:32:49 +0200144 @Option(name = "--setVlan", description = "Rewrite VLAN ID",
145 required = false, multiValued = false)
146 private String setVlan = null;
147
148 @Option(name = "--popVlan", description = "Pop VLAN Tag",
149 required = false, multiValued = false)
150 private boolean popVlan = false;
151
152 @Option(name = "--pushVlan", description = "Push VLAN ID",
153 required = false, multiValued = false)
154 private String pushVlan = null;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800155
Steffen Gebertba2d3b72015-10-22 11:14:31 +0200156 @Option(name = "--setQueue", description = "Set Queue ID (for OpenFlow 1.0, " +
157 "also the port has to be specified, i.e., <port>/<queue>",
Steffen Gebertbbfdaaa2015-09-29 11:01:46 +0200158 required = false, multiValued = false)
159 private String setQueue = null;
160
Ray Milkeyc24cde32015-03-10 18:20:18 -0700161 // Priorities
162 @Option(name = "-p", aliases = "--priority", description = "Priority",
163 required = false, multiValued = false)
164 private int priority = Intent.DEFAULT_INTENT_PRIORITY;
165
Michele Santuari05b882c2015-11-25 09:40:46 +0100166 // Constraints
167 @Option(name = "-b", aliases = "--bandwidth", description = "Bandwidth",
168 required = false, multiValued = false)
169 private String bandwidthString = null;
170
Michele Santuari05b882c2015-11-25 09:40:46 +0100171 @Option(name = "--partial", description = "Allow partial installation",
172 required = false, multiValued = false)
173 private boolean partial = false;
174
175 @Option(name = "-e", aliases = "--encapsulation", description = "Encapsulation type",
176 required = false, multiValued = false)
177 private String encapsulationString = null;
178
179
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700180 /**
181 * Constructs a traffic selector based on the command line arguments
182 * presented to the command.
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800183 * @return traffic selector
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700184 */
185 protected TrafficSelector buildTrafficSelector() {
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -0700186 IpPrefix srcIpPrefix = null;
187 IpPrefix dstIpPrefix = null;
Ray Milkeycaa450b2014-10-29 15:54:24 -0700188
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -0700189 TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
190
191 if (!isNullOrEmpty(srcIpString)) {
192 srcIpPrefix = IpPrefix.valueOf(srcIpString);
193 if (srcIpPrefix.isIp4()) {
194 selectorBuilder.matchIPSrc(srcIpPrefix);
195 } else {
196 selectorBuilder.matchIPv6Src(srcIpPrefix);
197 }
198 }
199
200 if (!isNullOrEmpty(dstIpString)) {
201 dstIpPrefix = IpPrefix.valueOf(dstIpString);
202 if (dstIpPrefix.isIp4()) {
203 selectorBuilder.matchIPDst(dstIpPrefix);
204 } else {
205 selectorBuilder.matchIPv6Dst(dstIpPrefix);
206 }
207 }
208
209 if ((srcIpPrefix != null) && (dstIpPrefix != null) &&
210 (srcIpPrefix.version() != dstIpPrefix.version())) {
211 // ERROR: IP src/dst version mismatch
212 throw new IllegalArgumentException(
213 "IP source and destination version mismatch");
214 }
215
216 //
217 // Set the default EthType based on the IP version if the matching
218 // source or destination IP prefixes.
219 //
Ayaka Koshibe8117f362015-06-02 13:44:01 -0700220 Short ethType = null;
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -0700221 if ((srcIpPrefix != null) && srcIpPrefix.isIp6()) {
222 ethType = EthType.IPV6.value();
223 }
224 if ((dstIpPrefix != null) && dstIpPrefix.isIp6()) {
225 ethType = EthType.IPV6.value();
226 }
Ray Milkey460f4022014-11-05 15:41:43 -0800227 if (!isNullOrEmpty(ethTypeString)) {
Jonathan Hart6e948282014-11-17 22:50:42 -0800228 ethType = EthType.parseFromString(ethTypeString);
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700229 }
Ayaka Koshibe8117f362015-06-02 13:44:01 -0700230 if (ethType != null) {
231 selectorBuilder.matchEthType(ethType);
232 }
Dusan Pajin6b887c92015-07-01 18:32:49 +0200233 if (!isNullOrEmpty(vlanString)) {
234 selectorBuilder.matchVlanId(VlanId.vlanId(Short.parseShort(vlanString)));
235 }
Ray Milkey460f4022014-11-05 15:41:43 -0800236 if (!isNullOrEmpty(srcMacString)) {
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700237 selectorBuilder.matchEthSrc(MacAddress.valueOf(srcMacString));
238 }
239
Ray Milkey460f4022014-11-05 15:41:43 -0800240 if (!isNullOrEmpty(dstMacString)) {
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700241 selectorBuilder.matchEthDst(MacAddress.valueOf(dstMacString));
242 }
243
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800244 if (!isNullOrEmpty(ipProtoString)) {
Jonathan Hart6e948282014-11-17 22:50:42 -0800245 short ipProtoShort = IpProtocol.parseFromString(ipProtoString);
246 selectorBuilder.matchIPProtocol((byte) ipProtoShort);
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800247 }
248
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800249 if (!isNullOrEmpty(fLabelString)) {
250 selectorBuilder.matchIPv6FlowLabel(Integer.parseInt(fLabelString));
251 }
252
253 if (!isNullOrEmpty(icmp6TypeString)) {
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800254 byte icmp6Type = Icmp6Type.parseFromString(icmp6TypeString);
255 selectorBuilder.matchIcmpv6Type(icmp6Type);
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800256 }
257
258 if (!isNullOrEmpty(icmp6CodeString)) {
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800259 byte icmp6Code = Icmp6Code.parseFromString(icmp6CodeString);
260 selectorBuilder.matchIcmpv6Code(icmp6Code);
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800261 }
262
263 if (!isNullOrEmpty(ndTargetString)) {
264 selectorBuilder.matchIPv6NDTargetAddress(Ip6Address.valueOf(ndTargetString));
265 }
266
Jonathan Hartd9df7bd2015-11-10 17:10:25 -0800267 if (!isNullOrEmpty(ndSllString)) {
268 selectorBuilder.matchIPv6NDSourceLinkLayerAddress(MacAddress.valueOf(ndSllString));
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800269 }
270
Jonathan Hartd9df7bd2015-11-10 17:10:25 -0800271 if (!isNullOrEmpty(ndTllString)) {
272 selectorBuilder.matchIPv6NDTargetLinkLayerAddress(MacAddress.valueOf(ndTllString));
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800273 }
274
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800275 if (!isNullOrEmpty(srcTcpString)) {
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700276 selectorBuilder.matchTcpSrc(TpPort.tpPort(Integer.parseInt(srcTcpString)));
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800277 }
278
279 if (!isNullOrEmpty(dstTcpString)) {
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700280 selectorBuilder.matchTcpDst(TpPort.tpPort(Integer.parseInt(dstTcpString)));
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800281 }
282
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800283 if (extHdrStringList != null) {
284 short extHdr = 0;
285 for (String extHdrString : extHdrStringList) {
286 extHdr = (short) (extHdr | ExtHeader.parseFromString(extHdrString));
287 }
288 selectorBuilder.matchIPv6ExthdrFlags(extHdr);
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800289 }
290
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700291 return selectorBuilder.build();
292 }
293
Ray Milkey460f4022014-11-05 15:41:43 -0800294 /**
Jonathan Hart2c25e362014-11-17 18:14:19 -0800295 * Generates a traffic treatment for this intent based on command line
296 * arguments presented to the command.
297 *
298 * @return traffic treatment
299 */
300 protected TrafficTreatment buildTrafficTreatment() {
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800301 final TrafficTreatment.Builder treatmentBuilder = builder();
Brian O'Connor11ff8702015-04-29 19:37:15 -0700302 boolean emptyTreatment = true;
Jonathan Hart2c25e362014-11-17 18:14:19 -0800303
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800304 if (!isNullOrEmpty(setEthSrcString)) {
305 treatmentBuilder.setEthSrc(MacAddress.valueOf(setEthSrcString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700306 emptyTreatment = false;
Brian O'Connor4f5a98a2015-03-14 19:50:09 -0700307 }
308
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800309 if (!isNullOrEmpty(setEthDstString)) {
310 treatmentBuilder.setEthDst(MacAddress.valueOf(setEthDstString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700311 emptyTreatment = false;
Jonathan Hart2c25e362014-11-17 18:14:19 -0800312 }
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800313
314 if (!isNullOrEmpty(setIpSrcString)) {
315 treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpSrcString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700316 emptyTreatment = false;
Jonathan Hart2c25e362014-11-17 18:14:19 -0800317 }
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800318
319 if (!isNullOrEmpty(setIpDstString)) {
Charles Chand4489882016-04-05 11:38:09 -0700320 treatmentBuilder.setIpDst(IpAddress.valueOf(setIpDstString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700321 emptyTreatment = false;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800322 }
Dusan Pajin6b887c92015-07-01 18:32:49 +0200323 if (!isNullOrEmpty(setVlan)) {
324 treatmentBuilder.setVlanId(VlanId.vlanId(Short.parseShort(setVlan)));
325 emptyTreatment = false;
326 }
327 if (popVlan) {
328 treatmentBuilder.popVlan();
329 emptyTreatment = false;
330 }
331 if (!isNullOrEmpty(pushVlan)) {
332 treatmentBuilder.pushVlan();
333 treatmentBuilder.setVlanId(VlanId.vlanId(Short.parseShort(pushVlan)));
334 emptyTreatment = false;
335 }
Steffen Gebertbbfdaaa2015-09-29 11:01:46 +0200336 if (!isNullOrEmpty(setQueue)) {
Steffen Gebertba2d3b72015-10-22 11:14:31 +0200337 // OpenFlow 1.0 notation (for ENQUEUE): <port>/<queue>
338 if (setQueue.contains("/")) {
339 String[] queueConfig = setQueue.split("/");
340 PortNumber port = PortNumber.portNumber(Long.parseLong(queueConfig[0]));
341 long queueId = Long.parseLong(queueConfig[1]);
342 treatmentBuilder.setQueue(queueId, port);
343 } else {
344 treatmentBuilder.setQueue(Long.parseLong(setQueue));
345 }
Steffen Gebertbbfdaaa2015-09-29 11:01:46 +0200346 emptyTreatment = false;
347 }
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800348
Brian O'Connor11ff8702015-04-29 19:37:15 -0700349 if (emptyTreatment) {
350 return DefaultTrafficTreatment.emptyTreatment();
351 } else {
352 return treatmentBuilder.build();
353 }
Jonathan Hart2c25e362014-11-17 18:14:19 -0800354 }
355
356 /**
Ray Milkey460f4022014-11-05 15:41:43 -0800357 * Builds the constraint list for this command based on the command line
358 * parameters.
359 *
360 * @return List of constraint objects describing the constraints requested
361 */
362 protected List<Constraint> buildConstraints() {
363 final List<Constraint> constraints = new LinkedList<>();
364
365 // Check for a bandwidth specification
366 if (!isNullOrEmpty(bandwidthString)) {
Sho SHIMIZU31f37ed2016-01-08 18:45:54 -0800367 Bandwidth bandwidth;
368 try {
369 bandwidth = Bandwidth.bps(Long.parseLong(bandwidthString));
370 // when the string can't be parsed as long, then try to parse as double
371 } catch (NumberFormatException e) {
372 bandwidth = Bandwidth.bps(Double.parseDouble(bandwidthString));
373 }
Sho SHIMIZUa88db492015-11-23 13:21:04 -0800374 constraints.add(new BandwidthConstraint(bandwidth));
Ray Milkey460f4022014-11-05 15:41:43 -0800375 }
376
Michele Santuari05b882c2015-11-25 09:40:46 +0100377 // Check for partial failure specification
Jonathan Hart96c5a4a2015-07-31 14:23:33 -0700378 if (partial) {
379 constraints.add(new PartialFailureConstraint());
380 }
381
Michele Santuari05b882c2015-11-25 09:40:46 +0100382 // Check for encapsulation specification
383 if (!isNullOrEmpty(encapsulationString)) {
384 final EncapsulationType encapType = EncapsulationType.valueOf(encapsulationString);
385 constraints.add(new EncapsulationConstraint(encapType));
386 }
387
Ray Milkey460f4022014-11-05 15:41:43 -0800388 return constraints;
389 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800390
Ray Milkey95c50872015-04-14 14:32:31 -0700391 @Override
392 protected ApplicationId appId() {
393 ApplicationId appIdForIntent;
394 if (appId == null) {
395 appIdForIntent = super.appId();
396 } else {
397 CoreService service = get(CoreService.class);
398 appIdForIntent = service.getAppId(appId);
399 }
400 return appIdForIntent;
401 }
402
Ray Milkey5b3717e2015-02-05 11:44:08 -0800403 /**
404 * Creates a key for an intent based on command line arguments. If a key
405 * has been specified, it is returned. If no key is specified, null
406 * is returned.
407 *
408 * @return intent key if specified, null otherwise
409 */
410 protected Key key() {
411 Key key = null;
Ray Milkey95c50872015-04-14 14:32:31 -0700412 ApplicationId appIdForIntent;
413
Ray Milkey5b3717e2015-02-05 11:44:08 -0800414 if (intentKey != null) {
415 key = Key.of(intentKey, appId());
416 }
417 return key;
418 }
Ray Milkeyc24cde32015-03-10 18:20:18 -0700419
420 /**
421 * Gets the priority to use for the intent.
422 *
423 * @return priority
424 */
425 protected int priority() {
426 return priority;
427 }
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700428}