blob: a1ad929d53553a65b0fce847b426a0402410bee3 [file] [log] [blame]
Charles Chanc7b3c452018-06-19 20:31:57 -07001/*
2 * Copyright 2018-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 */
16package org.onosproject.segmentrouting.cli;
17
18import com.google.common.collect.Sets;
19import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
21import org.onlab.packet.VlanId;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.net.DeviceId;
24import org.onosproject.net.PortNumber;
25import org.onosproject.segmentrouting.xconnect.api.XconnectService;
26
27import java.util.Set;
28
29/**
30 * Creates Xconnect.
31 */
32@Command(scope = "onos", name = "sr-xconnect-add", description = "Create Xconnect")
33public class XconnectAddCommand extends AbstractShellCommand {
34 @Argument(index = 0, name = "deviceId",
35 description = "Device ID",
36 required = true, multiValued = false)
37 private String deviceIdStr;
38
39 @Argument(index = 1, name = "vlanId",
40 description = "VLAN ID",
41 required = true, multiValued = false)
42 private String vlanIdStr;
43
44 @Argument(index = 2, name = "port1",
45 description = "Port 1",
46 required = true, multiValued = false)
47 private String port1Str;
48
49 @Argument(index = 3, name = "port2",
50 description = "Port 2",
51 required = true, multiValued = false)
52 private String port2Str;
53
54
55 @Override
56 protected void execute() {
57 DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
58 VlanId vlanId = VlanId.vlanId(vlanIdStr);
59 PortNumber port1 = PortNumber.portNumber(port1Str);
60 PortNumber port2 = PortNumber.portNumber(port2Str);
61 Set<PortNumber> ports = Sets.newHashSet(port1, port2);
62
63 XconnectService xconnectService = get(XconnectService.class);
64 xconnectService.addOrUpdateXconnect(deviceId, vlanId, ports);
65 }
66}