Committed by
Gerrit Code Review
[ONOS-4159] PCE Web GUI implementation
Change-Id: Idcad25df8b2eb947d4829232822f0e2e5b5af7a8
Showing
41 changed files
with
1216 additions
and
96 deletions
apps/pce/app/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2016-present Open Networking Laboratory | ||
| 4 | + ~ | ||
| 5 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 6 | + ~ you may not use this file except in compliance with the License. | ||
| 7 | + ~ You may obtain a copy of the License at | ||
| 8 | + ~ | ||
| 9 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| 10 | + ~ | ||
| 11 | + ~ Unless required by applicable law or agreed to in writing, software | ||
| 12 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
| 13 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 14 | + ~ See the License for the specific language governing permissions and | ||
| 15 | + ~ limitations under the License. | ||
| 16 | + --> | ||
| 17 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 18 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 19 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 20 | + <modelVersion>4.0.0</modelVersion> | ||
| 21 | + <parent> | ||
| 22 | + <groupId>org.onosproject</groupId> | ||
| 23 | + <artifactId>onos-pce</artifactId> | ||
| 24 | + <version>1.6.0-SNAPSHOT</version> | ||
| 25 | + <relativePath>../pom.xml</relativePath> | ||
| 26 | + </parent> | ||
| 27 | + <artifactId>onos-app-pce</artifactId> | ||
| 28 | + <packaging>bundle</packaging> | ||
| 29 | + | ||
| 30 | + <description>PCE as central controller</description> | ||
| 31 | + | ||
| 32 | + <properties> | ||
| 33 | + <onos.app.name>org.onosproject.pce</onos.app.name> | ||
| 34 | + <onos.app.category>default</onos.app.category> | ||
| 35 | + <onos.app.url>http://onosproject.org</onos.app.url> | ||
| 36 | + <onos.app.readme>PCE as central controller.</onos.app.readme> | ||
| 37 | + </properties> | ||
| 38 | + <dependencies> | ||
| 39 | + <dependency> | ||
| 40 | + <groupId>org.osgi</groupId> | ||
| 41 | + <artifactId>org.osgi.compendium</artifactId> | ||
| 42 | + </dependency> | ||
| 43 | + | ||
| 44 | + <dependency> | ||
| 45 | + <groupId>org.onosproject</groupId> | ||
| 46 | + <artifactId>onos-cli</artifactId> | ||
| 47 | + <version>${project.version}</version> | ||
| 48 | + </dependency> | ||
| 49 | + | ||
| 50 | + <dependency> | ||
| 51 | + <groupId>org.apache.karaf.shell</groupId> | ||
| 52 | + <artifactId>org.apache.karaf.shell.console</artifactId> | ||
| 53 | + <scope>compile</scope> | ||
| 54 | + </dependency> | ||
| 55 | + | ||
| 56 | + <dependency> | ||
| 57 | + <groupId>org.onosproject</groupId> | ||
| 58 | + <artifactId>onlab-junit</artifactId> | ||
| 59 | + <scope>test</scope> | ||
| 60 | + </dependency> | ||
| 61 | + <dependency> | ||
| 62 | + <groupId>org.onosproject</groupId> | ||
| 63 | + <artifactId>onos-core-serializers</artifactId> | ||
| 64 | + <version>${project.version}</version> | ||
| 65 | + </dependency> | ||
| 66 | + <dependency> | ||
| 67 | + <groupId>com.google.guava</groupId> | ||
| 68 | + <artifactId>guava-testlib</artifactId> | ||
| 69 | + <scope>test</scope> | ||
| 70 | + </dependency> | ||
| 71 | + <dependency> | ||
| 72 | + <groupId>org.easymock</groupId> | ||
| 73 | + <artifactId>easymock</artifactId> | ||
| 74 | + <scope>test</scope> | ||
| 75 | + </dependency> | ||
| 76 | + <dependency> | ||
| 77 | + <groupId>org.onosproject</groupId> | ||
| 78 | + <artifactId>onlab-osgi</artifactId> | ||
| 79 | + <classifier>tests</classifier> | ||
| 80 | + <scope>test</scope> | ||
| 81 | + </dependency> | ||
| 82 | + <dependency> | ||
| 83 | + <groupId>org.onosproject</groupId> | ||
| 84 | + <artifactId>onos-api</artifactId> | ||
| 85 | + <scope>test</scope> | ||
| 86 | + <classifier>tests</classifier> | ||
| 87 | + </dependency> | ||
| 88 | + <dependency> | ||
| 89 | + <groupId>org.onosproject</groupId> | ||
| 90 | + <artifactId>onos-rest</artifactId> | ||
| 91 | + <version>${project.version}</version> | ||
| 92 | + </dependency> | ||
| 93 | + <dependency> | ||
| 94 | + <groupId>org.onosproject</groupId> | ||
| 95 | + <artifactId>onlab-rest</artifactId> | ||
| 96 | + <version>${project.version}</version> | ||
| 97 | + </dependency> | ||
| 98 | + <dependency> | ||
| 99 | + <groupId>javax.ws.rs</groupId> | ||
| 100 | + <artifactId>jsr311-api</artifactId> | ||
| 101 | + <version>1.1.1</version> | ||
| 102 | + </dependency> | ||
| 103 | + <dependency> | ||
| 104 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
| 105 | + <artifactId>jackson-databind</artifactId> | ||
| 106 | + </dependency> | ||
| 107 | + <dependency> | ||
| 108 | + <groupId>com.fasterxml.jackson.core</groupId> | ||
| 109 | + <artifactId>jackson-annotations</artifactId> | ||
| 110 | + </dependency> | ||
| 111 | + <dependency> | ||
| 112 | + <groupId>org.glassfish.jersey.containers</groupId> | ||
| 113 | + <artifactId>jersey-container-servlet</artifactId> | ||
| 114 | + </dependency> | ||
| 115 | + <dependency> | ||
| 116 | + <groupId>org.glassfish.jersey.test-framework</groupId> | ||
| 117 | + <artifactId>jersey-test-framework-core</artifactId> | ||
| 118 | + <scope>test</scope> | ||
| 119 | + </dependency> | ||
| 120 | + <dependency> | ||
| 121 | + <groupId>org.glassfish.jersey.test-framework.providers</groupId> | ||
| 122 | + <artifactId>jersey-test-framework-provider-jetty</artifactId> | ||
| 123 | + <scope>test</scope> | ||
| 124 | + </dependency> | ||
| 125 | + <dependency> | ||
| 126 | + <groupId>org.onosproject</groupId> | ||
| 127 | + <artifactId>onos-incubator-api</artifactId> | ||
| 128 | + <version>${project.version}</version> | ||
| 129 | + </dependency> | ||
| 130 | + <dependency> | ||
| 131 | + <groupId>org.onosproject</groupId> | ||
| 132 | + <artifactId>onlab-misc</artifactId> | ||
| 133 | + <version>${project.version}</version> | ||
| 134 | + </dependency> | ||
| 135 | + </dependencies> | ||
| 136 | +</project> |
apps/pce/pceweb/app.png
0 → 100644
23.3 KB
apps/pce/pceweb/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2015-2016 Open Networking Laboratory | ||
| 4 | + ~ | ||
| 5 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 6 | + ~ you may not use this file except in compliance with the License. | ||
| 7 | + ~ You may obtain a copy of the License at | ||
| 8 | + ~ | ||
| 9 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| 10 | + ~ | ||
| 11 | + ~ Unless required by applicable law or agreed to in writing, software | ||
| 12 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
| 13 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 14 | + ~ See the License for the specific language governing permissions and | ||
| 15 | + ~ limitations under the License. | ||
| 16 | + --> | ||
| 17 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 18 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 19 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 20 | + <modelVersion>4.0.0</modelVersion> | ||
| 21 | + | ||
| 22 | + <parent> | ||
| 23 | + <groupId>org.onosproject</groupId> | ||
| 24 | + <artifactId>onos-pce</artifactId> | ||
| 25 | + <version>1.6.0-SNAPSHOT</version> | ||
| 26 | + <relativePath>../pom.xml</relativePath> | ||
| 27 | + </parent> | ||
| 28 | + | ||
| 29 | + <artifactId>onos-app-pceweb</artifactId> | ||
| 30 | + <packaging>bundle</packaging> | ||
| 31 | + | ||
| 32 | + <description>PCE web application</description> | ||
| 33 | + | ||
| 34 | + <dependencies> | ||
| 35 | + <dependency> | ||
| 36 | + <groupId>org.apache.karaf.shell</groupId> | ||
| 37 | + <artifactId>org.apache.karaf.shell.console</artifactId> | ||
| 38 | + <scope>compile</scope> | ||
| 39 | + </dependency> | ||
| 40 | + | ||
| 41 | + <dependency> | ||
| 42 | + <groupId>org.onosproject</groupId> | ||
| 43 | + <artifactId>onos-cli</artifactId> | ||
| 44 | + <version>${project.version}</version> | ||
| 45 | + </dependency> | ||
| 46 | + </dependencies> | ||
| 47 | + | ||
| 48 | + <properties> | ||
| 49 | + <onos.app.name>org.onosproject.pceweb</onos.app.name> | ||
| 50 | + <onos.app.title>PCE web application</onos.app.title> | ||
| 51 | + <onos.app.category>Utility</onos.app.category> | ||
| 52 | + <onos.app.url>https://wiki.onosproject.org/display/ONOS/</onos.app.url> | ||
| 53 | + <onos.app.readme> | ||
| 54 | + Allows the user to visualize different types of paths between | ||
| 55 | + network entities such as routers. | ||
| 56 | + LSP type stateful PCE, PCECC and PCECC SR. | ||
| 57 | + </onos.app.readme> | ||
| 58 | + </properties> | ||
| 59 | + | ||
| 60 | +</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 | + | ||
| 17 | +package org.onosproject.pceweb; | ||
| 18 | + | ||
| 19 | +import org.onosproject.net.Link; | ||
| 20 | +import org.onosproject.net.LinkKey; | ||
| 21 | +import org.onosproject.ui.topo.BiLink; | ||
| 22 | +import org.onosproject.ui.topo.LinkHighlight; | ||
| 23 | +import org.onosproject.ui.topo.LinkHighlight.Flavor; | ||
| 24 | + | ||
| 25 | +import java.util.Set; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * Provides the link color highlight mechanism for given links. | ||
| 29 | + */ | ||
| 30 | +public class PceWebLink extends BiLink { | ||
| 31 | + | ||
| 32 | + private boolean primary; | ||
| 33 | + private boolean secondary; | ||
| 34 | + /** | ||
| 35 | + * Initialize the Link key attributes. | ||
| 36 | + */ | ||
| 37 | + public PceWebLink(LinkKey key, Link link) { | ||
| 38 | + super(key, link); | ||
| 39 | + } | ||
| 40 | + /** | ||
| 41 | + * Highlight the color of given selected links. | ||
| 42 | + */ | ||
| 43 | + public void computeHilight(Set<Link> selectedLinks, Set<Link> allLinks) { | ||
| 44 | + primary = selectedLinks.contains(this.one()) || | ||
| 45 | + (two() != null && selectedLinks.contains(two())); | ||
| 46 | + secondary = allLinks.contains(this.one()) || | ||
| 47 | + (two() != null && allLinks.contains(two())); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public LinkHighlight highlight(Enum<?> anEnum) { | ||
| 52 | + Flavor flavor = primary ? Flavor.PRIMARY_HIGHLIGHT : | ||
| 53 | + (secondary ? Flavor.SECONDARY_HIGHLIGHT : Flavor.NO_HIGHLIGHT); | ||
| 54 | + return new LinkHighlight(this.linkId(), flavor); | ||
| 55 | + } | ||
| 56 | +} |
| 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 | + | ||
| 17 | +package org.onosproject.pceweb; | ||
| 18 | + | ||
| 19 | +import org.onosproject.net.Link; | ||
| 20 | +import org.onosproject.net.LinkKey; | ||
| 21 | +import org.onosproject.ui.topo.BiLinkMap; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * Our concrete link map. | ||
| 25 | + */ | ||
| 26 | +public class PceWebLinkMap extends BiLinkMap<PceWebLink> { | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + protected PceWebLink create(LinkKey linkKey, Link link) { | ||
| 30 | + return new PceWebLink(linkKey, link); | ||
| 31 | + } | ||
| 32 | +} |
| 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 | + | ||
| 17 | +package org.onosproject.pceweb; | ||
| 18 | + | ||
| 19 | +import com.google.common.collect.ImmutableList; | ||
| 20 | +import org.apache.felix.scr.annotations.Activate; | ||
| 21 | +import org.apache.felix.scr.annotations.Component; | ||
| 22 | +import org.apache.felix.scr.annotations.Deactivate; | ||
| 23 | +import org.apache.felix.scr.annotations.Reference; | ||
| 24 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 25 | +import org.onosproject.ui.UiExtension; | ||
| 26 | +import org.onosproject.ui.UiExtensionService; | ||
| 27 | +import org.onosproject.ui.UiMessageHandlerFactory; | ||
| 28 | +import org.onosproject.ui.UiTopoOverlayFactory; | ||
| 29 | +import org.onosproject.ui.UiView; | ||
| 30 | +import org.onosproject.ui.UiViewHidden; | ||
| 31 | +import org.slf4j.Logger; | ||
| 32 | +import org.slf4j.LoggerFactory; | ||
| 33 | + | ||
| 34 | +import java.util.List; | ||
| 35 | + | ||
| 36 | +/** | ||
| 37 | + * Skeletal ONOS UI Topology-Overlay application component. | ||
| 38 | + */ | ||
| 39 | +@Component(immediate = true) | ||
| 40 | +public class PceWebTopovComponent { | ||
| 41 | + | ||
| 42 | + private static final ClassLoader CL = PceWebTopovComponent.class.getClassLoader(); | ||
| 43 | + private static final String VIEW_ID = "pcewebTopov"; | ||
| 44 | + | ||
| 45 | + private final Logger log = LoggerFactory.getLogger(getClass()); | ||
| 46 | + | ||
| 47 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 48 | + protected UiExtensionService uiExtensionService; | ||
| 49 | + | ||
| 50 | + // List of application views | ||
| 51 | + private final List<UiView> uiViews = ImmutableList.of( | ||
| 52 | + new UiViewHidden(VIEW_ID) | ||
| 53 | + ); | ||
| 54 | + | ||
| 55 | + // Factory for UI message handlers | ||
| 56 | + private final UiMessageHandlerFactory messageHandlerFactory = | ||
| 57 | + () -> ImmutableList.of( | ||
| 58 | + new PceWebTopovMessageHandler() | ||
| 59 | + ); | ||
| 60 | + | ||
| 61 | + // Factory for UI topology overlays | ||
| 62 | + private final UiTopoOverlayFactory topoOverlayFactory = | ||
| 63 | + () -> ImmutableList.of( | ||
| 64 | + new PceWebTopovOverlay() | ||
| 65 | + ); | ||
| 66 | + | ||
| 67 | + // Application UI extension | ||
| 68 | + protected UiExtension extension = | ||
| 69 | + new UiExtension.Builder(CL, uiViews) | ||
| 70 | + .resourcePath(VIEW_ID) | ||
| 71 | + .messageHandlerFactory(messageHandlerFactory) | ||
| 72 | + .topoOverlayFactory(topoOverlayFactory) | ||
| 73 | + .build(); | ||
| 74 | + | ||
| 75 | + @Activate | ||
| 76 | + protected void activate() { | ||
| 77 | + uiExtensionService.register(extension); | ||
| 78 | + log.info("Started"); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Deactivate | ||
| 82 | + protected void deactivate() { | ||
| 83 | + uiExtensionService.unregister(extension); | ||
| 84 | + log.info("Stopped"); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | +} |
| 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 | + | ||
| 17 | +package org.onosproject.pceweb; | ||
| 18 | + | ||
| 19 | +import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +import com.google.common.collect.ImmutableSet; | ||
| 23 | +import org.onlab.osgi.ServiceDirectory; | ||
| 24 | +import org.onosproject.net.DeviceId; | ||
| 25 | +import org.onosproject.net.DisjointPath; | ||
| 26 | +import org.onosproject.net.ElementId; | ||
| 27 | +import org.onosproject.net.HostId; | ||
| 28 | +import org.onosproject.net.Link; | ||
| 29 | +import org.onosproject.net.Path; | ||
| 30 | +import org.onosproject.net.device.DeviceService; | ||
| 31 | +import org.onosproject.net.topology.LinkWeight; | ||
| 32 | +import org.onosproject.net.topology.PathService; | ||
| 33 | +import org.onosproject.net.topology.TopologyService; | ||
| 34 | +import org.onosproject.ui.RequestHandler; | ||
| 35 | +import org.onosproject.ui.UiConnection; | ||
| 36 | +import org.onosproject.ui.UiMessageHandler; | ||
| 37 | +import org.onosproject.ui.topo.DeviceHighlight; | ||
| 38 | +import org.onosproject.ui.topo.Highlights; | ||
| 39 | +import org.onosproject.ui.topo.HostHighlight; | ||
| 40 | +import org.onosproject.ui.topo.NodeBadge; | ||
| 41 | +import org.onosproject.ui.topo.TopoJson; | ||
| 42 | + | ||
| 43 | +import org.slf4j.Logger; | ||
| 44 | +import org.slf4j.LoggerFactory; | ||
| 45 | + | ||
| 46 | +import java.util.Collection; | ||
| 47 | +import java.util.List; | ||
| 48 | +import java.util.Set; | ||
| 49 | + | ||
| 50 | +/** | ||
| 51 | + * ONOS UI PCE WEB Topology-Overlay message handler. | ||
| 52 | + */ | ||
| 53 | +public class PceWebTopovMessageHandler extends UiMessageHandler { | ||
| 54 | + | ||
| 55 | + private static final String PCEWEB_CLEAR = "pceTopovClear"; | ||
| 56 | + private static final String PCEWEB_SET_SRC = "pceTopovSetSrc"; | ||
| 57 | + private static final String PCEWEB_SET_DST = "pceTopovSetDst"; | ||
| 58 | + private static final String PCEWEB_SET_PATH = "pceTopovSetMode"; | ||
| 59 | + | ||
| 60 | + private static final String ID = "id"; | ||
| 61 | + private static final String MODE = "mode"; | ||
| 62 | + private static final String TYPE = "type"; | ||
| 63 | + private static final String SWITCH = "switch"; | ||
| 64 | + private static final String ENDSTATION = "endstation"; | ||
| 65 | + public static final String DST = "Dst"; | ||
| 66 | + public static final String SRC = "Src"; | ||
| 67 | + // Delay for showHighlights event processing on GUI client side to | ||
| 68 | + // account for addLink animation. | ||
| 69 | + public static final int DELAY_MS = 1100; | ||
| 70 | + | ||
| 71 | + private static final String CLASS = "class"; | ||
| 72 | + private static final String UNKNOWN = "unknown"; | ||
| 73 | + private static final String DEVICE = "device"; | ||
| 74 | + | ||
| 75 | + private Set<Link> allPathLinks; | ||
| 76 | + private boolean listenersRemoved; | ||
| 77 | + private LinkWeight linkData; | ||
| 78 | + private int highlightDelay; | ||
| 79 | + | ||
| 80 | + private final Logger log = LoggerFactory.getLogger(getClass()); | ||
| 81 | + | ||
| 82 | + private PathService pathService; | ||
| 83 | + | ||
| 84 | + private ElementId src, dst; | ||
| 85 | + private String srcType, dstType; | ||
| 86 | + private List<Path> paths; | ||
| 87 | + private int pathIndex; | ||
| 88 | + | ||
| 89 | + protected TopologyService topologyService; | ||
| 90 | + protected DeviceService deviceService; | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + @Override | ||
| 94 | + public void init(UiConnection connection, ServiceDirectory directory) { | ||
| 95 | + | ||
| 96 | + super.init(connection, directory); | ||
| 97 | + //TODO: Need add listeners. | ||
| 98 | + //topologyService = directory.get(TopologyService.class); | ||
| 99 | + //addListeners(); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + @Override | ||
| 103 | + protected Collection<RequestHandler> createRequestHandlers() { | ||
| 104 | + return ImmutableSet.of( | ||
| 105 | + new ClearHandler(), | ||
| 106 | + new SetSrcHandler(), | ||
| 107 | + new SetDstHandler(), | ||
| 108 | + new SetPathHandler()); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + // Handler classes | ||
| 112 | + /** | ||
| 113 | + * Handles the 'clear' event received from the client. | ||
| 114 | + */ | ||
| 115 | + private final class ClearHandler extends RequestHandler { | ||
| 116 | + | ||
| 117 | + public ClearHandler() { | ||
| 118 | + super(PCEWEB_CLEAR); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + @Override | ||
| 122 | + public void process(long sid, ObjectNode payload) { | ||
| 123 | + src = null; | ||
| 124 | + dst = null; | ||
| 125 | + sendMessage(TopoJson.highlightsMessage(new Highlights())); | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + /** | ||
| 130 | + * Handles the 'set source' event received from the client. | ||
| 131 | + */ | ||
| 132 | + private final class SetSrcHandler extends RequestHandler { | ||
| 133 | + | ||
| 134 | + public SetSrcHandler() { | ||
| 135 | + super(PCEWEB_SET_SRC); | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + @Override | ||
| 139 | + public void process(long sid, ObjectNode payload) { | ||
| 140 | + log.info("PCE WEB Set source process method invoked"); | ||
| 141 | + String id = string(payload, ID); | ||
| 142 | + src = elementId(id); | ||
| 143 | + srcType = string(payload, TYPE); | ||
| 144 | + if (src.equals(dst)) { | ||
| 145 | + dst = null; | ||
| 146 | + } | ||
| 147 | + sendMessage(TopoJson.highlightsMessage(addBadge(new Highlights(), | ||
| 148 | + srcType, src.toString(), SRC))); | ||
| 149 | + | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + /** | ||
| 154 | + * Handles the 'set destination' event received from the client. | ||
| 155 | + */ | ||
| 156 | + private final class SetDstHandler extends RequestHandler { | ||
| 157 | + | ||
| 158 | + public SetDstHandler() { | ||
| 159 | + super(PCEWEB_SET_DST); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + @Override | ||
| 163 | + public void process(long sid, ObjectNode payload) { | ||
| 164 | + String id = string(payload, ID); | ||
| 165 | + dst = elementId(id); | ||
| 166 | + dstType = string(payload, TYPE); | ||
| 167 | + if (src.equals(dst)) { | ||
| 168 | + src = null; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + sendMessage(TopoJson.highlightsMessage(addBadge(new Highlights(), | ||
| 172 | + dstType, dst.toString(), DST))); | ||
| 173 | + | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + /** | ||
| 178 | + * Handles the 'patchcalculation' event received from the client. | ||
| 179 | + */ | ||
| 180 | + private final class SetPathHandler extends RequestHandler { | ||
| 181 | + | ||
| 182 | + public SetPathHandler() { | ||
| 183 | + super(PCEWEB_SET_PATH); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + @Override | ||
| 187 | + public void process(long sid, ObjectNode payload) { | ||
| 188 | + String mode = string(payload, MODE); | ||
| 189 | + | ||
| 190 | + // TODO: Read user input[constraints] and call the path calculation based on | ||
| 191 | + //given constrainsts. | ||
| 192 | + findAndSendPaths(); | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + // === ------------ | ||
| 197 | + /** | ||
| 198 | + * provides the element id. | ||
| 199 | + */ | ||
| 200 | + private ElementId elementId(String id) { | ||
| 201 | + try { | ||
| 202 | + return DeviceId.deviceId(id); | ||
| 203 | + } catch (IllegalArgumentException e) { | ||
| 204 | + return HostId.hostId(id); | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | + //TODO: Need to pass constraints to this method | ||
| 208 | + private void findAndSendPaths() { | ||
| 209 | + log.info("src={}; dst={};", src, dst); | ||
| 210 | + if (src != null && dst != null) { | ||
| 211 | + //TBD: Need to call pathcalulation API here | ||
| 212 | + hilightAndSendPaths(); | ||
| 213 | + | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + //TODO: The below code is not used. Once get path from PCE app then below code will be use. | ||
| 219 | + // the below code will get path and it will highlight the selected path. | ||
| 220 | + //Currently primary path in use, there is no use of secondary path. | ||
| 221 | + //secondary path need to remove based on path received by PCE app. | ||
| 222 | + private ImmutableSet.Builder<Link> buildPaths( | ||
| 223 | + ImmutableSet.Builder<Link> pathBuilder) { | ||
| 224 | + paths.forEach(path -> path.links().forEach(pathBuilder::add)); | ||
| 225 | + return pathBuilder; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + private ImmutableSet.Builder<Link> buildDisjointPaths( | ||
| 229 | + ImmutableSet.Builder<Link> pathBuilder) { | ||
| 230 | + paths.forEach(path -> { | ||
| 231 | + DisjointPath dp = (DisjointPath) path; | ||
| 232 | + pathBuilder.addAll(dp.primary().links()); | ||
| 233 | + pathBuilder.addAll(dp.backup().links()); | ||
| 234 | + }); | ||
| 235 | + return pathBuilder; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + private void hilightAndSendPaths() { | ||
| 239 | + PceWebLinkMap linkMap = new PceWebLinkMap(); | ||
| 240 | + allPathLinks.forEach(linkMap::add); | ||
| 241 | + | ||
| 242 | + Set<Link> selectedPathLinks; | ||
| 243 | + | ||
| 244 | + selectedPathLinks = paths.isEmpty() ? ImmutableSet.of() | ||
| 245 | + : ImmutableSet.copyOf(paths.get(pathIndex).links()); | ||
| 246 | + | ||
| 247 | + Highlights highlights = new Highlights(); | ||
| 248 | + if (highlightDelay > 0) { | ||
| 249 | + highlights.delay(highlightDelay); | ||
| 250 | + } | ||
| 251 | + for (PceWebLink plink : linkMap.biLinks()) { | ||
| 252 | + plink.computeHilight(selectedPathLinks, allPathLinks); | ||
| 253 | + highlights.add(plink.highlight(null)); | ||
| 254 | + } | ||
| 255 | + if (src != null) { | ||
| 256 | + highlights = addBadge(highlights, srcType, src.toString(), SRC); | ||
| 257 | + } | ||
| 258 | + if (dst != null) { | ||
| 259 | + highlights = addBadge(highlights, dstType, dst.toString(), DST); | ||
| 260 | + } | ||
| 261 | + sendMessage(TopoJson.highlightsMessage(highlights)); | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + private Highlights addBadge(Highlights highlights, String type, | ||
| 265 | + String elemId, String src) { | ||
| 266 | + if (SWITCH.equals(type)) { | ||
| 267 | + highlights = addDeviceBadge(highlights, elemId, src); | ||
| 268 | + } else if (ENDSTATION.equals(type)) { | ||
| 269 | + highlights = addHostBadge(highlights, elemId, src); | ||
| 270 | + } | ||
| 271 | + return highlights; | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + private Highlights addDeviceBadge(Highlights h, String elemId, String type) { | ||
| 275 | + DeviceHighlight dh = new DeviceHighlight(elemId); | ||
| 276 | + dh.setBadge(createBadge(type)); | ||
| 277 | + h.add(dh); | ||
| 278 | + return h; | ||
| 279 | + } | ||
| 280 | + | ||
| 281 | + private Highlights addHostBadge(Highlights h, String elemId, String type) { | ||
| 282 | + HostHighlight hh = new HostHighlight(elemId); | ||
| 283 | + hh.setBadge(createBadge(type)); | ||
| 284 | + h.add(hh); | ||
| 285 | + return h; | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + private NodeBadge createBadge(String type) { | ||
| 289 | + return NodeBadge.text(type); | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + //TODO: Listeners need to add. | ||
| 293 | + //If topology changes then path need to be re calculate. | ||
| 294 | + | ||
| 295 | +} |
| 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 | + | ||
| 17 | +package org.onosproject.pceweb; | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +import org.onosproject.net.AnnotationKeys; | ||
| 21 | +import org.onosproject.net.Annotations; | ||
| 22 | +import org.onosproject.net.Device; | ||
| 23 | +import org.onosproject.net.DeviceId; | ||
| 24 | +import org.onosproject.ui.UiTopoOverlay; | ||
| 25 | +import org.onosproject.ui.topo.ButtonId; | ||
| 26 | +import org.onosproject.ui.topo.PropertyPanel; | ||
| 27 | +import org.onosproject.net.HostId; | ||
| 28 | +import org.onosproject.net.device.DeviceService; | ||
| 29 | +import org.onosproject.ui.topo.TopoConstants.CoreButtons; | ||
| 30 | + | ||
| 31 | +import static org.onosproject.ui.topo.TopoConstants.Properties.*; | ||
| 32 | +import org.onosproject.cli.AbstractShellCommand; | ||
| 33 | + | ||
| 34 | +/** | ||
| 35 | + * PCE WEB topology overlay. | ||
| 36 | + */ | ||
| 37 | +public 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); | ||
| 66 | + log.info("Modify device details called."); | ||
| 67 | + | ||
| 68 | + DeviceService deviceService = AbstractShellCommand.get(DeviceService.class); | ||
| 69 | + | ||
| 70 | + pp.removeAllProps(); | ||
| 71 | + | ||
| 72 | + pp.addButton(SRC_BUTTON).addButton(DST_BUTTON); | ||
| 73 | + | ||
| 74 | + pp.removeButtons(CoreButtons.SHOW_PORT_VIEW) | ||
| 75 | + .removeButtons(CoreButtons.SHOW_GROUP_VIEW) | ||
| 76 | + .removeButtons(CoreButtons.SHOW_METER_VIEW); | ||
| 77 | + | ||
| 78 | + if (deviceService != null) { | ||
| 79 | + | ||
| 80 | + Device device = deviceService.getDevice(deviceId); | ||
| 81 | + Annotations annot = device.annotations(); | ||
| 82 | + | ||
| 83 | + String routerId = annot.value(AnnotationKeys.ROUTER_ID); | ||
| 84 | + String type = annot.value(AnnotationKeys.TYPE); | ||
| 85 | + String asNumber = annot.value(AS_NUMBER); | ||
| 86 | + String domain = annot.value(DOMAIN_IDENTIFIER); | ||
| 87 | + String routingUnverse = annot.value(ROUTING_UNIVERSE); | ||
| 88 | + | ||
| 89 | + if (type != null) { | ||
| 90 | + pp.addProp("Type", type); | ||
| 91 | + } | ||
| 92 | + /* TBD: Router ID need to print | ||
| 93 | + if (routerId != null) { | ||
| 94 | + pp.addProp("Router-ID", routerId); | ||
| 95 | + } */ | ||
| 96 | + if (routingUnverse != null) { | ||
| 97 | + pp.addProp("Routing Universe", routingUnverse); | ||
| 98 | + } | ||
| 99 | + if (asNumber != null) { | ||
| 100 | + pp.addProp("AS Number", asNumber); | ||
| 101 | + } | ||
| 102 | + if (domain != null) { | ||
| 103 | + pp.addProp("Domain ID", domain); | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @Override | ||
| 109 | + public void modifyHostDetails(PropertyPanel pp, HostId hostId) { | ||
| 110 | + pp.addButton(SRC_BUTTON).addButton(DST_BUTTON); | ||
| 111 | + } | ||
| 112 | +} |
| 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 | + | ||
| 17 | +/** | ||
| 18 | + * PCE visualization GUI topology view overlay. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.pceweb; |
| 1 | +/* css for sample app topology overlay */ | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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 | + | ||
| 17 | +/*PCE topology overlay web application implementation.*/ | ||
| 18 | + | ||
| 19 | +(function () { | ||
| 20 | + 'use strict'; | ||
| 21 | + | ||
| 22 | + // injected refs | ||
| 23 | + var $log, fs, flash, wss, tps, ns, tds, ds; | ||
| 24 | + | ||
| 25 | + // constants | ||
| 26 | + var srcMessage = 'pceTopovSetSrc', | ||
| 27 | + dstMessage = 'pceTopovSetDst', | ||
| 28 | + clearMessage = 'pceTopovClear', | ||
| 29 | + setModemsg = 'pceTopovSetMode', | ||
| 30 | + L3dev = 'requestIpDevDetails'; | ||
| 31 | + // internal state | ||
| 32 | + var currentMode = null; | ||
| 33 | + | ||
| 34 | + // === --------------------------- | ||
| 35 | + // === Helper functions | ||
| 36 | + | ||
| 37 | + // === --------------------------- | ||
| 38 | + // === Main API functions | ||
| 39 | + | ||
| 40 | + function setSrc(node) { | ||
| 41 | + wss.sendEvent(srcMessage, { | ||
| 42 | + id: node.id, | ||
| 43 | + type: node.type | ||
| 44 | + }); | ||
| 45 | + flash.flash('Source node: ' + node.id); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + function setDst(node) { | ||
| 49 | + wss.sendEvent(dstMessage, { | ||
| 50 | + id: node.id, | ||
| 51 | + type: node.type | ||
| 52 | + }); | ||
| 53 | + flash.flash('Destination node: ' + node.id); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + function clear() { | ||
| 57 | + wss.sendEvent(clearMessage); | ||
| 58 | + flash.flash('Cleared source and destination'); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + function dOk() { | ||
| 62 | + var bandWidth = d3.select('#band-width-box').property("checked"); | ||
| 63 | + var bandValue = null; | ||
| 64 | + var bandType = null; | ||
| 65 | + | ||
| 66 | + if (bandWidth) { | ||
| 67 | + | ||
| 68 | + bandValue = d3.select('#band-width-value').property("value"); | ||
| 69 | + | ||
| 70 | + if (d3.select("#band-kpbs-val").property("checked")) { | ||
| 71 | + bandType = 'kbps'; | ||
| 72 | + } else if (d3.select('#band-mpbs-val').property("checked")) { | ||
| 73 | + bandType = 'mbps'; | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + var costType = d3.select('#pce-cost-type').property("checked"); | ||
| 78 | + var costTypeVal = null; | ||
| 79 | + | ||
| 80 | + if (costType) { | ||
| 81 | + | ||
| 82 | + if (d3.select("#pce-cost-type-igp").property("checked")) { | ||
| 83 | + costTypeVal = 'igp'; | ||
| 84 | + } else if (d3.select('#pce-cost-type-te').property("checked")) { | ||
| 85 | + costTypeVal = 'te'; | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + var lspType = d3.select('#pce-lsp-type').property("checked"); | ||
| 90 | + var lspTypeVal = null; | ||
| 91 | + | ||
| 92 | + if (lspType) { | ||
| 93 | + | ||
| 94 | + if (d3.select("#pce-lsp-type-cr").property("checked")) { | ||
| 95 | + lspTypeVal = 'cr'; | ||
| 96 | + } else if (d3.select('#pce-lsp-type-srbe').property("checked")) { | ||
| 97 | + lspTypeVal = 'srbe'; | ||
| 98 | + } else if (d3.select('#pce-lsp-type-srte').property("checked")) { | ||
| 99 | + lspTypeVal = 'srte'; | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + //TBD: Read the user inputs and need to send the event for calculating the path based on constrainsts. | ||
| 104 | + // TBD: Need to read IGP cost type and LSP type. | ||
| 105 | + //wss.sendEvent(setModemsg); | ||
| 106 | + //flash.flash('creat path message'); | ||
| 107 | + | ||
| 108 | + $log.debug('Dialog OK button clicked'); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + function dClose() { | ||
| 112 | + $log.debug('Dialog Close button clicked (or Esc pressed)'); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + function createUserText() { | ||
| 116 | + var content = ds.createDiv(); | ||
| 117 | + var form = content.append('form'); | ||
| 118 | + var p = form.append('p'); | ||
| 119 | + | ||
| 120 | + //Add the bandwidth related inputs. | ||
| 121 | + p.append('input').attr({ | ||
| 122 | + id: 'band-width-box', | ||
| 123 | + type: 'checkbox', | ||
| 124 | + name: 'band-width-name' | ||
| 125 | + }); | ||
| 126 | + p.append('span').text('Band Width'); | ||
| 127 | + p.append('br'); | ||
| 128 | + p.append('input').attr({ | ||
| 129 | + id: 'band-width-value', | ||
| 130 | + type: 'number', | ||
| 131 | + name: 'band-width-value-name' | ||
| 132 | + }); | ||
| 133 | + p.append('input').attr({ | ||
| 134 | + id: 'band-kpbs-val', | ||
| 135 | + type: 'radio', | ||
| 136 | + name: 'pce-band-type' | ||
| 137 | + }); | ||
| 138 | + p.append('span').text('kpbs'); | ||
| 139 | + p.append('input').attr({ | ||
| 140 | + id: 'band-mpbs-val', | ||
| 141 | + type: 'radio', | ||
| 142 | + name: 'pce-band-type' | ||
| 143 | + }); | ||
| 144 | + p.append('span').text('mpbs'); | ||
| 145 | + p.append('br'); | ||
| 146 | + | ||
| 147 | + //Add the cost type related inputs. | ||
| 148 | + p.append('input').attr({ | ||
| 149 | + id: 'pce-cost-type', | ||
| 150 | + type: 'checkbox', | ||
| 151 | + name: 'pce-cost-type-name' | ||
| 152 | + }); | ||
| 153 | + p.append('span').text('Cost Type'); | ||
| 154 | + p.append('br'); | ||
| 155 | + p.append('input').attr({ | ||
| 156 | + id: 'pce-cost-type-igp', | ||
| 157 | + type: 'radio', | ||
| 158 | + name: 'pce-cost-type-valname' | ||
| 159 | + }); | ||
| 160 | + p.append('span').text('IGP'); | ||
| 161 | + p.append('input').attr({ | ||
| 162 | + id: 'pce-cost-type-te', | ||
| 163 | + type: 'radio', | ||
| 164 | + name: 'pce-cost-type-valname' | ||
| 165 | + }); | ||
| 166 | + p.append('span').text('TE'); | ||
| 167 | + p.append('br'); | ||
| 168 | + | ||
| 169 | + //Add the LSP type related inputs. | ||
| 170 | + p.append('input').attr({ | ||
| 171 | + id: 'pce-lsp-type', | ||
| 172 | + type: 'checkbox', | ||
| 173 | + name: 'pce-lsp-type-name' | ||
| 174 | + }); | ||
| 175 | + p.append('span').text('Lsp Type'); | ||
| 176 | + p.append('br'); | ||
| 177 | + p.append('input').attr({ | ||
| 178 | + id: 'pce-lsp-type-cr', | ||
| 179 | + type: 'radio', | ||
| 180 | + name: 'pce-lsp-type-valname' | ||
| 181 | + }); | ||
| 182 | + p.append('span').text('CR'); | ||
| 183 | + p.append('input').attr({ | ||
| 184 | + id: 'pce-lsp-type-srbe', | ||
| 185 | + type: 'radio', | ||
| 186 | + name: 'pce-lsp-type-valname' | ||
| 187 | + }); | ||
| 188 | + p.append('span').text('SR BE'); | ||
| 189 | + p.append('input').attr({ | ||
| 190 | + id: 'pce-lsp-type-srte', | ||
| 191 | + type: 'radio', | ||
| 192 | + name: 'pce-lsp-type-valname' | ||
| 193 | + }); | ||
| 194 | + p.append('span').text('SR TE'); | ||
| 195 | + | ||
| 196 | + return content; | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + function setMode() { | ||
| 200 | + tds.openDialog() | ||
| 201 | + .setTitle('constraints user') | ||
| 202 | + .addContent(createUserText()) | ||
| 203 | + .addOk(dOk, 'OK') | ||
| 204 | + .addCancel(dClose, 'Close') | ||
| 205 | + .bindKeys(); | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + // === --------------------------- | ||
| 209 | + // === Module Factory Definition | ||
| 210 | + | ||
| 211 | + angular.module('ovPcewebTopov', []) | ||
| 212 | + .factory('PcewebTopovDemoService', | ||
| 213 | + ['$log', 'FnService', 'FlashService', 'WebSocketService', | ||
| 214 | + 'TopoPanelService', 'NavService', 'TopoDialogService', 'DialogService', | ||
| 215 | + | ||
| 216 | + function (_$log_, _fs_, _flash_, _wss_, _tps_, _ns_,_tds_, _ds_) { | ||
| 217 | + $log = _$log_; | ||
| 218 | + fs = _fs_; | ||
| 219 | + flash = _flash_; | ||
| 220 | + wss = _wss_; | ||
| 221 | + tps = _tps_; | ||
| 222 | + ns = _ns_; | ||
| 223 | + tds = _tds_; | ||
| 224 | + ds = _ds_; | ||
| 225 | + | ||
| 226 | + return { | ||
| 227 | + setSrc: setSrc, | ||
| 228 | + setDst: setDst, | ||
| 229 | + clear: clear, | ||
| 230 | + setMode: setMode | ||
| 231 | + | ||
| 232 | + }; | ||
| 233 | + }]); | ||
| 234 | +}()); |
| 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 | + | ||
| 17 | +// PCE web topology overlay - client side | ||
| 18 | +// | ||
| 19 | +// This is the glue that binds our business logic (in pcewebTopovDemo.js) | ||
| 20 | +// to the overlay framework. | ||
| 21 | + | ||
| 22 | +(function () { | ||
| 23 | + 'use strict'; | ||
| 24 | + | ||
| 25 | + // injected refs | ||
| 26 | + var $log, tov, pps; | ||
| 27 | + | ||
| 28 | + // internal state should be kept in the service module (not here) | ||
| 29 | + var selection; | ||
| 30 | + // our overlay definition | ||
| 31 | + var overlay = { | ||
| 32 | + // NOTE: this must match the ID defined in AppUiTopovOverlay | ||
| 33 | + overlayId: 'PCE-web-overlay', | ||
| 34 | + glyphId: 'topo', | ||
| 35 | + tooltip: 'PCE web Topo Overlay', | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + activate: function () { | ||
| 39 | + $log.debug("PCE web topology overlay ACTIVATED"); | ||
| 40 | + }, | ||
| 41 | + deactivate: function () { | ||
| 42 | + pps.clear(); | ||
| 43 | + $log.debug("PCE web topology overlay DEACTIVATED"); | ||
| 44 | + }, | ||
| 45 | + | ||
| 46 | + // These glyphs get installed using the overlayId as a prefix. | ||
| 47 | + // e.g. 'src' is installed as 'PCE-web-overlay-src' | ||
| 48 | + // They can be referenced (from this overlay) as '*src' | ||
| 49 | + // That is, the '*' prefix stands in for 'PCE-web-overlay-' | ||
| 50 | + glyphs: { | ||
| 51 | + src: { | ||
| 52 | + vb: '0 0 110 110', | ||
| 53 | + d: 'M28.7,59.3 M14.9,53 M8.7,39 M32.4,92.5H25l-0.2-3.6' + | ||
| 54 | + 'c-0.5-9-5.4-23.9-12.9-33.5c-5.2-6.6-7-12.8-7-16.3c0-13.3,10.7-24,23.8-24c13.1,0,23.8,10.8,23.8,24c0,3.5-1.8,9.7-7,16.3' + | ||
| 55 | + 'C38,65,33.1,80,32.6,88.9L32.4,92.5z M27.9,89.5h1.7l0-0.7c0.5-9.4,5.7-25.2,13.5-35.2c4.7-6,6.4-11.4,6.4-14.5' + | ||
| 56 | + 'c0-11.6-9.3-21-20.8-21C17.3,18,7.9,27.5,7.9,39c0,3,1.7,8.4,6.4,14.5c7.9,10.1,13.1,25.8,13.5,35.2L27.9,89.5z M28.7,83.2' + | ||
| 57 | + 'M28.6,29.8c-4.7,0-8.5,3.8-8.5,8.5c0,4.7,3.8,8.5,8.5,8.5s8.5-3.8,8.5-8.5C37.1,33.6,33.3,29.8,28.6,29.8z M89.6,47 M89.6,29.5' + | ||
| 58 | + 'c-0.1,3.1-0.1,12.8,0,17c0.1,4.2,14.1-5.5,13.9-8.5C103.4,35.1,89.6,25.6,89.6,29.5z M51,38.1L89.5,38 M89.5,39.5l0-3L51,36.5l0,3' + | ||
| 59 | + 'L89.5,39.5z' | ||
| 60 | + }, | ||
| 61 | + dst: { | ||
| 62 | + vb: '0 0 110 110', | ||
| 63 | + d: 'M80.3,59.8 M85.8,92.5h-7.2L78.4,89c-0.4-8.8-5.2-23.6-12.3-33' + | ||
| 64 | + 'c-4.9-6.5-6.7-12.5-6.7-16c0-13,10.2-23.7,22.7-23.7c12.5,0,22.7,10.6,22.7,23.7c0,3.5-1.8,9.5-6.7,16C91.2,65.4,86.4,80.1,86,89' + | ||
| 65 | + 'L85.8,92.5z M81.4,89.5H83l0-0.7c0.5-9.3,5.4-24.8,12.9-34.7c4.5-5.9,6.1-11.2,6.1-14.2c0-11.4-8.9-20.7-19.8-20.7' + | ||
| 66 | + 'c-10.9,0-19.8,9.3-19.8,20.7c0,3,1.6,8.3,6.1,14.2C76,64,80.9,79.5,81.4,88.8L81.4,89.5z M82.1,30.8c-4.5,0-8.1,3.7-8.1,8.4' + | ||
| 67 | + 's3.6,8.4,8.1,8.4c4.5,0,8.1-3.7,8.1-8.4S86.6,30.8,82.1,30.8z M47.2,47.5 M45.2,30.8c-0.1,3.1-0.1,12.6,0,16.7' + | ||
| 68 | + 'c0.1,4.1,13.4-5.4,13.3-8.4C58.4,36.2,45.2,26.9,45.2,30.8z M45.2,39.1L6.7,39.2 M45.2,40.6l0-3L6.7,37.7l0,3L45.2,40.6z' | ||
| 69 | + }, | ||
| 70 | + jp: { | ||
| 71 | + vb: '0 0 110 110', | ||
| 72 | + d: 'M84.3,89.3L58.9,64.2l-1.4,1.4L83,90.7L84.3,89.3z M27,7.6H7.4v19.2H27V7.6z' + | ||
| 73 | + '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' | ||
| 74 | + }, | ||
| 75 | + }, | ||
| 76 | + | ||
| 77 | + // detail panel button definitions | ||
| 78 | + buttons: { | ||
| 79 | + src: { | ||
| 80 | + gid: '*src', | ||
| 81 | + tt: 'Set source node', | ||
| 82 | + cb: function (data) { | ||
| 83 | + $log.debug('Set src action invoked with data:', data); | ||
| 84 | + pps.setSrc(selection); | ||
| 85 | + } | ||
| 86 | + }, | ||
| 87 | + dst: { | ||
| 88 | + gid: '*dst', | ||
| 89 | + tt: 'Set destination node', | ||
| 90 | + cb: function (data) { | ||
| 91 | + $log.debug('Set dst action invoked with data:', data); | ||
| 92 | + pps.setDst(selection); | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + }, | ||
| 96 | + // Key bindings for PCE web overlay buttons | ||
| 97 | + // NOTE: fully qual. button ID is derived from overlay-id and key-name | ||
| 98 | + keyBindings: { | ||
| 99 | + openBracket: { | ||
| 100 | + cb: function () { | ||
| 101 | + pps.setSrc(selection); | ||
| 102 | + }, | ||
| 103 | + tt: 'Set source node', | ||
| 104 | + gid: '*src' | ||
| 105 | + }, | ||
| 106 | + closeBracket: { | ||
| 107 | + cb: function () { | ||
| 108 | + pps.setDst(selection); | ||
| 109 | + }, | ||
| 110 | + tt: 'Set destination node', | ||
| 111 | + gid: '*dst' | ||
| 112 | + }, | ||
| 113 | + 1: { | ||
| 114 | + cb: function () { | ||
| 115 | + pps.setMode("shortest"); | ||
| 116 | + }, | ||
| 117 | + tt: 'Select constraints for LSP', | ||
| 118 | + gid: '*jp' | ||
| 119 | + }, | ||
| 120 | + 0: { | ||
| 121 | + cb: function () { | ||
| 122 | + pps.clear(); | ||
| 123 | + }, | ||
| 124 | + tt: 'Clear source and destination', | ||
| 125 | + gid: 'xMark' | ||
| 126 | + }, | ||
| 127 | + | ||
| 128 | + _keyOrder: [ | ||
| 129 | + 'openBracket', 'closeBracket', '1', '0' | ||
| 130 | + ] | ||
| 131 | + }, | ||
| 132 | + hooks: { | ||
| 133 | + // hook for handling escape key | ||
| 134 | + // Must return true to consume ESC, false otherwise. | ||
| 135 | + escape: function () { | ||
| 136 | + selectionCallback(); | ||
| 137 | + pps.setSrc(); | ||
| 138 | + pps.setDst(); | ||
| 139 | + return true; | ||
| 140 | + }, | ||
| 141 | + | ||
| 142 | + // hooks for when the selection changes... | ||
| 143 | + empty: function () { | ||
| 144 | + selectionCallback(); | ||
| 145 | + }, | ||
| 146 | + single: function (data) { | ||
| 147 | + selectionCallback(data); | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + }; | ||
| 151 | + | ||
| 152 | + function selectionCallback(d) { | ||
| 153 | + $log.debug('Selection callback', d); | ||
| 154 | + selection = d; | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + // invoke code to register with the overlay service | ||
| 158 | + angular.module('ovPcewebTopov') | ||
| 159 | + .run(['$log', 'TopoOverlayService', 'PcewebTopovDemoService', | ||
| 160 | + | ||
| 161 | + function (_$log_, _tov_, _pps_) { | ||
| 162 | + $log = _$log_; | ||
| 163 | + tov = _tov_; | ||
| 164 | + pps = _pps_; | ||
| 165 | + tov.register(overlay); | ||
| 166 | + }]); | ||
| 167 | + | ||
| 168 | +}()); |
| 1 | +<link rel="stylesheet" href="app/view/pcewebTopov/pcewebTopov.css"> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -17,110 +17,22 @@ | ... | @@ -17,110 +17,22 @@ |
| 17 | <project xmlns="http://maven.apache.org/POM/4.0.0" | 17 | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| 18 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | 18 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 19 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | 19 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 20 | - <modelVersion>4.0.0</modelVersion> | ||
| 21 | <parent> | 20 | <parent> |
| 22 | <groupId>org.onosproject</groupId> | 21 | <groupId>org.onosproject</groupId> |
| 23 | <artifactId>onos-apps</artifactId> | 22 | <artifactId>onos-apps</artifactId> |
| 24 | <version>1.6.0-SNAPSHOT</version> | 23 | <version>1.6.0-SNAPSHOT</version> |
| 25 | <relativePath>../pom.xml</relativePath> | 24 | <relativePath>../pom.xml</relativePath> |
| 26 | </parent> | 25 | </parent> |
| 27 | - <artifactId>onos-app-pce</artifactId> | 26 | + <modelVersion>4.0.0</modelVersion> |
| 28 | - <packaging>bundle</packaging> | ||
| 29 | - | ||
| 30 | - <description>PCE as central controller</description> | ||
| 31 | 27 | ||
| 32 | - <properties> | 28 | + <artifactId>onos-pce</artifactId> |
| 33 | - <onos.app.name>org.onosproject.pce</onos.app.name> | ||
| 34 | - <onos.app.category>default</onos.app.category> | ||
| 35 | - <onos.app.url>http://onosproject.org</onos.app.url> | ||
| 36 | - <onos.app.readme>PCE as central controller.</onos.app.readme> | ||
| 37 | - </properties> | ||
| 38 | - <dependencies> | ||
| 39 | - <dependency> | ||
| 40 | - <groupId>org.osgi</groupId> | ||
| 41 | - <artifactId>org.osgi.compendium</artifactId> | ||
| 42 | - </dependency> | ||
| 43 | 29 | ||
| 44 | - <dependency> | 30 | + <packaging>pom</packaging> |
| 45 | - <groupId>org.onosproject</groupId> | 31 | + <description>PCE as central controller</description> |
| 46 | - <artifactId>onos-cli</artifactId> | ||
| 47 | - <version>${project.version}</version> | ||
| 48 | - </dependency> | ||
| 49 | 32 | ||
| 50 | - <dependency> | 33 | + <modules> |
| 51 | - <groupId>org.apache.karaf.shell</groupId> | 34 | + <module>app</module> |
| 52 | - <artifactId>org.apache.karaf.shell.console</artifactId> | 35 | + <module>pceweb</module> |
| 53 | - <scope>compile</scope> | 36 | + </modules> |
| 54 | - </dependency> | ||
| 55 | 37 | ||
| 56 | - <dependency> | ||
| 57 | - <groupId>org.onosproject</groupId> | ||
| 58 | - <artifactId>onlab-junit</artifactId> | ||
| 59 | - <scope>test</scope> | ||
| 60 | - </dependency> | ||
| 61 | - <dependency> | ||
| 62 | - <groupId>org.onosproject</groupId> | ||
| 63 | - <artifactId>onos-core-serializers</artifactId> | ||
| 64 | - <version>${project.version}</version> | ||
| 65 | - </dependency> | ||
| 66 | - <dependency> | ||
| 67 | - <groupId>com.google.guava</groupId> | ||
| 68 | - <artifactId>guava-testlib</artifactId> | ||
| 69 | - <scope>test</scope> | ||
| 70 | - </dependency> | ||
| 71 | - <dependency> | ||
| 72 | - <groupId>org.easymock</groupId> | ||
| 73 | - <artifactId>easymock</artifactId> | ||
| 74 | - <scope>test</scope> | ||
| 75 | - </dependency> | ||
| 76 | - <dependency> | ||
| 77 | - <groupId>org.onosproject</groupId> | ||
| 78 | - <artifactId>onlab-osgi</artifactId> | ||
| 79 | - <classifier>tests</classifier> | ||
| 80 | - <scope>test</scope> | ||
| 81 | - </dependency> | ||
| 82 | - <dependency> | ||
| 83 | - <groupId>org.onosproject</groupId> | ||
| 84 | - <artifactId>onos-api</artifactId> | ||
| 85 | - <scope>test</scope> | ||
| 86 | - <classifier>tests</classifier> | ||
| 87 | - </dependency> | ||
| 88 | - <dependency> | ||
| 89 | - <groupId>org.onosproject</groupId> | ||
| 90 | - <artifactId>onos-rest</artifactId> | ||
| 91 | - <version>${project.version}</version> | ||
| 92 | - </dependency> | ||
| 93 | - <dependency> | ||
| 94 | - <groupId>org.onosproject</groupId> | ||
| 95 | - <artifactId>onlab-rest</artifactId> | ||
| 96 | - <version>${project.version}</version> | ||
| 97 | - </dependency> | ||
| 98 | - <dependency> | ||
| 99 | - <groupId>javax.ws.rs</groupId> | ||
| 100 | - <artifactId>jsr311-api</artifactId> | ||
| 101 | - <version>1.1.1</version> | ||
| 102 | - </dependency> | ||
| 103 | - <dependency> | ||
| 104 | - <groupId>com.fasterxml.jackson.core</groupId> | ||
| 105 | - <artifactId>jackson-databind</artifactId> | ||
| 106 | - </dependency> | ||
| 107 | - <dependency> | ||
| 108 | - <groupId>com.fasterxml.jackson.core</groupId> | ||
| 109 | - <artifactId>jackson-annotations</artifactId> | ||
| 110 | - </dependency> | ||
| 111 | - <dependency> | ||
| 112 | - <groupId>org.glassfish.jersey.containers</groupId> | ||
| 113 | - <artifactId>jersey-container-servlet</artifactId> | ||
| 114 | - </dependency> | ||
| 115 | - <dependency> | ||
| 116 | - <groupId>org.glassfish.jersey.test-framework</groupId> | ||
| 117 | - <artifactId>jersey-test-framework-core</artifactId> | ||
| 118 | - <scope>test</scope> | ||
| 119 | - </dependency> | ||
| 120 | - <dependency> | ||
| 121 | - <groupId>org.glassfish.jersey.test-framework.providers</groupId> | ||
| 122 | - <artifactId>jersey-test-framework-provider-jetty</artifactId> | ||
| 123 | - <scope>test</scope> | ||
| 124 | - </dependency> | ||
| 125 | - </dependencies> | ||
| 126 | </project> | 38 | </project> | ... | ... |
-
Please register or login to post a comment