* Update the pool_id of the member to that this.loadBalancerPoolID
*/
if (loadBalancerPoolMembers != null) {
- for (NeutronLoadBalancerPoolMember member: loadBalancerPoolMembers)
+ for (NeutronLoadBalancerPoolMember member: loadBalancerPoolMembers) {
member.setPoolID(loadBalancerPoolID);
+ }
return loadBalancerPoolMembers;
}
return loadBalancerPoolMembers;
if(s.equals("protocol")) {
ans.setLoadBalancerPoolProtocol(this.getLoadBalancerPoolProtocol());
}
- if(s.equals("lb_algorithm")) {
+ if (s.equals("lb_algorithm")) {
ans.setLoadBalancerPoolLbAlgorithm(this.getLoadBalancerPoolLbAlgorithm());
}
- if(s.equals("healthmonitor_id")) {
+ if (s.equals("healthmonitor_id")) {
ans.setNeutronLoadBalancerPoolHealthMonitorID(this.getNeutronLoadBalancerPoolHealthMonitorID());
}
if (s.equals("admin_state_up")) {
(queryStatus == null || queryStatus.equals(oSS.getStatus())) &&
(queryRouterID == null || queryRouterID.equals(oSS.getRouterUUID())) &&
(queryTenantID == null || queryTenantID.equals(oSS.getTenantUUID()))) {
- if (fields.size() > 0)
+ if (fields.size() > 0) {
ans.add(extractFields(oSS,fields));
- else
+ } else {
ans.add(oSS);
+ }
}
}
//TODO: apply pagination to results
throw new ServiceUnavailableException("Floating IP CRUD Interface "
+ RestMessages.SERVICEUNAVAILABLE.toString());
}
- if (!floatingIPInterface.floatingIPExists(floatingipUUID))
+ if (!floatingIPInterface.floatingIPExists(floatingipUUID)) {
throw new ResourceNotFoundException("Floating IP UUID doesn't exist.");
+ }
if (fields.size() > 0) {
NeutronFloatingIP ans = floatingIPInterface.getFloatingIP(floatingipUUID);
return Response.status(200).entity(
if (input.isSingleton()) {
NeutronFloatingIP singleton = input.getSingleton();
// check existence of id in cache and return badrequest if exists
- if (floatingIPInterface.floatingIPExists(singleton.getID()))
+ if (floatingIPInterface.floatingIPExists(singleton.getID())) {
throw new BadRequestException("Floating IP UUID already exists.");
+ }
// check if the external network is specified, exists, and is an external network
String externalNetworkUUID = singleton.getFloatingNetworkUUID();
- if (externalNetworkUUID == null)
+ if (externalNetworkUUID == null) {
throw new BadRequestException("external network UUID doesn't exist.");
- if (!networkInterface.networkExists(externalNetworkUUID))
+ }
+ if (!networkInterface.networkExists(externalNetworkUUID)) {
throw new BadRequestException("external network UUID doesn't exist.");
+ }
NeutronNetwork externNetwork = networkInterface.getNetwork(externalNetworkUUID);
- if (!externNetwork.isRouterExternal())
+ if (!externNetwork.isRouterExternal()) {
throw new BadRequestException("external network isn't marked router:external");
+ }
// if floating IP is specified, make sure it can come from the network
String floatingIP = singleton.getFloatingIPAddress();
if (floatingIP != null) {
- if (externNetwork.getSubnets().size() != 1)
+ if (externNetwork.getSubnets().size() != 1) {
throw new BadRequestException("external network doesn't have a subnet");
+ }
NeutronSubnet externSubnet = subnetInterface.getSubnet(externNetwork.getSubnets().get(0));
- if (!externSubnet.isValidIP(floatingIP))
+ if (!externSubnet.isValidIP(floatingIP)) {
throw new BadRequestException("external IP isn't valid for the specified subnet.");
- if (externSubnet.getFloatingIpPortsInSubnet(floatingIP).isEmpty() && externSubnet.isIPInUse(floatingIP))
+ }
+ if (externSubnet.getFloatingIpPortsInSubnet(floatingIP).isEmpty() && externSubnet.isIPInUse(floatingIP)) {
throw new ResourceConflictException("floating IP is in use.");
+ }
}
// if port_id is specified, then check that the port exists and has at least one IP
String port_id = singleton.getPortUUID();
if (port_id != null) {
String fixedIP = null; // used for the fixedIP calculation
- if (!portInterface.portExists(port_id))
+ if (!portInterface.portExists(port_id)) {
throw new ResourceNotFoundException("Port UUID doesn't exist.");
+ }
NeutronPort port = portInterface.getPort(port_id);
- if (port.getFixedIPs().size() < 1)
+ if (port.getFixedIPs().size() < 1) {
throw new BadRequestException("port UUID doesn't have an IP address.");
+ }
// if there is more than one fixed IP then check for fixed_ip_address
// and that it is in the list of port addresses
if (port.getFixedIPs().size() > 1) {
fixedIP = singleton.getFixedIPAddress();
- if (fixedIP == null)
+ if (fixedIP == null) {
throw new BadRequestException("fixed IP address doesn't exist.");
+ }
Iterator<Neutron_IPs> i = port.getFixedIPs().iterator();
boolean validFixedIP = false;
while (i.hasNext() && !validFixedIP) {
Neutron_IPs ip = i.next();
- if (ip.getIpAddress().equals(fixedIP))
+ if (ip.getIpAddress().equals(fixedIP)) {
validFixedIP = true;
+ }
}
- if (!validFixedIP)
+ if (!validFixedIP) {
throw new BadRequestException("can't find a valid fixed IP address");
+ }
} else {
fixedIP = port.getFixedIPs().get(0).getIpAddress();
- if (singleton.getFixedIPAddress() != null && !fixedIP.equalsIgnoreCase(singleton.getFixedIPAddress()))
+ if (singleton.getFixedIPAddress() != null && !fixedIP.equalsIgnoreCase(singleton.getFixedIPAddress())) {
throw new BadRequestException("mismatched fixed IP address in request");
+ }
}
//lastly check that this fixed IP address isn't already used
- if (port.isBoundToFloatingIP(fixedIP))
+ if (port.isBoundToFloatingIP(fixedIP)) {
throw new ResourceConflictException("fixed IP is in use.");
+ }
singleton.setFixedIPAddress(fixedIP);
}
Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
for (Object instance : instances) {
INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
int status = service.canCreateFloatingIP(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
throw new ServiceUnavailableException("Port CRUD Interface "
+ RestMessages.SERVICEUNAVAILABLE.toString());
}
- if (!floatingIPInterface.floatingIPExists(floatingipUUID))
+ if (!floatingIPInterface.floatingIPExists(floatingipUUID)) {
throw new ResourceNotFoundException("Floating IP UUID doesn't exist.");
+ }
NeutronFloatingIP sourceFloatingIP = floatingIPInterface.getFloatingIP(floatingipUUID);
- if (!input.isSingleton())
+ if (!input.isSingleton()) {
throw new BadRequestException("only singleton requests allowed.");
+ }
NeutronFloatingIP singleton = input.getSingleton();
- if (singleton.getID() == null)
+ if (singleton.getID() == null) {
throw new BadRequestException("singleton UUID doesn't exist.");
+ }
NeutronNetwork externNetwork = networkInterface.getNetwork(
sourceFloatingIP.getFloatingNetworkUUID());
// if floating IP is specified, make sure it can come from the network
String floatingIP = singleton.getFloatingIPAddress();
if (floatingIP != null) {
- if (externNetwork.getSubnets().size() != 1)
+ if (externNetwork.getSubnets().size() != 1) {
throw new BadRequestException("external network doesn't have a subnet.");
+ }
NeutronSubnet externSubnet = subnetInterface.getSubnet(externNetwork.getSubnets().get(0));
- if (!externSubnet.isValidIP(floatingIP))
+ if (!externSubnet.isValidIP(floatingIP)) {
throw new BadRequestException("floating IP not valid for external subnet");
- if (externSubnet.isIPInUse(floatingIP))
+ }
+ if (externSubnet.isIPInUse(floatingIP)) {
throw new ResourceConflictException("floating IP is in use.");
+ }
}
// if port_id is specified, then check that the port exists and has at least one IP
String port_id = singleton.getPortUUID();
if (port_id != null) {
String fixedIP = null; // used for the fixedIP calculation
- if (!portInterface.portExists(port_id))
+ if (!portInterface.portExists(port_id)) {
throw new ResourceNotFoundException("Port UUID doesn't exist.");
+ }
NeutronPort port = portInterface.getPort(port_id);
- if (port.getFixedIPs().size() < 1)
+ if (port.getFixedIPs().size() < 1) {
throw new BadRequestException("port ID doesn't have a fixed IP address.");
+ }
// if there is more than one fixed IP then check for fixed_ip_address
// and that it is in the list of port addresses
if (port.getFixedIPs().size() > 1) {
fixedIP = singleton.getFixedIPAddress();
- if (fixedIP == null)
+ if (fixedIP == null) {
throw new BadRequestException("request doesn't have a fixed IP address");
+ }
Iterator<Neutron_IPs> i = port.getFixedIPs().iterator();
boolean validFixedIP = false;
while (i.hasNext() && !validFixedIP) {
Neutron_IPs ip = i.next();
- if (ip.getIpAddress().equals(fixedIP))
+ if (ip.getIpAddress().equals(fixedIP)) {
validFixedIP = true;
+ }
}
- if (!validFixedIP)
+ if (!validFixedIP) {
throw new BadRequestException("couldn't find a valid fixed IP address");
+ }
} else {
fixedIP = port.getFixedIPs().get(0).getIpAddress();
if (singleton.getFixedIPAddress() != null &&
- !fixedIP.equalsIgnoreCase(singleton.getFixedIPAddress()))
+ !fixedIP.equalsIgnoreCase(singleton.getFixedIPAddress())) {
throw new BadRequestException("mismatch in fixed IP addresses");
+ }
}
//lastly check that this fixed IP address isn't already used
- if (port.isBoundToFloatingIP(fixedIP))
+ if (port.isBoundToFloatingIP(fixedIP)) {
throw new ResourceConflictException("fixed IP is in use.");
+ }
singleton.setFixedIPAddress(fixedIP);
}
NeutronFloatingIP target = floatingIPInterface.getFloatingIP(floatingipUUID);
for (Object instance : instances) {
INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
int status = service.canUpdateFloatingIP(singleton, target);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
throw new ServiceUnavailableException("Floating IP CRUD Interface "
+ RestMessages.SERVICEUNAVAILABLE.toString());
}
- if (!floatingIPInterface.floatingIPExists(floatingipUUID))
+ if (!floatingIPInterface.floatingIPExists(floatingipUUID)) {
throw new ResourceNotFoundException("Floating IP UUID doesn't exist.");
+ }
// TODO: need to undo port association if it exists
NeutronFloatingIP singleton = floatingIPInterface.getFloatingIP(floatingipUUID);
Object[] instances = NeutronUtil.getInstances(INeutronFloatingIPAware.class, this);
for (Object instance : instances) {
INeutronFloatingIPAware service = (INeutronFloatingIPAware) instance;
int status = service.canDeleteFloatingIP(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
List<NeutronLoadBalancerPoolMember> members =
loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID).getLoadBalancerPoolMembers();
for (NeutronLoadBalancerPoolMember ans: members) {
- if (!ans.getPoolMemberID().equals(loadBalancerPoolMemberUUID))
+ if (!ans.getPoolMemberID().equals(loadBalancerPoolMemberUUID)) {
continue;
+ }
if (fields.size() > 0) {
return Response.status(200).entity(
if (singletonPool.getLoadBalancerPoolMembers() != null) {
List<NeutronLoadBalancerPoolMember> members = singletonPool.getLoadBalancerPoolMembers();
for (NeutronLoadBalancerPoolMember member: members) {
- if (member.getPoolMemberID().equals(loadBalancerPoolMemberUUID))
+ if (member.getPoolMemberID().equals(loadBalancerPoolMemberUUID)) {
throw new BadRequestException("LoadBalancerPoolMember UUID already exists");
+ }
}
}
*/
List<NeutronLoadBalancerPoolMember> members = singletonPool.getLoadBalancerPoolMembers();
for (NeutronLoadBalancerPoolMember member: members) {
- if (member.getPoolMemberID().equals(loadBalancerPoolMemberUUID))
+ if (member.getPoolMemberID().equals(loadBalancerPoolMemberUUID)) {
throw new BadRequestException("LoadBalancerPoolMember UUID already exists");
+ }
}
if (testMap.containsKey(test.getPoolMemberID())) {
break;
}
}
- if (singleton == null)
+ if (singleton == null) {
throw new BadRequestException("LoadBalancerPoolMember UUID does not exist.");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerPoolMemberAware.class, this);
if (instances != null) {
(queryDirection == null || queryDirection.equals(oSS.getMeteringLabelRuleDirection())) &&
(queryRemoteIPPrefix == null || queryRemoteIPPrefix.equals(oSS.getMeteringLabelRuleRemoteIPPrefix())) &&
(queryLabelID == null || queryLabelID.equals(oSS.getMeteringLabelRuleLabelID()))) {
- if (fields.size() > 0)
+ if (fields.size() > 0) {
ans.add(extractFields(oSS,fields));
- else
+ } else {
ans.add(oSS);
+ }
}
}
//TODO: apply pagination to results
/*
* verify that the meteringLabelRule doesn't already exist (issue: is deeper inspection necessary?)
*/
- if (meteringLabelRuleInterface.neutronMeteringLabelRuleExists(singleton.getMeteringLabelRuleUUID()))
+ if (meteringLabelRuleInterface.neutronMeteringLabelRuleExists(singleton.getMeteringLabelRuleUUID())) {
throw new BadRequestException("meteringLabelRule UUID already exists");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronMeteringLabelRuleAware.class, this);
if (instances != null) {
if (instances.length > 0) {
for (Object instance : instances) {
INeutronMeteringLabelRuleAware service = (INeutronMeteringLabelRuleAware) instance;
int status = service.canCreateMeteringLabelRule(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
/*
* verify that the meteringLabelRule exists and is not in use before removing it
*/
- if (!meteringLabelRuleInterface.neutronMeteringLabelRuleExists(ruleUUID))
+ if (!meteringLabelRuleInterface.neutronMeteringLabelRuleExists(ruleUUID)) {
throw new ResourceNotFoundException("MeteringLabelRule UUID not found");
+ }
NeutronMeteringLabelRule singleton = meteringLabelRuleInterface.getNeutronMeteringLabelRule(ruleUUID);
Object[] instances = NeutronUtil.getInstances(INeutronMeteringLabelRuleAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronMeteringLabelRuleAware service = (INeutronMeteringLabelRuleAware) instance;
int status = service.canDeleteMeteringLabelRule(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
(queryName == null || queryName.equals(oSS.getMeteringLabelName())) &&
(queryDescription == null || queryDescription.equals(oSS.getMeteringLabelDescription())) &&
(queryTenantID == null || queryTenantID.equals(oSS.getMeteringLabelTenantID()))) {
- if (fields.size() > 0)
+ if (fields.size() > 0) {
ans.add(extractFields(oSS,fields));
- else
+ } else {
ans.add(oSS);
+ }
}
}
//TODO: apply pagination to results
/*
* verify that the meteringLabel doesn't already exist (issue: is deeper inspection necessary?)
*/
- if (meteringLabelInterface.neutronMeteringLabelExists(singleton.getMeteringLabelUUID()))
+ if (meteringLabelInterface.neutronMeteringLabelExists(singleton.getMeteringLabelUUID())) {
throw new BadRequestException("meteringLabel UUID already exists");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronMeteringLabelAware.class, this);
if (instances != null) {
if (instances.length > 0) {
for (Object instance : instances) {
INeutronMeteringLabelAware service = (INeutronMeteringLabelAware) instance;
int status = service.canCreateMeteringLabel(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
/*
* verify that the meteringLabel exists and is not in use before removing it
*/
- if (!meteringLabelInterface.neutronMeteringLabelExists(labelUUID))
+ if (!meteringLabelInterface.neutronMeteringLabelExists(labelUUID)) {
throw new ResourceNotFoundException("MeteringLabel UUID not found");
+ }
NeutronMeteringLabel singleton = meteringLabelInterface.getNeutronMeteringLabel(labelUUID);
Object[] instances = NeutronUtil.getInstances(INeutronMeteringLabelAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronMeteringLabelAware service = (INeutronMeteringLabelAware) instance;
int status = service.canDeleteMeteringLabel(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
(queryStatus == null || queryStatus.equals(oSS.getStatus())) &&
(queryExternalGatewayInfo == null || queryExternalGatewayInfo.equals(oSS.getExternalGatewayInfo())) &&
(queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
- if (fields.size() > 0)
+ if (fields.size() > 0) {
ans.add(extractFields(oSS,fields));
- else
+ } else {
ans.add(oSS);
+ }
}
}
//TODO: apply pagination to results
* if there is external gateway information provided, verify that the specified network
* exists and has been designated as "router:external"
*/
- if (routerInterface.routerExists(singleton.getID()))
+ if (routerInterface.routerExists(singleton.getID())) {
throw new BadRequestException("router UUID already exists");
+ }
if (singleton.getExternalGatewayInfo() != null) {
String externNetworkPtr = singleton.getExternalGatewayInfo().getNetworkID();
- if (!networkInterface.networkExists(externNetworkPtr))
+ if (!networkInterface.networkExists(externNetworkPtr)) {
throw new BadRequestException("External Network Pointer doesn't exist");
+ }
NeutronNetwork externNetwork = networkInterface.getNetwork(externNetworkPtr);
- if (!externNetwork.isRouterExternal())
+ if (!externNetwork.isRouterExternal()) {
throw new BadRequestException("External Network Pointer isn't marked as router:external");
+ }
}
Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
int status = service.canCreateRouter(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
/*
* router has to exist and only a single delta can be supplied
*/
- if (!routerInterface.routerExists(routerUUID))
+ if (!routerInterface.routerExists(routerUUID)) {
throw new ResourceNotFoundException("Router UUID not found");
- if (!input.isSingleton())
+ }
+ if (!input.isSingleton()) {
throw new BadRequestException("Only single router deltas supported");
+ }
NeutronRouter singleton = input.getSingleton();
NeutronRouter original = routerInterface.getRouter(routerUUID);
* attribute changes blocked by Neutron
*/
if (singleton.getID() != null || singleton.getTenantID() != null ||
- singleton.getStatus() != null)
+ singleton.getStatus() != null) {
throw new BadRequestException("Request attribute change not allowed");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
int status = service.canUpdateRouter(singleton, original);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
*/
if (singleton.getExternalGatewayInfo() != null) {
String externNetworkPtr = singleton.getExternalGatewayInfo().getNetworkID();
- if (!networkInterface.networkExists(externNetworkPtr))
+ if (!networkInterface.networkExists(externNetworkPtr)) {
throw new BadRequestException("External Network Pointer does not exist");
+ }
NeutronNetwork externNetwork = networkInterface.getNetwork(externNetworkPtr);
- if (!externNetwork.isRouterExternal())
+ if (!externNetwork.isRouterExternal()) {
throw new BadRequestException("External Network Pointer isn't marked as router:external");
+ }
}
/*
/*
* verify that the router exists and is not in use before removing it
*/
- if (!routerInterface.routerExists(routerUUID))
+ if (!routerInterface.routerExists(routerUUID)) {
throw new ResourceNotFoundException("Router UUID not found");
- if (routerInterface.routerInUse(routerUUID))
+ }
+ if (routerInterface.routerInUse(routerUUID)) {
throw new ResourceConflictException("Router UUID in Use");
+ }
NeutronRouter singleton = routerInterface.getRouter(routerUUID);
Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
int status = service.canDeleteRouter(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
* While the Neutron specification says that the router has to exist and the input can only specify either a subnet id
* or a port id, but not both, this code assumes that the plugin has filled everything in for us and so both must be present
*/
- if (!routerInterface.routerExists(routerUUID))
+ if (!routerInterface.routerExists(routerUUID)) {
throw new BadRequestException("Router UUID doesn't exist");
+ }
NeutronRouter target = routerInterface.getRouter(routerUUID);
if (input.getSubnetUUID() == null ||
- input.getPortUUID() == null)
+ input.getPortUUID() == null) {
throw new BadRequestException("Must specify at subnet id, port id or both");
+ }
// check that the port is part of the subnet
NeutronSubnet targetSubnet = subnetInterface.getSubnet(input.getSubnetUUID());
- if (targetSubnet == null)
+ if (targetSubnet == null) {
throw new BadRequestException("Subnet id doesn't exist");
+ }
NeutronPort targetPort = portInterface.getPort(input.getPortUUID());
- if (targetPort == null)
+ if (targetPort == null) {
throw new BadRequestException("Port id doesn't exist");
- if (!targetSubnet.getPortsInSubnet().contains(targetPort))
+ }
+ if (!targetSubnet.getPortsInSubnet().contains(targetPort)) {
throw new BadRequestException("Port id not part of subnet id");
+ }
- if (targetPort.getFixedIPs().size() != 1)
+ if (targetPort.getFixedIPs().size() != 1) {
throw new BadRequestException("Port id must have a single fixedIP address");
- if (targetPort.getDeviceID() != null && !targetPort.getDeviceID().equals(routerUUID))
+ }
+ if (targetPort.getDeviceID() != null && !targetPort.getDeviceID().equals(routerUUID)) {
throw new ResourceConflictException("Target Port already allocated to a different device id");
+ }
if (targetPort.getDeviceOwner() != null &&
!targetPort.getDeviceOwner().equalsIgnoreCase(ROUTER_INTERFACE_STR) &&
- !targetPort.getDeviceOwner().equalsIgnoreCase(ROUTER_GATEWAY_STR))
+ !targetPort.getDeviceOwner().equalsIgnoreCase(ROUTER_GATEWAY_STR)) {
throw new ResourceConflictException("Target Port already allocated to non-router interface");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
if (instances.length > 0) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
int status = service.canAttachInterface(target, input);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
}
//mark the port device id and device owner fields
- if (targetPort.getDeviceOwner() == null || targetPort.getDeviceOwner().isEmpty())
+ if (targetPort.getDeviceOwner() == null || targetPort.getDeviceOwner().isEmpty()) {
targetPort.setDeviceOwner(ROUTER_INTERFACE_STR);
+ }
targetPort.setDeviceID(routerUUID);
target.addInterface(input.getPortUUID(), input);
}
// verify the router exists
- if (!routerInterface.routerExists(routerUUID))
+ if (!routerInterface.routerExists(routerUUID)) {
throw new BadRequestException("Router does not exist");
+ }
NeutronRouter target = routerInterface.getRouter(routerUUID);
/*
if (input.getPortUUID() == null &&
input.getSubnetUUID() != null) {
NeutronPort port = portInterface.getGatewayPort(input.getSubnetUUID());
- if (port == null)
+ if (port == null) {
throw new ResourceNotFoundException("Port UUID not found");
+ }
input.setPortUUID(port.getID());
input.setID(target.getID());
input.setTenantID(target.getTenantID());
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
int status = service.canDetachInterface(target, input);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
int status = service.canDetachInterface(target, input);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
if (subnet == null) {
throw new ResourceNotFoundException("Subnet UUID not found");
}
- if (!subnet.isValidIP(port.getFixedIPs().get(0).getIpAddress()))
+ if (!subnet.isValidIP(port.getFixedIPs().get(0).getIpAddress())) {
throw new ResourceConflictException("Target Port IP not in Target Subnet");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
if (instances != null) {
if (instances.length > 0) {
for (Object instance : instances) {
INeutronRouterAware service = (INeutronRouterAware) instance;
int status = service.canDetachInterface(target, input);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
for (Object instance : instances) {
INeutronSecurityGroupAware service = (INeutronSecurityGroupAware) instance;
int status = service.canCreateNeutronSecurityGroup(test);
- if ((status < 200) || (status > 299)) return Response.status(status).build();
+ if ((status < 200) || (status > 299)) {
+ return Response.status(status).build();
+ }
}
} else {
throw new BadRequestException("No providers registered. Please try again later");
(queryPFS == null || queryPFS.equals(oSS.getPerfectForwardSecrecy())) &&
(queryIKEVersion == null || queryIKEVersion.equals(oSS.getIkeVersion())) &&
(queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
- if (fields.size() > 0)
+ if (fields.size() > 0) {
ans.add(extractFields(oSS,fields));
- else
+ } else {
ans.add(oSS);
+ }
}
}
//TODO: apply pagination to results
/*
* verify that the ikePolicy doesn't already exist (issue: is deeper inspection necessary?)
*/
- if (ikePolicyInterface.neutronVPNIKEPolicyExists(singleton.getID()))
+ if (ikePolicyInterface.neutronVPNIKEPolicyExists(singleton.getID())) {
throw new BadRequestException("ikePolicy UUID already exists");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronVPNIKEPolicyAware.class, this);
if (instances != null) {
if (instances.length > 0) {
for (Object instance : instances) {
INeutronVPNIKEPolicyAware service = (INeutronVPNIKEPolicyAware) instance;
int status = service.canCreateNeutronVPNIKEPolicy(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
/*
* ikePolicy has to exist and only a single delta can be supplied
*/
- if (!ikePolicyInterface.neutronVPNIKEPolicyExists(policyUUID))
+ if (!ikePolicyInterface.neutronVPNIKEPolicyExists(policyUUID)) {
throw new ResourceNotFoundException("VPNIKEPolicy UUID not found");
- if (!input.isSingleton())
+ }
+ if (!input.isSingleton()) {
throw new BadRequestException("Only single ikePolicy deltas supported");
+ }
NeutronVPNIKEPolicy singleton = input.getSingleton();
NeutronVPNIKEPolicy original = ikePolicyInterface.getNeutronVPNIKEPolicy(policyUUID);
/*
* attribute changes blocked by Neutron
*/
- if (singleton.getID() != null || singleton.getTenantID() != null)
+ if (singleton.getID() != null || singleton.getTenantID() != null) {
throw new BadRequestException("Request attribute change not allowed");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronVPNIKEPolicyAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronVPNIKEPolicyAware service = (INeutronVPNIKEPolicyAware) instance;
int status = service.canUpdateNeutronVPNIKEPolicy(singleton, original);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
/*
* verify that the policy exists and is not in use before removing it
*/
- if (!policyInterface.neutronVPNIKEPolicyExists(policyUUID))
+ if (!policyInterface.neutronVPNIKEPolicyExists(policyUUID)) {
throw new ResourceNotFoundException("VPNIKEPolicy UUID not found");
+ }
NeutronVPNIKEPolicy singleton = policyInterface.getNeutronVPNIKEPolicy(policyUUID);
Object[] instances = NeutronUtil.getInstances(INeutronVPNIKEPolicyAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronVPNIKEPolicyAware service = (INeutronVPNIKEPolicyAware) instance;
int status = service.canDeleteNeutronVPNIKEPolicy(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
(queryTransformProtocol == null || queryTransformProtocol.equals(oSS.getTransformProtocol())) &&
(queryEncapsulationMode == null || queryEncapsulationMode.equals(oSS.getEncapsulationMode())) &&
(queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
- if (fields.size() > 0)
+ if (fields.size() > 0) {
ans.add(extractFields(oSS,fields));
- else
+ } else {
ans.add(oSS);
+ }
}
}
//TODO: apply pagination to results
/*
* verify that the ipsecPolicy doesn't already exist (issue: is deeper inspection necessary?)
*/
- if (ipsecPolicyInterface.neutronVPNIPSECPolicyExists(singleton.getID()))
+ if (ipsecPolicyInterface.neutronVPNIPSECPolicyExists(singleton.getID())) {
throw new BadRequestException("ipsecPolicy UUID already exists");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECPolicyAware.class, this);
if (instances != null) {
if (instances.length > 0) {
for (Object instance : instances) {
INeutronVPNIPSECPolicyAware service = (INeutronVPNIPSECPolicyAware) instance;
int status = service.canCreateNeutronVPNIPSECPolicy(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
/*
* ipsecPolicy has to exist and only a single delta can be supplied
*/
- if (!ipsecPolicyInterface.neutronVPNIPSECPolicyExists(policyUUID))
+ if (!ipsecPolicyInterface.neutronVPNIPSECPolicyExists(policyUUID)) {
throw new ResourceNotFoundException("VPNIPSECPolicy UUID not found");
- if (!input.isSingleton())
+ }
+ if (!input.isSingleton()) {
throw new BadRequestException("Only single ipsecPolicy deltas supported");
+ }
NeutronVPNIPSECPolicy singleton = input.getSingleton();
NeutronVPNIPSECPolicy original = ipsecPolicyInterface.getNeutronVPNIPSECPolicy(policyUUID);
/*
* attribute changes blocked by Neutron
*/
- if (singleton.getID() != null || singleton.getTenantID() != null)
+ if (singleton.getID() != null || singleton.getTenantID() != null) {
throw new BadRequestException("Request attribute change not allowed");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECPolicyAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronVPNIPSECPolicyAware service = (INeutronVPNIPSECPolicyAware) instance;
int status = service.canUpdateNeutronVPNIPSECPolicy(singleton, original);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
/*
* verify that the policy exists and is not in use before removing it
*/
- if (!policyInterface.neutronVPNIPSECPolicyExists(policyUUID))
+ if (!policyInterface.neutronVPNIPSECPolicyExists(policyUUID)) {
throw new ResourceNotFoundException("VPNIPSECPolicy UUID not found");
+ }
NeutronVPNIPSECPolicy singleton = policyInterface.getNeutronVPNIPSECPolicy(policyUUID);
Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECPolicyAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronVPNIPSECPolicyAware service = (INeutronVPNIPSECPolicyAware) instance;
int status = service.canDeleteNeutronVPNIPSECPolicy(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
&& (queryStatus == null || queryStatus.equals(oSS.getStatus()))
&& (queryIkePolicyID == null || queryIkePolicyID.equals(oSS.getIkePolicyID()))
&& (queryIpSecPolicyID == null || queryIpSecPolicyID.equals(oSS.getIpsecPolicyID()))
- && (queryVpnServiceID == null || queryVpnServiceID.equals(oSS.getVpnServiceID())))
- if (fields.size() > 0)
+ && (queryVpnServiceID == null || queryVpnServiceID.equals(oSS.getVpnServiceID()))) {
+ if (fields.size() > 0) {
ans.add(extractFields(oSS, fields));
- else
+ } else {
ans.add(oSS);
+ }
+ }
}
// TODO: apply pagination to results
* verify that the ipsec site connection doesn't already exist (issue: is deeper
* inspection necessary?)
*/
- if (ipsecSiteConnectionsInterface.neutronVPNIPSECSiteConnectionsExists(singleton.getID()))
+ if (ipsecSiteConnectionsInterface.neutronVPNIPSECSiteConnectionsExists(singleton.getID())) {
throw new BadRequestException("VPNIPSECSiteConnections ID already exists");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECSiteConnectionAware.class, this);
if (instances != null) {
if (instances.length > 0) {
for (Object instance : instances) {
INeutronVPNIPSECSiteConnectionAware service = (INeutronVPNIPSECSiteConnectionAware) instance;
int status = service.canCreateNeutronVPNIPSECSiteConnection(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
* ipsecSiteConnection has to exist and only a single delta can be
* supplied
*/
- if (!ipsecSiteConnectionsInterface.neutronVPNIPSECSiteConnectionsExists(policyID))
+ if (!ipsecSiteConnectionsInterface.neutronVPNIPSECSiteConnectionsExists(policyID)) {
throw new ResourceNotFoundException("VPNIPSECSiteConnections ID not found");
- if (!input.isSingleton())
+ }
+ if (!input.isSingleton()) {
throw new BadRequestException("Only singleton deltas supported");
+ }
NeutronVPNIPSECSiteConnection singleton = input.getSingleton();
NeutronVPNIPSECSiteConnection original = ipsecSiteConnectionsInterface
.getNeutronVPNIPSECSiteConnections(policyID);
/*
* attribute changes blocked by Neutron
*/
- if (singleton.getID() != null || singleton.getTenantID() != null)
+ if (singleton.getID() != null || singleton.getTenantID() != null) {
throw new BadRequestException("Request attribute change not allowed");
+ }
Object[] instances = NeutronUtil.getInstances(INeutronVPNIKEPolicyAware.class, this);
if (instances != null) {
for (Object instance : instances) {
INeutronVPNIPSECSiteConnectionAware service = (INeutronVPNIPSECSiteConnectionAware) instance;
int status = service.canUpdateNeutronVPNIPSECSiteConnection(singleton, original);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
* verify that the iSiteConnections exists and is not in use before
* removing it
*/
- if (!ipsecSiteConnectionsInterface.neutronVPNIPSECSiteConnectionsExists(policyID))
+ if (!ipsecSiteConnectionsInterface.neutronVPNIPSECSiteConnectionsExists(policyID)) {
throw new ResourceNotFoundException("VPNIPSECSiteConnections ID not found");
+ }
NeutronVPNIPSECSiteConnection singleton = ipsecSiteConnectionsInterface
.getNeutronVPNIPSECSiteConnections(policyID);
Object[] instances = NeutronUtil.getInstances(INeutronVPNIPSECSiteConnectionAware.class, this);
for (Object instance : instances) {
INeutronVPNIPSECSiteConnectionAware service = (INeutronVPNIPSECSiteConnectionAware) instance;
int status = service.canDeleteNeutronVPNIPSECSiteConnection(singleton);
- if (status < 200 || status > 299)
+ if (status < 200 || status > 299) {
return Response.status(status).build();
+ }
}
} else {
throw new ServiceUnavailableException("No providers registered. Please try again later");
&& (querySubnetID == null || querySubnetID.equals(oSS.getSubnetUUID()))
&& (queryRouterID == null || queryRouterID.equals(oSS.getRouterUUID()))
&& (queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
- if (fields.size() > 0)
+ if (fields.size() > 0) {
ans.add(extractFields(oSS, fields));
- else
+ } else {
ans.add(oSS);
+ }
}
}