blob: 5bf13ffdd3ee863d18980616c8a34a55004cdb14 [file] [log] [blame]
Mahesh Poojary Sd7a36922016-04-01 16:11:14 +05301/*
2 * Copyright 2016 Open Networking Laboratory
3 *
4 * 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
7 *
8 * 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.
15 */
16package org.onosproject.pce.cli;
17
18import static org.slf4j.LoggerFactory.getLogger;
19
20import java.util.List;
21import java.util.LinkedList;
22
23import org.apache.karaf.shell.commands.Argument;
24import org.apache.karaf.shell.commands.Command;
25import org.apache.karaf.shell.commands.Option;
26
27import org.onosproject.cli.AbstractShellCommand;
28import org.onosproject.net.DeviceId;
29import org.onosproject.net.intent.Constraint;
30import org.onosproject.pce.pceservice.LspType;
31import org.onosproject.pce.pceservice.api.PceService;
32
33import org.slf4j.Logger;
34
35/**
36 * Supports creating the pce path.
37 */
38@Command(scope = "onos", name = "pce-setup-path", description = "Supports creating pce path.")
39public class PceSetupPathCommand extends AbstractShellCommand {
40 private final Logger log = getLogger(getClass());
41
42 @Argument(index = 0, name = "src", description = "source device.", required = true, multiValued = false)
43 String src = null;
44
45 @Argument(index = 1, name = "dst", description = "destination device.", required = true, multiValued = false)
46 String dst = null;
47
48 @Argument(index = 2, name = "type", description = "LSP type:" + " It includes "
49 + "PCE tunnel with signalling in network (0), "
50 + "PCE tunnel without signalling in network with segment routing (1), "
51 + "PCE tunnel without signalling in network (2).",
52 required = true, multiValued = false)
53 int type = 0;
54
55 @Argument(index = 3, name = "name", description = "symbolic-path-name.", required = true, multiValued = false)
56 String name = null;
57
58 @Option(name = "-c", aliases = "--cost", description = "The cost attribute IGP cost(1) or TE cost(2)",
59 required = false, multiValued = false)
60 int cost = 2;
61
62 @Option(name = "-b", aliases = "--bandwidth", description = "The bandwidth attribute of path. "
63 + "Data rate unit is in BPS.", required = false, multiValued = false)
64 double bandwidth = 0.0;
65
66 @Override
67 protected void execute() {
68 log.info("executing pce-setup-path");
69
70 PceService service = get(PceService.class);
71
72 DeviceId srcDevice = DeviceId.deviceId(src);
73 DeviceId dstDevice = DeviceId.deviceId(dst);
74 LspType lspType = LspType.values()[type];
75 List<Constraint> listConstrnt = new LinkedList<>();
76
77 // add cost
78 //TODO: need to uncomment below lines once CostConstraint is ready
79 //CostConstraint.Type costType = CostConstraint.Type.values()[cost];
80 //listConstrnt.add(CostConstraint.of(costType));
81
82 // add bandwidth
83 // bandwidth default data rate unit is in BPS
84 if (bandwidth != 0.0) {
85 //TODO: need to uncomment below line once BandwidthConstraint is ready
86 //listConstrnt.add(LocalBandwidthConstraint.of(bandwidth, DataRateUnit.valueOf("BPS")));
87 }
88
89 //TODO: need to uncomment below lines once setupPath method is modified in PceService
90 //if (null == service.setupPath(srcDevice, dstDevice, name, listConstrnt, lspType)) {
91 // error("Path creation failed.");
92 //}
93 }
94}