diff options
Diffstat (limited to 'framework/src/onos/web')
35 files changed, 262 insertions, 86 deletions
diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/exceptions/AbstractMapper.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/exceptions/AbstractMapper.java index f49202dd..0d9d94d3 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/exceptions/AbstractMapper.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/exceptions/AbstractMapper.java @@ -29,6 +29,11 @@ import static com.google.common.base.Strings.isNullOrEmpty; public abstract class AbstractMapper<E extends Throwable> implements ExceptionMapper<E> { /** + * Holds the current exception for use in subclasses. + */ + protected Throwable error; + + /** * Returns the response status to be given when the exception occurs. * * @return response status @@ -37,6 +42,7 @@ public abstract class AbstractMapper<E extends Throwable> implements ExceptionMa @Override public Response toResponse(E exception) { + error = exception; return response(responseStatus(), exception).build(); } @@ -50,6 +56,7 @@ public abstract class AbstractMapper<E extends Throwable> implements ExceptionMa */ protected Response.ResponseBuilder response(Response.Status status, Throwable exception) { + error = exception; ObjectMapper mapper = new ObjectMapper(); String message = messageFrom(exception); ObjectNode result = mapper.createObjectNode() diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/exceptions/ServerErrorMapper.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/exceptions/ServerErrorMapper.java index 5a9050d0..778750e6 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/exceptions/ServerErrorMapper.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/exceptions/ServerErrorMapper.java @@ -18,13 +18,19 @@ package org.onosproject.rest.exceptions; import javax.ws.rs.core.Response; import javax.ws.rs.ext.Provider; +import org.slf4j.Logger; + +import static org.slf4j.LoggerFactory.getLogger; + /** * Mapper for service not found exceptions to the INTERNAL_SERVER_ERROR response code. */ @Provider public class ServerErrorMapper extends AbstractMapper<RuntimeException> { + private static final Logger log = getLogger(ServerErrorMapper.class); @Override protected Response.Status responseStatus() { + log.warn("Unhandled REST exception", error); return Response.Status.INTERNAL_SERVER_ERROR; } } diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java index 636fc333..b38633bf 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ApplicationsWebResource.java @@ -44,6 +44,7 @@ public class ApplicationsWebResource extends AbstractWebResource { * Get all installed applications. * Returns array of all installed applications. * + * @rsModel Applications * @return 200 OK */ @GET @@ -56,7 +57,7 @@ public class ApplicationsWebResource extends AbstractWebResource { /** * Get application details. * Returns details of the specified application. - * + * @rsModel Application * @param name application name * @return 200 OK; 404; 401 */ diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ClusterWebResource.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ClusterWebResource.java index 312f6e35..16a4dc7f 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ClusterWebResource.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ClusterWebResource.java @@ -49,6 +49,7 @@ public class ClusterWebResource extends AbstractWebResource { * Returns array of all cluster nodes. * * @return 200 OK + * @rsModel Cluster */ @GET public Response getClusterNodes() { @@ -62,6 +63,7 @@ public class ClusterWebResource extends AbstractWebResource { * * @param id cluster node identifier * @return 200 OK + * @rsModel ClusterNode */ @GET @Path("{id}") @@ -78,6 +80,7 @@ public class ClusterWebResource extends AbstractWebResource { * @param config cluster definition * @return 200 OK * @throws IOException to signify bad request + * @rsModel ClusterPost */ @POST @Path("configuration") diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java index dbd80cca..06c73d39 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java @@ -327,7 +327,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { String value = annotations.value("optical.waves").trim(); try { int numChls = Integer.parseInt(value); - updateOMSPorts(numChls, src, dst); + updateOmsPorts(numChls, src, dst); } catch (NumberFormatException e) { log.warn("Invalid channel ({}), can't configure port(s)", value); return; @@ -373,7 +373,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { } } - private void updateOMSPorts(int numChls, ConnectPoint srcCp, ConnectPoint dstCp) { + private void updateOmsPorts(int numChls, ConnectPoint srcCp, ConnectPoint dstCp) { // round down to largest slot that allows numChl channels to fit into C band range ChannelSpacing chl = null; Frequency perChl = TOTAL.floorDivision(numChls); diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/DevicesWebResource.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/DevicesWebResource.java index 05756e5a..23ca46e7 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/DevicesWebResource.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/DevicesWebResource.java @@ -46,6 +46,7 @@ public class DevicesWebResource extends AbstractWebResource { * Returns array of all discovered infrastructure devices. * * @return 200 OK + * @rsModel DevicesGet */ @GET public Response getDevices() { @@ -59,6 +60,7 @@ public class DevicesWebResource extends AbstractWebResource { * * @param id device identifier * @return 200 OK + * @rsModel DeviceGet */ @GET @Path("{id}") @@ -89,6 +91,7 @@ public class DevicesWebResource extends AbstractWebResource { * Get ports of infrastructure device. * Returns details of the specified infrastructure device. * + * @rsModel DeviceGetPorts * @param id device identifier * @return 200 OK */ diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java index 0e88e34e..252a3ba7 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/FlowsWebResource.java @@ -58,7 +58,7 @@ public class FlowsWebResource extends AbstractWebResource { /** * Get all flow entries. Returns array of all flow rules in the system. - * + * @rsModel Flows * @return array of all the intents in the system */ @GET @@ -80,7 +80,7 @@ public class FlowsWebResource extends AbstractWebResource { /** * Get flow entries of a device. Returns array of all flow rules for the * specified device. - * + * @rsModel Flows * @param deviceId device identifier * @return flow data as an array */ @@ -103,7 +103,7 @@ public class FlowsWebResource extends AbstractWebResource { /** * Get flow rule. Returns the flow entry specified by the device id and * flow rule id. - * + * @rsModel Flows * @param deviceId device identifier * @param flowId flow rule identifier * @return flow data as an array @@ -130,7 +130,7 @@ public class FlowsWebResource extends AbstractWebResource { /** * Create new flow rule. Creates and installs a new flow rule for the * specified device. - * + * @rsModel FlowsPost * @param deviceId device identifier * @param stream flow rule JSON * @return status of the request - CREATED if the JSON is correct, diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java index b89f5add..455e4929 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java @@ -70,6 +70,7 @@ public class HostsWebResource extends AbstractWebResource { * Returns array of all known end-station hosts. * * @return 200 OK + * @rsModel Hosts */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -85,6 +86,7 @@ public class HostsWebResource extends AbstractWebResource { * * @param id host identifier * @return 200 OK + * @rsModel Host */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -103,6 +105,7 @@ public class HostsWebResource extends AbstractWebResource { * @param mac host MAC address * @param vlan host VLAN identifier * @return 200 OK + * @rsModel Host */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -122,6 +125,7 @@ public class HostsWebResource extends AbstractWebResource { * @param stream input JSON * @return status of the request - CREATED if the JSON is correct, * BAD_REQUEST if the JSON is invalid + * @rsModel HostPut */ @POST @Consumes(MediaType.APPLICATION_JSON) @@ -195,6 +199,7 @@ public class HostsWebResource extends AbstractWebResource { while (ipStrings.hasNext()) { ips.add(IpAddress.valueOf(ipStrings.next().asText())); } + //TODO remove elements from json node after reading them SparseAnnotations annotations = annotations(node); // Update host inventory diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/LinksWebResource.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/LinksWebResource.java index c6270199..e36ea8af 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/LinksWebResource.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/LinksWebResource.java @@ -44,7 +44,7 @@ public class LinksWebResource extends AbstractWebResource { /** * Get infrastructure links. * Returns array of all links, or links for the specified device or port. - * + * @rsModel LinksGet * @param deviceId (optional) device identifier * @param port (optional) port number * @param direction (optional) direction qualifier diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/NetworkConfigWebResource.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/NetworkConfigWebResource.java index 808fcc16..69c0b6a3 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/NetworkConfigWebResource.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/NetworkConfigWebResource.java @@ -15,10 +15,9 @@ */ package org.onosproject.rest.resources; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.onosproject.net.config.NetworkConfigService; -import org.onosproject.net.config.SubjectFactory; -import org.onosproject.rest.AbstractWebResource; +import java.io.IOException; +import java.io.InputStream; +import java.util.Set; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -29,8 +28,16 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.IOException; -import java.io.InputStream; + +import org.onosproject.net.config.Config; +import org.onosproject.net.config.NetworkConfigService; +import org.onosproject.net.config.SubjectFactory; +import org.onosproject.rest.AbstractWebResource; + +import com.fasterxml.jackson.databind.node.ObjectNode; + +import static org.onlab.util.Tools.emptyIsNotFound; +import static org.onlab.util.Tools.nullIsNotFound; /** * Manage network configurations. @@ -38,9 +45,30 @@ import java.io.InputStream; @Path("network/configuration") public class NetworkConfigWebResource extends AbstractWebResource { + + private String subjectClassNotFoundErrorString(String subjectClassKey) { + return "Config for '" + subjectClassKey + "' not found"; + } + + private String subjectNotFoundErrorString(String subjectClassKey, + String subjectKey) { + return "Config for '" + + subjectClassKey + "/" + subjectKey + + "' not found"; + } + + private String configKeyNotFoundErrorString(String subjectClassKey, + String subjectKey, + String configKey) { + return "Config for '" + + subjectClassKey + "/" + subjectKey + "/" + configKey + + "' not found"; + } + /** * Get entire network configuration base. * + * @rsModel NetCfgGet * @return network configuration JSON */ @GET @@ -70,7 +98,9 @@ public class NetworkConfigWebResource extends AbstractWebResource { public Response download(@PathParam("subjectClassKey") String subjectClassKey) { NetworkConfigService service = get(NetworkConfigService.class); ObjectNode root = mapper().createObjectNode(); - SubjectFactory subjectFactory = service.getSubjectFactory(subjectClassKey); + SubjectFactory subjectFactory = + nullIsNotFound(service.getSubjectFactory(subjectClassKey), + subjectClassNotFoundErrorString(subjectClassKey)); produceJson(service, root, subjectFactory, subjectFactory.subjectClass()); return ok(root).build(); } @@ -90,8 +120,12 @@ public class NetworkConfigWebResource extends AbstractWebResource { @PathParam("subjectKey") String subjectKey) { NetworkConfigService service = get(NetworkConfigService.class); ObjectNode root = mapper().createObjectNode(); - SubjectFactory subjectFactory = service.getSubjectFactory(subjectClassKey); - produceSubjectJson(service, root, subjectFactory.createSubject(subjectKey)); + SubjectFactory subjectFactory = + nullIsNotFound(service.getSubjectFactory(subjectClassKey), + subjectClassNotFoundErrorString(subjectClassKey)); + produceSubjectJson(service, root, subjectFactory.createSubject(subjectKey), + true, + subjectNotFoundErrorString(subjectClassKey, subjectKey)); return ok(root).build(); } @@ -111,26 +145,47 @@ public class NetworkConfigWebResource extends AbstractWebResource { @PathParam("subjectKey") String subjectKey, @PathParam("configKey") String configKey) { NetworkConfigService service = get(NetworkConfigService.class); - return ok(service.getConfig(service.getSubjectFactory(subjectClassKey).createSubject(subjectKey), - service.getConfigClass(subjectClassKey, configKey)).node()).build(); + + Object subject = + nullIsNotFound(service.getSubjectFactory(subjectClassKey) + .createSubject(subjectKey), + subjectNotFoundErrorString(subjectClassKey, subjectKey)); + + Class configClass = + nullIsNotFound(service.getConfigClass(subjectClassKey, configKey), + configKeyNotFoundErrorString(subjectClassKey, subjectKey, configKey)); + Config config = + nullIsNotFound(service.getConfig(subject, configClass), + configKeyNotFoundErrorString(subjectClassKey, + subjectKey, + configKey)); + return ok(config.node()).build(); } @SuppressWarnings("unchecked") private void produceJson(NetworkConfigService service, ObjectNode node, SubjectFactory subjectFactory, Class subjectClass) { service.getSubjects(subjectClass).forEach(s -> - produceSubjectJson(service, newObject(node, subjectFactory.subjectKey(s)), s)); + produceSubjectJson(service, newObject(node, subjectFactory.subjectKey(s)), s, false, "")); } private void produceSubjectJson(NetworkConfigService service, ObjectNode node, - Object subject) { - service.getConfigs(subject).forEach(c -> node.set(c.key(), c.node())); + Object subject, + boolean emptyIsError, + String emptyErrorMessage) { + Set<? extends Config<Object>> configs = service.getConfigs(subject); + if (emptyIsError) { + // caller wants an empty set to be a 404 + configs = emptyIsNotFound(configs, emptyErrorMessage); + } + configs.forEach(c -> node.set(c.key(), c.node())); } /** * Upload bulk network configuration. * + * @rsModel NetCfgGet * @param request network configuration JSON rooted at the top node * @return empty response * @throws IOException if unable to parse the request @@ -253,17 +308,15 @@ public class NetworkConfigWebResource extends AbstractWebResource { * Clear all network configurations for a subject class. * * @param subjectClassKey subject class key - * @return empty response */ @DELETE @Path("{subjectClassKey}") @SuppressWarnings("unchecked") - public Response delete(@PathParam("subjectClassKey") String subjectClassKey) { + public void delete(@PathParam("subjectClassKey") String subjectClassKey) { NetworkConfigService service = get(NetworkConfigService.class); - service.getSubjects(service.getSubjectFactory(subjectClassKey).getClass()) + service.getSubjects(service.getSubjectFactory(subjectClassKey).subjectClass()) .forEach(subject -> service.getConfigs(subject) .forEach(config -> service.removeConfig(subject, config.getClass()))); - return Response.ok().build(); } /** @@ -271,17 +324,15 @@ public class NetworkConfigWebResource extends AbstractWebResource { * * @param subjectClassKey subjectKey class key * @param subjectKey subjectKey key - * @return empty response */ @DELETE @Path("{subjectClassKey}/{subjectKey}") @SuppressWarnings("unchecked") - public Response delete(@PathParam("subjectClassKey") String subjectClassKey, + public void delete(@PathParam("subjectClassKey") String subjectClassKey, @PathParam("subjectKey") String subjectKey) { NetworkConfigService service = get(NetworkConfigService.class); Object s = service.getSubjectFactory(subjectClassKey).createSubject(subjectKey); service.getConfigs(s).forEach(c -> service.removeConfig(s, c.getClass())); - return Response.ok().build(); } /** @@ -290,18 +341,16 @@ public class NetworkConfigWebResource extends AbstractWebResource { * @param subjectClassKey subjectKey class key * @param subjectKey subjectKey key * @param configKey configuration class key - * @return empty response */ @DELETE @Path("{subjectClassKey}/{subjectKey}/{configKey}") @SuppressWarnings("unchecked") - public Response delete(@PathParam("subjectClassKey") String subjectClassKey, + public void delete(@PathParam("subjectClassKey") String subjectClassKey, @PathParam("subjectKey") String subjectKey, @PathParam("configKey") String configKey) { NetworkConfigService service = get(NetworkConfigService.class); service.removeConfig(service.getSubjectFactory(subjectClassKey).createSubject(subjectKey), service.getConfigClass(subjectClassKey, configKey)); - return Response.ok().build(); } } diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/PathsWebResource.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/PathsWebResource.java index 9714690c..c14b4ec2 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/PathsWebResource.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/PathsWebResource.java @@ -60,7 +60,7 @@ public class PathsWebResource extends AbstractWebResource { /** * Get all shortest paths between any two hosts or devices. * Returns array of all shortest paths between any two elements. - * + * @rsModel Paths * @param src source identifier * @param dst destination identifier * @return path data @@ -79,7 +79,7 @@ public class PathsWebResource extends AbstractWebResource { /** * Get all shortest disjoint paths between any two hosts or devices. * Returns array of all shortest disjoint paths between any two elements. - * + * @rsModel Paths * @param src source identifier * @param dst destination identifier * @return path data diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/StatisticsWebResource.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/StatisticsWebResource.java index c91cb6d0..7a452044 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/StatisticsWebResource.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/StatisticsWebResource.java @@ -59,7 +59,7 @@ public class StatisticsWebResource extends AbstractWebResource { /** * Get load statistics for all links or for a specific link. - * + * @rsModel StatisticsFlowsLink * @param deviceId (optional) device ID for a specific link * @param port (optional) port number for a specified link * @return JSON encoded array lof Load objects @@ -101,7 +101,7 @@ public class StatisticsWebResource extends AbstractWebResource { /** * Get table statistics for all tables of all devices. - * + * @rsModel StatisticsFlowsTables * @return JSON encoded array of table statistics */ @GET @@ -111,11 +111,11 @@ public class StatisticsWebResource extends AbstractWebResource { final FlowRuleService service = get(FlowRuleService.class); final Iterable<Device> devices = get(DeviceService.class).getDevices(); final ObjectNode root = mapper().createObjectNode(); - final ArrayNode rootArrayNode = root.putArray("device-table-statistics"); + final ArrayNode rootArrayNode = root.putArray("statistics"); for (final Device device : devices) { final ObjectNode deviceStatsNode = mapper().createObjectNode(); deviceStatsNode.put("device", device.id().toString()); - final ArrayNode statisticsNode = deviceStatsNode.putArray("table-statistics"); + final ArrayNode statisticsNode = deviceStatsNode.putArray("table"); final Iterable<TableStatisticsEntry> tableStatsEntries = service.getFlowTableStatistics(device.id()); if (tableStatsEntries != null) { for (final TableStatisticsEntry entry : tableStatsEntries) { @@ -130,7 +130,7 @@ public class StatisticsWebResource extends AbstractWebResource { /** * Get table statistics for all tables of a specified device. - * + * @rsModel StatisticsFlowsTables * @param deviceId device ID * @return JSON encoded array of table statistics */ @@ -142,11 +142,11 @@ public class StatisticsWebResource extends AbstractWebResource { final Iterable<TableStatisticsEntry> tableStatisticsEntries = service.getFlowTableStatistics(DeviceId.deviceId(deviceId)); final ObjectNode root = mapper().createObjectNode(); - final ArrayNode rootArrayNode = root.putArray("table-statistics"); + final ArrayNode rootArrayNode = root.putArray("statistics"); final ObjectNode deviceStatsNode = mapper().createObjectNode(); deviceStatsNode.put("device", deviceId); - final ArrayNode statisticsNode = deviceStatsNode.putArray("table-statistics"); + final ArrayNode statisticsNode = deviceStatsNode.putArray("table"); for (final TableStatisticsEntry entry : tableStatisticsEntries) { statisticsNode.add(codec(TableStatisticsEntry.class).encode(entry, this)); } diff --git a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/TopologyWebResource.java b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/TopologyWebResource.java index f6ae8253..d51bd5a0 100644 --- a/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/TopologyWebResource.java +++ b/framework/src/onos/web/api/src/main/java/org/onosproject/rest/resources/TopologyWebResource.java @@ -50,6 +50,7 @@ public class TopologyWebResource extends AbstractWebResource { * Get overview of current topology. * * @return topology overview + * @rsModel Topology */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -63,6 +64,7 @@ public class TopologyWebResource extends AbstractWebResource { * Get overview of topology SCCs. * * @return topology clusters overview + * @rsModel TopologyClusters */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -80,6 +82,7 @@ public class TopologyWebResource extends AbstractWebResource { * * @param clusterId id of the cluster to query * @return topology cluster details + * @rsModel TopologyCluster */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -103,6 +106,7 @@ public class TopologyWebResource extends AbstractWebResource { * * @param clusterId id of the cluster to query * @return topology cluster devices + * @rsModel TopologyClustersDevices */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -126,6 +130,7 @@ public class TopologyWebResource extends AbstractWebResource { * * @param clusterId id of the cluster to query * @return topology cluster links + * @rsModel LinksGet */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -136,7 +141,7 @@ public class TopologyWebResource extends AbstractWebResource { List<Link> links = Lists.newArrayList(get(TopologyService.class) - .getClusterLinks(topology, cluster)); + .getClusterLinks(topology, cluster)); return ok(encodeArray(Link.class, "links", links)).build(); } @@ -174,7 +179,8 @@ public class TopologyWebResource extends AbstractWebResource { * * @param connectPointString deviceid:portnumber * @return JSON representation of true if the connect point is broadcast, - * false otherwise + * false otherwise + * @rsModel TopologyBroadcast */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -188,8 +194,8 @@ public class TopologyWebResource extends AbstractWebResource { boolean isBroadcast = get(TopologyService.class).isBroadcastPoint(topology, connectPoint); return ok(mapper() - .createObjectNode() - .put("broadcast", isBroadcast)) + .createObjectNode() + .put("broadcast", isBroadcast)) .build(); } @@ -198,7 +204,8 @@ public class TopologyWebResource extends AbstractWebResource { * * @param connectPointString deviceid:portnumber * @return JSON representation of true if the connect point is broadcast, - * false otherwise + * false otherwise + * @rsModel TopologyInfrastructure */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -212,8 +219,8 @@ public class TopologyWebResource extends AbstractWebResource { boolean isInfrastructure = get(TopologyService.class).isInfrastructure(topology, connectPoint); return ok(mapper() - .createObjectNode() - .put("infrastructure", isInfrastructure)) + .createObjectNode() + .put("infrastructure", isInfrastructure)) .build(); } diff --git a/framework/src/onos/web/api/src/test/java/org/onosproject/rest/ApplicationsResourceTest.java b/framework/src/onos/web/api/src/test/java/org/onosproject/rest/ApplicationsResourceTest.java index 6fee43ed..3e72f18d 100644 --- a/framework/src/onos/web/api/src/test/java/org/onosproject/rest/ApplicationsResourceTest.java +++ b/framework/src/onos/web/api/src/test/java/org/onosproject/rest/ApplicationsResourceTest.java @@ -85,19 +85,19 @@ public class ApplicationsResourceTest extends ResourceTest { private Application app1 = new DefaultApplication(id1, VER, "app1", "origin1", ApplicationRole.ADMIN, ImmutableSet.of(), Optional.of(FURL), - ImmutableList.of("My Feature")); + ImmutableList.of("My Feature"), ImmutableList.of()); private Application app2 = new DefaultApplication(id2, VER, "app2", "origin2", ApplicationRole.ADMIN, ImmutableSet.of(), Optional.of(FURL), - ImmutableList.of("My Feature")); + ImmutableList.of("My Feature"), ImmutableList.of()); private Application app3 = new DefaultApplication(id3, VER, "app3", "origin3", ApplicationRole.ADMIN, ImmutableSet.of(), Optional.of(FURL), - ImmutableList.of("My Feature")); + ImmutableList.of("My Feature"), ImmutableList.of()); private Application app4 = new DefaultApplication(id4, VER, "app4", "origin4", ApplicationRole.ADMIN, ImmutableSet.of(), Optional.of(FURL), - ImmutableList.of("My Feature")); + ImmutableList.of("My Feature"), ImmutableList.of()); /** * Hamcrest matcher to check that an application representation in JSON matches diff --git a/framework/src/onos/web/api/src/test/java/org/onosproject/rest/FlowsResourceTest.java b/framework/src/onos/web/api/src/test/java/org/onosproject/rest/FlowsResourceTest.java index 4fb58215..8910e733 100644 --- a/framework/src/onos/web/api/src/test/java/org/onosproject/rest/FlowsResourceTest.java +++ b/framework/src/onos/web/api/src/test/java/org/onosproject/rest/FlowsResourceTest.java @@ -585,7 +585,7 @@ public class FlowsResourceTest extends ResourceTest { replay(mockFlowService); WebResource rs = resource(); - InputStream jsonStream = IntentsResourceTest.class + InputStream jsonStream = FlowsResourceTest.class .getResourceAsStream("post-flow.json"); ClientResponse response = rs.path("flows/of:0000000000000001") diff --git a/framework/src/onos/web/api/src/test/java/org/onosproject/rest/HostResourceTest.java b/framework/src/onos/web/api/src/test/java/org/onosproject/rest/HostResourceTest.java index 8c765402..5ac483d8 100644 --- a/framework/src/onos/web/api/src/test/java/org/onosproject/rest/HostResourceTest.java +++ b/framework/src/onos/web/api/src/test/java/org/onosproject/rest/HostResourceTest.java @@ -375,7 +375,7 @@ public class HostResourceTest extends ResourceTest { replay(mockHostService); - InputStream jsonStream = IntentsResourceTest.class + InputStream jsonStream = HostResourceTest.class .getResourceAsStream("post-host.json"); WebResource rs = resource(); diff --git a/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java b/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java index 82b7a782..700e57e3 100644 --- a/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java +++ b/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandler.java @@ -289,6 +289,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { @Override public void process(long sid, ObjectNode payload) { + removeListeners(); stopSummaryMonitoring(); traffic.stopMonitoring(); } diff --git a/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java b/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java index 840e89f3..f35b6c03 100644 --- a/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java +++ b/framework/src/onos/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import org.onlab.osgi.ServiceDirectory; import org.onlab.packet.IpAddress; +import org.onlab.util.DefaultHashMap; import org.onosproject.cluster.ClusterEvent; import org.onosproject.cluster.ClusterService; import org.onosproject.cluster.ControllerNode; @@ -80,17 +81,9 @@ import java.util.concurrent.ConcurrentHashMap; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Strings.isNullOrEmpty; -import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_ADDED; -import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_REMOVED; import static org.onosproject.cluster.ControllerNode.State.ACTIVE; import static org.onosproject.net.DefaultEdgeLink.createEdgeLink; import static org.onosproject.net.PortNumber.portNumber; -import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED; -import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED; -import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; -import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED; -import static org.onosproject.net.link.LinkEvent.Type.LINK_ADDED; -import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED; import static org.onosproject.ui.topo.TopoConstants.CoreButtons; import static org.onosproject.ui.topo.TopoConstants.Properties; import static org.onosproject.ui.topo.TopoUtils.compactLinkString; @@ -100,6 +93,33 @@ import static org.onosproject.ui.topo.TopoUtils.compactLinkString; */ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { + // default to an "add" event... + private static final DefaultHashMap<ClusterEvent.Type, String> CLUSTER_EVENT = + new DefaultHashMap<>("addInstance"); + + // default to an "update" event... + private static final DefaultHashMap<DeviceEvent.Type, String> DEVICE_EVENT = + new DefaultHashMap<>("updateDevice"); + private static final DefaultHashMap<LinkEvent.Type, String> LINK_EVENT = + new DefaultHashMap<>("updateLink"); + private static final DefaultHashMap<HostEvent.Type, String> HOST_EVENT = + new DefaultHashMap<>("updateHost"); + + // but call out specific events that we care to differentiate... + static { + CLUSTER_EVENT.put(ClusterEvent.Type.INSTANCE_REMOVED, "removeInstance"); + + DEVICE_EVENT.put(DeviceEvent.Type.DEVICE_ADDED, "addDevice"); + DEVICE_EVENT.put(DeviceEvent.Type.DEVICE_REMOVED, "removeDevice"); + + LINK_EVENT.put(LinkEvent.Type.LINK_ADDED, "addLink"); + LINK_EVENT.put(LinkEvent.Type.LINK_REMOVED, "removeLink"); + + HOST_EVENT.put(HostEvent.Type.HOST_ADDED, "addHost"); + HOST_EVENT.put(HostEvent.Type.HOST_REMOVED, "removeHost"); + HOST_EVENT.put(HostEvent.Type.HOST_MOVED, "moveHost"); + } + protected static final Logger log = LoggerFactory.getLogger(TopologyViewMessageHandlerBase.class); @@ -204,7 +224,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { } // Produces a cluster instance message to the client. - protected ObjectNode instanceMessage(ClusterEvent event, String messageType) { + protected ObjectNode instanceMessage(ClusterEvent event, String msgType) { ControllerNode node = event.subject(); int switchCount = mastershipService.getDevicesOf(node.id()).size(); ObjectNode payload = objectNode() @@ -222,10 +242,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { payload.set("labels", labels); addMetaUi(node.id().toString(), payload); - String type = messageType != null ? messageType : - ((event.type() == INSTANCE_ADDED) ? "addInstance" : - ((event.type() == INSTANCE_REMOVED ? "removeInstance" : - "addInstance"))); + String type = msgType != null ? msgType : CLUSTER_EVENT.get(event.type()); return JsonUtils.envelope(type, 0, payload); } @@ -251,8 +268,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { addGeoLocation(device, payload); addMetaUi(device.id().toString(), payload); - String type = (event.type() == DEVICE_ADDED) ? "addDevice" : - ((event.type() == DEVICE_REMOVED) ? "removeDevice" : "updateDevice"); + String type = DEVICE_EVENT.get(event.type()); return JsonUtils.envelope(type, 0, payload); } @@ -268,29 +284,32 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { .put("srcPort", link.src().port().toString()) .put("dst", link.dst().deviceId().toString()) .put("dstPort", link.dst().port().toString()); - String type = (event.type() == LINK_ADDED) ? "addLink" : - ((event.type() == LINK_REMOVED) ? "removeLink" : "updateLink"); + String type = LINK_EVENT.get(event.type()); return JsonUtils.envelope(type, 0, payload); } // Produces a host event message to the client. protected ObjectNode hostMessage(HostEvent event) { Host host = event.subject(); + Host prevHost = event.prevSubject(); String hostType = host.annotations().value(AnnotationKeys.TYPE); + ObjectNode payload = objectNode() .put("id", host.id().toString()) .put("type", isNullOrEmpty(hostType) ? "endstation" : hostType) .put("ingress", compactLinkString(edgeLink(host, true))) .put("egress", compactLinkString(edgeLink(host, false))); payload.set("cp", hostConnect(host.location())); + if (prevHost != null && prevHost.location() != null) { + payload.set("prevCp", hostConnect(prevHost.location())); + } payload.set("labels", labels(ip(host.ipAddresses()), host.mac().toString())); payload.set("props", props(host.annotations())); addGeoLocation(host, payload); addMetaUi(host.id().toString(), payload); - String type = (event.type() == HOST_ADDED) ? "addHost" : - ((event.type() == HOST_REMOVED) ? "removeHost" : "updateHost"); + String type = HOST_EVENT.get(event.type()); return JsonUtils.envelope(type, 0, payload); } diff --git a/framework/src/onos/web/gui/src/main/webapp/app/fw/svg/icon.js b/framework/src/onos/web/gui/src/main/webapp/app/fw/svg/icon.js index 12536361..cc26360f 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/fw/svg/icon.js +++ b/framework/src/onos/web/gui/src/main/webapp/app/fw/svg/icon.js @@ -51,6 +51,7 @@ devIcon_SWITCH: 'switch', devIcon_ROADM: 'roadm', + deviceTable: 'switch', flowTable: 'flowTable', portTable: 'portTable', groupTable: 'groupTable', diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/device/device.css b/framework/src/onos/web/gui/src/main/webapp/app/view/device/device.css index e0e9cf57..8d8a582b 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/device/device.css +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/device/device.css @@ -23,7 +23,20 @@ } #ov-device div.ctrl-btns { - width: 240px; +} + +.light #ov-device .current-view use { + fill: white; +} +.dark #ov-device .current-view use { + fill: #304860; +} + +.light #ov-device .current-view rect { + fill: deepskyblue; +} +.dark #ov-device .current-view rect { + fill: #eee; } /* More in generic panel.css */ diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/device/device.html b/framework/src/onos/web/gui/src/main/webapp/app/view/device/device.html index 63a04db8..6f1813a0 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/device/device.html +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/device/device.html @@ -9,6 +9,9 @@ ng-click="toggleRefresh()"></div> <div class="separator"></div> + <div ng-class="{'current-view': !!selId}" + icon icon-id="deviceTable" icon-size="36"></div> + <div ng-class="{active: !!selId}" icon icon-id="flowTable" icon-size="36" tooltip tt-msg="flowTip" diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.css b/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.css index 4aa96210..30226222 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.css +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.css @@ -23,7 +23,6 @@ } #ov-flow div.ctrl-btns { - width: 240px; } .light #ov-flow .current-view use { diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.html b/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.html index 5fce98cf..8fc1839e 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.html +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.html @@ -13,6 +13,11 @@ <div class="separator"></div> + <div class="active" + icon icon-id="deviceTable" icon-size="36" + tooltip tt-msg="deviceTip" + ng-click="nav('device')"></div> + <div class="current-view" icon icon-id="flowTable" icon-size="36"></div> diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.js b/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.js index 15678d5e..7bb988a2 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.js +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/flow/flow.js @@ -37,6 +37,7 @@ fs = _fs_; tbs = _tbs_; ns = _ns_; + $scope.deviceTip = 'Show device table'; $scope.portTip = 'Show port view for this device'; $scope.groupTip = 'Show group view for this device'; diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.css b/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.css index 42f1c31d..6773aa83 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.css +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.css @@ -23,7 +23,6 @@ } #ov-group div.ctrl-btns { - width: 240px; } .light #ov-group .current-view use { diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.html b/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.html index b963f469..93484dc8 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.html +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.html @@ -30,6 +30,11 @@ <div class="separator"></div> <div class="active" + icon icon-id="deviceTable" icon-size="36" + tooltip tt-msg="deviceTip" + ng-click="nav('device')"></div> + + <div class="active" icon icon-id="flowTable" icon-size="36" tooltip tt-msg="flowTip" ng-click="nav('flow')"></div> diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.js b/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.js index 2510190b..2cb1f0c4 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.js +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/group/group.js @@ -37,6 +37,7 @@ fs = _fs_; tbs = _tbs_; ns = _ns_; + $scope.deviceTip = 'Show device table'; $scope.flowTip = 'Show flow view for this device'; $scope.portTip = 'Show port view for this device'; diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.css b/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.css index 7fcfee3f..2aaacfce 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.css +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.css @@ -23,7 +23,6 @@ } #ov-port div.ctrl-btns { - width: 240px; } .light #ov-port .current-view use { diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.html b/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.html index 8eecb9d6..fa79e5ea 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.html +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.html @@ -30,6 +30,11 @@ <div class="separator"></div> <div class="active" + icon icon-id="deviceTable" icon-size="36" + tooltip tt-msg="deviceTip" + ng-click="nav('device')"></div> + + <div class="active" icon icon-id="flowTable" icon-size="36" tooltip tt-msg="flowTip" ng-click="nav('flow')"></div> diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.js b/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.js index a157c5be..1e8585dd 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.js +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/port/port.js @@ -37,6 +37,7 @@ fs = _fs_; tbs = _tbs_; ns = _ns_; + $scope.deviceTip = 'Show device table'; $scope.flowTip = 'Show flow view for this device'; $scope.groupTip = 'Show group view for this device'; diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topo.js b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topo.js index 7ddfd136..702584af 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topo.js +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topo.js @@ -30,7 +30,7 @@ // references to injected services etc. var $scope, $log, $cookies, fs, ks, zs, gs, ms, sus, flash, wss, ps, - tes, tfs, tps, tis, tss, tls, tts, tos, fltr, ttbs, ttip, tov; + tds, tes, tfs, tps, tis, tss, tls, tts, tos, fltr, ttbs, ttip, tov; // DOM elements var ovtopo, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer; @@ -425,7 +425,7 @@ .controller('OvTopoCtrl', ['$scope', '$log', '$location', '$timeout', '$cookies', 'FnService', 'MastService', 'KeyService', 'ZoomService', 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService', - 'WebSocketService', 'PrefsService', + 'WebSocketService', 'PrefsService', 'TopoDialogService', 'TopoEventService', 'TopoForceService', 'TopoPanelService', 'TopoInstService', 'TopoSelectService', 'TopoLinkService', 'TopoTrafficService', 'TopoObliqueService', 'TopoFilterService', @@ -433,9 +433,9 @@ 'TopoOverlayService', function (_$scope_, _$log_, $loc, $timeout, _$cookies_, _fs_, mast, _ks_, - _zs_, _gs_, _ms_, _sus_, _flash_, _wss_, _ps_, _tes_, _tfs_, - _tps_, _tis_, _tss_, _tls_, _tts_, _tos_, _fltr_, _ttbs_, tspr, - _ttip_, _tov_) { + _zs_, _gs_, _ms_, _sus_, _flash_, _wss_, _ps_, _tds_, _tes_, + _tfs_, _tps_, _tis_, _tss_, _tls_, _tts_, _tos_, _fltr_, + _ttbs_, tspr, _ttip_, _tov_) { var params = $loc.search(), projection, dim, @@ -461,6 +461,7 @@ flash = _flash_; wss = _wss_; ps = _ps_; + tds = _tds_; tes = _tes_; tfs = _tfs_; // TODO: consider funnelling actions through TopoForceService... @@ -495,6 +496,7 @@ tes.stop(); ks.unbindKeys(); tps.destroyPanels(); + tds.closeDialog(); tis.destroyInst(); tfs.destroyForce(); ttbs.destroyToolbar(); diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoDialog.js b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoDialog.js index 93079183..0c47511b 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoDialog.js +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoDialog.js @@ -106,6 +106,13 @@ .on('click', invoke); } + function setTitle(title) { + if (pApi) { + pApi.appendHeader('h2').text(title); + } + return dApi; + } + function addContent(content) { if (pApi) { pApi.appendBody(content); @@ -127,11 +134,11 @@ pApi = createDialog(); } pApi.reset(); - pApi.appendHeader('h2').text('=dialog='); panel.show(); // return the dialog object API dApi = { + setTitle: setTitle, addContent: addContent, addButton: addButton }; diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoEvent.js b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoEvent.js index 2957629a..9b07f878 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoEvent.js +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoEvent.js @@ -55,6 +55,7 @@ removeDevice: tfs, addHost: tfs, updateHost: tfs, + moveHost: tfs, removeHost: tfs, addLink: tfs, updateLink: tfs, diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoForce.js b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoForce.js index 844d7dc9..175ee796 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoForce.js +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoForce.js @@ -187,6 +187,35 @@ } } + function moveHost(data) { + var id = data.id, + d = lu[id], + lnk; + if (d) { + // first remove the old host link + removeLinkElement(d.linkData); + + // merge new data + angular.extend(d, data); + if (tms.positionNode(d, true)) { + sendUpdateMeta(d); + } + + // now create a new host link + lnk = tms.createHostLink(data); + if (lnk) { + d.linkData = lnk; + network.links.push(lnk); + lu[d.ingress] = lnk; + lu[d.egress] = lnk; + } + + updateNodes(); + updateLinks(); + fResume(); + } + } + function removeHost(data) { var id = data.id, d = lu[id]; @@ -1142,6 +1171,7 @@ removeDevice: removeDevice, addHost: addHost, updateHost: updateHost, + moveHost: moveHost, removeHost: removeHost, addLink: addLink, updateLink: updateLink, diff --git a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoToolbar.js b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoToolbar.js index 06285442..804e2a3c 100644 --- a/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoToolbar.js +++ b/framework/src/onos/web/gui/src/main/webapp/app/view/topo/topoToolbar.js @@ -23,7 +23,7 @@ 'use strict'; // injected references - var $log, fs, tbs, ps, tov, api; + var $log, fs, tbs, ps, tov, tds, api; // API: // getActionEntry @@ -192,6 +192,8 @@ }); } + // ensure dialog has closed (if opened by outgoing overlay) + tds.closeDialog(); thirdRow.clear(); if (!order.length) { @@ -271,14 +273,15 @@ angular.module('ovTopo') .factory('TopoToolbarService', ['$log', 'FnService', 'ToolbarService', 'PrefsService', - 'TopoOverlayService', + 'TopoOverlayService', 'TopoDialogService', - function (_$log_, _fs_, _tbs_, _ps_, _tov_) { + function (_$log_, _fs_, _tbs_, _ps_, _tov_, _tds_) { $log = _$log_; fs = _fs_; tbs = _tbs_; ps = _ps_; tov = _tov_; + tds = _tds_; return { init: init, |