blob: 9bfdadde6409670954a8a8e185a8ce69f7b39c08 [file] [log] [blame]
samuel7a5691a2015-05-23 00:36:32 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
samuel7a5691a2015-05-23 00:36:32 +08003 *
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 */
cheng fan7716ec92015-05-31 01:53:19 +080016package org.onosproject.cli.net;
samuel7a5691a2015-05-23 00:36:32 +080017
Ray Milkeyd84f89b2018-08-17 14:54:17 -070018import org.apache.karaf.shell.api.action.Argument;
19import org.apache.karaf.shell.api.action.Command;
20import org.apache.karaf.shell.api.action.lifecycle.Service;
21import org.apache.karaf.shell.api.action.Option;
samuel7a5691a2015-05-23 00:36:32 +080022import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
24import org.onosproject.incubator.net.tunnel.TunnelDescription;
25import org.onosproject.incubator.net.tunnel.TunnelId;
26import org.onosproject.incubator.net.tunnel.TunnelProvider;
27import org.onosproject.net.DefaultAnnotations;
28import org.onosproject.net.SparseAnnotations;
29
30/**
31 * Supports for updating a tunnel by tunnel identity.
32 * It's used by producers.
33 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070034@Service
samuel7a5691a2015-05-23 00:36:32 +080035@Command(scope = "onos", name = "tunnel-update",
36description = "Supports for updating a tunnel by tunnel identity."
37 + " It's used by producers.")
38public class TunnelUpdateCommand extends AbstractShellCommand {
39 @Argument(index = 0, name = "tunnelId", description = "the tunnel identity.",
40 required = true, multiValued = false)
41 String tunnelId = null;
42
43 @Option(name = "-b", aliases = "--bandwidth",
44 description = "The bandwidth attribute of tunnel", required = false, multiValued = false)
45 String bandwidth = null;
46
47 @Override
Ray Milkeyd84f89b2018-08-17 14:54:17 -070048 protected void doExecute() {
samuel7a5691a2015-05-23 00:36:32 +080049 TunnelProvider service = get(TunnelProvider.class);
50 TunnelId id = TunnelId.valueOf(tunnelId);
51 SparseAnnotations annotations = DefaultAnnotations
52 .builder()
53 .set("bandwidth", bandwidth)
54 .build();
55 TunnelDescription tunnel = new DefaultTunnelDescription(id, null,
56 null,
57 null, null,
58 null,
59 null, null, annotations);
60 service.tunnelUpdated(tunnel);
61 }
62
63}