</configuration>
<executions>
<execution>
+ <id>failsafe-integration-tests</id>
+ <phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
+ <execution>
+ <id>failsafe-verify</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
</executions>
</plugin>
<plugin>
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.opendaylight.controller.clustering.services.IClusterServices;
import org.opendaylight.controller.configuration.IConfigurationService;
import org.opendaylight.controller.sal.utils.GlobalConstants;
import org.opendaylight.controller.sal.utils.Status;
// get the OSGI bundle context
@Inject
private BundleContext bc;
- private IClusterServices clusterService = null;
private IConfigurationService configService = null;
// Configure the OSGi container
// Set the systemPackages (used by clustering)
systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
// List framework bundles
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",
- "1.0.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",
- "1.0.400.v20120522-2049"),
- mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",
- "3.3.100.v20120522-1822"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",
- "1.4.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",
- "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",
- "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
- "0.8.0.v201110170705"),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.util").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.osgi.services").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject(),
// List logger bundles
- mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
- mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
- mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
- mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
- mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
- mavenBundle("org.jboss.spec.javax.transaction",
- "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
+ mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
+ mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(),
+ mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
+ mavenBundle("org.jboss.spec.javax.transaction", "jboss-transaction-api_1.1_spec").versionAsInProject(),
mavenBundle("eclipselink", "javax.resource").versionAsInProject(),
- mavenBundle("org.apache.felix",
- "org.apache.felix.dependencymanager", "3.1.0"),
+ mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").versionAsInProject(),
// List all the bundles on which the test case depends
- mavenBundle("org.opendaylight.controller", "sal",
- "0.5.0-SNAPSHOT"), // SAL connects the protocols
- // plug-ins to other stuff
- mavenBundle("org.opendaylight.controller",
- "sal.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller",
- "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "sal.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "protocol_plugins.stub").versionAsInProject(),
// needed bundles by switchmanager
- mavenBundle("org.opendaylight.controller", "containermanager",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller",
- "containermanager.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "containermanager").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "containermanager.implementation").versionAsInProject(),
// needed bundles by configuration
- mavenBundle("org.opendaylight.controller",
- "clustering.services", "0.4.0-SNAPSHOT"), // what are
- // the
- // clustering
- // services
- // for
- mavenBundle("org.opendaylight.controller", "clustering.stub",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller",
- "clustering.services-implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "configuration",
- "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller",
- "configuration.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "clustering.services").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "clustering.stub").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "configuration").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "configuration.implementation").versionAsInProject(),
junitBundles());
}
// Assert if true, if false we are good to go!
assertFalse(debugit);
- ServiceReference r = bc.getServiceReference(IClusterServices.class
- .getName());
- if (r != null) {
- this.clusterService = (IClusterServices) bc.getService(r);
- }
- // If StatisticsManager is null, cannot run tests.
- assertNotNull(this.clusterService);
-
}
@Before
# of.discoveryTimeoutMultiple=2
# For newly added ports, allow one more retry if the elapsed time exceeds this threshold (default 30 sec)
# of.discoveryThreshold=30
-# The maximum number of ports handled in one discovery batch (default 1024)
-# of.discoveryBatchMaxPorts=1024
+# The maximum number of ports handled in one discovery batch (default 512)
+# of.discoveryBatchMaxPorts=512
# TLS configuration
# To enable TLS, set secureChannelEnabled=true and specify the location of controller Java KeyStore and TrustStore files.
// Set the systemPackages (used by clustering)
systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
// List framework bundles
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",
- "1.0.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",
- "1.0.400.v20120522-2049"),
- mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",
- "3.3.100.v20120522-1822"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",
- "1.4.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",
- "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",
- "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
- "0.8.0.v201110170705"),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.util").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.osgi.services").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject(),
// List logger bundles
mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
mavenBundle("org.slf4j", "log4j-over-slf4j")
* @param nc
* NodeConnector to which the host is attached
* @param vlan
- * VLAN the host belongs to
+ * VLAN the host belongs to (null or empty for no vlan)
* @return The status object as described in {@code Status} indicating the
* result of this action.
*/
@Override
public Future<HostNodeConnector> discoverHost(InetAddress networkAddress) {
if (executor == null) {
- logger.error("discoverHost: Null executor");
+ logger.debug("discoverHost: Null executor");
return null;
}
Callable<HostNodeConnector> worker = new HostTrackerCallable(this, networkAddress);
@Override
public Set<HostNodeConnector> getAllHosts() {
- Set<HostNodeConnector> allHosts = new HashSet<HostNodeConnector>();
- for (Entry<InetAddress, HostNodeConnector> entry : hostsDB.entrySet()) {
- HostNodeConnector host = entry.getValue();
- allHosts.add(host);
- }
- logger.debug("Exiting getAllHosts, Found {} Hosts", allHosts.size());
+ Set<HostNodeConnector> allHosts = new HashSet<HostNodeConnector>(hostsDB.values());
return allHosts;
}
list.add(host);
}
}
- logger.debug("getActiveStaticHosts(): Found {} Hosts", list.size());
return list;
}
@Override
public Set<HostNodeConnector> getInactiveStaticHosts() {
- Set<HostNodeConnector> list = new HashSet<HostNodeConnector>();
- for (Entry<NodeConnector, HostNodeConnector> entry : inactiveStaticHosts.entrySet()) {
- list.add(entry.getValue());
- }
- logger.debug("getInactiveStaticHosts(): Found {} Hosts", list.size());
+ Set<HostNodeConnector> list = new HashSet<HostNodeConnector>(inactiveStaticHosts.values());
return list;
}
ta.notifyHTClientHostRemoved(host);
}
} catch (Exception e) {
- logger.error("Exception on callback", e);
+ logger.error("Exception on new host notification", e);
}
}
}
* probe. However, continue the age out the hosts since
* we don't know if the host is indeed out there or not.
*/
- logger.warn("ARPHandler is not avaialable, can't send the probe");
+ logger.trace("ARPHandler is not avaialable, can't send the probe");
continue;
}
hostFinder.probe(host);
* indicating the result of this action.
*/
- public Status addStaticHostReq(InetAddress networkAddr, byte[] dataLayerAddress, NodeConnector nc, short vlan) {
+ protected Status addStaticHostReq(InetAddress networkAddr, byte[] dataLayerAddress, NodeConnector nc, short vlan) {
if (dataLayerAddress.length != NetUtils.MACAddrLengthInBytes) {
return new Status(StatusCode.BADREQUEST, "Invalid MAC address");
}
// northbound request
HostNodeConnector transHost = hostsDB.get(networkAddr);
transHost.setStaticHost(true);
- return new Status(StatusCode.SUCCESS, null);
+ return new Status(StatusCode.SUCCESS);
}
if (hostsDB.get(networkAddr) != null) {
// There is already a host with this IP address (but behind
// a different (switch, port, vlan) tuple. Return an error
- return new Status(StatusCode.CONFLICT, "Existing IP, Use PUT to update");
+ return new Status(StatusCode.CONFLICT, "Host with this IP already exists.");
}
host.setStaticHost(true);
/*
logger.debug("Switch or switchport is not up, adding host {} to inactive list",
networkAddr.getHostName());
}
- return new Status(StatusCode.SUCCESS, null);
+ return new Status(StatusCode.SUCCESS);
} catch (ConstructionException e) {
logger.error("", e);
return new Status(StatusCode.INTERNALERROR, "Host could not be created");
public Status addStaticHost(String networkAddress, String dataLayerAddress, NodeConnector nc, String vlan) {
try {
InetAddress ip = InetAddress.getByName(networkAddress);
- if (nc == null) {
- return new Status(StatusCode.BADREQUEST, "Invalid NodeId");
+ short vl = 0;
+ if (vlan != null && !vlan.isEmpty()) {
+ vl = Short.decode(vlan);
+ if (vl < 1 || vl > 4095) {
+ return new Status(StatusCode.BADREQUEST, "Host vlan out of range [1 - 4095]");
+ }
}
- return addStaticHostReq(ip, HexEncode.bytesFromHexString(dataLayerAddress), nc, Short.valueOf(vlan));
+
+ return addStaticHostReq(ip, HexEncode.bytesFromHexString(dataLayerAddress), nc, vl);
+
} catch (UnknownHostException e) {
- logger.error("", e);
- return new Status(StatusCode.BADREQUEST, "Invalid Address");
+ logger.debug("Invalid host IP specified when adding static host", e);
+ return new Status(StatusCode.BADREQUEST, "Invalid Host IP Address");
+ } catch (NumberFormatException nfe) {
+ logger.debug("Invalid host vlan or MAC specified when adding static host", nfe);
+ return new Status(StatusCode.BADREQUEST, "Invalid Host vLan/MAC");
}
}
@Override
public Status removeStaticHost(String networkAddress) {
- InetAddress address;
try {
- address = InetAddress.getByName(networkAddress);
+ InetAddress address = InetAddress.getByName(networkAddress);
return removeStaticHostReq(address);
} catch (UnknownHostException e) {
- logger.error("", e);
- return new Status(StatusCode.BADREQUEST, "Invalid Address");
+ logger.debug("Invalid IP Address when trying to remove host", e);
+ return new Status(StatusCode.BADREQUEST, "Invalid IP Address when trying to remove host");
}
}
ARPPending arphost;
HostNodeConnector host = null;
- logger.debug("handleNodeConnectorStatusUp {}", nodeConnector);
+ logger.trace("handleNodeConnectorStatusUp {}", nodeConnector);
for (Entry<InetAddress, ARPPending> entry : failedARPReqList.entrySet()) {
arphost = entry.getValue();
- logger.debug("Sending the ARP from FailedARPReqList fors IP: {}", arphost.getHostIP().getHostAddress());
+ logger.trace("Sending the ARP from FailedARPReqList fors IP: {}", arphost.getHostIP().getHostAddress());
if (hostFinder == null) {
logger.warn("ARPHandler is not available at interface up");
logger.warn("Since this event is missed, host(s) connected to interface {} may not be discovered",
arphost.getHostIP(), nodeConnector);
logger.error("", e);
}
- logger.debug("Done. handleNodeConnectorStatusUp {}", nodeConnector);
}
host = inactiveStaticHosts.get(nodeConnector);
}
private void handleNodeConnectorStatusDown(NodeConnector nodeConnector) {
- logger.debug("handleNodeConnectorStatusDown {}", nodeConnector);
+ logger.trace("handleNodeConnectorStatusDown {}", nodeConnector);
for (Entry<InetAddress, HostNodeConnector> entry : hostsDB.entrySet()) {
HostNodeConnector host = entry.getValue();
// Set the systemPackages (used by clustering)
systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
// List framework bundles
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.console", "1.0.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.util", "1.0.400.v20120522-2049"),
- mavenBundle("equinoxSDK381", "org.eclipse.osgi.services","3.3.100.v20120522-1822"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds", "1.4.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command", "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime", "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell", "0.8.0.v201110170705"),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.util").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.osgi.services").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject(),
// List logger bundles
mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),
NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1);
// test addStaticHost(), store into inactive host DB
- Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66", nc1_1, "0");
+ Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66", nc1_1, null);
Assert.assertTrue(st.isSuccess());
- st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77", nc1_2, "0");
+ st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77", nc1_2, "");
Assert.assertTrue(st.isSuccess());
// check inactive DB
NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1);
// test addStaticHost(), put into inactive host DB if not verifiable
- Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66", nc1_1, "0");
+ Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66", nc1_1, null);
+ Assert.assertTrue(st.isSuccess());
st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77", nc1_2, "0");
+ Assert.assertFalse(st.isSuccess());
+
this.invtoryListener.notifyNodeConnector(nc1_1, UpdateType.ADDED, null);
NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1);
// test addStaticHost(), put into inactive host DB if not verifiable
- Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66", nc1_1, "0");
- st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77", nc1_2, "0");
+ Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66", nc1_1, null);
+ st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77", nc1_2, "");
HostNodeConnector hnc_1 = this.hosttracker.hostFind(InetAddress.getByName("192.168.0.8"));
assertNull(hnc_1);
"Operation failed due to Resource Conflict"), NODEFAULT("Container default is not a custom container"), DEFAULTDISABLED(
"Container(s) are configured. Container default is not operational"), NOTALLOWEDONDEFAULT(
"Container default is a static resource, no modification allowed on it"), UNKNOWNACTION("Unknown action"), INVALIDJSON(
- "JSON message is invalid"), INVALIDADDRESS("invalid InetAddress"), AVAILABLESOON(
+ "JSON message is invalid"), INVALIDADDRESS("Invalid InetAddress"), AVAILABLESOON(
"Resource is not implemented yet"), INTERNALERROR("Internal Error"), SERVICEUNAVAILABLE(
"Service is not available. Could be down for maintanence"), INVALIDDATA(
"Data is invalid or conflicts with URI");
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
import javax.xml.bind.JAXBElement;
import org.codehaus.enunciate.jaxrs.ResponseCode;
import org.opendaylight.controller.hosttracker.IfIptoHost;
import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.InternalServerErrorException;
+import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException;
import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
-import org.opendaylight.controller.northbound.commons.exception.UnsupportedMediaTypeException;
import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
import org.opendaylight.controller.sal.authorization.Privilege;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.GlobalConstants;
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.controller.switchmanager.ISwitchManager;
/**
}
private IfIptoHost getIfIpToHostService(String containerName) {
- IContainerManager containerManager = (IContainerManager) ServiceHelper
- .getGlobalInstance(IContainerManager.class, this);
+ IContainerManager containerManager = (IContainerManager) ServiceHelper.getGlobalInstance(
+ IContainerManager.class, this);
if (containerManager == null) {
- throw new ServiceUnavailableException("Container "
- + RestMessages.SERVICEUNAVAILABLE.toString());
+ throw new ServiceUnavailableException("Container " + RestMessages.SERVICEUNAVAILABLE.toString());
}
boolean found = false;
for (String cName : containerNames) {
if (cName.trim().equalsIgnoreCase(containerName.trim())) {
found = true;
+ break;
}
}
- if (found == false) {
- throw new ResourceNotFoundException(containerName + " "
- + RestMessages.NOCONTAINER.toString());
+ if (!found) {
+ throw new ResourceNotFoundException(containerName + " " + RestMessages.NOCONTAINER.toString());
}
- IfIptoHost hostTracker = (IfIptoHost) ServiceHelper.getInstance(
- IfIptoHost.class, containerName, this);
-
+ IfIptoHost hostTracker = (IfIptoHost) ServiceHelper.getInstance(IfIptoHost.class, containerName, this);
if (hostTracker == null) {
- throw new ServiceUnavailableException("Host Tracker "
- + RestMessages.SERVICEUNAVAILABLE.toString());
+ throw new ServiceUnavailableException("Host Tracker " + RestMessages.SERVICEUNAVAILABLE.toString());
}
return hostTracker;
@ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public Hosts getActiveHosts(@PathParam("containerName") String containerName) {
- if (!NorthboundUtils.isAuthorized(
- getUserName(), containerName, Privilege.READ, this)) {
- throw new UnauthorizedException(
- "User is not authorized to perform this operation on container "
- + containerName);
+ if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
+ throw new UnauthorizedException("User is not authorized to perform this operation on container "
+ + containerName);
}
IfIptoHost hostTracker = getIfIpToHostService(containerName);
- if (hostTracker == null) {
- throw new ServiceUnavailableException("Host Tracker "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
return convertHosts(hostTracker.getAllHosts());
}
@ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public Hosts getInactiveHosts(
@PathParam("containerName") String containerName) {
- if (!NorthboundUtils.isAuthorized(
- getUserName(), containerName, Privilege.READ, this)) {
- throw new UnauthorizedException(
- "User is not authorized to perform this operation on container "
- + containerName);
+ if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
+ throw new UnauthorizedException("User is not authorized to perform this operation on container "
+ + containerName);
}
IfIptoHost hostTracker = getIfIpToHostService(containerName);
- if (hostTracker == null) {
- throw new ServiceUnavailableException("Host Tracker "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
return convertHosts(hostTracker.getInactiveStaticHosts());
}
@TypeHint(HostConfig.class)
@StatusCodes({
@ResponseCode(code = 200, condition = "Operation successful"),
+ @ResponseCode(code = 400, condition = "Invalid IP specified in networkAddress parameter"),
@ResponseCode(code = 404, condition = "The containerName is not found"),
- @ResponseCode(code = 415, condition = "Invalid IP Address passed in networkAddress parameter"),
@ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public HostConfig getHostDetails(
@PathParam("containerName") String containerName,
@PathParam("networkAddress") String networkAddress) {
- if (!NorthboundUtils.isAuthorized(
- getUserName(), containerName, Privilege.READ, this)) {
- throw new UnauthorizedException(
- "User is not authorized to perform this operation on container "
- + containerName);
+ if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
+ throw new UnauthorizedException("User is not authorized to perform this operation on container "
+ + containerName);
}
IfIptoHost hostTracker = getIfIpToHostService(containerName);
- if (hostTracker == null) {
- throw new ServiceUnavailableException("Host Tracker "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
InetAddress ip;
try {
ip = InetAddress.getByName(networkAddress);
} catch (UnknownHostException e) {
- throw new UnsupportedMediaTypeException(networkAddress + " "
- + RestMessages.INVALIDADDRESS.toString());
+ throw new BadRequestException(RestMessages.INVALIDADDRESS.toString() + " " + networkAddress);
}
for (HostNodeConnector host : hostTracker.getAllHosts()) {
if (host.getNetworkAddress().equals(ip)) {
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
@ResponseCode(code = 201, condition = "Static host created successfully"),
- @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"),
- @ResponseCode(code = 406, condition = "Cannot operate on Default Container when other Containers are active"),
- @ResponseCode(code = 415, condition = "Invalid IP Address passed in networkAddress parameter"),
- @ResponseCode(code = 500, condition = "Failed to create Static Host entry. Failure Reason included in HTTP Error response"),
+ @ResponseCode(code = 400, condition = "Invalid parameters specified, see response body for details"),
+ @ResponseCode(code = 404, condition = "The container or resource is not found"),
+ @ResponseCode(code = 409, condition = "Resource conflict, see response body for details"),
@ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
- public Response addHost(@PathParam("containerName") String containerName,
+ public Response addHost(@Context UriInfo uriInfo, @PathParam("containerName") String containerName,
@PathParam("networkAddress") String networkAddress,
@TypeHint(HostConfig.class) JAXBElement<HostConfig> hostConfig) {
- if (!NorthboundUtils.isAuthorized(
- getUserName(), containerName, Privilege.WRITE, this)) {
- throw new UnauthorizedException(
- "User is not authorized to perform this operation on container "
- + containerName);
+ if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.WRITE, this)) {
+ return Response.status(Response.Status.UNAUTHORIZED)
+ .entity("User is not authorized to perform this operation on container " + containerName)
+ .build();
}
handleDefaultDisabled(containerName);
IfIptoHost hostTracker = getIfIpToHostService(containerName);
- if (hostTracker == null) {
- throw new ServiceUnavailableException("Host Tracker "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
HostConfig hc = hostConfig.getValue();
- Node node = handleNodeAvailability(containerName, hc.getNodeType(), hc.getNodeId());
- if (node == null) {
- throw new InternalServerErrorException(
- RestMessages.NONODE.toString());
+ if (!networkAddress.equals(hc.getNetworkAddress())) {
+ return Response.status(Response.Status.CONFLICT)
+ .entity("Resource name in config object doesn't match URI")
+ .build();
}
-
- try {
- InetAddress.getByName(networkAddress);
- } catch (UnknownHostException e) {
- throw new UnsupportedMediaTypeException(networkAddress + " "
- + RestMessages.INVALIDADDRESS.toString());
- }
- if(!networkAddress.equals(hc.getNetworkAddress())) {
- throw new UnsupportedMediaTypeException(networkAddress + " is not the same as "
- + hc.getNetworkAddress());
- }
- if(!hc.isStaticHost()) {
- throw new UnsupportedMediaTypeException("StaticHost flag must be true");
+ if (!hc.isStaticHost()) {
+ return Response.status(Response.Status.BAD_REQUEST)
+ .entity("Can only add static host.")
+ .build();
}
+ Node node = handleNodeAvailability(containerName, hc.getNodeType(), hc.getNodeId());
NodeConnector nc = NodeConnector.fromStringNoNode(hc.getNodeConnectorType(), hc.getNodeConnectorId(), node);
- if (nc == null) {
- throw new ResourceNotFoundException(hc.getNodeConnectorType() + "|"
- + hc.getNodeConnectorId() + " : " + RestMessages.NONODE.toString());
- }
- Status status = hostTracker.addStaticHost(networkAddress,
- hc.getDataLayerAddress(), nc, hc.getVlan());
+
+ Status status = hostTracker.addStaticHost(networkAddress, hc.getDataLayerAddress(), nc, hc.getVlan());
if (status.isSuccess()) {
NorthboundUtils.auditlog("Static Host", username, "added", networkAddress, containerName);
- return Response.status(Response.Status.CREATED).build();
- } else if (status.getCode().equals(StatusCode.BADREQUEST)) {
- throw new UnsupportedMediaTypeException(status.getDescription());
+ return Response.created(uriInfo.getRequestUri()).build();
}
- throw new InternalServerErrorException(status.getDescription());
+
+ return NorthboundUtils.getResponse(status);
}
/**
@DELETE
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
- @ResponseCode(code = 200, condition = "Flow Config deleted successfully"),
- @ResponseCode(code = 404, condition = "The Container Name or Node-id or Flow Name passed is not found"),
+ @ResponseCode(code = 204, condition = "Static host deleted successfully"),
+ @ResponseCode(code = 404, condition = "The container or a specified resource was not found"),
@ResponseCode(code = 406, condition = "Cannot operate on Default Container when other Containers are active"),
- @ResponseCode(code = 415, condition = "Invalid IP Address passed in networkAddress parameter"),
- @ResponseCode(code = 500, condition = "Failed to delete Flow config. Failure Reason included in HTTP Error response"),
@ResponseCode(code = 503, condition = "One or more of Controller service is unavailable") })
- public Response deleteFlow(
+ public Response deleteHost(
@PathParam(value = "containerName") String containerName,
@PathParam(value = "networkAddress") String networkAddress) {
- if (!NorthboundUtils.isAuthorized(
- getUserName(), containerName, Privilege.WRITE, this)) {
- throw new UnauthorizedException(
- "User is not authorized to perform this operation on container "
- + containerName);
+ if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.WRITE, this)) {
+ return Response.status(Response.Status.UNAUTHORIZED)
+ .entity("User is not authorized to perform this operation on container " + containerName)
+ .build();
}
handleDefaultDisabled(containerName);
IfIptoHost hostTracker = getIfIpToHostService(containerName);
- if (hostTracker == null) {
- throw new ServiceUnavailableException("Host Tracker "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- try {
- InetAddress.getByName(networkAddress);
- } catch (UnknownHostException e) {
- throw new UnsupportedMediaTypeException(networkAddress + " "
- + RestMessages.INVALIDADDRESS.toString());
- }
Status status = hostTracker.removeStaticHost(networkAddress);
if (status.isSuccess()) {
NorthboundUtils.auditlog("Static Host", username, "removed", networkAddress, containerName);
- return Response.ok().build();
+ return Response.noContent().build();
}
- throw new InternalServerErrorException(status.getDescription());
+ return NorthboundUtils.getResponse(status);
}
IContainerManager containerManager = (IContainerManager) ServiceHelper
.getGlobalInstance(IContainerManager.class, this);
if (containerManager == null) {
- throw new InternalServerErrorException(
- RestMessages.INTERNALERROR.toString());
+ throw new ServiceUnavailableException(
+ RestMessages.SERVICEUNAVAILABLE.toString());
}
if (containerName.equals(GlobalConstants.DEFAULT.toString())
&& containerManager.hasNonDefaultContainer()) {
}
}
- private Node handleNodeAvailability(String containerName, String nodeType,
- String nodeId) {
+ private Node handleNodeAvailability(String containerName, String nodeType, String nodeId) {
Node node = Node.fromString(nodeType, nodeId);
if (node == null) {
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.opendaylight</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../../commons/opendaylight</relativePath>
+ <artifactId>commons.integrationtest</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ <relativePath>../../commons/integrationtest</relativePath>
</parent>
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
<artifactId>usermanager</artifactId>
<version>0.4.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>usermanager.implementation</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>security</artifactId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.8</version>
+ </dependency>
<dependency>
<groupId>equinoxSDK381</groupId>
<artifactId>javax.servlet</artifactId>
Integer nodeId_1 = 3366;
String nodeConnectorType_1 = "STUB";
Integer nodeConnectorId_1 = 12;
- String vlan_1 = "4";
+ String vlan_1 = "";
// 2nd host
String networkAddress_2 = "10.1.1.1";
Integer nodeId_2 = 4477;
String nodeConnectorType_2 = "STUB";
Integer nodeConnectorId_2 = 34;
- String vlan_2 = "0";
+ String vlan_2 = "123";
String baseURL = "http://127.0.0.1:8080/controller/nb/v2/host/default";
Assert.assertTrue(host_jo.getInt("nodeConnectorId") == nodeConnectorId_1);
Assert.assertTrue(host_jo.getString("nodeType").equalsIgnoreCase(nodeType_1));
Assert.assertTrue(host_jo.getInt("nodeId") == nodeId_1);
- Assert.assertTrue(host_jo.getString("vlan").equalsIgnoreCase(vlan_1));
+ Assert.assertTrue(host_jo.getString("vlan").equals("0"));
Assert.assertTrue(host_jo.getBoolean("staticHost"));
} else if (networkAddress.equalsIgnoreCase(networkAddress_2)) {
Assert.assertTrue(host_jo.getString("dataLayerAddress").equalsIgnoreCase(dataLayerAddress_2));
Assert.assertTrue(json.getInt("nodeConnectorId") == nodeConnectorId_1);
Assert.assertTrue(json.getString("nodeType").equalsIgnoreCase(nodeType_1));
Assert.assertTrue(json.getInt("nodeId") == nodeId_1);
- Assert.assertTrue(json.getString("vlan").equalsIgnoreCase(vlan_1));
+ Assert.assertTrue(json.getString("vlan").equals("0"));
Assert.assertTrue(json.getBoolean("staticHost"));
// test DELETE method for deleteFlow()
result = getJsonResult(baseURL + "/" + networkAddress_1, "DELETE");
- Assert.assertTrue(httpResponseCode == 200);
+ Assert.assertTrue(httpResponseCode == 204);
// verify host_1 removed from active host DB
// test GET method: getActiveHosts() - no host expected
// Set the systemPackages (used by clustering)
systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
- mavenBundle("javax.servlet", "servlet-api", "2.5"),
-
- mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.2"),
- mavenBundle("org.slf4j", "slf4j-api", "1.7.2"),
- mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"),
- mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
- mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
- mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
- mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager", "3.1.0"),
+ mavenBundle("org.slf4j", "jcl-over-slf4j").versionAsInProject(),
+ mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
+ mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),
+ mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(),
+ mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").versionAsInProject(),
// the plugin stub to get data for the tests
- mavenBundle("org.opendaylight.controller", "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "protocol_plugins.stub").versionAsInProject(),
// List all the opendaylight modules
- mavenBundle("org.opendaylight.controller", "configuration", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "configuration.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "containermanager", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "containermanager.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "clustering.services", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "clustering.services-implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "security", "0.4.0-SNAPSHOT").noStart(),
- mavenBundle("org.opendaylight.controller", "sal", "0.5.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "sal.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "sal.connection", "0.1.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "sal.connection.implementation", "0.1.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "switchmanager", "0.5.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "connectionmanager", "0.1.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "connectionmanager.implementation", "0.1.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "switchmanager.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "forwardingrulesmanager", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "forwardingrulesmanager.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "statisticsmanager", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "statisticsmanager.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "arphandler", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "hosttracker", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "hosttracker.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "arphandler", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "routing.dijkstra_implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "topologymanager", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "usermanager", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "usermanager.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "logging.bridge", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "clustering.test", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "forwarding.staticrouting", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "configuration").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "configuration.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "containermanager").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "containermanager.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "clustering.services").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "clustering.services-implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "security").versionAsInProject().noStart(),
+ mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "sal.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "sal.connection").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "sal.connection.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "switchmanager").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "connectionmanager").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "connectionmanager.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "switchmanager.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "forwardingrulesmanager").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller",
+ "forwardingrulesmanager.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "statisticsmanager").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "statisticsmanager.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "arphandler").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "hosttracker").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "hosttracker.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "arphandler").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "routing.dijkstra_implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "topologymanager").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "usermanager").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "usermanager.implementation").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "logging.bridge").versionAsInProject(),
+// mavenBundle("org.opendaylight.controller", "clustering.test").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "forwarding.staticrouting").versionAsInProject(),
// Northbound bundles
- mavenBundle("org.opendaylight.controller", "commons.northbound", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "forwarding.staticrouting.northbound", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "statistics.northbound", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "topology.northbound", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "hosttracker.northbound", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "switchmanager.northbound", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "flowprogrammer.northbound", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "subnets.northbound", "0.4.0-SNAPSHOT"),
-
- mavenBundle("org.codehaus.jackson", "jackson-mapper-asl", "1.9.8"),
- mavenBundle("org.codehaus.jackson", "jackson-core-asl", "1.9.8"),
- mavenBundle("org.codehaus.jackson", "jackson-jaxrs", "1.9.8"),
- mavenBundle("org.codehaus.jettison", "jettison", "1.3.3"),
-
- mavenBundle("commons-io", "commons-io", "2.3"),
-
- mavenBundle("commons-fileupload", "commons-fileupload", "1.2.2"),
-
- mavenBundle("equinoxSDK381", "javax.servlet", "3.0.0.v201112011016"),
- mavenBundle("equinoxSDK381", "javax.servlet.jsp", "2.2.0.v201112011158"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds", "1.4.0.v20120522-1841"),
- mavenBundle("orbit", "javax.xml.rpc", "1.1.0.v201005080400"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.util", "1.0.400.v20120522-2049"),
- mavenBundle("equinoxSDK381", "org.eclipse.osgi.services", "3.3.100.v20120522-1822"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command", "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime", "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell", "0.8.0.v201110170705"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.cm", "1.0.400.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.console", "1.0.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.launcher", "1.3.0.v20120522-1813"),
-
- mavenBundle("geminiweb", "org.eclipse.gemini.web.core", "2.2.0.RELEASE"),
- mavenBundle("geminiweb", "org.eclipse.gemini.web.extender", "2.2.0.RELEASE"),
- mavenBundle("geminiweb", "org.eclipse.gemini.web.tomcat", "2.2.0.RELEASE"),
- mavenBundle("geminiweb", "org.eclipse.virgo.kernel.equinox.extensions", "3.6.0.RELEASE").noStart(),
- mavenBundle("geminiweb", "org.eclipse.virgo.util.common", "3.6.0.RELEASE"),
- mavenBundle("geminiweb", "org.eclipse.virgo.util.io", "3.6.0.RELEASE"),
- mavenBundle("geminiweb", "org.eclipse.virgo.util.math", "3.6.0.RELEASE"),
- mavenBundle("geminiweb", "org.eclipse.virgo.util.osgi", "3.6.0.RELEASE"),
- mavenBundle("geminiweb", "org.eclipse.virgo.util.osgi.manifest", "3.6.0.RELEASE"),
- mavenBundle("geminiweb", "org.eclipse.virgo.util.parser.manifest", "3.6.0.RELEASE"),
-
- mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager", "3.1.0"),
- mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager.shell", "3.0.1"),
-
- mavenBundle("com.google.code.gson", "gson", "2.1"),
- mavenBundle("org.jboss.spec.javax.transaction", "jboss-transaction-api_1.1_spec", "1.0.1.Final"),
- mavenBundle("org.apache.felix", "org.apache.felix.fileinstall", "3.1.6"),
- mavenBundle("org.apache.commons", "commons-lang3", "3.1"),
- mavenBundle("commons-codec", "commons-codec"),
- mavenBundle("virgomirror", "org.eclipse.jdt.core.compiler.batch", "3.8.0.I20120518-2145"),
- mavenBundle("eclipselink", "javax.persistence", "2.0.4.v201112161009"),
- mavenBundle("eclipselink", "javax.resource", "1.5.0.v200906010428"),
-
- mavenBundle("orbit", "javax.activation", "1.1.0.v201211130549"),
- mavenBundle("orbit", "javax.annotation", "1.1.0.v201209060031"),
- mavenBundle("orbit", "javax.ejb", "3.1.1.v201204261316"),
- mavenBundle("orbit", "javax.el", "2.2.0.v201108011116"),
- mavenBundle("orbit", "javax.mail.glassfish", "1.4.1.v201108011116"),
- mavenBundle("orbit", "javax.xml.rpc", "1.1.0.v201005080400"),
- mavenBundle("orbit", "org.apache.catalina", "7.0.32.v201211201336"),
+ mavenBundle("org.opendaylight.controller", "commons.northbound").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "forwarding.staticrouting.northbound").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "statistics.northbound").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "topology.northbound").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "hosttracker.northbound").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "switchmanager.northbound").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "flowprogrammer.northbound").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller", "subnets.northbound").versionAsInProject(),
+
+ mavenBundle("org.codehaus.jackson", "jackson-mapper-asl").versionAsInProject(),
+ mavenBundle("org.codehaus.jackson", "jackson-core-asl").versionAsInProject(),
+ mavenBundle("org.codehaus.jackson", "jackson-jaxrs").versionAsInProject(),
+ mavenBundle("org.codehaus.jettison", "jettison").versionAsInProject(),
+
+ mavenBundle("commons-io", "commons-io").versionAsInProject(),
+
+ mavenBundle("commons-fileupload", "commons-fileupload").versionAsInProject(),
+
+ mavenBundle("equinoxSDK381", "javax.servlet").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "javax.servlet.jsp").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds").versionAsInProject(),
+ mavenBundle("orbit", "javax.xml.rpc").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.util").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.osgi.services").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.cm").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.launcher").versionAsInProject(),
+
+ mavenBundle("geminiweb", "org.eclipse.gemini.web.core").versionAsInProject(),
+ mavenBundle("geminiweb", "org.eclipse.gemini.web.extender").versionAsInProject(),
+ mavenBundle("geminiweb", "org.eclipse.gemini.web.tomcat").versionAsInProject(),
+ mavenBundle("geminiweb", "org.eclipse.virgo.kernel.equinox.extensions").versionAsInProject().noStart(),
+ mavenBundle("geminiweb", "org.eclipse.virgo.util.common").versionAsInProject(),
+ mavenBundle("geminiweb", "org.eclipse.virgo.util.io").versionAsInProject(),
+ mavenBundle("geminiweb", "org.eclipse.virgo.util.math").versionAsInProject(),
+ mavenBundle("geminiweb", "org.eclipse.virgo.util.osgi").versionAsInProject(),
+ mavenBundle("geminiweb", "org.eclipse.virgo.util.osgi.manifest").versionAsInProject(),
+ mavenBundle("geminiweb", "org.eclipse.virgo.util.parser.manifest").versionAsInProject(),
+
+ mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager.shell").versionAsInProject(),
+
+ mavenBundle("com.google.code.gson", "gson").versionAsInProject(),
+ mavenBundle("org.jboss.spec.javax.transaction", "jboss-transaction-api_1.1_spec").versionAsInProject(),
+ mavenBundle("org.apache.felix", "org.apache.felix.fileinstall").versionAsInProject(),
+ mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
+ mavenBundle("commons-codec", "commons-codec").versionAsInProject(),
+ mavenBundle("virgomirror", "org.eclipse.jdt.core.compiler.batch").versionAsInProject(),
+ mavenBundle("eclipselink", "javax.persistence").versionAsInProject(),
+ mavenBundle("eclipselink", "javax.resource").versionAsInProject(),
+
+ mavenBundle("orbit", "javax.activation").versionAsInProject(),
+ mavenBundle("orbit", "javax.annotation").versionAsInProject(),
+ mavenBundle("orbit", "javax.ejb").versionAsInProject(),
+ mavenBundle("orbit", "javax.el").versionAsInProject(),
+ mavenBundle("orbit", "javax.mail.glassfish").versionAsInProject(),
+ mavenBundle("orbit", "javax.xml.rpc").versionAsInProject(),
+ mavenBundle("orbit", "org.apache.catalina").versionAsInProject(),
// these are bundle fragments that can't be started on its own
- mavenBundle("orbit", "org.apache.catalina.ha", "7.0.32.v201211201952").noStart(),
- mavenBundle("orbit", "org.apache.catalina.tribes", "7.0.32.v201211201952").noStart(),
- mavenBundle("orbit", "org.apache.coyote", "7.0.32.v201211201952").noStart(),
- mavenBundle("orbit", "org.apache.jasper", "7.0.32.v201211201952").noStart(),
-
- mavenBundle("orbit", "org.apache.el", "7.0.32.v201211081135"),
- mavenBundle("orbit", "org.apache.juli.extras", "7.0.32.v201211081135"),
- mavenBundle("orbit", "org.apache.tomcat.api", "7.0.32.v201211081135"),
- mavenBundle("orbit", "org.apache.tomcat.util", "7.0.32.v201211201952").noStart(),
- mavenBundle("orbit", "javax.servlet.jsp.jstl", "1.2.0.v201105211821"),
- mavenBundle("orbit", "javax.servlet.jsp.jstl.impl", "1.2.0.v201210211230"),
-
- mavenBundle("org.ops4j.pax.exam", "pax-exam-container-native"),
- mavenBundle("org.ops4j.pax.exam", "pax-exam-junit4"),
- mavenBundle("org.ops4j.pax.exam", "pax-exam-link-mvn"),
- mavenBundle("org.ops4j.pax.url", "pax-url-aether"),
-
- mavenBundle("org.springframework", "org.springframework.asm", "3.1.3.RELEASE"),
- mavenBundle("org.springframework", "org.springframework.aop", "3.1.3.RELEASE"),
- mavenBundle("org.springframework", "org.springframework.context", "3.1.3.RELEASE"),
- mavenBundle("org.springframework", "org.springframework.context.support", "3.1.3.RELEASE"),
- mavenBundle("org.springframework", "org.springframework.core", "3.1.3.RELEASE"),
- mavenBundle("org.springframework", "org.springframework.beans", "3.1.3.RELEASE"),
- mavenBundle("org.springframework", "org.springframework.expression", "3.1.3.RELEASE"),
- mavenBundle("org.springframework", "org.springframework.web", "3.1.3.RELEASE"),
-
- mavenBundle("org.aopalliance", "com.springsource.org.aopalliance", "1.0.0"),
- mavenBundle("org.springframework", "org.springframework.web.servlet", "3.1.3.RELEASE"),
- mavenBundle("org.springframework.security", "spring-security-config", "3.1.3.RELEASE"),
- mavenBundle("org.springframework.security", "spring-security-core", "3.1.3.RELEASE"),
- mavenBundle("org.springframework.security", "spring-security-web", "3.1.3.RELEASE"),
- mavenBundle("org.springframework.security", "spring-security-taglibs", "3.1.3.RELEASE"),
- mavenBundle("org.springframework", "org.springframework.transaction", "3.1.3.RELEASE"),
-
- mavenBundle("org.ow2.chameleon.management", "chameleon-mbeans", "1.0.0"),
- mavenBundle("org.opendaylight.controller.thirdparty", "net.sf.jung2", "2.0.1-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller.thirdparty", "com.sun.jersey.jersey-servlet", "1.17-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller.thirdparty", "org.apache.catalina.filters.CorsFilter",
- "7.0.42-SNAPSHOT").noStart(),
+ mavenBundle("orbit", "org.apache.catalina.ha").versionAsInProject().noStart(),
+ mavenBundle("orbit", "org.apache.catalina.tribes").versionAsInProject().noStart(),
+ mavenBundle("orbit", "org.apache.coyote").versionAsInProject().noStart(),
+ mavenBundle("orbit", "org.apache.jasper").versionAsInProject().noStart(),
+
+ mavenBundle("orbit", "org.apache.el").versionAsInProject(),
+ mavenBundle("orbit", "org.apache.juli.extras").versionAsInProject(),
+ mavenBundle("orbit", "org.apache.tomcat.api").versionAsInProject(),
+ mavenBundle("orbit", "org.apache.tomcat.util").versionAsInProject().noStart(),
+ mavenBundle("orbit", "javax.servlet.jsp.jstl").versionAsInProject(),
+ mavenBundle("orbit", "javax.servlet.jsp.jstl.impl").versionAsInProject(),
+
+ mavenBundle("org.ops4j.pax.exam", "pax-exam-container-native").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.exam", "pax-exam-junit4").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.exam", "pax-exam-link-mvn").versionAsInProject(),
+ mavenBundle("org.ops4j.pax.url", "pax-url-aether").versionAsInProject(),
+
+ mavenBundle("org.springframework", "org.springframework.asm").versionAsInProject(),
+ mavenBundle("org.springframework", "org.springframework.aop").versionAsInProject(),
+ mavenBundle("org.springframework", "org.springframework.context").versionAsInProject(),
+ mavenBundle("org.springframework", "org.springframework.context.support").versionAsInProject(),
+ mavenBundle("org.springframework", "org.springframework.core").versionAsInProject(),
+ mavenBundle("org.springframework", "org.springframework.beans").versionAsInProject(),
+ mavenBundle("org.springframework", "org.springframework.expression").versionAsInProject(),
+ mavenBundle("org.springframework", "org.springframework.web").versionAsInProject(),
+
+ mavenBundle("org.aopalliance", "com.springsource.org.aopalliance").versionAsInProject(),
+ mavenBundle("org.springframework", "org.springframework.web.servlet").versionAsInProject(),
+ mavenBundle("org.springframework.security", "spring-security-config").versionAsInProject(),
+ mavenBundle("org.springframework.security", "spring-security-core").versionAsInProject(),
+ mavenBundle("org.springframework.security", "spring-security-web").versionAsInProject(),
+ mavenBundle("org.springframework.security", "spring-security-taglibs").versionAsInProject(),
+ mavenBundle("org.springframework", "org.springframework.transaction").versionAsInProject(),
+
+ mavenBundle("org.ow2.chameleon.management", "chameleon-mbeans").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller.thirdparty", "net.sf.jung2").versionAsInProject(),
+ mavenBundle("org.opendaylight.controller.thirdparty", "com.sun.jersey.jersey-servlet")
+ .versionAsInProject(),
+ mavenBundle("org.opendaylight.controller.thirdparty", "org.apache.catalina.filters.CorsFilter")
+ .versionAsInProject().noStart(),
// Jersey needs to be started before the northbound application
// bundles, using a lower start level
- mavenBundle("com.sun.jersey", "jersey-client", "1.17"),
- mavenBundle("com.sun.jersey", "jersey-server", "1.17").startLevel(2),
- mavenBundle("com.sun.jersey", "jersey-core", "1.17").startLevel(2),
- mavenBundle("com.sun.jersey", "jersey-json", "1.17").startLevel(2), junitBundles());
+ mavenBundle("com.sun.jersey", "jersey-client").versionAsInProject(),
+ mavenBundle("com.sun.jersey", "jersey-server").versionAsInProject().startLevel(2),
+ mavenBundle("com.sun.jersey", "jersey-core").versionAsInProject().startLevel(2),
+ mavenBundle("com.sun.jersey", "jersey-json").versionAsInProject().startLevel(2), junitBundles());
}
}
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
import org.codehaus.enunciate.jaxrs.ResponseCode;
import org.codehaus.enunciate.jaxrs.StatusCodes;
@ResponseCode(code = 409, condition = "Unable to update configuration due to cluster conflict or conflicting description property"),
@ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
public Response addNodeProperty(
+ @Context UriInfo uriInfo,
@PathParam("containerName") String containerName,
@PathParam("nodeType") String nodeType,
@PathParam("nodeId") String nodeId,
SwitchConfig newSwitchConfig = new SwitchConfig(node.toString(), nodeProperties);
Status status = switchManager.updateNodeConfig(newSwitchConfig);
if (status.isSuccess()) {
- return Response.status(Response.Status.CREATED).build();
+ return Response.created(uriInfo.getRequestUri()).build();
}
return NorthboundUtils.getResponse(status);
}
@ResponseCode(code = 409, condition = "Unable to add property due to cluster conflict"),
@ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
public Response addNodeConnectorProperty(
+ @Context UriInfo uriInfo,
@PathParam("containerName") String containerName,
@PathParam("nodeType") String nodeType,
@PathParam("nodeId") String nodeId,
Status ret = switchManager.addNodeConnectorProp(nc, prop);
if (ret.isSuccess()) {
- return Response.status(Response.Status.CREATED).build();
+ return Response.created(uriInfo.getRequestUri()).build();
}
throw new InternalServerErrorException(ret.getDescription());
}
class DiscoveryTransmit implements Runnable {
private final BlockingQueue<NodeConnector> transmitQ;
+ private int count = 0;
DiscoveryTransmit(BlockingQueue<NodeConnector> transmitQ) {
this.transmitQ = transmitQ;
RawPacket outPkt = createDiscoveryPacket(nodeConnector);
sendDiscoveryPacket(nodeConnector, outPkt);
nodeConnector = null;
+ if ((++count & 0x7f) == 0) {
+ Thread.sleep(10);
+ }
} catch (InterruptedException e1) {
logger.warn("DiscoveryTransmit interupted", e1.getMessage());
if (shuttingDown) {
*/
private int getDiscoveryBatchMaxPorts() {
String val = System.getProperty("of.discoveryBatchMaxPorts");
- int ports = 1024;
+ int ports = 512;
if (val != null) {
try {
public String toString() {
return "Actions[" + actionsValue + "]";
}
+
+ @Override
+ public String getStringValue() {
+ return Integer.toHexString(actionsValue);
+ }
}
@Override
public String toString() {
- StringBuffer sb = new StringBuffer();
+ return "BandWidth[" + getStringValue() + "]";
+ }
- sb.append("BandWidth[");
+ @Override
+ public String getStringValue() {
if (this.bandwidthValue == 0) {
- sb.append("UnKnown");
+ return("UnKnown");
} else if (this.bandwidthValue < BW1Kbps) {
- sb.append(this.bandwidthValue + "bps");
+ return(this.bandwidthValue + "bps");
} else if (this.bandwidthValue < BW1Mbps) {
- sb.append(Long.toString(this.bandwidthValue / BW1Kbps) + "Kbps");
+ return(Long.toString(this.bandwidthValue / BW1Kbps) + "Kbps");
} else if (this.bandwidthValue < BW1Gbps) {
- sb.append(Long.toString(this.bandwidthValue / BW1Mbps) + "Mbps");
+ return(Long.toString(this.bandwidthValue / BW1Mbps) + "Mbps");
} else if (this.bandwidthValue < BW1Tbps) {
- sb.append(Long.toString(this.bandwidthValue / BW1Gbps) + "Gbps");
+ return(Long.toString(this.bandwidthValue / BW1Gbps) + "Gbps");
} else if (this.bandwidthValue < BW1Pbps) {
- sb.append(Long.toString(this.bandwidthValue / BW1Tbps) + "Tbps");
+ return(Long.toString(this.bandwidthValue / BW1Tbps) + "Tbps");
+ } else {
+ return(this.bandwidthValue + "bps");
}
-
- sb.append("]");
- return sb.toString();
}
}
public String toString() {
return "Buffers[" + buffersValue + "]";
}
+
+ @Override
+ public String getStringValue() {
+ return Integer.toHexString(buffersValue);
+ }
}
public String toString() {
return "Capabilities[" + capabilitiesValue + "]";
}
+
+ @Override
+ public String getStringValue() {
+ return Integer.toHexString(capabilitiesValue);
+ }
}
public String toString() {
return "Config["+ configValue +"]";
}
+
+ @Override
+ public String getStringValue() {
+ if (configValue == 0) {
+ return "ADMIN_DOWN";
+ } else if (configValue == 1) {
+ return "ADMIN_UP";
+ } else if (configValue == 0x7fff) {
+ return "ADMIN_UNDEF";
+ } else {
+ return String.valueOf(configValue);
+ }
+ }
}
public String toString() {
return "Description[" + descriptionValue + "]";
}
+
+ @Override
+ public String getStringValue() {
+ return descriptionValue;
+ }
}
public String toString() {
return "Mode[" + modeValue + "]";
}
+
+ @Override
+ public String getStringValue() {
+ return (modeValue == ForwardingMode.PROACTIVE_FORWARDING) ? "Proactive" : "Reactive";
+ }
}
\ No newline at end of file
sb.append("]");
return sb.toString();
}
+
+ @Override
+ public String getStringValue() {
+ if (this.latencyValue == 0) {
+ return("UnKnown");
+ } else if (this.latencyValue < LATENCY1ns) {
+ return(this.latencyValue + "psec");
+ } else if (this.latencyValue < LATENCY1us) {
+ return(Long.toString(this.latencyValue / LATENCY1ns) + "nsec");
+ } else if (this.latencyValue < LATENCY1ms) {
+ return(Long.toString(this.latencyValue / LATENCY1us) + "usec");
+ } else if (this.latencyValue < LATENCY1s) {
+ return(Long.toString(this.latencyValue / LATENCY1ms) + "msec");
+ } else {
+ return Long.toString(this.latencyValue) + "sec";
+ }
+ }
}
public String toString() {
return "MacAddress[" + address + "]";
}
+
+ @Override
+ public String getStringValue() {
+ return address;
+ }
}
public String toString() {
return "Name[" + nameValue + "]";
}
+
+ @Override
+ public String getStringValue() {
+ return nameValue;
+ }
}
return this.name;
}
+ public abstract String getStringValue();
+
/**
* Used to copy the Property in a polymorphic way
*
public String toString() {
return "State[" + stateValue + "]";
}
+
+ @Override
+ public String getStringValue() {
+ if (stateValue == 0) {
+ return ("EDGE_DOWN");
+ } else if (stateValue == 1) {
+ return ("EDGE_UP");
+ } else if (stateValue == 0x7fff) {
+ return ("EDGE_UNK");
+ } else {
+ return String.valueOf(stateValue);
+ }
+ }
}
public String toString() {
return "Tables[" + tablesValue + "]";
}
+
+ @Override
+ public String getStringValue() {
+ return String.format("%02x", tablesValue);
+ }
}
public String toString() {
return "Tier[" + tierValue + "]";
}
+
+ @Override
+ public String getStringValue() {
+ return String.valueOf(tierValue);
+ }
}
package org.opendaylight.controller.sal.core;
+import java.util.Date;
+
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
public String toString() {
return "TimeStamp[" + timestampName + ": " + timestamp +"]";
}
+
+ @Override
+ public String getStringValue() {
+ return timestampName + ": " + new Date(timestamp);
+ }
}
// Set the systemPackages (used by clustering)
systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
// List framework bundles
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",
- "1.0.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",
- "1.0.400.v20120522-2049"),
- mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",
- "3.3.100.v20120522-1822"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",
- "1.4.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",
- "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",
- "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
- "0.8.0.v201110170705"),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.util").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.osgi.services").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject(),
// List logger bundles
mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
mavenBundle("org.slf4j", "log4j-over-slf4j")
}
}
-}
\ No newline at end of file
+}
propMap.put(Description.propertyName, desc);
}
continue;
+ } else if (prop.equals(ForwardingMode.name)) {
+ Property defaultMode = new ForwardingMode(ForwardingMode.REACTIVE_FORWARDING);
+ propMap.put(ForwardingMode.name, defaultMode);
+ continue;
}
propMap.remove(prop);
}
}
}
- // copy node properties from config
boolean proactiveForwarding = false;
+ // copy node properties from config
if (nodeConfigList != null) {
String nodeId = node.toString();
SwitchConfig conf = nodeConfigList.get(nodeId);
}
}
+ if (!propMap.containsKey(ForwardingMode.name)) {
+ Property defaultMode = new ForwardingMode(ForwardingMode.REACTIVE_FORWARDING);
+ propMap.put(ForwardingMode.name, defaultMode);
+ }
boolean result = false;
if (propMapCurr == null) {
if (nodeProps.putIfAbsent(node, propMap) == null) {
@Override
public Set<Node> getNodes() {
return (nodeProps != null) ? new HashSet<Node>(nodeProps.keySet())
- : null;
+ : new HashSet<Node>();
}
/*
public String getHelp() {
StringBuffer help = new StringBuffer();
help.append("---Switch Manager---\n");
- help.append("\t pns - Print connected nodes\n");
- help.append("\t pncs <node id> - Print node connectors for a given node\n");
help.append("\t pencs <node id> - Print enabled node connectors for a given node\n");
help.append("\t pdm <node id> - Print switch ports in device map\n");
help.append("\t snt <node id> <tier> - Set node tier number\n");
return help.toString();
}
- public void _pns(CommandInterpreter ci) {
- ci.println(" Node Type MAC Name Tier");
- if (nodeProps == null) {
- return;
- }
- Set<Node> nodeSet = nodeProps.keySet();
- if (nodeSet == null) {
- return;
- }
- List<String> nodeArray = new ArrayList<String>();
- for (Node node : nodeSet) {
- nodeArray.add(node.toString());
- }
- Collections.sort(nodeArray);
- for (String str: nodeArray) {
- Node node = Node.fromString(str);
- Description desc = ((Description) getNodeProp(node,
- Description.propertyName));
- Tier tier = ((Tier) getNodeProp(node, Tier.TierPropName));
- String nodeName = (desc == null) ? "" : desc.getValue();
- MacAddress mac = (MacAddress) getNodeProp(node,
- MacAddress.name);
- String macAddr = (mac == null) ? "" : HexEncode
- .bytesToHexStringFormat(mac.getMacAddress());
- int tierNum = (tier == null) ? 0 : tier.getValue();
- ci.println(node + " " + node.getType() + " " + macAddr
- + " " + nodeName + " " + tierNum);
- }
- ci.println("Total number of Nodes: " + nodeSet.size());
- }
-
public void _pencs(CommandInterpreter ci) {
String st = ci.nextArgument();
if (st == null) {
ci.println("Total number of NodeConnectors: " + nodeConnectorSet.size());
}
- public void _pncs(CommandInterpreter ci) {
- String st = ci.nextArgument();
- if (st == null) {
- ci.println("Please enter node id");
- return;
- }
-
- Node node = Node.fromString(st);
- if (node == null) {
- ci.println("Please enter node id");
- return;
- }
-
- ci.println(" NodeConnector BandWidth(Gbps) Admin State");
- Set<NodeConnector> nodeConnectorSet = getNodeConnectors(node);
- if (nodeConnectorSet == null) {
- return;
- }
- for (NodeConnector nodeConnector : nodeConnectorSet) {
- if (nodeConnector == null) {
- continue;
- }
- Map<String, Property> propMap = getNodeConnectorProps(nodeConnector);
- Bandwidth bw = (Bandwidth) propMap.get(Bandwidth.BandwidthPropName);
- Config config = (Config) propMap.get(Config.ConfigPropName);
- State state = (State) propMap.get(State.StatePropName);
- String out = nodeConnector + " ";
- out += (bw != null) ? bw.getValue() / Math.pow(10, 9) : " ";
- out += " ";
- out += (config != null) ? config.getValue() : " ";
- out += " ";
- out += (state != null) ? state.getValue() : " ";
- ci.println(out);
- }
- ci.println("Total number of NodeConnectors: " + nodeConnectorSet.size());
- }
-
public void _pdm(CommandInterpreter ci) {
String st = ci.nextArgument();
if (st == null) {
import java.util.ArrayList;
import java.util.Collections;
import java.util.Dictionary;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.felix.service.command.Descriptor;
-import org.opendaylight.controller.sal.core.Bandwidth;
-import org.opendaylight.controller.sal.core.Config;
-import org.opendaylight.controller.sal.core.Description;
-import org.opendaylight.controller.sal.core.MacAddress;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.Property;
-import org.opendaylight.controller.sal.core.State;
-import org.opendaylight.controller.sal.core.Tier;
import org.opendaylight.controller.sal.utils.GlobalConstants;
-import org.opendaylight.controller.sal.utils.HexEncode;
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.opendaylight.controller.switchmanager.ISwitchManager;
import org.osgi.framework.ServiceRegistration;
return;
}
- System.out.println(" Node Type MAC Name Tier");
-
Set<Node> nodes = sm.getNodes();
if (nodes == null || nodes.isEmpty()) {
return;
}
- List<String> nodeArray = new ArrayList<String>();
+ Set<String> propertyList = new HashSet<String>();
for (Node node : nodes) {
- nodeArray.add(node.toString());
+ Map<String, Property> propList = sm.getNodeProps(node);
+ propertyList.addAll(propList.keySet());
+ }
+ List<String> sortedProps = new ArrayList<String>(propertyList);
+ Collections.sort(sortedProps);
+ String properties = String.format("%-26s ", "Node");
+ for (String s : sortedProps) {
+ properties = properties.concat(String.format("%-18s ", s));
}
- Collections.sort(nodeArray);
- for (String str : nodeArray) {
- Node node = Node.fromString(str);
- Description desc = ((Description) sm.getNodeProp(node, Description.propertyName));
- Tier tier = ((Tier) sm.getNodeProp(node, Tier.TierPropName));
- String nodeName = (desc == null) ? "" : desc.getValue();
- MacAddress mac = (MacAddress) sm.getNodeProp(node, MacAddress.name);
- String macAddr = (mac == null) ? "" : HexEncode.bytesToHexStringFormat(mac.getMacAddress());
- int tierNum = (tier == null) ? 0 : tier.getValue();
- System.out.println(node + " " + node.getType() + " " + macAddr + " " + nodeName + " "
- + tierNum);
+ System.out.println(properties);
+ for (Node node : nodes) {
+ String nodeProp = String.format("%-26s ", node);
+ Map<String, Property> propList = sm.getNodeProps(node);
+ for (String s : sortedProps) {
+ if (propList.containsKey(s)) {
+ nodeProp = nodeProp.concat(String.format("%-18s ", propList.get(s).getStringValue()));
+ } else {
+ nodeProp = nodeProp.concat(String.format("%-18s ", "null"));
+ }
+ }
+ System.out.println(nodeProp);
}
System.out.println("Total number of Nodes: " + nodes.size());
}
return;
}
- System.out.println(" NodeConnector BandWidth(Gbps) Admin State");
Set<NodeConnector> nodeConnectorSet = sm.getNodeConnectors(target);
- if (nodeConnectorSet == null) {
+ if (nodeConnectorSet == null || nodeConnectorSet.isEmpty()) {
return;
}
+
+ Set<String> propertyList = new HashSet<String>();
+ for (NodeConnector nodeConnector : nodeConnectorSet) {
+ Map<String, Property> propList = sm.getNodeConnectorProps(nodeConnector);
+ propertyList.addAll(propList.keySet());
+ }
+ List<String> sortedProps = new ArrayList<String>(propertyList);
+ Collections.sort(sortedProps);
+ String properties = String.format("%-33s ", "NodeConnector");
+ for (String s : sortedProps) {
+ properties = properties.concat(String.format("%-18s ", s));
+ }
+ System.out.println(properties);
for (NodeConnector nodeConnector : nodeConnectorSet) {
- if (nodeConnector == null) {
- continue;
+ String ncProp = String.format("%-33s ", nodeConnector);
+ Map<String, Property> ncProperties = sm.getNodeConnectorProps(nodeConnector);
+ for (String s : sortedProps) {
+ if (ncProperties.containsKey(s)) {
+ ncProp = ncProp.concat(String.format("%-18s ", ncProperties.get(s).getStringValue()));
+ } else {
+ ncProp = ncProp.concat(String.format("%-18s ", "null"));
+ }
}
- Map<String, Property> propMap = sm.getNodeConnectorProps(nodeConnector);
- Bandwidth bw = (Bandwidth) propMap.get(Bandwidth.BandwidthPropName);
- Config config = (Config) propMap.get(Config.ConfigPropName);
- State state = (State) propMap.get(State.StatePropName);
- String out = nodeConnector + " ";
- out += (bw != null) ? bw.getValue() / Math.pow(10, 9) : " ";
- out += " ";
- out += (config != null) ? config.getValue() : " ";
- out += " ";
- out += (state != null) ? state.getValue() : " ";
- System.out.println(out);
+ System.out.println(ncProp);
}
System.out.println("Total number of NodeConnectors: " + nodeConnectorSet.size());
}
// Set the systemPackages (used by clustering)
systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"),
// List framework bundles
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.console",
- "1.0.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.util",
- "1.0.400.v20120522-2049"),
- mavenBundle("equinoxSDK381", "org.eclipse.osgi.services",
- "3.3.100.v20120522-1822"),
- mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds",
- "1.4.0.v20120522-1841"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command",
- "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime",
- "0.8.0.v201108120515"),
- mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell",
- "0.8.0.v201110170705"),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.util").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.osgi.services").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject(),
+ mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject(),
// List logger bundles
mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
mavenBundle("org.slf4j", "log4j-over-slf4j")
},
modal: {
modal: "one_f_switchmanager_subnetGatewayConfig_id_modal_modal",
+ ports : "one_f_switchmanager_subnetGatewayConfig_id_modal_ports",
save: "one_f_switchmanager_subnetGatewayConfig_id_modal_save",
form: {
name : "one_f_switchmanager_subnetGatewayConfig_id_modal_form_gatewayname",
ports: function() {
var h3 = "Add Ports";
var footer = one.f.switchmanager.subnetGatewayConfig.modal.footer();
- var $modal = one.lib.modal.spawn(one.f.switchmanager.subnetGatewayConfig.id.modal.modal, h3, "", footer);
+ var $modal = one.lib.modal.spawn(one.f.switchmanager.subnetGatewayConfig.id.modal.ports, h3, "", footer);
// bind save button
$('#' + one.f.switchmanager.subnetGatewayConfig.id.modal.save, $modal).click(function() {
one.f.switchmanager.subnetGatewayConfig.modal.save.ports($modal);
org.opendaylight.controller.sal.utils,
org.opendaylight.controller.usermanager,
org.opendaylight.controller.containermanager,
+ org.opendaylight.controller.clustering.services,
+ org.opendaylight.controller.connectionmanager,
+ org.opendaylight.controller.switchmanager,
com.google.gson,
javax.annotation,
javax.naming,
</plugins>
</build>
<dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>connectionmanager</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>configuration</artifactId>
<artifactId>containermanager</artifactId>
<version>0.4.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
--- /dev/null
+package org.opendaylight.controller.web;
+
+import java.net.InetAddress;
+
+/**
+ * Information about a clustered controller to send to the UI frontend
+ * @author andrekim
+ */
+public class ClusterNodeBean {
+ private final byte[] address;
+ private final String name;
+ private final Boolean me;
+ private final Boolean coordinator;
+
+ public static class Builder {
+ // required params
+ private final byte[] address;
+ private final String name;
+
+ // optional params
+ private Boolean me = null;
+ private Boolean coordinator = null;
+
+ public Builder(InetAddress address) {
+ this.address = address.getAddress();
+ this.name = address.getHostAddress();
+ }
+
+ public Builder highlightMe() {
+ this.me = true;
+ return this;
+ }
+
+ public Builder iAmCoordinator() {
+ this.coordinator = true;
+ return this;
+ }
+
+ public ClusterNodeBean build() {
+ return new ClusterNodeBean(this);
+ }
+ }
+
+ private ClusterNodeBean(Builder builder) {
+ this.address = builder.address;
+ this.name = builder.name;
+ this.me = builder.me;
+ this.coordinator = builder.coordinator;
+ }
+}
\ No newline at end of file
package org.opendaylight.controller.web;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
+import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
+import org.opendaylight.controller.connectionmanager.IConnectionManager;
import org.opendaylight.controller.sal.authorization.UserLevel;
+import org.opendaylight.controller.sal.core.Description;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.controller.sal.utils.StatusCode;
+import org.opendaylight.controller.switchmanager.ISwitchManager;
import org.opendaylight.controller.usermanager.IUserManager;
import org.opendaylight.controller.usermanager.UserConfig;
import org.springframework.stereotype.Controller;
@Controller
@RequestMapping("/admin")
public class DaylightWebAdmin {
+ Gson gson = new Gson();
+ /**
+ * Returns list of clustered controllers. Highlights "this" controller and
+ * if controller is coordinator
+ * @return List<ClusterBean>
+ */
+ @RequestMapping("/cluster")
+ @ResponseBody
+ public String getClusteredControllers() {
+ IClusterGlobalServices clusterServices = (IClusterGlobalServices) ServiceHelper.getGlobalInstance(
+ IClusterGlobalServices.class, this);
+ if (clusterServices == null) {
+ return null;
+ }
+
+ List<ClusterNodeBean> clusterNodes = new ArrayList<ClusterNodeBean>();
+
+ List<InetAddress> controllers = clusterServices.getClusteredControllers();
+ for (InetAddress controller : controllers) {
+ ClusterNodeBean.Builder clusterBeanBuilder = new ClusterNodeBean.Builder(controller);
+ if (controller.equals(clusterServices.getMyAddress())) {
+ clusterBeanBuilder.highlightMe();
+ }
+ if (clusterServices.getCoordinatorAddress().equals(controller)) {
+ clusterBeanBuilder.iAmCoordinator();
+ }
+ clusterNodes.add(clusterBeanBuilder.build());
+ }
+ return gson.toJson(clusterNodes);
+ }
+
+ /**
+ * Return nodes connected to controller {controller}
+ * @param controller
+ * - byte[] of the address of the controller
+ * @return List<NodeBean>
+ */
+ @RequestMapping("/cluster/controller/{controller}")
+ @ResponseBody
+ public String getNodesConnectedToController(@PathVariable("controller") String controller) {
+ IClusterGlobalServices clusterServices = (IClusterGlobalServices) ServiceHelper.getGlobalInstance(
+ IClusterGlobalServices.class, this);
+ if (clusterServices == null) {
+ return null;
+ }
+ IConnectionManager connectionManager = (IConnectionManager) ServiceHelper.getGlobalInstance(
+ IConnectionManager.class, this);
+ if (connectionManager == null) {
+ return null;
+ }
+ ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class,
+ GlobalConstants.DEFAULT.toString(), this);
+ if (switchManager == null) {
+ return null;
+ }
+
+ byte[] address = gson.fromJson(controller, byte[].class);
+ InetAddress controllerAddress = null;
+ try {
+ controllerAddress = InetAddress.getByAddress(address);
+ } catch (UnknownHostException e) {
+ return null;
+ }
+
+ List<NodeBean> result = new ArrayList<NodeBean>();
+
+ Set<Node> nodes = connectionManager.getNodes(controllerAddress);
+ if (nodes == null) {
+ return gson.toJson(result);
+ }
+ for (Node node : nodes) {
+ Description description = (Description) switchManager.getNodeProp(node, Description.propertyName);
+ NodeBean nodeBean;
+ if (description == null || description.getValue().equals("None")) {
+ nodeBean = new NodeBean(node);
+ } else {
+ nodeBean = new NodeBean(node, description.getValue());
+ }
+ result.add(nodeBean);
+ }
+
+ return gson.toJson(result);
+ }
@RequestMapping("/users")
@ResponseBody
public List<UserConfig> getUsers() {
- IUserManager userManager = (IUserManager) ServiceHelper
- .getGlobalInstance(IUserManager.class, this);
+ IUserManager userManager = (IUserManager) ServiceHelper.getGlobalInstance(IUserManager.class, this);
if (userManager == null) {
return null;
}
*/
@RequestMapping(value = "/users", method = RequestMethod.POST)
@ResponseBody
- public String saveLocalUserConfig(
- @RequestParam(required = true) String json,
- @RequestParam(required = true) String action,
- HttpServletRequest request) {
+ public String saveLocalUserConfig(@RequestParam(required = true) String json,
+ @RequestParam(required = true) String action, HttpServletRequest request) {
- IUserManager userManager = (IUserManager) ServiceHelper
- .getGlobalInstance(IUserManager.class, this);
+ IUserManager userManager = (IUserManager) ServiceHelper.getGlobalInstance(IUserManager.class, this);
if (userManager == null) {
return "Internal Error";
}
Gson gson = new Gson();
UserConfig config = gson.fromJson(json, UserConfig.class);
- Status result = (action.equals("add")) ? userManager
- .addLocalUser(config) : userManager.removeLocalUser(config);
- if(result.getCode().equals(StatusCode.SUCCESS)) {
- String userAction=(action.equals("add")) ? "added":"removed";
+ Status result = (action.equals("add")) ? userManager.addLocalUser(config) : userManager.removeLocalUser(config);
+ if (result.isSuccess()) {
+ String userAction = (action.equals("add")) ? "added" : "removed";
DaylightWebUtil.auditlog("User", request.getUserPrincipal().getName(), userAction, config.getUser());
return "Success";
}
@RequestMapping(value = "/users/{username}", method = RequestMethod.POST)
@ResponseBody
- public String removeLocalUser(@PathVariable("username") String userName,
- HttpServletRequest request) {
+ public String removeLocalUser(@PathVariable("username") String userName, HttpServletRequest request) {
String username = request.getUserPrincipal().getName();
if (username.equals(userName)) {
return "Invalid Request: User cannot delete itself";
}
- IUserManager userManager = (IUserManager) ServiceHelper
- .getGlobalInstance(IUserManager.class, this);
+ IUserManager userManager = (IUserManager) ServiceHelper.getGlobalInstance(IUserManager.class, this);
if (userManager == null) {
return "Internal Error";
}
}
Status result = userManager.removeLocalUser(userName);
- if(result.getCode().equals(StatusCode.SUCCESS)) {
+ if (result.isSuccess()) {
DaylightWebUtil.auditlog("User", request.getUserPrincipal().getName(), "removed", userName);
return "Success";
}
@ResponseBody
public Status changePassword(@PathVariable("username") String username, HttpServletRequest request,
@RequestParam("currentPassword") String currentPassword, @RequestParam("newPassword") String newPassword) {
- IUserManager userManager = (IUserManager) ServiceHelper
- .getGlobalInstance(IUserManager.class, this);
+ IUserManager userManager = (IUserManager) ServiceHelper.getGlobalInstance(IUserManager.class, this);
if (userManager == null) {
return new Status(StatusCode.GONE, "User Manager not found");
}
}
Status status = userManager.changeLocalUserPassword(username, currentPassword, newPassword);
- if(status.isSuccess()){
+ if (status.isSuccess()) {
DaylightWebUtil.auditlog("User", request.getUserPrincipal().getName(), "changed password for", username);
}
return status;
/**
* Is the operation permitted for the given level
- *
* @param level
*/
- private boolean authorize(IUserManager userManager, UserLevel level,
- HttpServletRequest request) {
+ private boolean authorize(IUserManager userManager, UserLevel level, HttpServletRequest request) {
String username = request.getUserPrincipal().getName();
UserLevel userLevel = userManager.getUserLevel(username);
return userLevel.toNumber() <= level.toNumber();
--- /dev/null
+package org.opendaylight.controller.web;
+
+import org.opendaylight.controller.sal.core.Node;
+
+/**
+ * Information about a node connected to a controller to send to the UI frontend
+ * @author andrekim
+ */
+public class NodeBean {
+ private final String node;
+ private final String description;
+
+ public NodeBean(Node node) {
+ this(node, node.toString());
+ }
+
+ public NodeBean(Node node, String description) {
+ this.node = node.toString();
+ this.description = description;
+ }
+}
<div class="icon-user"></div> ${username} <span class="caret"></span>
</a>
<ul class="dropdown-menu">
- <li><a href="#admin" id="admin" data-role="${role}"><div
- class="icon-users"></div> Users</a></li>
- <li><a href="#save" id="save"><div class="icon-save"></div>
- Save</a></li>
- <li><a href="#logout" id="logout"><div
- class="icon-logout"></div> Logout</a></li>
+ <li><a href="#admin" id="admin" data-role="${role}"><div class="icon-users"></div> Users</a></li>
+ <li><a href="#cluster" id="cluster"><div class="icon-cluster"></div>Cluster</a></li>
+ <li><a href="#save" id="save"><div class="icon-save"></div>Save</a></li>
+ <li><a href="#logout" id="logout"><div class="icon-logout"></div> Logout</a></li>
</ul>
</div>
</div>
.icon;
background-image: url('../img/user_group_0107_16.png');
}
+ .icon-cluster {
+ .icon;
+ background-image: url('../img/topology_view_1033_16.png');
+ }
.icon-save {
.icon;
background-image: url('../img/save_as_0106_16.png');
$h4.text(header);
return $h4;
},
+ label : function(name, type) {
+ var $span = $(document.createElement('span'));
+ $span.addClass('label');
+ if (type !== undefined) {
+ $span.addClass(type);
+ } else if (type !== null) {
+ $span.addClass('label-info');
+ }
+ $span.append(name);
+ return $span;
+ },
list : function(list) {
var $ul = $(document.createElement('ul'));
$(list).each(function(index, value) {
one.lib.form = {
// create select-option form element
select : {
- create : function(options, multiple) {
+ create : function(options, multiple, sort) {
// assert - auto assign
if (options == undefined)
options = {};
$select.attr("multiple", "multiple");
}
var optionArray = one.lib.form.select.options(options);
+
+ // If specified, sort the option elements based on their text field
+ if (sort == true && optionArray.length > 1) {
+ var shifted = true;
+ var limit = optionArray.length;
+ while (shifted) {
+ shifted = false;
+ for ( var i = 1; i < limit; i++) {
+ if (optionArray[i - 1].text() > optionArray[i].text()) {
+ var swap = optionArray[i - 1];
+ optionArray[i - 1] = optionArray[i];
+ optionArray[i] = swap;
+ shifted = true;
+ }
+ }
+ }
+ }
+
$(optionArray).each(function(index, value) {
$select.append(value);
});
},
footer : function() {
var footer = [];
-
- var closeButton = one.lib.dashlet.button.single("Close",
- one.main.admin.id.modal.close, "", "");
+ var closeButton = one.lib.dashlet.button.single('Close', one.main.admin.id.modal.close, '', '');
var $closeButton = one.lib.dashlet.button.button(closeButton);
footer.push($closeButton);
-
return footer;
}
},
var $body = one.main.admin.remove.body();
var $modal = one.lib.modal.spawn(one.main.admin.id.modal.user,
h3, $body, footer);
-
// close binding
- $('#' + one.main.admin.id.modal.remove.close, $modal).click(
- function() {
- $modal.modal('hide');
- });
-
+ $('#'+one.main.admin.id.modal.remove.close, $modal).click(function() {
+ $modal.modal('hide');
+ });
// remove binding
- $('#' + one.main.admin.id.modal.remove.user, $modal)
- .click(
- function() {
- one.main.admin.remove.modal
- .ajax(
- id,
- function(result) {
- if (result == 'Success') {
- $modal
- .modal('hide');
- // body inject
- var $admin = $('#'
- + one.main.admin.id.modal.main);
- one.main.admin.ajax
- .users(function($body) {
- one.lib.modal.inject
- .body(
- $admin,
- $body);
- });
- } else
- alert("Failed to remove user: "
- + result);
- });
- });
-
+ $('#' + one.main.admin.id.modal.remove.user, $modal).click(function() {
+ one.main.admin.remove.modal.ajax(id, function(result) {
+ if (result == 'Success') {
+ $modal.modal('hide');
+ // body inject
+ var $admin = $('#'+one.main.admin.id.modal.main);
+ one.main.admin.ajax.users(function($body) {
+ one.lib.modal.inject.body($admin, $body);
+ });
+ } else {
+ alert("Failed to remove user: " + result);
+ }
+ });
+ });
// change password binding
$('#' + one.main.admin.id.modal.remove.password, $modal).click(function() {
one.main.admin.password.initialize(id, function() {
$modal.modal('hide');
});
});
-
$modal.modal();
},
ajax : function(id, callback) {
- $.post(one.main.admin.address.root
- + one.main.admin.address.users + '/' + id,
- function(data) {
- callback(data);
- });
+ $.post(one.main.admin.address.root + one.main.admin.address.users + '/' + id, function(data) {
+ callback(data);
+ });
},
},
-
footer : function() {
var footer = [];
-
var removeButton = one.lib.dashlet.button.single("Remove User",
one.main.admin.id.modal.remove.user, "btn-danger", "");
var $removeButton = one.lib.dashlet.button.button(removeButton);
footer.push($removeButton);
-
var change = one.lib.dashlet.button.single('Change Password',
one.main.admin.id.modal.remove.password, 'btn-success', '');
var $change = one.lib.dashlet.button.button(change);
footer.push($change);
-
var closeButton = one.lib.dashlet.button.single("Close",
one.main.admin.id.modal.remove.close, "", "");
var $closeButton = one.lib.dashlet.button.button(closeButton);
footer.push($closeButton);
-
return footer;
},
body : function() {
var $body = one.main.admin.add.body();
var $modal = one.lib.modal.spawn(one.main.admin.id.modal.user,
h3, $body, footer);
-
// close binding
- $('#' + one.main.admin.id.modal.add.close, $modal).click(
- function() {
- $modal.modal('hide');
- });
-
+ $('#' + one.main.admin.id.modal.add.close, $modal).click(function() {
+ $modal.modal('hide');
+ });
// add binding
- $('#' + one.main.admin.id.modal.add.user, $modal)
- .click(
- function() {
- one.main.admin.add.modal
- .add(
- $modal,
- function(result) {
- if (result == 'Success') {
- $modal
- .modal('hide');
- // body inject
- var $admin = $('#'
- + one.main.admin.id.modal.main);
- one.main.admin.ajax
- .users(function($body) {
- one.lib.modal.inject
- .body(
- $admin,
- $body);
- });
- } else
- alert("Failed to add user: "
- + result);
- });
- });
-
+ $('#' + one.main.admin.id.modal.add.user, $modal).click(function() {
+ one.main.admin.add.modal.add($modal, function(result) {
+ if (result == 'Success') {
+ $modal.modal('hide');
+ // body inject
+ var $admin = $('#'+one.main.admin.id.modal.main);
+ one.main.admin.ajax.users(function($body) {
+ one.lib.modal.inject.body($admin, $body);
+ });
+ } else {
+ alert("Failed to add user: "+result);
+ }
+ });
+ });
$modal.modal();
},
add : function($modal, callback) {
}
}
+one.main.cluster = {
+ id : { // one.main.cluster.id
+ modal : 'one-main-cluster-id-modal',
+ close : 'one-main-cluster-id-close',
+ datagrid : 'one-main-cluster-id-datagrid'
+ },
+ initialize : function() {
+ var h3 = 'Cluster Management';
+ var footer = one.main.cluster.footer();
+ var $body = '';
+ var $modal = one.lib.modal.spawn(one.main.cluster.id.modal, h3, $body, footer);
+
+ // close
+ $('#'+one.main.cluster.id.close, $modal).click(function() {
+ $modal.modal('hide');
+ });
+
+ // body
+ $.getJSON('/admin/cluster', function(data) {
+ var $gridHTML = one.lib.dashlet.datagrid.init(one.main.cluster.id.datagrid, {
+ searchable: true,
+ filterable: false,
+ pagination: true,
+ flexibleRowsPerPage: true
+ }, 'table-striped table-condensed table-cursor');
+ var source = one.main.cluster.data(data);
+ $gridHTML.datagrid({dataSource : source}).on('loaded', function() {
+ $(this).find('tbody tr').click(function() {
+ var $tr = $(this);
+ if ($tr.find('td:nth-child(1)').attr('colspan') === '1') {
+ return false;
+ }
+ var address = $tr.find('.ux-id').text();
+ one.main.cluster.nodes.initialize(address);
+ });
+ });
+ one.lib.modal.inject.body($modal, $gridHTML);
+ });
+
+ $modal.modal();
+ },
+ data : function(data) {
+ var tdata = [];
+ var registry = [];
+ $(data).each(function(idx, val) {
+ var name = val.name;
+ var address = val.address;
+ var $registry = $(document.createElement('span'));
+ $registry
+ .append(JSON.stringify(address))
+ .css('display', 'none')
+ .addClass('ux-id');
+ name = one.lib.dashlet.label(name, null)[0].outerHTML;
+ name += $registry[0].outerHTML;
+ if (val.me === true) {
+ var me = one.lib.dashlet.label('*', 'label-inverse')[0].outerHTML;
+ name += ' '+me;
+ }
+ if (val.coordinator === true) {
+ var coord = one.lib.dashlet.label('C')[0].outerHTML;
+ name += ' '+coord;
+ }
+ tdata.push({
+ 'controller' : name
+ });
+ });
+ var source = new StaticDataSource({
+ columns : [
+ {
+ property : 'controller',
+ label : 'Controller',
+ sortable : true
+ }
+ ],
+ data : tdata,
+ delay : 0
+ });
+ return source;
+ },
+ footer : function() {
+ var footer = [];
+ var close = one.lib.dashlet.button.single('Close', one.main.cluster.id.close, '', '');
+ var $close = one.lib.dashlet.button.button(close);
+ footer.push($close);
+ return footer;
+ }
+}
+
+one.main.cluster.nodes = {
+ id : { // one.main.cluster.nodes.id
+ modal : 'one-main-cluster-nodes-id-modal',
+ close : 'one-main-cluster-nodes-id-close',
+ datagrid : 'one-main-cluser-nodes-id-datagrid'
+ },
+ initialize : function(address) { // one.main.cluster.nodes.initialize
+ var h3 = 'Connected Nodes';
+ var footer = one.main.cluster.nodes.footer();
+ var $body = '';
+ var $modal = one.lib.modal.spawn(one.main.cluster.nodes.id.modal, h3, $body, footer);
+
+ // close
+ $('#'+one.main.cluster.nodes.id.close, $modal).click(function() {
+ $modal.modal('hide');
+ });
+
+ // body
+ $.getJSON('/admin/cluster/controller/'+address, function(data) {
+ var $gridHTML = one.lib.dashlet.datagrid.init(one.main.cluster.nodes.id.datagrid, {
+ searchable: true,
+ filterable: false,
+ pagination: true,
+ flexibleRowsPerPage: true
+ }, 'table-striped table-condensed');
+ var source = one.main.cluster.nodes.data(data);
+ $gridHTML.datagrid({dataSource : source});
+ one.lib.modal.inject.body($modal, $gridHTML);
+ });
+
+ $modal.modal();
+ },
+ data : function(data) {
+ var tdata = [];
+ $(data).each(function(idx, val) {
+ tdata.push({
+ 'node' : val.description
+ });
+ });
+ var source = new StaticDataSource({
+ columns : [
+ {
+ property : 'node',
+ label : 'Node',
+ sortable : true
+ }
+ ],
+ data : tdata,
+ delay : 0
+ });
+ return source;
+ },
+ footer : function() { // one.main.cluster.nodes.footer
+ var footer = [];
+ var close = one.lib.dashlet.button.single('Close', one.main.cluster.nodes.id.close, '', '');
+ var $close = one.lib.dashlet.button.button(close);
+ footer.push($close);
+ return footer;
+ }
+}
+
one.main.dashlet = {
left : {
top : $("#left-top .dashlet"),
});
});
+// cluster
+$('#cluster').click(function() {
+ one.main.cluster.initialize();
+});
+
// save
$("#save").click(function() {
$.post(one.main.constants.address.save, function(data) {