NeutronPort ans = new NeutronPort(); Iterator<String> i = fields.iterator(); while (i.hasNext()) { String s = i.next(); if (s.equals("id")) { ans.setPortUUID(this.getPortUUID()); ans.setNetworkUUID(this.getNetworkUUID()); ans.setName(this.getName()); ans.setAdminStateUp(this.getAdminStateUp()); ans.setStatus(this.getStatus()); ans.setMacAddress(this.getMacAddress()); fixedIPs.addAll(this.getFixedIPs()); ans.setFixedIPs(fixedIPs); ans.setDeviceID(this.getDeviceID()); ans.setDeviceOwner(this.getDeviceOwner()); ans.setTenantID(this.getTenantID()); securityGroups.addAll(this.getSecurityGroups()); ans.setSecurityGroups(securityGroups);
public int canCreatePort(NeutronPort port) { // openDove specific requirement on create if (port.getAdminStateUp() != null && !port.isAdminStateUp()) { return 400; } return canAllocateEGW(port.getNetworkUUID(), false); }
while (i.hasNext()) { NeutronPort oSS = i.next(); if ((queryID == null || queryID.equals(oSS.getID())) && (queryNetworkID == null || queryNetworkID.equals(oSS.getNetworkUUID())) && (queryName == null || queryName.equals(oSS.getName())) && (queryAdminStateUp == null || queryAdminStateUp.equals(oSS.getAdminStateUp())) && (queryStatus == null || queryStatus.equals(oSS.getStatus())) && (queryMACAddress == null || queryMACAddress.equals(oSS.getMacAddress())) && (queryDeviceID == null || queryDeviceID.equals(oSS.getDeviceID())) && (queryDeviceOwner == null || queryDeviceOwner.equals(oSS.getDeviceOwner())) && (queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) { if (fields.size() > 0) { ans.add(extractFields(oSS,fields));
if (singleton.getID() != null || singleton.getTenantID() != null || singleton.getStatus() != null) { throw new BadRequestException("attribute change blocked by Neutron"); List<Neutron_IPs> fixedIPs = singleton.getFixedIPs(); if (fixedIPs != null && fixedIPs.size() > 0) { Iterator<Neutron_IPs> fixedIPIterator = fixedIPs.iterator(); if (!target.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) { throw new BadRequestException("network UUID must match that of subnet");
throw new BadRequestException("Port id not part of subnet id"); if (targetPort.getFixedIPs().size() != 1) throw new BadRequestException("Port id must have a single fixedIP address"); 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)) throw new ResourceConflictException("Target Port already allocated to non-router interface"); Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null); if (targetPort.getDeviceOwner() == null || targetPort.getDeviceOwner().isEmpty()) targetPort.setDeviceOwner(ROUTER_INTERFACE_STR); targetPort.setDeviceID(routerUUID);
if (singleton.getNetworkUUID() == null) { throw new BadRequestException("network UUID musy be specified"); if (portInterface.portExists(singleton.getID())) { throw new BadRequestException("port UUID already exists"); if (!networkInterface.networkExists(singleton.getNetworkUUID())) { throw new ResourceNotFoundException("network UUID does not exist."); if (singleton.getMacAddress() == null || !singleton.getMacAddress().matches(mac_regex)) { throw new BadRequestException("MAC address not properly formatted"); if (portInterface.macInUse(singleton.getMacAddress())) { throw new ResourceConflictException("MAC Address is in use."); List<Neutron_IPs> fixedIPs = singleton.getFixedIPs(); if (fixedIPs != null && fixedIPs.size() > 0) { Iterator<Neutron_IPs> fixedIPIterator = fixedIPs.iterator(); if (!singleton.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) { throw new BadRequestException("network UUID must match that of subnet"); if (portInterface.portExists(test.getID())) { throw new BadRequestException("port UUID already exists"); if (testMap.containsKey(test.getID())) { throw new BadRequestException("port UUID already exists");
OpenDoveCRUDInterfaces.getIfDoveNetworkSubnetAssociationCRUD(this); INeutronNetworkCRUD neutronNetworkIf = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this); NeutronNetwork neutronNetwork = neutronNetworkIf.getNetwork(port.getNetworkUUID()); INeutronSubnetCRUD neutronSubnetIf = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this); NeutronSubnet neutronSubnet = neutronSubnetIf.getSubnet(port.getFixedIPs().get(0).getSubnetUUID());
if (port == null) throw new ResourceNotFoundException("Port UUID not found"); input.setPortUUID(port.getID()); input.setID(target.getID()); input.setTenantID(target.getTenantID()); port.setDeviceID(null); port.setDeviceOwner(null); port.setDeviceID(null); port.setDeviceOwner(null); target.removeInterface(input.getPortUUID()); for (Object instance : instances) { throw new ResourceNotFoundException("Port UUID not found"); if (port.getFixedIPs() == null) { throw new ResourceNotFoundException("Port UUID has no fixed IPs"); if (!subnet.isValidIP(port.getFixedIPs().get(0).getIpAddress())) throw new ResourceConflictException("Target Port IP not in Target Subnet"); Object[] instances = ServiceHelper.getGlobalInstances(INeutronRouterAware.class, this, null); port.setDeviceID(null); port.setDeviceOwner(null); target.removeInterface(input.getPortUUID()); for (Object instance : instances) {
INeutronPortCRUD neutronPortCRUDif = NeutronCRUDInterfaces.getINeutronPortCRUD(o); NeutronPort port = neutronPortCRUDif.getPort(floatingIP.getPortUUID()); String neutronNetwork = port.getNetworkUUID(); INeutronNetworkCRUD neutronNetworkCRUDif = NeutronCRUDInterfaces.getINeutronNetworkCRUD(o); NeutronNetwork network = neutronNetworkCRUDif.getNetwork(neutronNetwork); String doveDomainName = "Neutron "+port.getTenantID(); String doveNetworkName = "Neutron "+network.getID(); IfNBSystemRU systemDB = OpenDoveCRUDInterfaces.getIfSystemRU(o);
throw new ResourceNotFoundException("Port UUID doesn't exist."); NeutronPort port = portInterface.getPort(port_id); if (port.getFixedIPs().size() < 1) throw new BadRequestException("port ID doesn't have a fixed IP address."); if (port.getFixedIPs().size() > 1) { fixedIP = singleton.getFixedIPAddress(); 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) { 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())) if (port.isBoundToFloatingIP(fixedIP)) throw new ResourceConflictException("fixed IP is in use."); singleton.setFixedIPAddress(fixedIP);
if (port.getDeviceID() != null || port.getDeviceOwner() != null) { Response.status(403).build();
public int canUpdatePort(NeutronPort delta, NeutronPort original) { // openDove specific things that can't be changed if (delta.getAdminStateUp() != null) { return 403; } return 200; } public void neutronPortUpdated(NeutronPort port) {
OpenDoveCRUDInterfaces.getIfDoveNetworkSubnetAssociationCRUD(this); INeutronNetworkCRUD neutronNetworkIf = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this); NeutronNetwork neutronNetwork = neutronNetworkIf.getNetwork(port.getNetworkUUID()); INeutronSubnetCRUD neutronSubnetIf = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this); NeutronSubnet neutronSubnet = neutronSubnetIf.getSubnet(port.getFixedIPs().get(0).getSubnetUUID()); if (!neutronNetwork.isRouterExternal()) { if (neutronNetwork.isShared()) {
throw new ResourceNotFoundException("Port UUID doesn't exist."); NeutronPort port = portInterface.getPort(port_id); if (port.getFixedIPs().size() < 1) throw new BadRequestException("port UUID doesn't have an IP address."); if (port.getFixedIPs().size() > 1) { fixedIP = singleton.getFixedIPAddress(); 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) { 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())) throw new BadRequestException("mismatched fixed IP address in request"); if (port.isBoundToFloatingIP(fixedIP)) throw new ResourceConflictException("fixed IP is in use."); singleton.setFixedIPAddress(fixedIP);