blob: 392d4238d3ca11b4a6af6715d0cdd6cb4e723dde [file] [log] [blame]
rama-huaweic78f3092016-05-19 18:09:29 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
rama-huaweic78f3092016-05-19 18:09:29 +05303 *
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.sfcweb;
17
Phaneendra Mandab212bc92016-07-08 16:50:11 +053018import org.onlab.packet.MacAddress;
19import org.onosproject.cli.AbstractShellCommand;
rama-huaweic78f3092016-05-19 18:09:29 +053020import org.onosproject.net.DeviceId;
Phaneendra Mandab212bc92016-07-08 16:50:11 +053021import org.onosproject.net.Host;
rama-huaweic78f3092016-05-19 18:09:29 +053022import org.onosproject.net.HostId;
Phaneendra Mandab212bc92016-07-08 16:50:11 +053023import org.onosproject.net.host.HostService;
rama-huaweic78f3092016-05-19 18:09:29 +053024import org.onosproject.ui.UiTopoOverlay;
25import org.onosproject.ui.topo.PropertyPanel;
Phaneendra Mandab212bc92016-07-08 16:50:11 +053026import org.onosproject.vtnrsc.PortPair;
27import org.onosproject.vtnrsc.VirtualPort;
28import org.onosproject.vtnrsc.VirtualPortId;
29import org.onosproject.vtnrsc.portpair.PortPairService;
30import org.onosproject.vtnrsc.virtualport.VirtualPortService;
rama-huaweic78f3092016-05-19 18:09:29 +053031
32/**
33 * Our sfcweb topology overlay.
34 */
35public 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 Mandab212bc92016-07-08 16:50:11 +053057 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-huaweic78f3092016-05-19 18:09:29 +053070 pp.addProp("SF host Address", hostId.toString());
71 }
72
73}