blob: 5ea868683ba9269415ff7cefca14b2f168127218 [file] [log] [blame]
Mahesh Poojary Sd7a36922016-04-01 16:11:14 +05301/*
Mahesh Poojary S8e1670e2016-05-19 22:15:34 +05302 * Copyright 2016-present Open Networking Laboratory
Mahesh Poojary Sd7a36922016-04-01 16:11:14 +05303 *
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.intent.Constraint;
29import org.onosproject.pce.pceservice.api.PceService;
30
31import org.slf4j.Logger;
32
33/**
34 * Supports updating the PCE path.
35 */
36@Command(scope = "onos", name = "pce-update-path",
37 description = "Supports updating PCE path.")
38public class PceUpdatePathCommand extends AbstractShellCommand {
39 private final Logger log = getLogger(getClass());
40
41 @Argument(index = 0, name = "id", description = "Path Id.", required = true, multiValued = false)
42 String id = null;
43
44 @Option(name = "-c", aliases = "--cost", description = "The cost attribute IGP cost (1) or TE cost (2).",
45 required = false, multiValued = false)
46 int cost = 0;
47
48 @Option(name = "-b", aliases = "--bandwidth", description = "The bandwidth attribute of path. "
49 + "Data rate unit is in Bps.", required = false, multiValued = false)
50 double bandwidth = 0.0;
51
52 @Override
53 protected void execute() {
54 log.info("executing pce-update-path");
55
56 PceService service = get(PceService.class);
57
58 List<Constraint> constrntList = new LinkedList<>();
59 // Assign cost
60 if (cost != 0) {
61 //TODO: need to uncomment below lines once CostConstraint is ready
62 //CostConstraint.Type costType = CostConstraint.Type.values()[Integer.valueOf(cost)];
63 //constrntList.add(CostConstraint.of(costType));
64 }
65
66 // Assign bandwidth. Data rate unit is in Bps.
67 if (bandwidth != 0.0) {
68 //TODO: need to uncomment below line once BandwidthConstraint is ready
69 //constrntList.add(LocalBandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit.valueOf("BPS")));
70 }
71
72 //TODO: need to uncomment below lines once updatePath method is added to PceService
73 //if (null == service.updatePath(PcePathId.of(id), constrntList)) {
74 // error("Path updation failed.");
75 // return;
76 //}
77 }
78}