blob: 5d5d18b5b7b7e6ec3f3e243bba24cd0016a87cc5 [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;
jaegonkim7e876632017-01-25 06:01:49 +090040import org.onosproject.net.intent.constraint.HashedPathSelectionConstraint;
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 Milkey95c50872015-04-14 14:32:31 -0700119 @Option(name = "-a", aliases = "--appId", description = "Application Id",
120 required = false, multiValued = false)
121 private String appId = null;
122
Ray Milkey5b3717e2015-02-05 11:44:08 -0800123 @Option(name = "-k", aliases = "--key", description = "Intent Key",
124 required = false, multiValued = false)
125 private String intentKey = null;
126
Jonathan Hart2c25e362014-11-17 18:14:19 -0800127
128 // Treatments
129 @Option(name = "--setEthSrc", description = "Rewrite Source MAC Address",
130 required = false, multiValued = false)
131 private String setEthSrcString = null;
132
133 @Option(name = "--setEthDst", description = "Rewrite Destination MAC Address",
134 required = false, multiValued = false)
135 private String setEthDstString = null;
136
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800137 @Option(name = "--setIpSrc", description = "Rewrite Source IP Address",
138 required = false, multiValued = false)
139 private String setIpSrcString = null;
140
141 @Option(name = "--setIpDst", description = "Rewrite Destination IP Address",
142 required = false, multiValued = false)
143 private String setIpDstString = null;
144
Dusan Pajin6b887c92015-07-01 18:32:49 +0200145 @Option(name = "--setVlan", description = "Rewrite VLAN ID",
146 required = false, multiValued = false)
147 private String setVlan = null;
148
149 @Option(name = "--popVlan", description = "Pop VLAN Tag",
150 required = false, multiValued = false)
151 private boolean popVlan = false;
152
153 @Option(name = "--pushVlan", description = "Push VLAN ID",
154 required = false, multiValued = false)
155 private String pushVlan = null;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800156
Steffen Gebertba2d3b72015-10-22 11:14:31 +0200157 @Option(name = "--setQueue", description = "Set Queue ID (for OpenFlow 1.0, " +
158 "also the port has to be specified, i.e., <port>/<queue>",
Steffen Gebertbbfdaaa2015-09-29 11:01:46 +0200159 required = false, multiValued = false)
160 private String setQueue = null;
161
Ray Milkeyc24cde32015-03-10 18:20:18 -0700162 // Priorities
163 @Option(name = "-p", aliases = "--priority", description = "Priority",
164 required = false, multiValued = false)
165 private int priority = Intent.DEFAULT_INTENT_PRIORITY;
166
Michele Santuari05b882c2015-11-25 09:40:46 +0100167 // Constraints
168 @Option(name = "-b", aliases = "--bandwidth", description = "Bandwidth",
169 required = false, multiValued = false)
170 private String bandwidthString = null;
171
Michele Santuari05b882c2015-11-25 09:40:46 +0100172 @Option(name = "--partial", description = "Allow partial installation",
173 required = false, multiValued = false)
174 private boolean partial = false;
175
176 @Option(name = "-e", aliases = "--encapsulation", description = "Encapsulation type",
177 required = false, multiValued = false)
178 private String encapsulationString = null;
179
jaegonkim7e876632017-01-25 06:01:49 +0900180 @Option(name = "--hashed", description = "Hashed path selection",
181 required = false, multiValued = false)
182 private boolean hashedPathSelection = false;
183
Michele Santuari05b882c2015-11-25 09:40:46 +0100184
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700185 /**
186 * Constructs a traffic selector based on the command line arguments
187 * presented to the command.
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800188 * @return traffic selector
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700189 */
190 protected TrafficSelector buildTrafficSelector() {
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -0700191 IpPrefix srcIpPrefix = null;
192 IpPrefix dstIpPrefix = null;
Ray Milkeycaa450b2014-10-29 15:54:24 -0700193
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -0700194 TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
195
196 if (!isNullOrEmpty(srcIpString)) {
197 srcIpPrefix = IpPrefix.valueOf(srcIpString);
198 if (srcIpPrefix.isIp4()) {
199 selectorBuilder.matchIPSrc(srcIpPrefix);
200 } else {
201 selectorBuilder.matchIPv6Src(srcIpPrefix);
202 }
203 }
204
205 if (!isNullOrEmpty(dstIpString)) {
206 dstIpPrefix = IpPrefix.valueOf(dstIpString);
207 if (dstIpPrefix.isIp4()) {
208 selectorBuilder.matchIPDst(dstIpPrefix);
209 } else {
210 selectorBuilder.matchIPv6Dst(dstIpPrefix);
211 }
212 }
213
214 if ((srcIpPrefix != null) && (dstIpPrefix != null) &&
215 (srcIpPrefix.version() != dstIpPrefix.version())) {
216 // ERROR: IP src/dst version mismatch
217 throw new IllegalArgumentException(
218 "IP source and destination version mismatch");
219 }
220
221 //
222 // Set the default EthType based on the IP version if the matching
223 // source or destination IP prefixes.
224 //
Ayaka Koshibe8117f362015-06-02 13:44:01 -0700225 Short ethType = null;
Pavlin Radoslavov6ba7efc2015-03-20 16:26:10 -0700226 if ((srcIpPrefix != null) && srcIpPrefix.isIp6()) {
227 ethType = EthType.IPV6.value();
228 }
229 if ((dstIpPrefix != null) && dstIpPrefix.isIp6()) {
230 ethType = EthType.IPV6.value();
231 }
Ray Milkey460f4022014-11-05 15:41:43 -0800232 if (!isNullOrEmpty(ethTypeString)) {
Jonathan Hart6e948282014-11-17 22:50:42 -0800233 ethType = EthType.parseFromString(ethTypeString);
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700234 }
Ayaka Koshibe8117f362015-06-02 13:44:01 -0700235 if (ethType != null) {
236 selectorBuilder.matchEthType(ethType);
237 }
Dusan Pajin6b887c92015-07-01 18:32:49 +0200238 if (!isNullOrEmpty(vlanString)) {
239 selectorBuilder.matchVlanId(VlanId.vlanId(Short.parseShort(vlanString)));
240 }
Ray Milkey460f4022014-11-05 15:41:43 -0800241 if (!isNullOrEmpty(srcMacString)) {
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700242 selectorBuilder.matchEthSrc(MacAddress.valueOf(srcMacString));
243 }
244
Ray Milkey460f4022014-11-05 15:41:43 -0800245 if (!isNullOrEmpty(dstMacString)) {
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700246 selectorBuilder.matchEthDst(MacAddress.valueOf(dstMacString));
247 }
248
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800249 if (!isNullOrEmpty(ipProtoString)) {
Jonathan Hart6e948282014-11-17 22:50:42 -0800250 short ipProtoShort = IpProtocol.parseFromString(ipProtoString);
251 selectorBuilder.matchIPProtocol((byte) ipProtoShort);
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800252 }
253
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800254 if (!isNullOrEmpty(fLabelString)) {
255 selectorBuilder.matchIPv6FlowLabel(Integer.parseInt(fLabelString));
256 }
257
258 if (!isNullOrEmpty(icmp6TypeString)) {
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800259 byte icmp6Type = Icmp6Type.parseFromString(icmp6TypeString);
260 selectorBuilder.matchIcmpv6Type(icmp6Type);
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800261 }
262
263 if (!isNullOrEmpty(icmp6CodeString)) {
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800264 byte icmp6Code = Icmp6Code.parseFromString(icmp6CodeString);
265 selectorBuilder.matchIcmpv6Code(icmp6Code);
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800266 }
267
268 if (!isNullOrEmpty(ndTargetString)) {
269 selectorBuilder.matchIPv6NDTargetAddress(Ip6Address.valueOf(ndTargetString));
270 }
271
Jonathan Hartd9df7bd2015-11-10 17:10:25 -0800272 if (!isNullOrEmpty(ndSllString)) {
273 selectorBuilder.matchIPv6NDSourceLinkLayerAddress(MacAddress.valueOf(ndSllString));
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800274 }
275
Jonathan Hartd9df7bd2015-11-10 17:10:25 -0800276 if (!isNullOrEmpty(ndTllString)) {
277 selectorBuilder.matchIPv6NDTargetLinkLayerAddress(MacAddress.valueOf(ndTllString));
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800278 }
279
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800280 if (!isNullOrEmpty(srcTcpString)) {
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700281 selectorBuilder.matchTcpSrc(TpPort.tpPort(Integer.parseInt(srcTcpString)));
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800282 }
283
284 if (!isNullOrEmpty(dstTcpString)) {
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700285 selectorBuilder.matchTcpDst(TpPort.tpPort(Integer.parseInt(dstTcpString)));
Jonathan Hart5f7097e2014-11-11 11:50:28 -0800286 }
287
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800288 if (extHdrStringList != null) {
289 short extHdr = 0;
290 for (String extHdrString : extHdrStringList) {
291 extHdr = (short) (extHdr | ExtHeader.parseFromString(extHdrString));
292 }
293 selectorBuilder.matchIPv6ExthdrFlags(extHdr);
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800294 }
295
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700296 return selectorBuilder.build();
297 }
298
Ray Milkey460f4022014-11-05 15:41:43 -0800299 /**
Jonathan Hart2c25e362014-11-17 18:14:19 -0800300 * Generates a traffic treatment for this intent based on command line
301 * arguments presented to the command.
302 *
303 * @return traffic treatment
304 */
305 protected TrafficTreatment buildTrafficTreatment() {
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800306 final TrafficTreatment.Builder treatmentBuilder = builder();
Brian O'Connor11ff8702015-04-29 19:37:15 -0700307 boolean emptyTreatment = true;
Jonathan Hart2c25e362014-11-17 18:14:19 -0800308
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800309 if (!isNullOrEmpty(setEthSrcString)) {
310 treatmentBuilder.setEthSrc(MacAddress.valueOf(setEthSrcString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700311 emptyTreatment = false;
Brian O'Connor4f5a98a2015-03-14 19:50:09 -0700312 }
313
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800314 if (!isNullOrEmpty(setEthDstString)) {
315 treatmentBuilder.setEthDst(MacAddress.valueOf(setEthDstString));
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(setIpSrcString)) {
320 treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpSrcString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700321 emptyTreatment = false;
Jonathan Hart2c25e362014-11-17 18:14:19 -0800322 }
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800323
324 if (!isNullOrEmpty(setIpDstString)) {
Charles Chand4489882016-04-05 11:38:09 -0700325 treatmentBuilder.setIpDst(IpAddress.valueOf(setIpDstString));
Brian O'Connor11ff8702015-04-29 19:37:15 -0700326 emptyTreatment = false;
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800327 }
Dusan Pajin6b887c92015-07-01 18:32:49 +0200328 if (!isNullOrEmpty(setVlan)) {
329 treatmentBuilder.setVlanId(VlanId.vlanId(Short.parseShort(setVlan)));
330 emptyTreatment = false;
331 }
332 if (popVlan) {
333 treatmentBuilder.popVlan();
334 emptyTreatment = false;
335 }
336 if (!isNullOrEmpty(pushVlan)) {
337 treatmentBuilder.pushVlan();
338 treatmentBuilder.setVlanId(VlanId.vlanId(Short.parseShort(pushVlan)));
339 emptyTreatment = false;
340 }
Steffen Gebertbbfdaaa2015-09-29 11:01:46 +0200341 if (!isNullOrEmpty(setQueue)) {
Steffen Gebertba2d3b72015-10-22 11:14:31 +0200342 // OpenFlow 1.0 notation (for ENQUEUE): <port>/<queue>
343 if (setQueue.contains("/")) {
344 String[] queueConfig = setQueue.split("/");
345 PortNumber port = PortNumber.portNumber(Long.parseLong(queueConfig[0]));
346 long queueId = Long.parseLong(queueConfig[1]);
347 treatmentBuilder.setQueue(queueId, port);
348 } else {
349 treatmentBuilder.setQueue(Long.parseLong(setQueue));
350 }
Steffen Gebertbbfdaaa2015-09-29 11:01:46 +0200351 emptyTreatment = false;
352 }
Charles M.C. Chane9c8bbc2015-04-24 05:03:02 +0800353
Brian O'Connor11ff8702015-04-29 19:37:15 -0700354 if (emptyTreatment) {
355 return DefaultTrafficTreatment.emptyTreatment();
356 } else {
357 return treatmentBuilder.build();
358 }
Jonathan Hart2c25e362014-11-17 18:14:19 -0800359 }
360
361 /**
Ray Milkey460f4022014-11-05 15:41:43 -0800362 * Builds the constraint list for this command based on the command line
363 * parameters.
364 *
365 * @return List of constraint objects describing the constraints requested
366 */
367 protected List<Constraint> buildConstraints() {
368 final List<Constraint> constraints = new LinkedList<>();
369
370 // Check for a bandwidth specification
371 if (!isNullOrEmpty(bandwidthString)) {
Sho SHIMIZU31f37ed2016-01-08 18:45:54 -0800372 Bandwidth bandwidth;
373 try {
374 bandwidth = Bandwidth.bps(Long.parseLong(bandwidthString));
375 // when the string can't be parsed as long, then try to parse as double
376 } catch (NumberFormatException e) {
377 bandwidth = Bandwidth.bps(Double.parseDouble(bandwidthString));
378 }
Sho SHIMIZUa88db492015-11-23 13:21:04 -0800379 constraints.add(new BandwidthConstraint(bandwidth));
Ray Milkey460f4022014-11-05 15:41:43 -0800380 }
381
Michele Santuari05b882c2015-11-25 09:40:46 +0100382 // Check for partial failure specification
Jonathan Hart96c5a4a2015-07-31 14:23:33 -0700383 if (partial) {
384 constraints.add(new PartialFailureConstraint());
385 }
386
Michele Santuari05b882c2015-11-25 09:40:46 +0100387 // Check for encapsulation specification
388 if (!isNullOrEmpty(encapsulationString)) {
389 final EncapsulationType encapType = EncapsulationType.valueOf(encapsulationString);
390 constraints.add(new EncapsulationConstraint(encapType));
391 }
392
jaegonkim7e876632017-01-25 06:01:49 +0900393 // Check for hashed path selection
394 if (hashedPathSelection) {
395 constraints.add(new HashedPathSelectionConstraint());
396 }
Ray Milkey460f4022014-11-05 15:41:43 -0800397 return constraints;
398 }
Ray Milkey5b3717e2015-02-05 11:44:08 -0800399
Ray Milkey95c50872015-04-14 14:32:31 -0700400 @Override
401 protected ApplicationId appId() {
402 ApplicationId appIdForIntent;
403 if (appId == null) {
404 appIdForIntent = super.appId();
405 } else {
406 CoreService service = get(CoreService.class);
407 appIdForIntent = service.getAppId(appId);
408 }
409 return appIdForIntent;
410 }
411
Ray Milkey5b3717e2015-02-05 11:44:08 -0800412 /**
413 * Creates a key for an intent based on command line arguments. If a key
414 * has been specified, it is returned. If no key is specified, null
415 * is returned.
416 *
417 * @return intent key if specified, null otherwise
418 */
419 protected Key key() {
420 Key key = null;
Ray Milkey95c50872015-04-14 14:32:31 -0700421 ApplicationId appIdForIntent;
422
Ray Milkey5b3717e2015-02-05 11:44:08 -0800423 if (intentKey != null) {
424 key = Key.of(intentKey, appId());
425 }
426 return key;
427 }
Ray Milkeyc24cde32015-03-10 18:20:18 -0700428
429 /**
430 * Gets the priority to use for the intent.
431 *
432 * @return priority
433 */
434 protected int priority() {
435 return priority;
436 }
Ray Milkey9fdf1ea2014-10-21 09:48:02 -0700437}