blob: 41f3243b2ef3aeae2a5c80dd7a1a7bd95d50b908 [file] [log] [blame]
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +05301/*
2 * Copyright 2016-present Open Networking Laboratory
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
17package org.onosproject.pceweb;
18
19
20import org.onosproject.net.AnnotationKeys;
21import org.onosproject.net.Annotations;
22import org.onosproject.net.Device;
23import org.onosproject.net.DeviceId;
24import org.onosproject.ui.UiTopoOverlay;
25import org.onosproject.ui.topo.ButtonId;
26import org.onosproject.ui.topo.PropertyPanel;
27import org.onosproject.net.HostId;
28import org.onosproject.net.device.DeviceService;
29import org.onosproject.ui.topo.TopoConstants.CoreButtons;
30
31import static org.onosproject.ui.topo.TopoConstants.Properties.*;
32import org.onosproject.cli.AbstractShellCommand;
33
34/**
35 * PCE WEB topology overlay.
36 */
37public class PceWebTopovOverlay extends UiTopoOverlay {
38
39 // NOTE: this must match the ID defined in pcewebTopovOverlay.js
40 private static final String OVERLAY_ID = "PCE-web-overlay";
41 private static final String MY_TITLE = "Device details";
42
43 public static final String AS_NUMBER = "asNumber";
44 public static final String DOMAIN_IDENTIFIER = "domainIdentifier";
45 public static final String ROUTING_UNIVERSE = "routingUniverse";
46
47 private static final ButtonId SRC_BUTTON = new ButtonId("src");
48 private static final ButtonId DST_BUTTON = new ButtonId("dst");
49 /**
50 * Initialize the overlay ID.
51 */
52 public PceWebTopovOverlay() {
53 super(OVERLAY_ID);
54 }
55
56 @Override
57 public void deactivate() {
58 super.deactivate();
59 log.debug("Deactivated");
60 }
61
62 @Override
63 public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
64
65 pp.title(MY_TITLE);
Mahesh Raju-Huawei85930052016-04-26 21:09:57 +053066
67 DeviceService deviceService = AbstractShellCommand.get(DeviceService.class);
68
69 pp.removeAllProps();
70
71 pp.addButton(SRC_BUTTON).addButton(DST_BUTTON);
72
73 pp.removeButtons(CoreButtons.SHOW_PORT_VIEW)
74 .removeButtons(CoreButtons.SHOW_GROUP_VIEW)
75 .removeButtons(CoreButtons.SHOW_METER_VIEW);
76
77 if (deviceService != null) {
78
79 Device device = deviceService.getDevice(deviceId);
80 Annotations annot = device.annotations();
81
82 String routerId = annot.value(AnnotationKeys.ROUTER_ID);
83 String type = annot.value(AnnotationKeys.TYPE);
84 String asNumber = annot.value(AS_NUMBER);
85 String domain = annot.value(DOMAIN_IDENTIFIER);
86 String routingUnverse = annot.value(ROUTING_UNIVERSE);
87
88 if (type != null) {
89 pp.addProp("Type", type);
90 }
91 /* TBD: Router ID need to print
92 if (routerId != null) {
93 pp.addProp("Router-ID", routerId);
94 } */
95 if (routingUnverse != null) {
96 pp.addProp("Routing Universe", routingUnverse);
97 }
98 if (asNumber != null) {
99 pp.addProp("AS Number", asNumber);
100 }
101 if (domain != null) {
102 pp.addProp("Domain ID", domain);
103 }
104 }
105 }
106
107 @Override
108 public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
109 pp.addButton(SRC_BUTTON).addButton(DST_BUTTON);
110 }
111}