samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014-2015 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 | */ |
cheng fan | 7716ec9 | 2015-05-31 01:53:19 +0800 | [diff] [blame] | 16 | package org.onosproject.cli.net; |
samuel | 7a5691a | 2015-05-23 00:36:32 +0800 | [diff] [blame] | 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.apache.karaf.shell.commands.Option; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription; |
| 23 | import org.onosproject.incubator.net.tunnel.TunnelDescription; |
| 24 | import org.onosproject.incubator.net.tunnel.TunnelId; |
| 25 | import org.onosproject.incubator.net.tunnel.TunnelProvider; |
| 26 | import org.onosproject.net.DefaultAnnotations; |
| 27 | import 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", |
| 34 | description = "Supports for updating a tunnel by tunnel identity." |
| 35 | + " It's used by producers.") |
| 36 | public 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 | } |