X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fweb%2Froot%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fweb%2FDaylightWebUtil.java;h=e88983630148a7d3c42b2e3ddeeaed409c4ec018;hb=4c1e9ed9fa2386ca63a0bbf11da620c83a6d7d5e;hp=3add0e6a40b22d0745421d7f0d4db46a82babbfa;hpb=0d8516471e3ee70a8bc9f02d046c5c0a20db01b1;p=controller.git diff --git a/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebUtil.java b/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebUtil.java index 3add0e6a40..e889836301 100644 --- a/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebUtil.java +++ b/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebUtil.java @@ -1,9 +1,21 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.web; import org.opendaylight.controller.containermanager.IContainerAuthorization; import org.opendaylight.controller.sal.authorization.Privilege; +import org.opendaylight.controller.sal.core.Description; +import org.opendaylight.controller.sal.core.Name; +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.ServiceHelper; +import org.opendaylight.controller.switchmanager.ISwitchManager; import org.opendaylight.controller.usermanager.IUserManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,17 +73,68 @@ public class DaylightWebUtil { public static void auditlog(String moduleName, String user, String action, String resource, String containerName) { String auditMsg = ""; - String mode = "WEB"; + String mode = "UI"; if (containerName != null) { auditMsg = "Mode: " + mode + " User " + user + " " + action + " " + moduleName + " " + resource + " in container " + containerName; } else { auditMsg = "Mode: " + mode + " User " + user + " " + action + " " + moduleName + " " + resource; } - logger.info(auditMsg); + logger.trace(auditMsg); } public static void auditlog(String moduleName, String user, String action, String resource) { auditlog(moduleName, user, action, resource, null); } -} \ No newline at end of file + + public static String getNodeDesc(Node node, ISwitchManager switchManager) { + Description desc = (Description) switchManager.getNodeProp(node, + Description.propertyName); + String description = (desc == null) ? "" : desc.getValue(); + return (description.isEmpty() || description.equalsIgnoreCase("none")) ? node + .toString() : description; + } + + public static String getNodeDesc(Node node, String containerName, + Object bundle) { + ISwitchManager switchManager = (ISwitchManager) ServiceHelper + .getInstance(ISwitchManager.class, containerName, bundle); + if (switchManager == null) { + return null; + } + + return getNodeDesc(node, switchManager); + } + + public static String getNodeDesc(Node node, Object bundle) { + ISwitchManager switchManager = (ISwitchManager) ServiceHelper + .getInstance(ISwitchManager.class, + GlobalConstants.DEFAULT.toString(), bundle); + if (switchManager == null) { + return null; + } + + return getNodeDesc(node, switchManager); + } + + public static String getPortName(NodeConnector nodeConnector, + String container, Object bundle) { + ISwitchManager switchManager = (ISwitchManager) ServiceHelper + .getInstance(ISwitchManager.class, container, bundle); + return getPortName(nodeConnector, switchManager); + } + + public static String getPortName(NodeConnector nodeConnector, Object bundle) { + return getPortName(nodeConnector, GlobalConstants.DEFAULT.toString(), bundle); + } + + public static String getPortName(NodeConnector nodeConnector, + ISwitchManager switchManager) { + Name ncName = ((Name) switchManager.getNodeConnectorProp(nodeConnector, + Name.NamePropName)); + String nodeConnectorName = (ncName != null) ? ncName.getValue() : nodeConnector.getNodeConnectorIdAsString(); + nodeConnectorName = nodeConnectorName + "@" + + getNodeDesc(nodeConnector.getNode(), switchManager); + return nodeConnectorName.substring(0, nodeConnectorName.length()); + } +}