blob: ec71db701fbc7d2fdebbc9943902f6d2fbcbad8f [file] [log] [blame]
daniel park128c52c2017-09-04 13:15:51 +09001/*
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 */
16package org.onosproject.openstacknetworkingui;
17
18import org.onlab.osgi.DefaultServiceDirectory;
Daniel Park577b69c2018-07-16 17:29:34 +090019import org.onosproject.net.DeviceId;
daniel park128c52c2017-09-04 13:15:51 +090020import org.onosproject.net.HostId;
21import org.onosproject.net.host.HostService;
22import org.onosproject.ui.UiTopoOverlay;
23import org.onosproject.ui.topo.ButtonId;
24import org.onosproject.ui.topo.PropertyPanel;
25
26import static org.onosproject.ui.topo.TopoConstants.Properties.INTENTS;
27import static org.onosproject.ui.topo.TopoConstants.Properties.TOPOLOGY_SSCS;
28import static org.onosproject.ui.topo.TopoConstants.Properties.TUNNELS;
29import static org.onosproject.ui.topo.TopoConstants.Properties.VERSION;
30import static org.onosproject.ui.topo.TopoConstants.Properties.VLAN;
31
32/**
33 * Topology overlay for OpenStack Networking UI.
34 */
35public 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 Park577b69c2018-07-16 17:29:34 +090042 private static final String DEVICE_ID = "DeviceId";
daniel park128c52c2017-09-04 13:15:51 +090043
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 Park577b69c2018-07-16 17:29:34 +090073 DeviceId deviceId = hostService.getHost(hostId).location().deviceId();
daniel park128c52c2017-09-04 13:15:51 +090074
75 pp.removeProps(VLAN);
Daniel Park577b69c2018-07-16 17:29:34 +090076 pp.addProp(VNI, VNI, vni == null ? NOT_AVAILABLE : vni)
77 .addProp(DEVICE_ID, DEVICE_ID, deviceId.toString())
daniel park128c52c2017-09-04 13:15:51 +090078 .addButton(FLOW_TRACE_BUTTON)
79 .addButton(RESET_BUTTON)
80 .addButton(TO_GATEWAY_BUTTON)
daniel park128c52c2017-09-04 13:15:51 +090081 .addButton(TO_EXTERNAL_BUTTON);
82 }
83}