Search in sources :

Example 1 with UiGlyph

use of org.onosproject.ui.UiGlyph in project onos by opennetworkinglab.

the class UiWebSocket method sendBootstrapData.

// Sends initial information (username and cluster member information)
// to allow GUI to display logged-in user, and to be able to
// fail-over to an alternate cluster member if necessary.
private void sendBootstrapData() {
    ClusterService service = directory.get(ClusterService.class);
    ArrayNode instances = arrayNode();
    for (ControllerNode node : service.getNodes()) {
        IpAddress nodeIp = node.ip();
        ObjectNode instance = objectNode().put(ID, node.id().toString()).put(IP, nodeIp != null ? nodeIp.toString() : node.host()).put(GlyphConstants.UI_ATTACHED, node.equals(service.getLocalNode()));
        instances.add(instance);
    }
    ArrayNode glyphInstances = arrayNode();
    UiExtensionService uiExtensionService = directory.get(UiExtensionService.class);
    for (UiGlyph glyph : uiExtensionService.getGlyphs()) {
        ObjectNode glyphInstance = objectNode().put(GlyphConstants.ID, glyph.id()).put(GlyphConstants.VIEWBOX, glyph.viewbox()).put(GlyphConstants.PATH, glyph.path());
        glyphInstances.add(glyphInstance);
    }
    ObjectNode payload = objectNode();
    payload.set(CLUSTER_NODES, instances);
    payload.set(GLYPHS, glyphInstances);
    payload.put(USER, userName);
    sendMessage(BOOTSTRAP, payload);
}
Also used : UiGlyph(org.onosproject.ui.UiGlyph) ClusterService(org.onosproject.cluster.ClusterService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) UiExtensionService(org.onosproject.ui.UiExtensionService) ControllerNode(org.onosproject.cluster.ControllerNode) IpAddress(org.onlab.packet.IpAddress) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 2 with UiGlyph

use of org.onosproject.ui.UiGlyph in project onos by opennetworkinglab.

the class UiExtensionManager method unregister.

@Override
public synchronized void unregister(UiGlyphFactory glyphFactory) {
    checkPermission(GLYPH_WRITE);
    boolean glyphRemoved = false;
    for (UiGlyph glyph : glyphFactory.glyphs()) {
        glyphs.remove(glyph);
        glyphRemoved = true;
    }
    if (glyphRemoved) {
        UiWebSocketServlet.sendToAll(GLYPH_REMOVED, null);
    }
}
Also used : UiGlyph(org.onosproject.ui.UiGlyph)

Example 3 with UiGlyph

use of org.onosproject.ui.UiGlyph in project onos by opennetworkinglab.

the class UiExtensionManager method register.

@Override
public synchronized void register(UiGlyphFactory glyphFactory) {
    checkPermission(GLYPH_WRITE);
    boolean glyphAdded = false;
    for (UiGlyph glyph : glyphFactory.glyphs()) {
        if (!glyphs.contains(glyph)) {
            glyphs.add(glyph);
            glyphAdded = true;
        }
    }
    if (glyphAdded) {
        UiWebSocketServlet.sendToAll(GLYPH_ADDED, null);
    }
}
Also used : UiGlyph(org.onosproject.ui.UiGlyph)

Aggregations

UiGlyph (org.onosproject.ui.UiGlyph)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 IpAddress (org.onlab.packet.IpAddress)1 ClusterService (org.onosproject.cluster.ClusterService)1 ControllerNode (org.onosproject.cluster.ControllerNode)1 UiExtensionService (org.onosproject.ui.UiExtensionService)1