daniel park | 128c52c | 2017-09-04 13:15:51 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-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 | */ |
| 16 | package org.onosproject.openstacknetworkingui; |
| 17 | |
| 18 | import org.onlab.osgi.DefaultServiceDirectory; |
Daniel Park | 577b69c | 2018-07-16 17:29:34 +0900 | [diff] [blame] | 19 | import org.onosproject.net.DeviceId; |
daniel park | 128c52c | 2017-09-04 13:15:51 +0900 | [diff] [blame] | 20 | import org.onosproject.net.HostId; |
| 21 | import org.onosproject.net.host.HostService; |
| 22 | import org.onosproject.ui.UiTopoOverlay; |
| 23 | import org.onosproject.ui.topo.ButtonId; |
| 24 | import org.onosproject.ui.topo.PropertyPanel; |
| 25 | |
| 26 | import static org.onosproject.ui.topo.TopoConstants.Properties.INTENTS; |
| 27 | import static org.onosproject.ui.topo.TopoConstants.Properties.TOPOLOGY_SSCS; |
| 28 | import static org.onosproject.ui.topo.TopoConstants.Properties.TUNNELS; |
| 29 | import static org.onosproject.ui.topo.TopoConstants.Properties.VERSION; |
| 30 | import static org.onosproject.ui.topo.TopoConstants.Properties.VLAN; |
| 31 | |
| 32 | /** |
| 33 | * Topology overlay for OpenStack Networking UI. |
| 34 | */ |
| 35 | public class OpenstackNetworkingUiOverlay extends UiTopoOverlay { |
| 36 | private static final String OVERLAY_ID = "sona-overlay"; |
| 37 | private static final String SONA = "SONA"; |
| 38 | private static final String SUMMARY_TITLE = "OpenStack Networking UI"; |
| 39 | private static final String SUMMARY_VERSION = "0.9"; |
| 40 | private static final String VNI = "VNI"; |
| 41 | private static final String ANNOTATION_SEGMENT_ID = "segId"; |
Daniel Park | 577b69c | 2018-07-16 17:29:34 +0900 | [diff] [blame] | 42 | private static final String DEVICE_ID = "DeviceId"; |
daniel park | 128c52c | 2017-09-04 13:15:51 +0900 | [diff] [blame] | 43 | |
| 44 | private static final String NOT_AVAILABLE = "N/A"; |
| 45 | |
| 46 | private static final ButtonId FLOW_TRACE_BUTTON = new ButtonId("flowtrace"); |
| 47 | private static final ButtonId RESET_BUTTON = new ButtonId("reset"); |
| 48 | private static final ButtonId TO_GATEWAY_BUTTON = new ButtonId("toGateway"); |
| 49 | private static final ButtonId TO_EXTERNAL_BUTTON = new ButtonId("toExternal"); |
| 50 | |
| 51 | private final HostService hostService = DefaultServiceDirectory.getService(HostService.class); |
| 52 | |
| 53 | public OpenstackNetworkingUiOverlay() { |
| 54 | super(OVERLAY_ID); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | @Override |
| 59 | public void modifySummary(PropertyPanel pp) { |
| 60 | pp.title(SUMMARY_TITLE) |
| 61 | .removeProps( |
| 62 | TOPOLOGY_SSCS, |
| 63 | INTENTS, |
| 64 | TUNNELS, |
| 65 | VERSION |
| 66 | ) |
| 67 | .addProp(SONA, VERSION, SUMMARY_VERSION); |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public void modifyHostDetails(PropertyPanel pp, HostId hostId) { |
| 72 | String vni = hostService.getHost(hostId).annotations().value(ANNOTATION_SEGMENT_ID); |
Daniel Park | 577b69c | 2018-07-16 17:29:34 +0900 | [diff] [blame] | 73 | DeviceId deviceId = hostService.getHost(hostId).location().deviceId(); |
daniel park | 128c52c | 2017-09-04 13:15:51 +0900 | [diff] [blame] | 74 | |
| 75 | pp.removeProps(VLAN); |
Daniel Park | 577b69c | 2018-07-16 17:29:34 +0900 | [diff] [blame] | 76 | pp.addProp(VNI, VNI, vni == null ? NOT_AVAILABLE : vni) |
| 77 | .addProp(DEVICE_ID, DEVICE_ID, deviceId.toString()) |
daniel park | 128c52c | 2017-09-04 13:15:51 +0900 | [diff] [blame] | 78 | .addButton(FLOW_TRACE_BUTTON) |
| 79 | .addButton(RESET_BUTTON) |
| 80 | .addButton(TO_GATEWAY_BUTTON) |
daniel park | 128c52c | 2017-09-04 13:15:51 +0900 | [diff] [blame] | 81 | .addButton(TO_EXTERNAL_BUTTON); |
| 82 | } |
| 83 | } |