Committed by
Gerrit Code Review
[ONOS-4713]GUI improvement and issue fix
Change-Id: I9cec96584549e841dddf7759873fd7059b5ce2ba
Showing
25 changed files
with
526 additions
and
182 deletions
| ... | @@ -635,7 +635,10 @@ public class SfcFlowRuleInstallerImpl implements SfcFlowRuleInstallerService { | ... | @@ -635,7 +635,10 @@ public class SfcFlowRuleInstallerImpl implements SfcFlowRuleInstallerService { |
| 635 | treatment.extension(tunnelDsttreatment, deviceId); | 635 | treatment.extension(tunnelDsttreatment, deviceId); |
| 636 | treatment.transition(TUNNEL_SEND_TABLE); | 636 | treatment.transition(TUNNEL_SEND_TABLE); |
| 637 | sendSfcRule(selector, treatment, deviceId, type, flowClassifier.priority()); | 637 | sendSfcRule(selector, treatment, deviceId, type, flowClassifier.priority()); |
| 638 | - classifierList.add(deviceIdfromPortPair); | 638 | + |
| 639 | + selector.matchInPort(PortNumber.CONTROLLER); | ||
| 640 | + sendSfcRule(selector, treatment, deviceId, type, flowClassifier.priority()); | ||
| 641 | + classifierList.add(deviceId); | ||
| 639 | 642 | ||
| 640 | installSfcTunnelSendRule(deviceId, nshSpiId, type); | 643 | installSfcTunnelSendRule(deviceId, nshSpiId, type); |
| 641 | installSfcTunnelReceiveRule(deviceIdfromPortPair, nshSpiId, type); | 644 | installSfcTunnelReceiveRule(deviceIdfromPortPair, nshSpiId, type); |
| ... | @@ -647,6 +650,9 @@ public class SfcFlowRuleInstallerImpl implements SfcFlowRuleInstallerService { | ... | @@ -647,6 +650,9 @@ public class SfcFlowRuleInstallerImpl implements SfcFlowRuleInstallerService { |
| 647 | nshSpiId, flowClassifier); | 650 | nshSpiId, flowClassifier); |
| 648 | treatment.transition(ENCAP_OUTPUT_TABLE); | 651 | treatment.transition(ENCAP_OUTPUT_TABLE); |
| 649 | sendSfcRule(selector, treatment, deviceIdfromPortPair, type, flowClassifier.priority()); | 652 | sendSfcRule(selector, treatment, deviceIdfromPortPair, type, flowClassifier.priority()); |
| 653 | + | ||
| 654 | + selector.matchInPort(PortNumber.CONTROLLER); | ||
| 655 | + sendSfcRule(selector, treatment, deviceId, type, flowClassifier.priority()); | ||
| 650 | classifierList.add(deviceIdfromPortPair); | 656 | classifierList.add(deviceIdfromPortPair); |
| 651 | } | 657 | } |
| 652 | } | 658 | } | ... | ... |
| ... | @@ -507,6 +507,7 @@ public class SfcManager implements SfcService { | ... | @@ -507,6 +507,7 @@ public class SfcManager implements SfcService { |
| 507 | int portDst = 0; | 507 | int portDst = 0; |
| 508 | byte protocol = 0; | 508 | byte protocol = 0; |
| 509 | MacAddress macSrc = packet.getSourceMAC(); | 509 | MacAddress macSrc = packet.getSourceMAC(); |
| 510 | + MacAddress macDst = packet.getDestinationMAC(); | ||
| 510 | TenantId tenantId = getTenantId(macSrc); | 511 | TenantId tenantId = getTenantId(macSrc); |
| 511 | 512 | ||
| 512 | if (ethType == Ethernet.TYPE_IPV4) { | 513 | if (ethType == Ethernet.TYPE_IPV4) { |
| ... | @@ -539,6 +540,8 @@ public class SfcManager implements SfcService { | ... | @@ -539,6 +540,8 @@ public class SfcManager implements SfcService { |
| 539 | .setPortDst(PortNumber.portNumber(portDst)) | 540 | .setPortDst(PortNumber.portNumber(portDst)) |
| 540 | .setProtocol(protocol) | 541 | .setProtocol(protocol) |
| 541 | .setTenantId(tenantId) | 542 | .setTenantId(tenantId) |
| 543 | + .setMacSrc(macSrc) | ||
| 544 | + .setMacDst(macDst) | ||
| 542 | .build(); | 545 | .build(); |
| 543 | 546 | ||
| 544 | PortChainId portChainId = findPortChainFromFiveTuple(fiveTuple); | 547 | PortChainId portChainId = findPortChainFromFiveTuple(fiveTuple); |
| ... | @@ -577,13 +580,12 @@ public class SfcManager implements SfcService { | ... | @@ -577,13 +580,12 @@ public class SfcManager implements SfcService { |
| 577 | * Send packet back to classifier. | 580 | * Send packet back to classifier. |
| 578 | * | 581 | * |
| 579 | * @param context packet context | 582 | * @param context packet context |
| 580 | - * @param connectPoint connect point of first service function | ||
| 581 | */ | 583 | */ |
| 582 | private void sendPacket(PacketContext context) { | 584 | private void sendPacket(PacketContext context) { |
| 583 | 585 | ||
| 584 | ConnectPoint sourcePoint = context.inPacket().receivedFrom(); | 586 | ConnectPoint sourcePoint = context.inPacket().receivedFrom(); |
| 585 | 587 | ||
| 586 | - TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(sourcePoint.port()).build(); | 588 | + TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.TABLE).build(); |
| 587 | OutboundPacket packet = new DefaultOutboundPacket(sourcePoint.deviceId(), treatment, context.inPacket() | 589 | OutboundPacket packet = new DefaultOutboundPacket(sourcePoint.deviceId(), treatment, context.inPacket() |
| 588 | .unparsed()); | 590 | .unparsed()); |
| 589 | packetService.emit(packet); | 591 | packetService.emit(packet); | ... | ... |
| ... | @@ -16,16 +16,17 @@ | ... | @@ -16,16 +16,17 @@ |
| 16 | package org.onosproject.sfc.util; | 16 | package org.onosproject.sfc.util; |
| 17 | 17 | ||
| 18 | import java.util.Collection; | 18 | import java.util.Collection; |
| 19 | -import java.util.concurrent.ConcurrentMap; | ||
| 20 | import java.util.concurrent.ConcurrentHashMap; | 19 | import java.util.concurrent.ConcurrentHashMap; |
| 20 | +import java.util.concurrent.ConcurrentMap; | ||
| 21 | 21 | ||
| 22 | import org.onlab.packet.IpAddress; | 22 | import org.onlab.packet.IpAddress; |
| 23 | import org.onosproject.net.DeviceId; | 23 | import org.onosproject.net.DeviceId; |
| 24 | import org.onosproject.vtnrsc.FixedIp; | 24 | import org.onosproject.vtnrsc.FixedIp; |
| 25 | import org.onosproject.vtnrsc.TenantId; | 25 | import org.onosproject.vtnrsc.TenantId; |
| 26 | +import org.onosproject.vtnrsc.TenantNetworkId; | ||
| 26 | import org.onosproject.vtnrsc.VirtualPort; | 27 | import org.onosproject.vtnrsc.VirtualPort; |
| 27 | import org.onosproject.vtnrsc.VirtualPortId; | 28 | import org.onosproject.vtnrsc.VirtualPortId; |
| 28 | -import org.onosproject.vtnrsc.TenantNetworkId; | 29 | +import org.onosproject.vtnrsc.virtualport.VirtualPortListener; |
| 29 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; | 30 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
| 30 | 31 | ||
| 31 | /** | 32 | /** |
| ... | @@ -95,4 +96,12 @@ public class VirtualPortAdapter implements VirtualPortService { | ... | @@ -95,4 +96,12 @@ public class VirtualPortAdapter implements VirtualPortService { |
| 95 | public boolean removePorts(Iterable<VirtualPortId> vPortIds) { | 96 | public boolean removePorts(Iterable<VirtualPortId> vPortIds) { |
| 96 | return true; | 97 | return true; |
| 97 | } | 98 | } |
| 99 | + | ||
| 100 | + @Override | ||
| 101 | + public void addListener(VirtualPortListener listener) { | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @Override | ||
| 105 | + public void removeListener(VirtualPortListener listener) { | ||
| 106 | + } | ||
| 98 | } | 107 | } | ... | ... |
| ... | @@ -53,6 +53,11 @@ | ... | @@ -53,6 +53,11 @@ |
| 53 | <artifactId>onos-app-vtn-rsc</artifactId> | 53 | <artifactId>onos-app-vtn-rsc</artifactId> |
| 54 | <version>${project.version}</version> | 54 | <version>${project.version}</version> |
| 55 | </dependency> | 55 | </dependency> |
| 56 | + <dependency> | ||
| 57 | + <groupId>org.apache.karaf.shell</groupId> | ||
| 58 | + <artifactId>org.apache.karaf.shell.console</artifactId> | ||
| 59 | + <scope>compile</scope> | ||
| 60 | + </dependency> | ||
| 56 | </dependencies> | 61 | </dependencies> |
| 57 | 62 | ||
| 58 | </project> | 63 | </project> | ... | ... |
| 1 | +/* | ||
| 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 | +package org.onosproject.sfcweb; | ||
| 17 | + | ||
| 18 | +import org.onosproject.net.Link; | ||
| 19 | +import org.onosproject.net.LinkKey; | ||
| 20 | +import org.onosproject.ui.topo.BiLink; | ||
| 21 | +import org.onosproject.ui.topo.LinkHighlight; | ||
| 22 | +import org.onosproject.ui.topo.LinkHighlight.Flavor; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * Bi-directional link capable of different highlights. | ||
| 26 | + */ | ||
| 27 | +public class SfcLink extends BiLink { | ||
| 28 | + | ||
| 29 | + private boolean primary = false; | ||
| 30 | + private boolean secondary = false; | ||
| 31 | + | ||
| 32 | + public SfcLink(LinkKey key, Link link) { | ||
| 33 | + super(key, link); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + public LinkHighlight highlight(Enum<?> anEnum) { | ||
| 38 | + Flavor flavor = primary ? Flavor.PRIMARY_HIGHLIGHT : | ||
| 39 | + (secondary ? Flavor.SECONDARY_HIGHLIGHT : Flavor.NO_HIGHLIGHT); | ||
| 40 | + return new LinkHighlight(this.linkId(), Flavor.PRIMARY_HIGHLIGHT); | ||
| 41 | + } | ||
| 42 | +} |
| 1 | +/* | ||
| 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 | +package org.onosproject.sfcweb; | ||
| 17 | + | ||
| 18 | +import org.onosproject.net.Link; | ||
| 19 | +import org.onosproject.net.LinkKey; | ||
| 20 | +import org.onosproject.ui.topo.BiLinkMap; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Sfc concrete link map. | ||
| 24 | + */ | ||
| 25 | +public class SfcLinkMap extends BiLinkMap<SfcLink> { | ||
| 26 | + @Override | ||
| 27 | + protected SfcLink create(LinkKey linkKey, Link link) { | ||
| 28 | + return new SfcLink(linkKey, link); | ||
| 29 | + } | ||
| 30 | +} |
This diff is collapsed. Click to expand it.
| ... | @@ -15,11 +15,19 @@ | ... | @@ -15,11 +15,19 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.sfcweb; | 16 | package org.onosproject.sfcweb; |
| 17 | 17 | ||
| 18 | +import org.onlab.packet.MacAddress; | ||
| 19 | +import org.onosproject.cli.AbstractShellCommand; | ||
| 18 | import org.onosproject.net.DeviceId; | 20 | import org.onosproject.net.DeviceId; |
| 21 | +import org.onosproject.net.Host; | ||
| 19 | import org.onosproject.net.HostId; | 22 | import org.onosproject.net.HostId; |
| 23 | +import org.onosproject.net.host.HostService; | ||
| 20 | import org.onosproject.ui.UiTopoOverlay; | 24 | import org.onosproject.ui.UiTopoOverlay; |
| 21 | import org.onosproject.ui.topo.PropertyPanel; | 25 | import org.onosproject.ui.topo.PropertyPanel; |
| 22 | - | 26 | +import org.onosproject.vtnrsc.PortPair; |
| 27 | +import org.onosproject.vtnrsc.VirtualPort; | ||
| 28 | +import org.onosproject.vtnrsc.VirtualPortId; | ||
| 29 | +import org.onosproject.vtnrsc.portpair.PortPairService; | ||
| 30 | +import org.onosproject.vtnrsc.virtualport.VirtualPortService; | ||
| 23 | 31 | ||
| 24 | /** | 32 | /** |
| 25 | * Our sfcweb topology overlay. | 33 | * Our sfcweb topology overlay. |
| ... | @@ -46,6 +54,19 @@ public class SfcwebUiTopovOverlay extends UiTopoOverlay { | ... | @@ -46,6 +54,19 @@ public class SfcwebUiTopovOverlay extends UiTopoOverlay { |
| 46 | public void modifyHostDetails(PropertyPanel pp, HostId hostId) { | 54 | public void modifyHostDetails(PropertyPanel pp, HostId hostId) { |
| 47 | pp.title(MY_HOST_TITLE); | 55 | pp.title(MY_HOST_TITLE); |
| 48 | pp.removeAllProps(); | 56 | pp.removeAllProps(); |
| 57 | + 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 | + } | ||
| 49 | pp.addProp("SF host Address", hostId.toString()); | 70 | pp.addProp("SF host Address", hostId.toString()); |
| 50 | } | 71 | } |
| 51 | 72 | ... | ... |
| ... | @@ -28,31 +28,41 @@ | ... | @@ -28,31 +28,41 @@ |
| 28 | var displayStart = 'sfcwebTopovDisplayStart', | 28 | var displayStart = 'sfcwebTopovDisplayStart', |
| 29 | showSfcInf = 'showSfcInfo', | 29 | showSfcInf = 'showSfcInfo', |
| 30 | clearMessage = 'sfcTopovClear', | 30 | clearMessage = 'sfcTopovClear', |
| 31 | - configSfpMessage = 'configSfpMessage' ; | 31 | + configSfpMessage = 'configSfpMessage', |
| 32 | + sfcPath = 'showSfcPath' ; | ||
| 32 | 33 | ||
| 33 | // internal state | 34 | // internal state |
| 34 | var currentMode = null; | 35 | var currentMode = null; |
| 36 | + var sfpInfo; | ||
| 35 | 37 | ||
| 36 | // === Main API functions | 38 | // === Main API functions |
| 37 | 39 | ||
| 38 | function start() { | 40 | function start() { |
| 39 | handlerMap[showSfcInf] = showSfcInformation; | 41 | handlerMap[showSfcInf] = showSfcInformation; |
| 42 | + handlerMap[sfcPath] = showSfcPath; | ||
| 40 | wss.bindHandlers(handlerMap); | 43 | wss.bindHandlers(handlerMap); |
| 41 | wss.sendEvent(displayStart); | 44 | wss.sendEvent(displayStart); |
| 42 | } | 45 | } |
| 43 | 46 | ||
| 44 | - function dOk() { | 47 | + function dOkSfp() { |
| 45 | - var sfcId = null; | 48 | + var tdString; |
| 46 | - sfcId = d3.select('#sfp-value').property("value"); | 49 | + var i = 0; |
| 47 | 50 | ||
| 48 | - if (sfcId) { | 51 | + sfpInfo.a.forEach( function () { |
| 49 | - console.log(sfcId); | 52 | + var sfpId = d3.select("#sfp-value-id-"+i).property("checked"); |
| 50 | - } | 53 | + if (sfpId) |
| 54 | + { | ||
| 55 | + tdString = sfpInfo.a[i]; | ||
| 56 | + } | ||
| 57 | + i++; | ||
| 58 | + } ); | ||
| 51 | 59 | ||
| 52 | - $log.debug('Dialog OK button clicked'); | 60 | + if (!tdString) { |
| 61 | + $log.debug("No SFP ID is selected."); | ||
| 62 | + } | ||
| 53 | 63 | ||
| 54 | wss.sendEvent(configSfpMessage, { | 64 | wss.sendEvent(configSfpMessage, { |
| 55 | - id: sfcId | 65 | + id: tdString |
| 56 | }); | 66 | }); |
| 57 | 67 | ||
| 58 | flash.flash('SFP ID query:'); | 68 | flash.flash('SFP ID query:'); |
| ... | @@ -62,68 +72,67 @@ | ... | @@ -62,68 +72,67 @@ |
| 62 | $log.debug('Dialog Close button clicked (or Esc pressed)'); | 72 | $log.debug('Dialog Close button clicked (or Esc pressed)'); |
| 63 | } | 73 | } |
| 64 | 74 | ||
| 65 | - function createUserText() { | 75 | + function createUserTextSfp(data) { |
| 76 | + console.log(data); | ||
| 77 | + | ||
| 66 | var content = ds.createDiv(); | 78 | var content = ds.createDiv(); |
| 67 | var form = content.append('form'); | 79 | var form = content.append('form'); |
| 68 | var p = form.append('p'); | 80 | var p = form.append('p'); |
| 81 | + var i = 0; | ||
| 69 | 82 | ||
| 70 | - p.append('input').attr({ | 83 | + p.append('span').text('SFP IDs'); |
| 71 | - id: 'sfp-value', | ||
| 72 | - type: 'string', | ||
| 73 | - name: 'sfp-value-name' | ||
| 74 | - }); | ||
| 75 | - p.append('span').text('ID'); | ||
| 76 | p.append('br'); | 84 | p.append('br'); |
| 85 | + sfpInfo = data; | ||
| 86 | + data.a.forEach( function () { | ||
| 77 | 87 | ||
| 78 | - return content; | 88 | + p.append('input').attr({ |
| 79 | - } | 89 | + id: 'sfp-value-id-'+i, |
| 90 | + type: 'radio', | ||
| 91 | + name: 'sfp-id-name', | ||
| 92 | + value: data.a[i] | ||
| 93 | + }); | ||
| 80 | 94 | ||
| 81 | - function configSfp() { | 95 | + p.append('span').text(data.a[i]); |
| 82 | - tds.openDialog() | 96 | + p.append('br'); |
| 83 | - .setTitle('SFP ID User Input') | 97 | + i++; |
| 84 | - .addContent(createUserText()) | 98 | + } ); |
| 85 | - .addOk(dOk, 'OK') | 99 | + |
| 86 | - .addCancel(dClose, 'Close') | 100 | + return content; |
| 87 | - .bindKeys(); | ||
| 88 | } | 101 | } |
| 89 | 102 | ||
| 90 | function showSfcInformation(data) { | 103 | function showSfcInformation(data) { |
| 91 | - console.log(data); | 104 | + tds.openDialog() |
| 92 | - wss.unbindHandlers(handlerMap); | 105 | + .setTitle('List of active service functions') |
| 93 | - | 106 | + .addContent(createUserTextSfp(data)) |
| 94 | - // Get the modal | 107 | + .addOk(dOkSfp, 'Select SFP ID') |
| 95 | - var modal = document.getElementById('myModal'); | 108 | + .addCancel(dClose, 'Close') |
| 96 | - | 109 | + .bindKeys(); |
| 97 | - // Get the button that opens the modal | ||
| 98 | - var btn = document.getElementById("myBtn"); | ||
| 99 | - | ||
| 100 | - // Get the <span> element that closes the modal | ||
| 101 | - var span = document.getElementsByClassName("close")[0]; | ||
| 102 | - | ||
| 103 | - modal.style.display = "block"; | ||
| 104 | - | ||
| 105 | - var tBody = document.getElementById('sfc-info-body'); | ||
| 106 | 110 | ||
| 107 | - var tdString = '' ; | 111 | + } |
| 108 | 112 | ||
| 109 | - for (var i = 0; i < data.a.length; i++) { | 113 | + function createSfcPathText(data) { |
| 110 | - tdString += '<tr> <td>'+ data.a[i] +'</td></tr>'; | ||
| 111 | - } | ||
| 112 | 114 | ||
| 113 | - tBody.innerHTML = tdString; | 115 | + var content = ds.createDiv(); |
| 116 | + var form = content.append('form'); | ||
| 117 | + var p = form.append('p'); | ||
| 118 | + var i = 0; | ||
| 114 | 119 | ||
| 115 | - // When the user clicks on <span> (x), close the modal | 120 | + p.append('span').text('SFC Path'); |
| 116 | - span.onclick = function() { | 121 | + p.append('br'); |
| 117 | - modal.style.display = "none"; | 122 | + data.sfcPathList.forEach( function (val, idx) { |
| 118 | - } | 123 | + p.append('span').text(val); |
| 124 | + p.append('br') | ||
| 125 | + } ); | ||
| 119 | 126 | ||
| 120 | - // When the user clicks anywhere outside of the modal, close it | 127 | + return content; |
| 121 | - window.onclick = function(event) { | 128 | + } |
| 122 | - if (event.target == modal) { | ||
| 123 | - modal.style.display = "none"; | ||
| 124 | - } | ||
| 125 | - } | ||
| 126 | 129 | ||
| 130 | + function showSfcPath(data) { | ||
| 131 | + tds.openDialog() | ||
| 132 | + .setTitle('Service function path') | ||
| 133 | + .addContent(createSfcPathText(data)) | ||
| 134 | + .addCancel(dClose, 'Close') | ||
| 135 | + .bindKeys(); | ||
| 127 | } | 136 | } |
| 128 | 137 | ||
| 129 | function clear() { | 138 | function clear() { |
| ... | @@ -146,8 +155,8 @@ | ... | @@ -146,8 +155,8 @@ |
| 146 | return { | 155 | return { |
| 147 | start: start, | 156 | start: start, |
| 148 | showSfcInformation: showSfcInformation, | 157 | showSfcInformation: showSfcInformation, |
| 149 | - clear: clear, | 158 | + showSfcPath : showSfcPath, |
| 150 | - configSfp: configSfp | 159 | + clear: clear |
| 151 | }; | 160 | }; |
| 152 | }]); | 161 | }]); |
| 153 | 162 | ... | ... |
| ... | @@ -27,11 +27,6 @@ | ... | @@ -27,11 +27,6 @@ |
| 27 | star4: { | 27 | star4: { |
| 28 | vb: '0 0 8 8', | 28 | vb: '0 0 8 8', |
| 29 | d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z' | 29 | d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z' |
| 30 | - }, | ||
| 31 | - jp: { | ||
| 32 | - vb: '0 0 110 110', | ||
| 33 | - d: 'M84.3,89.3L58.9,64.2l-1.4,1.4L83,90.7L84.3,89.3z M27,7.6H7.4v19.2H27V7.6z' + | ||
| 34 | - 'M59.3,47.1H39.8v19.2h19.5V47.1z M102.1,79.5H82.6v19.2h19.5V79.5z M41.7,47.6L19,25.1l-1.2,1.2l22.7,22.5L41.7,47.6z' | ||
| 35 | } | 30 | } |
| 36 | }, | 31 | }, |
| 37 | activate: function () { | 32 | activate: function () { |
| ... | @@ -53,16 +48,9 @@ | ... | @@ -53,16 +48,9 @@ |
| 53 | tt: 'Query SFP active list information', | 48 | tt: 'Query SFP active list information', |
| 54 | gid: 'summary' | 49 | gid: 'summary' |
| 55 | }, | 50 | }, |
| 56 | - 5: { | ||
| 57 | - cb: function () { | ||
| 58 | - pps.configSfp(); | ||
| 59 | - }, | ||
| 60 | - tt: 'Highlight SFP active list information', | ||
| 61 | - gid: '*jp' | ||
| 62 | - }, | ||
| 63 | 51 | ||
| 64 | _keyOrder: [ | 52 | _keyOrder: [ |
| 65 | - '4' , '5' | 53 | + '4' |
| 66 | ] | 54 | ] |
| 67 | } | 55 | } |
| 68 | 56 | ... | ... |
| 1 | <script src="app/view/sfcwebTopov/sfcwebTopovDemo.js"></script> | 1 | <script src="app/view/sfcwebTopov/sfcwebTopovDemo.js"></script> |
| 2 | <script src="app/view/sfcwebTopov/sfcwebTopovOverlay.js"></script> | 2 | <script src="app/view/sfcwebTopov/sfcwebTopovOverlay.js"></script> |
| 3 | - | ||
| 4 | -<style> | ||
| 5 | - /* The Modal (background) */ | ||
| 6 | - .modal { | ||
| 7 | - display: none; | ||
| 8 | - position: fixed; | ||
| 9 | - z-index: 1; | ||
| 10 | - padding-top: 0px; | ||
| 11 | - left: 0px; | ||
| 12 | - top: 0; | ||
| 13 | - width: 37%; | ||
| 14 | - height: 25%; | ||
| 15 | - overflow: auto; | ||
| 16 | - background-color: none; | ||
| 17 | - margin: 178px 0px 0px -8px; | ||
| 18 | - } | ||
| 19 | - | ||
| 20 | - /* Modal Content */ | ||
| 21 | - .modal-content { | ||
| 22 | - background-color: #fefefe; | ||
| 23 | - margin: auto; | ||
| 24 | - padding: 20px; | ||
| 25 | - border: 1px solid #888; | ||
| 26 | - width: 80%; | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - /* The Close Button */ | ||
| 30 | - .close { | ||
| 31 | - color: #aaaaaa; | ||
| 32 | - float: right; | ||
| 33 | - font-size: 28px; | ||
| 34 | - font-weight: bold; | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - .close:hover, | ||
| 38 | - .close:focus { | ||
| 39 | - color: #000; | ||
| 40 | - text-decoration: none; | ||
| 41 | - cursor: pointer; | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | -</style> | ||
| 45 | - | ||
| 46 | -<!-- The Modal --> | ||
| 47 | -<div id="myModal" class="modal"> | ||
| 48 | - | ||
| 49 | - <!-- Modal content --> | ||
| 50 | - <div class="modal-content"> | ||
| 51 | - <span class="close">×</span> | ||
| 52 | - <table id='sfc-info'> | ||
| 53 | - <thead> | ||
| 54 | - <td>SFP ID information</td> | ||
| 55 | - </thead> | ||
| 56 | - <tbody id='sfc-info-body'> | ||
| 57 | - | ||
| 58 | - </tbody> | ||
| 59 | - </table> | ||
| 60 | - </div> | ||
| 61 | -</div> | ... | ... |
| ... | @@ -62,6 +62,7 @@ import org.onosproject.net.behaviour.BridgeDescription; | ... | @@ -62,6 +62,7 @@ import org.onosproject.net.behaviour.BridgeDescription; |
| 62 | import org.onosproject.net.behaviour.ExtensionTreatmentResolver; | 62 | import org.onosproject.net.behaviour.ExtensionTreatmentResolver; |
| 63 | import org.onosproject.net.config.NetworkConfigService; | 63 | import org.onosproject.net.config.NetworkConfigService; |
| 64 | import org.onosproject.net.config.basics.BasicDeviceConfig; | 64 | import org.onosproject.net.config.basics.BasicDeviceConfig; |
| 65 | +import org.onosproject.net.config.basics.BasicHostConfig; | ||
| 65 | import org.onosproject.net.device.DeviceEvent; | 66 | import org.onosproject.net.device.DeviceEvent; |
| 66 | import org.onosproject.net.device.DeviceListener; | 67 | import org.onosproject.net.device.DeviceListener; |
| 67 | import org.onosproject.net.device.DeviceService; | 68 | import org.onosproject.net.device.DeviceService; |
| ... | @@ -207,6 +208,9 @@ public class VtnManager implements VtnService { | ... | @@ -207,6 +208,9 @@ public class VtnManager implements VtnService { |
| 207 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 208 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 208 | protected FlowRuleService flowRuleService; | 209 | protected FlowRuleService flowRuleService; |
| 209 | 210 | ||
| 211 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 212 | + protected NetworkConfigService networkConfigService; | ||
| 213 | + | ||
| 210 | private ApplicationId appId; | 214 | private ApplicationId appId; |
| 211 | private ClassifierService classifierService; | 215 | private ClassifierService classifierService; |
| 212 | private L2ForwardService l2ForwardService; | 216 | private L2ForwardService l2ForwardService; |
| ... | @@ -847,13 +851,16 @@ public class VtnManager implements VtnService { | ... | @@ -847,13 +851,16 @@ public class VtnManager implements VtnService { |
| 847 | VtnRscEventFeedback l3Feedback = event.subject(); | 851 | VtnRscEventFeedback l3Feedback = event.subject(); |
| 848 | if (VtnRscEvent.Type.ROUTER_INTERFACE_PUT == event.type()) { | 852 | if (VtnRscEvent.Type.ROUTER_INTERFACE_PUT == event.type()) { |
| 849 | onRouterInterfaceDetected(l3Feedback); | 853 | onRouterInterfaceDetected(l3Feedback); |
| 850 | - } else | 854 | + } else if (VtnRscEvent.Type.ROUTER_INTERFACE_DELETE == event.type()) { |
| 851 | - if (VtnRscEvent.Type.ROUTER_INTERFACE_DELETE == event.type()) { | ||
| 852 | onRouterInterfaceVanished(l3Feedback); | 855 | onRouterInterfaceVanished(l3Feedback); |
| 853 | } else if (VtnRscEvent.Type.FLOATINGIP_BIND == event.type()) { | 856 | } else if (VtnRscEvent.Type.FLOATINGIP_BIND == event.type()) { |
| 854 | onFloatingIpDetected(l3Feedback); | 857 | onFloatingIpDetected(l3Feedback); |
| 855 | } else if (VtnRscEvent.Type.FLOATINGIP_UNBIND == event.type()) { | 858 | } else if (VtnRscEvent.Type.FLOATINGIP_UNBIND == event.type()) { |
| 856 | onFloatingIpVanished(l3Feedback); | 859 | onFloatingIpVanished(l3Feedback); |
| 860 | + } else if (VtnRscEvent.Type.VIRTUAL_PORT_PUT == event.type()) { | ||
| 861 | + onVirtualPortCreated(l3Feedback); | ||
| 862 | + } else if (VtnRscEvent.Type.VIRTUAL_PORT_DELETE == event.type()) { | ||
| 863 | + onVirtualPortDeleted(l3Feedback); | ||
| 857 | } | 864 | } |
| 858 | } | 865 | } |
| 859 | 866 | ||
| ... | @@ -926,6 +933,29 @@ public class VtnManager implements VtnService { | ... | @@ -926,6 +933,29 @@ public class VtnManager implements VtnService { |
| 926 | programFloatingIpEvent(l3Feedback, VtnRscEvent.Type.FLOATINGIP_UNBIND); | 933 | programFloatingIpEvent(l3Feedback, VtnRscEvent.Type.FLOATINGIP_UNBIND); |
| 927 | } | 934 | } |
| 928 | 935 | ||
| 936 | + public void onVirtualPortCreated(VtnRscEventFeedback l3Feedback) { | ||
| 937 | + VirtualPort vPort = l3Feedback.virtualPort(); | ||
| 938 | + BasicHostConfig basicHostConfig = networkConfigService.addConfig(HostId.hostId(vPort.macAddress()), | ||
| 939 | + BasicHostConfig.class); | ||
| 940 | + Set<IpAddress> ips = new HashSet<>(); | ||
| 941 | + for (FixedIp fixedIp : vPort.fixedIps()) { | ||
| 942 | + ips.add(fixedIp.ip()); | ||
| 943 | + } | ||
| 944 | + basicHostConfig.setIps(ips).apply(); | ||
| 945 | + } | ||
| 946 | + | ||
| 947 | + public void onVirtualPortDeleted(VtnRscEventFeedback l3Feedback) { | ||
| 948 | + VirtualPort vPort = l3Feedback.virtualPort(); | ||
| 949 | + HostId hostId = HostId.hostId(vPort.macAddress()); | ||
| 950 | + BasicHostConfig basicHostConfig = networkConfigService.addConfig(hostId, | ||
| 951 | + BasicHostConfig.class); | ||
| 952 | + Set<IpAddress> ips = hostService.getHost(hostId).ipAddresses(); | ||
| 953 | + for (FixedIp fixedIp : vPort.fixedIps()) { | ||
| 954 | + ips.remove(fixedIp.ip()); | ||
| 955 | + } | ||
| 956 | + basicHostConfig.setIps(ips).apply(); | ||
| 957 | + } | ||
| 958 | + | ||
| 929 | private void programInterfacesSet(Set<RouterInterface> interfacesSet, | 959 | private void programInterfacesSet(Set<RouterInterface> interfacesSet, |
| 930 | Objective.Operation operation) { | 960 | Objective.Operation operation) { |
| 931 | int subnetVmNum = 0; | 961 | int subnetVmNum = 0; | ... | ... |
| ... | @@ -22,6 +22,7 @@ import java.util.Objects; | ... | @@ -22,6 +22,7 @@ import java.util.Objects; |
| 22 | 22 | ||
| 23 | import org.onlab.packet.IPv4; | 23 | import org.onlab.packet.IPv4; |
| 24 | import org.onlab.packet.IpAddress; | 24 | import org.onlab.packet.IpAddress; |
| 25 | +import org.onlab.packet.MacAddress; | ||
| 25 | import org.onosproject.net.PortNumber; | 26 | import org.onosproject.net.PortNumber; |
| 26 | 27 | ||
| 27 | /** | 28 | /** |
| ... | @@ -29,6 +30,8 @@ import org.onosproject.net.PortNumber; | ... | @@ -29,6 +30,8 @@ import org.onosproject.net.PortNumber; |
| 29 | */ | 30 | */ |
| 30 | public final class DefaultFiveTuple implements FiveTuple { | 31 | public final class DefaultFiveTuple implements FiveTuple { |
| 31 | 32 | ||
| 33 | + private final MacAddress macSrc; | ||
| 34 | + private final MacAddress macDst; | ||
| 32 | private final IpAddress ipSrc; | 35 | private final IpAddress ipSrc; |
| 33 | private final IpAddress ipDst; | 36 | private final IpAddress ipDst; |
| 34 | private final PortNumber portSrc; | 37 | private final PortNumber portSrc; |
| ... | @@ -46,7 +49,7 @@ public final class DefaultFiveTuple implements FiveTuple { | ... | @@ -46,7 +49,7 @@ public final class DefaultFiveTuple implements FiveTuple { |
| 46 | * @param portDst destination port of the packet | 49 | * @param portDst destination port of the packet |
| 47 | */ | 50 | */ |
| 48 | private DefaultFiveTuple(byte protocol, IpAddress ipSrc, IpAddress ipDst, PortNumber portSrc, PortNumber portDst, | 51 | private DefaultFiveTuple(byte protocol, IpAddress ipSrc, IpAddress ipDst, PortNumber portSrc, PortNumber portDst, |
| 49 | - TenantId tenantId) { | 52 | + TenantId tenantId, MacAddress macSrc, MacAddress macDst) { |
| 50 | 53 | ||
| 51 | this.protocol = protocol; | 54 | this.protocol = protocol; |
| 52 | this.ipSrc = ipSrc; | 55 | this.ipSrc = ipSrc; |
| ... | @@ -54,6 +57,8 @@ public final class DefaultFiveTuple implements FiveTuple { | ... | @@ -54,6 +57,8 @@ public final class DefaultFiveTuple implements FiveTuple { |
| 54 | this.portSrc = portSrc; | 57 | this.portSrc = portSrc; |
| 55 | this.portDst = portDst; | 58 | this.portDst = portDst; |
| 56 | this.tenantId = tenantId; | 59 | this.tenantId = tenantId; |
| 60 | + this.macSrc = macSrc; | ||
| 61 | + this.macDst = macDst; | ||
| 57 | } | 62 | } |
| 58 | 63 | ||
| 59 | @Override | 64 | @Override |
| ... | @@ -82,6 +87,16 @@ public final class DefaultFiveTuple implements FiveTuple { | ... | @@ -82,6 +87,16 @@ public final class DefaultFiveTuple implements FiveTuple { |
| 82 | } | 87 | } |
| 83 | 88 | ||
| 84 | @Override | 89 | @Override |
| 90 | + public MacAddress macSrc() { | ||
| 91 | + return macSrc; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + @Override | ||
| 95 | + public MacAddress macDst() { | ||
| 96 | + return macDst; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + @Override | ||
| 85 | public TenantId tenantId() { | 100 | public TenantId tenantId() { |
| 86 | return tenantId; | 101 | return tenantId; |
| 87 | } | 102 | } |
| ... | @@ -139,6 +154,8 @@ public final class DefaultFiveTuple implements FiveTuple { | ... | @@ -139,6 +154,8 @@ public final class DefaultFiveTuple implements FiveTuple { |
| 139 | private PortNumber portDst; | 154 | private PortNumber portDst; |
| 140 | private byte protocol; | 155 | private byte protocol; |
| 141 | private TenantId tenantId; | 156 | private TenantId tenantId; |
| 157 | + private MacAddress macSrc; | ||
| 158 | + private MacAddress macDst; | ||
| 142 | 159 | ||
| 143 | @Override | 160 | @Override |
| 144 | public Builder setIpSrc(IpAddress ipSrc) { | 161 | public Builder setIpSrc(IpAddress ipSrc) { |
| ... | @@ -171,17 +188,29 @@ public final class DefaultFiveTuple implements FiveTuple { | ... | @@ -171,17 +188,29 @@ public final class DefaultFiveTuple implements FiveTuple { |
| 171 | } | 188 | } |
| 172 | 189 | ||
| 173 | @Override | 190 | @Override |
| 174 | - public org.onosproject.vtnrsc.FiveTuple.Builder setTenantId(TenantId tenantId) { | 191 | + public Builder setTenantId(TenantId tenantId) { |
| 175 | this.tenantId = tenantId; | 192 | this.tenantId = tenantId; |
| 176 | return this; | 193 | return this; |
| 177 | } | 194 | } |
| 178 | 195 | ||
| 179 | @Override | 196 | @Override |
| 197 | + public Builder setMacSrc(MacAddress macSrc) { | ||
| 198 | + this.macSrc = macSrc; | ||
| 199 | + return this; | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + @Override | ||
| 203 | + public Builder setMacDst(MacAddress macDst) { | ||
| 204 | + this.macDst = macDst; | ||
| 205 | + return this; | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + @Override | ||
| 180 | public FiveTuple build() { | 209 | public FiveTuple build() { |
| 181 | checkArgument(protocol == IPv4.PROTOCOL_TCP || protocol == IPv4.PROTOCOL_UDP || | 210 | checkArgument(protocol == IPv4.PROTOCOL_TCP || protocol == IPv4.PROTOCOL_UDP || |
| 182 | protocol == IPv4.PROTOCOL_ICMP, "Unsupported value for protocol while creating five tuple"); | 211 | protocol == IPv4.PROTOCOL_ICMP, "Unsupported value for protocol while creating five tuple"); |
| 183 | 212 | ||
| 184 | - return new DefaultFiveTuple(protocol, ipSrc, ipDst, portSrc, portDst, tenantId); | 213 | + return new DefaultFiveTuple(protocol, ipSrc, ipDst, portSrc, portDst, tenantId, macSrc, macDst); |
| 185 | } | 214 | } |
| 186 | } | 215 | } |
| 187 | } | 216 | } | ... | ... |
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | package org.onosproject.vtnrsc; | 16 | package org.onosproject.vtnrsc; |
| 17 | 17 | ||
| 18 | import org.onlab.packet.IpAddress; | 18 | import org.onlab.packet.IpAddress; |
| 19 | +import org.onlab.packet.MacAddress; | ||
| 19 | import org.onosproject.net.PortNumber; | 20 | import org.onosproject.net.PortNumber; |
| 20 | 21 | ||
| 21 | /** | 22 | /** |
| ... | @@ -61,6 +62,20 @@ public interface FiveTuple { | ... | @@ -61,6 +62,20 @@ public interface FiveTuple { |
| 61 | PortNumber portDst(); | 62 | PortNumber portDst(); |
| 62 | 63 | ||
| 63 | /** | 64 | /** |
| 65 | + * Returns source mac. | ||
| 66 | + * | ||
| 67 | + * @return srcMac | ||
| 68 | + */ | ||
| 69 | + MacAddress macSrc(); | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * Returns destination mac. | ||
| 73 | + * | ||
| 74 | + * @return dstMac | ||
| 75 | + */ | ||
| 76 | + MacAddress macDst(); | ||
| 77 | + | ||
| 78 | + /** | ||
| 64 | * Returns the tenant id. | 79 | * Returns the tenant id. |
| 65 | * | 80 | * |
| 66 | * @return tenantId | 81 | * @return tenantId |
| ... | @@ -105,6 +120,22 @@ public interface FiveTuple { | ... | @@ -105,6 +120,22 @@ public interface FiveTuple { |
| 105 | Builder setPortDst(PortNumber portDst); | 120 | Builder setPortDst(PortNumber portDst); |
| 106 | 121 | ||
| 107 | /** | 122 | /** |
| 123 | + * Assign the source mac address to this object. | ||
| 124 | + * | ||
| 125 | + * @param macSrc source mac address | ||
| 126 | + * @return this the builder object | ||
| 127 | + */ | ||
| 128 | + Builder setMacSrc(MacAddress macSrc); | ||
| 129 | + | ||
| 130 | + /** | ||
| 131 | + * Assign the destination mac address to this object. | ||
| 132 | + * | ||
| 133 | + * @param macDst destination mac address | ||
| 134 | + * @return this the builder object | ||
| 135 | + */ | ||
| 136 | + Builder setMacDst(MacAddress macDst); | ||
| 137 | + | ||
| 138 | + /** | ||
| 108 | * Assign the protocol to this object. | 139 | * Assign the protocol to this object. |
| 109 | * | 140 | * |
| 110 | * @param protocol packet protocol | 141 | * @param protocol packet protocol | ... | ... |
| ... | @@ -107,7 +107,15 @@ public class VtnRscEvent | ... | @@ -107,7 +107,15 @@ public class VtnRscEvent |
| 107 | /** | 107 | /** |
| 108 | * Signifies that port-chain has update. | 108 | * Signifies that port-chain has update. |
| 109 | */ | 109 | */ |
| 110 | - PORT_CHAIN_UPDATE | 110 | + PORT_CHAIN_UPDATE, |
| 111 | + /** | ||
| 112 | + * Signifies that virtual-port has created. | ||
| 113 | + */ | ||
| 114 | + VIRTUAL_PORT_PUT, | ||
| 115 | + /** | ||
| 116 | + * Signifies that virtual-port has removed. | ||
| 117 | + */ | ||
| 118 | + VIRTUAL_PORT_DELETE | ||
| 111 | } | 119 | } |
| 112 | 120 | ||
| 113 | /** | 121 | /** | ... | ... |
| ... | @@ -15,18 +15,19 @@ | ... | @@ -15,18 +15,19 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.vtnrsc.event; | 16 | package org.onosproject.vtnrsc.event; |
| 17 | 17 | ||
| 18 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 19 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 20 | + | ||
| 18 | import java.util.Objects; | 21 | import java.util.Objects; |
| 19 | 22 | ||
| 20 | import org.onosproject.vtnrsc.FloatingIp; | 23 | import org.onosproject.vtnrsc.FloatingIp; |
| 21 | -import org.onosproject.vtnrsc.Router; | ||
| 22 | -import org.onosproject.vtnrsc.RouterInterface; | ||
| 23 | -import org.onosproject.vtnrsc.PortPair; | ||
| 24 | -import org.onosproject.vtnrsc.PortPairGroup; | ||
| 25 | import org.onosproject.vtnrsc.FlowClassifier; | 24 | import org.onosproject.vtnrsc.FlowClassifier; |
| 26 | import org.onosproject.vtnrsc.PortChain; | 25 | import org.onosproject.vtnrsc.PortChain; |
| 27 | - | 26 | +import org.onosproject.vtnrsc.PortPair; |
| 28 | -import static com.google.common.base.MoreObjects.toStringHelper; | 27 | +import org.onosproject.vtnrsc.PortPairGroup; |
| 29 | -import static com.google.common.base.Preconditions.checkNotNull; | 28 | +import org.onosproject.vtnrsc.Router; |
| 29 | +import org.onosproject.vtnrsc.RouterInterface; | ||
| 30 | +import org.onosproject.vtnrsc.VirtualPort; | ||
| 30 | 31 | ||
| 31 | /** | 32 | /** |
| 32 | * Representation of a VtnRsc event feedback. | 33 | * Representation of a VtnRsc event feedback. |
| ... | @@ -39,6 +40,7 @@ public class VtnRscEventFeedback { | ... | @@ -39,6 +40,7 @@ public class VtnRscEventFeedback { |
| 39 | private final PortPairGroup portPairGroup; | 40 | private final PortPairGroup portPairGroup; |
| 40 | private final FlowClassifier flowClassifier; | 41 | private final FlowClassifier flowClassifier; |
| 41 | private final PortChain portChain; | 42 | private final PortChain portChain; |
| 43 | + private final VirtualPort virtualPort; | ||
| 42 | 44 | ||
| 43 | /** | 45 | /** |
| 44 | * Creates VtnRscEventFeedback object. | 46 | * Creates VtnRscEventFeedback object. |
| ... | @@ -53,6 +55,7 @@ public class VtnRscEventFeedback { | ... | @@ -53,6 +55,7 @@ public class VtnRscEventFeedback { |
| 53 | this.portPairGroup = null; | 55 | this.portPairGroup = null; |
| 54 | this.flowClassifier = null; | 56 | this.flowClassifier = null; |
| 55 | this.portChain = null; | 57 | this.portChain = null; |
| 58 | + this.virtualPort = null; | ||
| 56 | } | 59 | } |
| 57 | 60 | ||
| 58 | /** | 61 | /** |
| ... | @@ -68,6 +71,7 @@ public class VtnRscEventFeedback { | ... | @@ -68,6 +71,7 @@ public class VtnRscEventFeedback { |
| 68 | this.portPairGroup = null; | 71 | this.portPairGroup = null; |
| 69 | this.flowClassifier = null; | 72 | this.flowClassifier = null; |
| 70 | this.portChain = null; | 73 | this.portChain = null; |
| 74 | + this.virtualPort = null; | ||
| 71 | } | 75 | } |
| 72 | 76 | ||
| 73 | /** | 77 | /** |
| ... | @@ -84,6 +88,7 @@ public class VtnRscEventFeedback { | ... | @@ -84,6 +88,7 @@ public class VtnRscEventFeedback { |
| 84 | this.portPairGroup = null; | 88 | this.portPairGroup = null; |
| 85 | this.flowClassifier = null; | 89 | this.flowClassifier = null; |
| 86 | this.portChain = null; | 90 | this.portChain = null; |
| 91 | + this.virtualPort = null; | ||
| 87 | } | 92 | } |
| 88 | 93 | ||
| 89 | /** | 94 | /** |
| ... | @@ -100,6 +105,7 @@ public class VtnRscEventFeedback { | ... | @@ -100,6 +105,7 @@ public class VtnRscEventFeedback { |
| 100 | this.portPairGroup = null; | 105 | this.portPairGroup = null; |
| 101 | this.flowClassifier = null; | 106 | this.flowClassifier = null; |
| 102 | this.portChain = null; | 107 | this.portChain = null; |
| 108 | + this.virtualPort = null; | ||
| 103 | } | 109 | } |
| 104 | 110 | ||
| 105 | /** | 111 | /** |
| ... | @@ -113,9 +119,10 @@ public class VtnRscEventFeedback { | ... | @@ -113,9 +119,10 @@ public class VtnRscEventFeedback { |
| 113 | this.routerInterface = null; | 119 | this.routerInterface = null; |
| 114 | this.portPair = null; | 120 | this.portPair = null; |
| 115 | this.portPairGroup = checkNotNull(portPairGroup, | 121 | this.portPairGroup = checkNotNull(portPairGroup, |
| 116 | - "Port-Pair-Group cannot be null"); | 122 | + "Port-Pair-Group cannot be null"); |
| 117 | this.flowClassifier = null; | 123 | this.flowClassifier = null; |
| 118 | this.portChain = null; | 124 | this.portChain = null; |
| 125 | + this.virtualPort = null; | ||
| 119 | } | 126 | } |
| 120 | 127 | ||
| 121 | /** | 128 | /** |
| ... | @@ -130,8 +137,9 @@ public class VtnRscEventFeedback { | ... | @@ -130,8 +137,9 @@ public class VtnRscEventFeedback { |
| 130 | this.portPair = null; | 137 | this.portPair = null; |
| 131 | this.portPairGroup = null; | 138 | this.portPairGroup = null; |
| 132 | this.flowClassifier = checkNotNull(flowClassifier, | 139 | this.flowClassifier = checkNotNull(flowClassifier, |
| 133 | - "Flow-Classifier cannot be null"); | 140 | + "Flow-Classifier cannot be null"); |
| 134 | this.portChain = null; | 141 | this.portChain = null; |
| 142 | + this.virtualPort = null; | ||
| 135 | } | 143 | } |
| 136 | 144 | ||
| 137 | /** | 145 | /** |
| ... | @@ -147,7 +155,25 @@ public class VtnRscEventFeedback { | ... | @@ -147,7 +155,25 @@ public class VtnRscEventFeedback { |
| 147 | this.portPairGroup = null; | 155 | this.portPairGroup = null; |
| 148 | this.flowClassifier = null; | 156 | this.flowClassifier = null; |
| 149 | this.portChain = checkNotNull(portChain, | 157 | this.portChain = checkNotNull(portChain, |
| 150 | - "Port-Chain cannot be null"); | 158 | + "Port-Chain cannot be null"); |
| 159 | + this.virtualPort = null; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + /** | ||
| 163 | + * Creates VtnRscEventFeedback object. | ||
| 164 | + * | ||
| 165 | + * @param virtualPort the Virtual-Port | ||
| 166 | + */ | ||
| 167 | + public VtnRscEventFeedback(VirtualPort virtualPort) { | ||
| 168 | + this.floaingtIp = null; | ||
| 169 | + this.router = null; | ||
| 170 | + this.routerInterface = null; | ||
| 171 | + this.portPair = null; | ||
| 172 | + this.portPairGroup = null; | ||
| 173 | + this.flowClassifier = null; | ||
| 174 | + this.portChain = null; | ||
| 175 | + this.virtualPort = checkNotNull(virtualPort, | ||
| 176 | + "Virtual-port cannot be null"); | ||
| 151 | } | 177 | } |
| 152 | 178 | ||
| 153 | /** | 179 | /** |
| ... | @@ -213,10 +239,19 @@ public class VtnRscEventFeedback { | ... | @@ -213,10 +239,19 @@ public class VtnRscEventFeedback { |
| 213 | return portChain; | 239 | return portChain; |
| 214 | } | 240 | } |
| 215 | 241 | ||
| 242 | + /** | ||
| 243 | + * Returns Virtual-Port. | ||
| 244 | + * | ||
| 245 | + * @return virtualPort the Virtual-Port | ||
| 246 | + */ | ||
| 247 | + public VirtualPort virtualPort() { | ||
| 248 | + return virtualPort; | ||
| 249 | + } | ||
| 250 | + | ||
| 216 | @Override | 251 | @Override |
| 217 | public int hashCode() { | 252 | public int hashCode() { |
| 218 | return Objects.hash(floaingtIp, router, routerInterface, portPair, | 253 | return Objects.hash(floaingtIp, router, routerInterface, portPair, |
| 219 | - portPairGroup, flowClassifier, portChain); | 254 | + portPairGroup, flowClassifier, portChain, virtualPort); |
| 220 | } | 255 | } |
| 221 | 256 | ||
| 222 | @Override | 257 | @Override |
| ... | @@ -232,7 +267,8 @@ public class VtnRscEventFeedback { | ... | @@ -232,7 +267,8 @@ public class VtnRscEventFeedback { |
| 232 | && Objects.equals(this.portPair, that.portPair) | 267 | && Objects.equals(this.portPair, that.portPair) |
| 233 | && Objects.equals(this.portPairGroup, that.portPairGroup) | 268 | && Objects.equals(this.portPairGroup, that.portPairGroup) |
| 234 | && Objects.equals(this.flowClassifier, that.flowClassifier) | 269 | && Objects.equals(this.flowClassifier, that.flowClassifier) |
| 235 | - && Objects.equals(this.portChain, that.portChain); | 270 | + && Objects.equals(this.portChain, that.portChain) |
| 271 | + && Objects.equals(this.virtualPort, that.virtualPort); | ||
| 236 | } | 272 | } |
| 237 | return false; | 273 | return false; |
| 238 | } | 274 | } |
| ... | @@ -247,6 +283,7 @@ public class VtnRscEventFeedback { | ... | @@ -247,6 +283,7 @@ public class VtnRscEventFeedback { |
| 247 | .add("portPairGroup", portPairGroup) | 283 | .add("portPairGroup", portPairGroup) |
| 248 | .add("flowClassifier", flowClassifier) | 284 | .add("flowClassifier", flowClassifier) |
| 249 | .add("portChain", portChain) | 285 | .add("portChain", portChain) |
| 286 | + .add("virtualPort", virtualPort) | ||
| 250 | .toString(); | 287 | .toString(); |
| 251 | } | 288 | } |
| 252 | } | 289 | } | ... | ... |
| ... | @@ -97,6 +97,7 @@ public class PortChainManager extends AbstractListenerManager<PortChainEvent, Po | ... | @@ -97,6 +97,7 @@ public class PortChainManager extends AbstractListenerManager<PortChainEvent, Po |
| 97 | @Deactivate | 97 | @Deactivate |
| 98 | public void deactivate() { | 98 | public void deactivate() { |
| 99 | eventDispatcher.removeSink(PortChainEvent.class); | 99 | eventDispatcher.removeSink(PortChainEvent.class); |
| 100 | + portChainStore.removeListener(portChainListener); | ||
| 100 | portChainStore.destroy(); | 101 | portChainStore.destroy(); |
| 101 | log.info("Stopped"); | 102 | log.info("Stopped"); |
| 102 | } | 103 | } | ... | ... |
| ... | @@ -87,6 +87,8 @@ import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService; | ... | @@ -87,6 +87,8 @@ import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService; |
| 87 | import org.onosproject.vtnrsc.service.VtnRscService; | 87 | import org.onosproject.vtnrsc.service.VtnRscService; |
| 88 | import org.onosproject.vtnrsc.subnet.SubnetService; | 88 | import org.onosproject.vtnrsc.subnet.SubnetService; |
| 89 | import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; | 89 | import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; |
| 90 | +import org.onosproject.vtnrsc.virtualport.VirtualPortEvent; | ||
| 91 | +import org.onosproject.vtnrsc.virtualport.VirtualPortListener; | ||
| 90 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; | 92 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
| 91 | import org.slf4j.Logger; | 93 | import org.slf4j.Logger; |
| 92 | 94 | ||
| ... | @@ -112,6 +114,7 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -112,6 +114,7 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
| 112 | private PortPairGroupListener portPairGroupListener = new InnerPortPairGroupListener(); | 114 | private PortPairGroupListener portPairGroupListener = new InnerPortPairGroupListener(); |
| 113 | private FlowClassifierListener flowClassifierListener = new InnerFlowClassifierListener(); | 115 | private FlowClassifierListener flowClassifierListener = new InnerFlowClassifierListener(); |
| 114 | private PortChainListener portChainListener = new InnerPortChainListener(); | 116 | private PortChainListener portChainListener = new InnerPortChainListener(); |
| 117 | + private VirtualPortListener virtualPortListener = new InnerVirtualPortListener(); | ||
| 115 | 118 | ||
| 116 | private EventuallyConsistentMap<TenantId, SegmentationId> l3vniTenantMap; | 119 | private EventuallyConsistentMap<TenantId, SegmentationId> l3vniTenantMap; |
| 117 | private EventuallyConsistentMap<TenantRouter, SegmentationId> l3vniTenantRouterMap; | 120 | private EventuallyConsistentMap<TenantRouter, SegmentationId> l3vniTenantRouterMap; |
| ... | @@ -165,6 +168,7 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -165,6 +168,7 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
| 165 | portPairGroupService.addListener(portPairGroupListener); | 168 | portPairGroupService.addListener(portPairGroupListener); |
| 166 | flowClassifierService.addListener(flowClassifierListener); | 169 | flowClassifierService.addListener(flowClassifierListener); |
| 167 | portChainService.addListener(portChainListener); | 170 | portChainService.addListener(portChainListener); |
| 171 | + virtualPortService.addListener(virtualPortListener); | ||
| 168 | 172 | ||
| 169 | KryoNamespace.Builder serializer = KryoNamespace.newBuilder() | 173 | KryoNamespace.Builder serializer = KryoNamespace.newBuilder() |
| 170 | .register(KryoNamespaces.API) | 174 | .register(KryoNamespaces.API) |
| ... | @@ -205,6 +209,7 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -205,6 +209,7 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
| 205 | portPairGroupService.removeListener(portPairGroupListener); | 209 | portPairGroupService.removeListener(portPairGroupListener); |
| 206 | flowClassifierService.removeListener(flowClassifierListener); | 210 | flowClassifierService.removeListener(flowClassifierListener); |
| 207 | portChainService.removeListener(portChainListener); | 211 | portChainService.removeListener(portChainListener); |
| 212 | + virtualPortService.removeListener(virtualPortListener); | ||
| 208 | 213 | ||
| 209 | l3vniTenantMap.destroy(); | 214 | l3vniTenantMap.destroy(); |
| 210 | l3vniTenantRouterMap.destroy(); | 215 | l3vniTenantRouterMap.destroy(); |
| ... | @@ -401,6 +406,22 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi | ... | @@ -401,6 +406,22 @@ public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscLi |
| 401 | } | 406 | } |
| 402 | } | 407 | } |
| 403 | 408 | ||
| 409 | + private class InnerVirtualPortListener implements VirtualPortListener { | ||
| 410 | + | ||
| 411 | + @Override | ||
| 412 | + public void event(VirtualPortEvent event) { | ||
| 413 | + checkNotNull(event, EVENT_NOT_NULL); | ||
| 414 | + VirtualPort virtualPort = event.subject(); | ||
| 415 | + if (VirtualPortEvent.Type.VIRTUAL_PORT_PUT == event.type()) { | ||
| 416 | + notifyListeners(new VtnRscEvent(VtnRscEvent.Type.VIRTUAL_PORT_PUT, | ||
| 417 | + new VtnRscEventFeedback(virtualPort))); | ||
| 418 | + } else if (VirtualPortEvent.Type.VIRTUAL_PORT_DELETE == event.type()) { | ||
| 419 | + notifyListeners(new VtnRscEvent(VtnRscEvent.Type.VIRTUAL_PORT_DELETE, | ||
| 420 | + new VtnRscEventFeedback(virtualPort))); | ||
| 421 | + } | ||
| 422 | + } | ||
| 423 | + } | ||
| 424 | + | ||
| 404 | @Override | 425 | @Override |
| 405 | public Iterator<Device> getClassifierOfTenant(TenantId tenantId) { | 426 | public Iterator<Device> getClassifierOfTenant(TenantId tenantId) { |
| 406 | checkNotNull(tenantId, TENANTID_NOT_NULL); | 427 | checkNotNull(tenantId, TENANTID_NOT_NULL); | ... | ... |
| 1 | +/* | ||
| 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 | +package org.onosproject.vtnrsc.virtualport; | ||
| 17 | + | ||
| 18 | +import org.onosproject.event.AbstractEvent; | ||
| 19 | +import org.onosproject.vtnrsc.VirtualPort; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * Describes virtual port event. | ||
| 23 | + */ | ||
| 24 | +public class VirtualPortEvent extends AbstractEvent<VirtualPortEvent.Type, VirtualPort> { | ||
| 25 | + /** | ||
| 26 | + * Type of virtual port events. | ||
| 27 | + */ | ||
| 28 | + public enum Type { | ||
| 29 | + /** | ||
| 30 | + * Signifies that virtual port has been created. | ||
| 31 | + */ | ||
| 32 | + VIRTUAL_PORT_PUT, | ||
| 33 | + /** | ||
| 34 | + * Signifies that virtual port has been deleted. | ||
| 35 | + */ | ||
| 36 | + VIRTUAL_PORT_DELETE, | ||
| 37 | + /** | ||
| 38 | + * Signifies that virtual port has been updated. | ||
| 39 | + */ | ||
| 40 | + VIRTUAL_PORT_UPDATE | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * Creates an event of a given type and for the specified virtual port. | ||
| 45 | + * | ||
| 46 | + * @param type virtual port event type | ||
| 47 | + * @param virtualPort virtual port subject | ||
| 48 | + */ | ||
| 49 | + public VirtualPortEvent(Type type, VirtualPort virtualPort) { | ||
| 50 | + super(type, virtualPort); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * Creates an event of a given type and for the specified virtual port. | ||
| 55 | + * | ||
| 56 | + * @param type virtual port event type | ||
| 57 | + * @param virtualPort virtual port subject | ||
| 58 | + * @param time occurrence time | ||
| 59 | + */ | ||
| 60 | + public VirtualPortEvent(Type type, VirtualPort virtualPort, long time) { | ||
| 61 | + super(type, virtualPort, time); | ||
| 62 | + } | ||
| 63 | +} |
apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortListener.java
0 → 100644
| 1 | +/* | ||
| 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 | +package org.onosproject.vtnrsc.virtualport; | ||
| 17 | + | ||
| 18 | +import org.onosproject.event.EventListener; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Entity capable of virtual port related events. | ||
| 22 | + */ | ||
| 23 | +public interface VirtualPortListener extends EventListener<VirtualPortEvent> { | ||
| 24 | + | ||
| 25 | +} |
| ... | @@ -18,6 +18,7 @@ package org.onosproject.vtnrsc.virtualport; | ... | @@ -18,6 +18,7 @@ package org.onosproject.vtnrsc.virtualport; |
| 18 | import java.util.Collection; | 18 | import java.util.Collection; |
| 19 | 19 | ||
| 20 | import org.onlab.packet.IpAddress; | 20 | import org.onlab.packet.IpAddress; |
| 21 | +import org.onosproject.event.ListenerService; | ||
| 21 | import org.onosproject.net.DeviceId; | 22 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.vtnrsc.FixedIp; | 23 | import org.onosproject.vtnrsc.FixedIp; |
| 23 | import org.onosproject.vtnrsc.TenantId; | 24 | import org.onosproject.vtnrsc.TenantId; |
| ... | @@ -28,7 +29,7 @@ import org.onosproject.vtnrsc.VirtualPortId; | ... | @@ -28,7 +29,7 @@ import org.onosproject.vtnrsc.VirtualPortId; |
| 28 | /** | 29 | /** |
| 29 | * Service for interacting with the inventory of virtualPort. | 30 | * Service for interacting with the inventory of virtualPort. |
| 30 | */ | 31 | */ |
| 31 | -public interface VirtualPortService { | 32 | +public interface VirtualPortService extends ListenerService<VirtualPortEvent, VirtualPortListener> { |
| 32 | /** | 33 | /** |
| 33 | * Returns if the virtualPort is existed. | 34 | * Returns if the virtualPort is existed. |
| 34 | * | 35 | * | ... | ... |
| ... | @@ -18,12 +18,10 @@ package org.onosproject.vtnrsc.virtualport.impl; | ... | @@ -18,12 +18,10 @@ package org.onosproject.vtnrsc.virtualport.impl; |
| 18 | import static com.google.common.base.Preconditions.checkNotNull; | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | 19 | ||
| 20 | import java.util.ArrayList; | 20 | import java.util.ArrayList; |
| 21 | -import java.util.Arrays; | ||
| 22 | import java.util.Collection; | 21 | import java.util.Collection; |
| 23 | import java.util.Collections; | 22 | import java.util.Collections; |
| 24 | import java.util.Iterator; | 23 | import java.util.Iterator; |
| 25 | import java.util.List; | 24 | import java.util.List; |
| 26 | -import java.util.Map; | ||
| 27 | import java.util.stream.Collectors; | 25 | import java.util.stream.Collectors; |
| 28 | 26 | ||
| 29 | import org.apache.felix.scr.annotations.Activate; | 27 | import org.apache.felix.scr.annotations.Activate; |
| ... | @@ -33,12 +31,18 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -33,12 +31,18 @@ import org.apache.felix.scr.annotations.Reference; |
| 33 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 31 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 34 | import org.apache.felix.scr.annotations.Service; | 32 | import org.apache.felix.scr.annotations.Service; |
| 35 | import org.onlab.packet.IpAddress; | 33 | import org.onlab.packet.IpAddress; |
| 34 | +import org.onlab.util.KryoNamespace; | ||
| 36 | import org.onosproject.core.ApplicationId; | 35 | import org.onosproject.core.ApplicationId; |
| 37 | import org.onosproject.core.CoreService; | 36 | import org.onosproject.core.CoreService; |
| 37 | +import org.onosproject.event.AbstractListenerManager; | ||
| 38 | import org.onosproject.net.DeviceId; | 38 | import org.onosproject.net.DeviceId; |
| 39 | import org.onosproject.store.serializers.KryoNamespaces; | 39 | import org.onosproject.store.serializers.KryoNamespaces; |
| 40 | -import org.onosproject.store.service.Serializer; | 40 | +import org.onosproject.store.service.EventuallyConsistentMap; |
| 41 | +import org.onosproject.store.service.EventuallyConsistentMapEvent; | ||
| 42 | +import org.onosproject.store.service.EventuallyConsistentMapListener; | ||
| 43 | +import org.onosproject.store.service.MultiValuedTimestamp; | ||
| 41 | import org.onosproject.store.service.StorageService; | 44 | import org.onosproject.store.service.StorageService; |
| 45 | +import org.onosproject.store.service.WallClockTimestamp; | ||
| 42 | import org.onosproject.vtnrsc.AllowedAddressPair; | 46 | import org.onosproject.vtnrsc.AllowedAddressPair; |
| 43 | import org.onosproject.vtnrsc.BindingHostId; | 47 | import org.onosproject.vtnrsc.BindingHostId; |
| 44 | import org.onosproject.vtnrsc.DefaultVirtualPort; | 48 | import org.onosproject.vtnrsc.DefaultVirtualPort; |
| ... | @@ -50,6 +54,8 @@ import org.onosproject.vtnrsc.TenantNetworkId; | ... | @@ -50,6 +54,8 @@ import org.onosproject.vtnrsc.TenantNetworkId; |
| 50 | import org.onosproject.vtnrsc.VirtualPort; | 54 | import org.onosproject.vtnrsc.VirtualPort; |
| 51 | import org.onosproject.vtnrsc.VirtualPortId; | 55 | import org.onosproject.vtnrsc.VirtualPortId; |
| 52 | import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; | 56 | import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; |
| 57 | +import org.onosproject.vtnrsc.virtualport.VirtualPortEvent; | ||
| 58 | +import org.onosproject.vtnrsc.virtualport.VirtualPortListener; | ||
| 53 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; | 59 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
| 54 | import org.slf4j.Logger; | 60 | import org.slf4j.Logger; |
| 55 | import org.slf4j.LoggerFactory; | 61 | import org.slf4j.LoggerFactory; |
| ... | @@ -59,7 +65,8 @@ import org.slf4j.LoggerFactory; | ... | @@ -59,7 +65,8 @@ import org.slf4j.LoggerFactory; |
| 59 | */ | 65 | */ |
| 60 | @Component(immediate = true) | 66 | @Component(immediate = true) |
| 61 | @Service | 67 | @Service |
| 62 | -public class VirtualPortManager implements VirtualPortService { | 68 | +public class VirtualPortManager extends AbstractListenerManager<VirtualPortEvent, VirtualPortListener> |
| 69 | +implements VirtualPortService { | ||
| 63 | 70 | ||
| 64 | private final Logger log = LoggerFactory.getLogger(getClass()); | 71 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 65 | 72 | ||
| ... | @@ -73,8 +80,9 @@ public class VirtualPortManager implements VirtualPortService { | ... | @@ -73,8 +80,9 @@ public class VirtualPortManager implements VirtualPortService { |
| 73 | private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null"; | 80 | private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null"; |
| 74 | private static final String FIXEDIP_NOT_NULL = "FixedIp cannot be null"; | 81 | private static final String FIXEDIP_NOT_NULL = "FixedIp cannot be null"; |
| 75 | private static final String IP_NOT_NULL = "Ip cannot be null"; | 82 | private static final String IP_NOT_NULL = "Ip cannot be null"; |
| 83 | + private static final String EVENT_NOT_NULL = "event cannot be null"; | ||
| 76 | 84 | ||
| 77 | - protected Map<VirtualPortId, VirtualPort> vPortStore; | 85 | + protected EventuallyConsistentMap<VirtualPortId, VirtualPort> vPortStore; |
| 78 | protected ApplicationId appId; | 86 | protected ApplicationId appId; |
| 79 | 87 | ||
| 80 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 88 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| ... | @@ -86,28 +94,35 @@ public class VirtualPortManager implements VirtualPortService { | ... | @@ -86,28 +94,35 @@ public class VirtualPortManager implements VirtualPortService { |
| 86 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 94 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 87 | protected CoreService coreService; | 95 | protected CoreService coreService; |
| 88 | 96 | ||
| 97 | + private EventuallyConsistentMapListener<VirtualPortId, VirtualPort> virtualPortListener = | ||
| 98 | + new InnerVirtualPortStoreListener(); | ||
| 99 | + | ||
| 89 | @Activate | 100 | @Activate |
| 90 | public void activate() { | 101 | public void activate() { |
| 91 | 102 | ||
| 92 | appId = coreService.registerApplication(VTNRSC_APP); | 103 | appId = coreService.registerApplication(VTNRSC_APP); |
| 93 | 104 | ||
| 94 | - vPortStore = storageService.<VirtualPortId, VirtualPort>consistentMapBuilder() | 105 | + eventDispatcher.addSink(VirtualPortEvent.class, listenerRegistry); |
| 106 | + | ||
| 107 | + vPortStore = storageService.<VirtualPortId, VirtualPort>eventuallyConsistentMapBuilder() | ||
| 95 | .withName(VIRTUALPORT) | 108 | .withName(VIRTUALPORT) |
| 96 | - .withApplicationId(appId) | 109 | + .withSerializer(KryoNamespace.newBuilder().register(KryoNamespaces.API) |
| 97 | - .withPurgeOnUninstall() | 110 | + .register(MultiValuedTimestamp.class) |
| 98 | - .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API), | 111 | + .register(VirtualPortId.class, |
| 99 | - VirtualPortId.class, | 112 | + TenantNetworkId.class, |
| 100 | - TenantNetworkId.class, | 113 | + VirtualPort.State.class, |
| 101 | - VirtualPort.State.class, | 114 | + TenantId.class, |
| 102 | - TenantId.class, | 115 | + AllowedAddressPair.class, |
| 103 | - AllowedAddressPair.class, | 116 | + FixedIp.class, |
| 104 | - FixedIp.class, | 117 | + BindingHostId.class, |
| 105 | - BindingHostId.class, | 118 | + SecurityGroup.class, |
| 106 | - SecurityGroup.class, | 119 | + SubnetId.class, |
| 107 | - SubnetId.class, | 120 | + IpAddress.class, |
| 108 | - IpAddress.class, | 121 | + DefaultVirtualPort.class)) |
| 109 | - DefaultVirtualPort.class)) | 122 | + .withTimestampProvider((k, v) ->new WallClockTimestamp()) |
| 110 | - .build().asJavaMap(); | 123 | + .build(); |
| 124 | + | ||
| 125 | + vPortStore.addListener(virtualPortListener); | ||
| 111 | log.info("Started"); | 126 | log.info("Started"); |
| 112 | } | 127 | } |
| 113 | 128 | ||
| ... | @@ -246,4 +261,35 @@ public class VirtualPortManager implements VirtualPortService { | ... | @@ -246,4 +261,35 @@ public class VirtualPortManager implements VirtualPortService { |
| 246 | return true; | 261 | return true; |
| 247 | } | 262 | } |
| 248 | 263 | ||
| 264 | + private class InnerVirtualPortStoreListener | ||
| 265 | + implements | ||
| 266 | + EventuallyConsistentMapListener<VirtualPortId, VirtualPort> { | ||
| 267 | + | ||
| 268 | + @Override | ||
| 269 | + public void event(EventuallyConsistentMapEvent<VirtualPortId, VirtualPort> event) { | ||
| 270 | + checkNotNull(event, EVENT_NOT_NULL); | ||
| 271 | + log.info("virtual port event raised"); | ||
| 272 | + VirtualPort virtualPort = event.value(); | ||
| 273 | + if (EventuallyConsistentMapEvent.Type.PUT == event.type()) { | ||
| 274 | + notifyListeners(new VirtualPortEvent( | ||
| 275 | + VirtualPortEvent.Type.VIRTUAL_PORT_PUT, | ||
| 276 | + virtualPort)); | ||
| 277 | + } | ||
| 278 | + if (EventuallyConsistentMapEvent.Type.REMOVE == event.type()) { | ||
| 279 | + notifyListeners(new VirtualPortEvent( | ||
| 280 | + VirtualPortEvent.Type.VIRTUAL_PORT_DELETE, | ||
| 281 | + virtualPort)); | ||
| 282 | + } | ||
| 283 | + } | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + /** | ||
| 287 | + * Notifies specify event to all listeners. | ||
| 288 | + * | ||
| 289 | + * @param event virtual port event | ||
| 290 | + */ | ||
| 291 | + private void notifyListeners(VirtualPortEvent event) { | ||
| 292 | + checkNotNull(event, EVENT_NOT_NULL); | ||
| 293 | + post(event); | ||
| 294 | + } | ||
| 249 | } | 295 | } | ... | ... |
| ... | @@ -50,7 +50,7 @@ import com.google.common.collect.ImmutableSet; | ... | @@ -50,7 +50,7 @@ import com.google.common.collect.ImmutableSet; |
| 50 | */ | 50 | */ |
| 51 | public class SfcViewMessageHandler extends UiMessageHandler { | 51 | public class SfcViewMessageHandler extends UiMessageHandler { |
| 52 | 52 | ||
| 53 | - private static final String SLASH = " ; "; | 53 | + private static final String SLASH = " -> "; |
| 54 | private static final String NONE = "none"; | 54 | private static final String NONE = "none"; |
| 55 | private static final String SFCTYPE = "Service Function Chain"; | 55 | private static final String SFCTYPE = "Service Function Chain"; |
| 56 | 56 | ||
| ... | @@ -61,13 +61,13 @@ public class SfcViewMessageHandler extends UiMessageHandler { | ... | @@ -61,13 +61,13 @@ public class SfcViewMessageHandler extends UiMessageHandler { |
| 61 | private static final String ID = "id"; | 61 | private static final String ID = "id"; |
| 62 | private static final String STATE = "_iconid_state"; | 62 | private static final String STATE = "_iconid_state"; |
| 63 | private static final String PORTCHAINNAME = "portChainName"; | 63 | private static final String PORTCHAINNAME = "portChainName"; |
| 64 | - private static final String HOSTS = "hosts"; | 64 | + private static final String SFS = "sfs"; |
| 65 | private static final String TYPE = "type"; | 65 | private static final String TYPE = "type"; |
| 66 | private static final String SRCIP = "srcIp"; | 66 | private static final String SRCIP = "srcIp"; |
| 67 | private static final String DSTIP = "dstIp"; | 67 | private static final String DSTIP = "dstIp"; |
| 68 | 68 | ||
| 69 | private static final String[] COL_IDS = { | 69 | private static final String[] COL_IDS = { |
| 70 | - ID, STATE, PORTCHAINNAME, HOSTS, TYPE, SRCIP, DSTIP | 70 | + ID, STATE, PORTCHAINNAME, SFS, TYPE, SRCIP, DSTIP |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| 73 | private static final String ICON_ID_ONLINE = "active"; | 73 | private static final String ICON_ID_ONLINE = "active"; |
| ... | @@ -116,7 +116,7 @@ public class SfcViewMessageHandler extends UiMessageHandler { | ... | @@ -116,7 +116,7 @@ public class SfcViewMessageHandler extends UiMessageHandler { |
| 116 | row.cell(ID, pchain.portChainId().value().toString()) | 116 | row.cell(ID, pchain.portChainId().value().toString()) |
| 117 | .cell(STATE, sfcState(vpList)) | 117 | .cell(STATE, sfcState(vpList)) |
| 118 | .cell(PORTCHAINNAME, pchain.name()) | 118 | .cell(PORTCHAINNAME, pchain.name()) |
| 119 | - .cell(HOSTS, sfcHosts(vpList)) | 119 | + .cell(SFS, sfcHosts(vpList)) |
| 120 | .cell(TYPE, SFCTYPE) | 120 | .cell(TYPE, SFCTYPE) |
| 121 | .cell(SRCIP, portChainIpRange.srcip()) | 121 | .cell(SRCIP, portChainIpRange.srcip()) |
| 122 | .cell(DSTIP, portChainIpRange.dstip()); | 122 | .cell(DSTIP, portChainIpRange.dstip()); | ... | ... |
| ... | @@ -32,7 +32,7 @@ | ... | @@ -32,7 +32,7 @@ |
| 32 | <tr> | 32 | <tr> |
| 33 | <td colId="_iconid_state" class="table-icon" sortable></td> | 33 | <td colId="_iconid_state" class="table-icon" sortable></td> |
| 34 | <td colId="portChainName" sortable>PortChainName </td> | 34 | <td colId="portChainName" sortable>PortChainName </td> |
| 35 | - <td colId="hosts" sortable>Hosts </td> | 35 | + <td colId="sfs" sortable>Sfs </td> |
| 36 | <td colId="type" sortable>Type </td> | 36 | <td colId="type" sortable>Type </td> |
| 37 | <td colId="srcIp" sortable>Source IP Prefix </td> | 37 | <td colId="srcIp" sortable>Source IP Prefix </td> |
| 38 | <td colId="dstIp" sortable>Destination IP Prefix </td> | 38 | <td colId="dstIp" sortable>Destination IP Prefix </td> |
| ... | @@ -54,7 +54,7 @@ | ... | @@ -54,7 +54,7 @@ |
| 54 | <div icon icon-id="{{sfc._iconid_state}}"></div> | 54 | <div icon icon-id="{{sfc._iconid_state}}"></div> |
| 55 | </td> | 55 | </td> |
| 56 | <td>{{sfc.portChainName}}</td> | 56 | <td>{{sfc.portChainName}}</td> |
| 57 | - <td>{{sfc.hosts}}</td> | 57 | + <td>{{sfc.sfs}}</td> |
| 58 | <td>{{sfc.type}}</td> | 58 | <td>{{sfc.type}}</td> |
| 59 | <td>{{sfc.srcIp}}</td> | 59 | <td>{{sfc.srcIp}}</td> |
| 60 | <td>{{sfc.dstIp}}</td> | 60 | <td>{{sfc.dstIp}}</td> | ... | ... |
| ... | @@ -38,7 +38,6 @@ public class DefaultMoveExtensionTreatment extends AbstractExtension | ... | @@ -38,7 +38,6 @@ public class DefaultMoveExtensionTreatment extends AbstractExtension |
| 38 | private ExtensionTreatmentType type; | 38 | private ExtensionTreatmentType type; |
| 39 | 39 | ||
| 40 | private final KryoNamespace appKryo = new KryoNamespace.Builder() | 40 | private final KryoNamespace appKryo = new KryoNamespace.Builder() |
| 41 | - .register(byte[].class) | ||
| 42 | .register(Map.class) | 41 | .register(Map.class) |
| 43 | .build("DefaultMoveExtensionTreatment"); | 42 | .build("DefaultMoveExtensionTreatment"); |
| 44 | 43 | ... | ... |
-
Please register or login to post a comment