blob: efa0a9f3b85e84a7118040583bb271cab11f9364 [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
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.apache.karaf.shell.commands.Option;
21import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
23import org.onosproject.incubator.net.tunnel.TunnelDescription;
24import org.onosproject.incubator.net.tunnel.TunnelId;
25import org.onosproject.incubator.net.tunnel.TunnelProvider;
26import org.onosproject.net.DefaultAnnotations;
27import org.onosproject.net.SparseAnnotations;
28
29/**
30 * Supports for updating a tunnel by tunnel identity.
31 * It's used by producers.
32 */
33@Command(scope = "onos", name = "tunnel-update",
34description = "Supports for updating a tunnel by tunnel identity."
35 + " It's used by producers.")
36public class TunnelUpdateCommand extends AbstractShellCommand {
37 @Argument(index = 0, name = "tunnelId", description = "the tunnel identity.",
38 required = true, multiValued = false)
39 String tunnelId = null;
40
41 @Option(name = "-b", aliases = "--bandwidth",
42 description = "The bandwidth attribute of tunnel", required = false, multiValued = false)
43 String bandwidth = null;
44
45 @Override
46 protected void execute() {
47 TunnelProvider service = get(TunnelProvider.class);
48 TunnelId id = TunnelId.valueOf(tunnelId);
49 SparseAnnotations annotations = DefaultAnnotations
50 .builder()
51 .set("bandwidth", bandwidth)
52 .build();
53 TunnelDescription tunnel = new DefaultTunnelDescription(id, null,
54 null,
55 null, null,
56 null,
57 null, null, annotations);
58 service.tunnelUpdated(tunnel);
59 }
60
61}