mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Assert when capability is not supported by service
This commit is contained in:
parent
6b653f2c3a
commit
eb1f1da035
@ -36,6 +36,7 @@ public interface Network extends ControlledEntity {
|
||||
|
||||
public Service(String name, Capability... caps) {
|
||||
this.name = name;
|
||||
this.caps = caps;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -45,6 +46,21 @@ public interface Network extends ControlledEntity {
|
||||
public Capability[] getCapabilities() {
|
||||
return caps;
|
||||
}
|
||||
|
||||
public boolean containsCapability(Capability cap) {
|
||||
boolean success = false;
|
||||
if (caps != null) {
|
||||
int length = caps.length;
|
||||
for (int i = 0; i< length; i++) {
|
||||
if (caps[i].getName().equalsIgnoreCase(cap.getName())) {
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Provider {
|
||||
|
||||
@ -2142,7 +2142,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
public Map<Service, Map<Capability, String>> getZoneCapabilities(long zoneId) {
|
||||
DataCenterVO dc = _dcDao.findById(zoneId);
|
||||
if (dc == null) {
|
||||
throw new InvalidParameterValueException("Zone id=" + dc.getId() + " doesn't exist in the system.");
|
||||
throw new InvalidParameterValueException("Zone id=" + zoneId + " doesn't exist in the system.");
|
||||
}
|
||||
|
||||
//Get all service providers from the datacenter
|
||||
@ -2168,7 +2168,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
Service service = it.next();
|
||||
if (providers.get(service).equalsIgnoreCase(element.getProvider().getName())) {
|
||||
if (elementCapabilities.containsKey(service)) {
|
||||
networkCapabilities.put(service, elementCapabilities.get(service));
|
||||
Map<Capability, String> capabilities = elementCapabilities.get(service);
|
||||
//Verify if Service support capability
|
||||
if (capabilities != null) {
|
||||
for (Capability capability : capabilities.keySet()) {
|
||||
assert(service.containsCapability(capability)) : "Capability " + capability.getName() + " is not supported by the service " + service.getName();
|
||||
}
|
||||
}
|
||||
networkCapabilities.put(service, capabilities);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user