Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 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 | */ |
| 16 | package org.onosproject.segmentrouting.cli; |
| 17 | |
| 18 | |
| 19 | import org.apache.karaf.shell.commands.Argument; |
| 20 | import org.apache.karaf.shell.commands.Command; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.segmentrouting.SegmentRoutingService; |
| 23 | import org.onosproject.segmentrouting.pwaas.L2TunnelHandler; |
| 24 | |
| 25 | |
| 26 | /** |
| 27 | * Command to add a pseuwodire. |
| 28 | */ |
| 29 | @Command(scope = "onos", name = "pseudowire-add", |
| 30 | description = "Add a pseudowire to the network configuration, if it already exists update it.") |
| 31 | public class PseudowireAddCommand extends AbstractShellCommand { |
| 32 | |
| 33 | @Argument(index = 0, name = "pwId", |
| 34 | description = "Pseudowire ID", |
| 35 | required = true, multiValued = false) |
| 36 | String pwId; |
| 37 | |
| 38 | @Argument(index = 1, name = "pwLabel", |
| 39 | description = "Pseudowire Label", |
| 40 | required = true, multiValued = false) |
| 41 | String pwLabel; |
| 42 | |
| 43 | @Argument(index = 2, name = "mode", |
| 44 | description = "Mode used for pseudowire", |
| 45 | required = true, multiValued = false) |
| 46 | String mode; |
| 47 | |
| 48 | @Argument(index = 3, name = "sDTag", |
| 49 | description = "Service delimiting tag", |
| 50 | required = true, multiValued = false) |
| 51 | String sDTag; |
| 52 | |
| 53 | @Argument(index = 4, name = "cP1", |
| 54 | description = "Connection Point 1", |
| 55 | required = true, multiValued = false) |
| 56 | String cP1; |
| 57 | |
| 58 | @Argument(index = 5, name = "cP1InnerVlan", |
| 59 | description = "Inner Vlan of Connection Point 1", |
| 60 | required = true, multiValued = false) |
| 61 | String cP1InnerVlan; |
| 62 | |
| 63 | @Argument(index = 6, name = "cP1OuterVlan", |
| 64 | description = "Outer Vlan of Connection Point 1", |
| 65 | required = true, multiValued = false) |
| 66 | String cP1OuterVlan; |
| 67 | |
| 68 | @Argument(index = 7, name = "cP2", |
| 69 | description = "Connection Point 2", |
| 70 | required = true, multiValued = false) |
| 71 | String cP2; |
| 72 | |
| 73 | @Argument(index = 8, name = "cP2InnerVlan", |
| 74 | description = "Inner Vlan of Connection Point 2", |
| 75 | required = true, multiValued = false) |
| 76 | String cP2InnerVlan; |
| 77 | |
| 78 | @Argument(index = 9, name = "cP2OuterVlan", |
| 79 | description = "Outer Vlan of Connection Point 2", |
| 80 | required = true, multiValued = false) |
| 81 | String cP2OuterVlan; |
| 82 | |
| 83 | @Override |
| 84 | protected void execute() { |
| 85 | |
| 86 | SegmentRoutingService srService = |
| 87 | AbstractShellCommand.get(SegmentRoutingService.class); |
| 88 | |
| 89 | L2TunnelHandler.Result res = srService.addPseudowire(pwId, pwLabel, |
| 90 | cP1, cP1InnerVlan, cP1OuterVlan, |
| 91 | cP2, cP2InnerVlan, cP2OuterVlan, |
| 92 | mode, sDTag); |
| 93 | switch (res) { |
| 94 | case ADDITION_ERROR: |
| 95 | print("Pseudowire could not be added, error in configuration, please check logs for more details!"); |
| 96 | break; |
| 97 | case CONFIG_NOT_FOUND: |
| 98 | print("Configuration for pwaas was not found! Initialize the configuration first through netcfg."); |
| 99 | break; |
| 100 | default: |
Andreas Pantelopoulos | 20474e0 | 2017-12-20 18:04:27 -0800 | [diff] [blame] | 101 | break; |
Andreas Pantelopoulos | 27532cd | 2017-10-23 12:18:25 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | } |
| 105 | } |