blob: 6f00174647d3b4c8d93e8a71a932fce57867dc48 [file] [log] [blame]
Brian O'Connor5296b322014-10-23 14:59:05 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Brian O'Connor5296b322014-10-23 14:59:05 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Brian O'Connor5296b322014-10-23 14:59:05 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Brian O'Connor5296b322014-10-23 14:59:05 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.cli.net;
Brian O'Connor5296b322014-10-23 14:59:05 -070017
Brian O'Connor5296b322014-10-23 14:59:05 -070018import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.ConnectPoint;
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070021import org.onosproject.net.OduSignalType;
Brian O'Connorabafb502014-12-02 22:26:20 -080022import org.onosproject.net.intent.Intent;
23import org.onosproject.net.intent.IntentService;
24import org.onosproject.net.intent.OpticalConnectivityIntent;
Brian O'Connor5296b322014-10-23 14:59:05 -070025
26/**
27 * Installs optical connectivity intents.
28 */
29@Command(scope = "onos", name = "add-optical-intent",
30 description = "Installs optical connectivity intent")
31public class AddOpticalIntentCommand extends ConnectivityIntentCommand {
32
33 @Argument(index = 0, name = "ingressDevice",
34 description = "Ingress Device/Port Description",
35 required = true, multiValued = false)
36 String ingressDeviceString = null;
37
38 @Argument(index = 1, name = "egressDevice",
39 description = "Egress Device/Port Description",
40 required = true, multiValued = false)
41 String egressDeviceString = null;
42
43 @Override
44 protected void execute() {
45 IntentService service = get(IntentService.class);
46
Jonathan Hartc3af35a2015-04-30 22:20:29 -070047 ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
Brian O'Connor5296b322014-10-23 14:59:05 -070048
Jonathan Hartc3af35a2015-04-30 22:20:29 -070049 ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
Brian O'Connor5296b322014-10-23 14:59:05 -070050
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070051 // FIXME: Hardcoded ODU signal type
Ray Milkeye076c792015-03-24 09:38:30 -070052 Intent intent = OpticalConnectivityIntent.builder()
53 .appId(appId())
54 .key(key())
55 .src(ingress)
56 .dst(egress)
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070057 .signalType(OduSignalType.ODU4)
Ray Milkeye076c792015-03-24 09:38:30 -070058 .build();
Brian O'Connor5296b322014-10-23 14:59:05 -070059 service.submit(intent);
Ray Milkeycb33a132015-02-02 10:05:12 -080060 print("Optical intent submitted:\n%s", intent.toString());
Brian O'Connor5296b322014-10-23 14:59:05 -070061 }
Brian O'Connor5296b322014-10-23 14:59:05 -070062}