blob: 8ad477ce1dda6c8cbfcac9a9bc99768473e717e3 [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;
19import org.onosproject.net.HostId;
20import org.onosproject.net.host.HostService;
21import org.onosproject.ui.UiTopoOverlay;
22import org.onosproject.ui.topo.ButtonId;
23import org.onosproject.ui.topo.PropertyPanel;
24
25import static org.onosproject.ui.topo.TopoConstants.Properties.INTENTS;
26import static org.onosproject.ui.topo.TopoConstants.Properties.TOPOLOGY_SSCS;
27import static org.onosproject.ui.topo.TopoConstants.Properties.TUNNELS;
28import static org.onosproject.ui.topo.TopoConstants.Properties.VERSION;
29import static org.onosproject.ui.topo.TopoConstants.Properties.VLAN;
30
31/**
32 * Topology overlay for OpenStack Networking UI.
33 */
34public class OpenstackNetworkingUiOverlay extends UiTopoOverlay {
35 private static final String OVERLAY_ID = "sona-overlay";
36 private static final String SONA = "SONA";
37 private static final String SUMMARY_TITLE = "OpenStack Networking UI";
38 private static final String SUMMARY_VERSION = "0.9";
39 private static final String VNI = "VNI";
40 private static final String ANNOTATION_SEGMENT_ID = "segId";
41
42 private static final String NOT_AVAILABLE = "N/A";
43
44 private static final ButtonId FLOW_TRACE_BUTTON = new ButtonId("flowtrace");
45 private static final ButtonId RESET_BUTTON = new ButtonId("reset");
46 private static final ButtonId TO_GATEWAY_BUTTON = new ButtonId("toGateway");
47 private static final ButtonId TO_EXTERNAL_BUTTON = new ButtonId("toExternal");
48
49 private final HostService hostService = DefaultServiceDirectory.getService(HostService.class);
50
51 public OpenstackNetworkingUiOverlay() {
52 super(OVERLAY_ID);
53 }
54
55
56 @Override
57 public void modifySummary(PropertyPanel pp) {
58 pp.title(SUMMARY_TITLE)
59 .removeProps(
60 TOPOLOGY_SSCS,
61 INTENTS,
62 TUNNELS,
63 VERSION
64 )
65 .addProp(SONA, VERSION, SUMMARY_VERSION);
66 }
67
68 @Override
69 public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
70 String vni = hostService.getHost(hostId).annotations().value(ANNOTATION_SEGMENT_ID);
71
72 pp.removeProps(VLAN);
73 pp.addProp(SONA, VNI, vni == null ? NOT_AVAILABLE : vni)
74 .addButton(FLOW_TRACE_BUTTON)
75 .addButton(RESET_BUTTON)
76 .addButton(TO_GATEWAY_BUTTON)
77 .addButton(TO_EXTERNAL_BUTTON);
78 }
79}