rama-huawei | c78f309 | 2016-05-19 18:09:29 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
rama-huawei | c78f309 | 2016-05-19 18:09:29 +0530 | [diff] [blame] | 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.sfcweb; |
| 17 | |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 18 | import org.onlab.packet.MacAddress; |
| 19 | import org.onosproject.cli.AbstractShellCommand; |
rama-huawei | c78f309 | 2016-05-19 18:09:29 +0530 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 21 | import org.onosproject.net.Host; |
rama-huawei | c78f309 | 2016-05-19 18:09:29 +0530 | [diff] [blame] | 22 | import org.onosproject.net.HostId; |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 23 | import org.onosproject.net.host.HostService; |
rama-huawei | c78f309 | 2016-05-19 18:09:29 +0530 | [diff] [blame] | 24 | import org.onosproject.ui.UiTopoOverlay; |
| 25 | import org.onosproject.ui.topo.PropertyPanel; |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 26 | import org.onosproject.vtnrsc.PortPair; |
| 27 | import org.onosproject.vtnrsc.VirtualPort; |
| 28 | import org.onosproject.vtnrsc.VirtualPortId; |
| 29 | import org.onosproject.vtnrsc.portpair.PortPairService; |
| 30 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
rama-huawei | c78f309 | 2016-05-19 18:09:29 +0530 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Our sfcweb topology overlay. |
| 34 | */ |
| 35 | public class SfcwebUiTopovOverlay extends UiTopoOverlay { |
| 36 | |
| 37 | // NOTE: this must match the ID defined in sfcwebTopov.js |
| 38 | private static final String OVERLAY_ID = "SFC-Service-overlay"; |
| 39 | private static final String MY_DEVICE_TITLE = "SFF specific device details"; |
| 40 | private static final String MY_HOST_TITLE = "SF specific host details"; |
| 41 | |
| 42 | public SfcwebUiTopovOverlay() { |
| 43 | super(OVERLAY_ID); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { |
| 48 | pp.title(MY_DEVICE_TITLE); |
| 49 | pp.removeAllProps(); |
| 50 | pp.addProp("SFF Device Id", deviceId.toString()); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public void modifyHostDetails(PropertyPanel pp, HostId hostId) { |
| 55 | pp.title(MY_HOST_TITLE); |
| 56 | pp.removeAllProps(); |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 57 | PortPairService portPairService = AbstractShellCommand.get(PortPairService.class); |
| 58 | VirtualPortService virtualPortService = AbstractShellCommand.get(VirtualPortService.class); |
| 59 | HostService hostService = AbstractShellCommand.get(HostService.class); |
| 60 | Iterable<PortPair> portPairs = portPairService.getPortPairs(); |
| 61 | for (PortPair portPair : portPairs) { |
| 62 | VirtualPort vPort = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())); |
| 63 | MacAddress dstMacAddress = vPort.macAddress(); |
| 64 | Host host = hostService.getHost(HostId.hostId(dstMacAddress)); |
| 65 | if (hostId.toString().equals(host.id().toString())) { |
| 66 | pp.addProp("SF Name", portPair.name()); |
| 67 | pp.addProp("SF Ip", vPort.fixedIps().iterator().next().ip()); |
| 68 | } |
| 69 | } |
rama-huawei | c78f309 | 2016-05-19 18:09:29 +0530 | [diff] [blame] | 70 | pp.addProp("SF host Address", hostId.toString()); |
| 71 | } |
| 72 | |
| 73 | } |