Committed by
Gerrit Code Review
Merge "Remove prototype bandwidth limited intent commands"
Showing
2 changed files
with
0 additions
and
120 deletions
| 1 | -/* | ||
| 2 | - * Licensed to the Apache Software Foundation (ASF) under one | ||
| 3 | - * or more contributor license agreements. See the NOTICE file | ||
| 4 | - * distributed with this work for additional information | ||
| 5 | - * regarding copyright ownership. The ASF licenses this file | ||
| 6 | - * to you under the Apache License, Version 2.0 (the | ||
| 7 | - * "License"); you may not use this file except in compliance | ||
| 8 | - * with the License. You may obtain a copy of the License at | ||
| 9 | - * | ||
| 10 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 11 | - * | ||
| 12 | - * Unless required by applicable law or agreed to in writing, | ||
| 13 | - * software distributed under the License is distributed on an | ||
| 14 | - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| 15 | - * KIND, either express or implied. See the License for the | ||
| 16 | - * specific language governing permissions and limitations | ||
| 17 | - * under the License. | ||
| 18 | - */ | ||
| 19 | -package org.onlab.onos.cli.net; | ||
| 20 | - | ||
| 21 | -import org.apache.karaf.shell.commands.Argument; | ||
| 22 | -import org.apache.karaf.shell.commands.Command; | ||
| 23 | -import org.onlab.onos.net.ConnectPoint; | ||
| 24 | -import org.onlab.onos.net.DeviceId; | ||
| 25 | -import org.onlab.onos.net.PortNumber; | ||
| 26 | -import org.onlab.onos.net.flow.TrafficSelector; | ||
| 27 | -import org.onlab.onos.net.flow.TrafficTreatment; | ||
| 28 | -import org.onlab.onos.net.intent.Intent; | ||
| 29 | -import org.onlab.onos.net.intent.IntentService; | ||
| 30 | -import org.onlab.onos.net.intent.PointToPointIntent; | ||
| 31 | - | ||
| 32 | -import static org.onlab.onos.net.DeviceId.deviceId; | ||
| 33 | -import static org.onlab.onos.net.PortNumber.portNumber; | ||
| 34 | -import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder; | ||
| 35 | - | ||
| 36 | -/** | ||
| 37 | - * Installs point-to-point connectivity intents. | ||
| 38 | - */ | ||
| 39 | -@Command(scope = "onos", name = "add-point-intent-bw", | ||
| 40 | - description = "Installs point-to-point connectivity intent with bandwidth constraint") | ||
| 41 | -public class AddPointToPointIntentWithBandwidthConstraintCommand extends ConnectivityIntentCommand { | ||
| 42 | - | ||
| 43 | - @Argument(index = 0, name = "ingressDevice", | ||
| 44 | - description = "Ingress Device/Port Description", | ||
| 45 | - required = true, multiValued = false) | ||
| 46 | - String ingressDeviceString = null; | ||
| 47 | - | ||
| 48 | - @Argument(index = 1, name = "egressDevice", | ||
| 49 | - description = "Egress Device/Port Description", | ||
| 50 | - required = true, multiValued = false) | ||
| 51 | - String egressDeviceString = null; | ||
| 52 | - | ||
| 53 | - @Argument(index = 2, name = "bandwidth", | ||
| 54 | - description = "Bandwidth", | ||
| 55 | - required = true, multiValued = false) | ||
| 56 | - String bandwidthString = null; | ||
| 57 | - | ||
| 58 | - @Override | ||
| 59 | - protected void execute() { | ||
| 60 | - IntentService service = get(IntentService.class); | ||
| 61 | - | ||
| 62 | - DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString)); | ||
| 63 | - PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString)); | ||
| 64 | - ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber); | ||
| 65 | - | ||
| 66 | - DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString)); | ||
| 67 | - PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString)); | ||
| 68 | - ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber); | ||
| 69 | - | ||
| 70 | - long bandwidth = Long.parseLong(bandwidthString); | ||
| 71 | - | ||
| 72 | - TrafficSelector selector = buildTrafficSelector(); | ||
| 73 | - TrafficTreatment treatment = builder().build(); | ||
| 74 | - | ||
| 75 | - // FIXME: add bandwitdh constraint | ||
| 76 | - Intent intent = new PointToPointIntent( | ||
| 77 | - appId(), selector, treatment, | ||
| 78 | - ingress, egress); | ||
| 79 | - service.submit(intent); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - /** | ||
| 83 | - * Extracts the port number portion of the ConnectPoint. | ||
| 84 | - * | ||
| 85 | - * @param deviceString string representing the device/port | ||
| 86 | - * @return port number as a string, empty string if the port is not found | ||
| 87 | - */ | ||
| 88 | - private String getPortNumber(String deviceString) { | ||
| 89 | - int slash = deviceString.indexOf('/'); | ||
| 90 | - if (slash <= 0) { | ||
| 91 | - return ""; | ||
| 92 | - } | ||
| 93 | - return deviceString.substring(slash + 1, deviceString.length()); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - /** | ||
| 97 | - * Extracts the device ID portion of the ConnectPoint. | ||
| 98 | - * | ||
| 99 | - * @param deviceString string representing the device/port | ||
| 100 | - * @return device ID string | ||
| 101 | - */ | ||
| 102 | - private String getDeviceId(String deviceString) { | ||
| 103 | - int slash = deviceString.indexOf('/'); | ||
| 104 | - if (slash <= 0) { | ||
| 105 | - return ""; | ||
| 106 | - } | ||
| 107 | - return deviceString.substring(0, slash); | ||
| 108 | - } | ||
| 109 | -} |
| ... | @@ -116,17 +116,6 @@ | ... | @@ -116,17 +116,6 @@ |
| 116 | </optional-completers> | 116 | </optional-completers> |
| 117 | </command> | 117 | </command> |
| 118 | <command> | 118 | <command> |
| 119 | - <action class="org.onlab.onos.cli.net.AddPointToPointIntentWithBandwidthConstraintCommand"/> | ||
| 120 | - <completers> | ||
| 121 | - <ref component-id="connectPointCompleter"/> | ||
| 122 | - <ref component-id="connectPointCompleter"/> | ||
| 123 | - <null/> | ||
| 124 | - </completers> | ||
| 125 | - <optional-completers> | ||
| 126 | - <entry key="-t" value-ref="ethTypeCompleter"/> | ||
| 127 | - </optional-completers> | ||
| 128 | - </command> | ||
| 129 | - <command> | ||
| 130 | <action class="org.onlab.onos.cli.net.AddOpticalIntentCommand"/> | 119 | <action class="org.onlab.onos.cli.net.AddOpticalIntentCommand"/> |
| 131 | <completers> | 120 | <completers> |
| 132 | <ref component-id="connectPointCompleter"/> | 121 | <ref component-id="connectPointCompleter"/> | ... | ... |
-
Please register or login to post a comment