blob: ba46ea7e8e7ae5cd77efd948ae5a5863d7e45854 [file] [log] [blame]
Luca Prete092e8952016-10-26 16:25:56 +02001/*
2 * Copyright 2016-present 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 */
16
17package org.onosproject.vpls.cli;
18
19import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
21import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.vpls.config.VplsConfigurationService;
23
24/**
25 * CLI to set encapsulation for a VPLS.
26 */
27@Command(scope = "onos", name = "vpls-set-encap",
28 description = "Sets the encapsulation type for a given VPLS. None means" +
29 "no encapsulation has been set")
30public class VplsSetEncapCommand extends AbstractShellCommand {
31
32 private static final String VPLS_NOT_FOUND = "VPLS %s not found.";
33 private VplsConfigurationService vplsConfigService =
34 get(VplsConfigurationService.class);
35
36 @Argument(index = 0, name = "vplsName", description = "Name of the VPLS",
37 required = true, multiValued = false)
38 private String vplsName = null;
39
40 @Argument(index = 1, name = "encapsulation", description = "The encapsulation" +
41 "type. For example, VLAN or MPLS. None for no encapsulation",
42 required = true, multiValued = false)
43 String encap = null;
44
45 @Override
46 protected void execute() {
47 if (!VplsCommandUtils.vplsExists(vplsName)) {
48 print(VplsCommandUtils.VPLS_NOT_FOUND, vplsName);
49 return;
50 }
51
52 vplsConfigService.setEncap(vplsName, encap);
53 }
54}