@@ -476,6 +476,7 @@ public boolean configure(String name, Map<String, Object> params) {
476476 SearchBuilder <VlanVO > vlanSearch = _vlanDao .createSearchBuilder ();
477477 vlanSearch .and ("type" , vlanSearch .entity ().getVlanType (), Op .EQ );
478478 vlanSearch .and ("networkId" , vlanSearch .entity ().getNetworkId (), Op .EQ );
479+ vlanSearch .and ("vlanGateway" , vlanSearch .entity ().getVlanGateway (), Op .EQ );
479480 AssignIpAddressSearch .join ("vlan" , vlanSearch , vlanSearch .entity ().getId (), AssignIpAddressSearch .entity ().getVlanId (), JoinType .INNER );
480481 AssignIpAddressSearch .done ();
481482
@@ -487,6 +488,7 @@ public boolean configure(String name, Map<String, Object> params) {
487488 SearchBuilder <VlanVO > podVlanSearch = _vlanDao .createSearchBuilder ();
488489 podVlanSearch .and ("type" , podVlanSearch .entity ().getVlanType (), Op .EQ );
489490 podVlanSearch .and ("networkId" , podVlanSearch .entity ().getNetworkId (), Op .EQ );
491+ podVlanSearch .and ("vlanGateway" , podVlanSearch .entity ().getVlanGateway (), Op .EQ );
490492 SearchBuilder <PodVlanMapVO > podVlanMapSB = _podVlanMapDao .createSearchBuilder ();
491493 podVlanMapSB .and ("podId" , podVlanMapSB .entity ().getPodId (), Op .EQ );
492494 AssignIpAddressFromPodVlanSearch .join ("podVlanMapSB" , podVlanMapSB , podVlanMapSB .entity ().getVlanDbId (), AssignIpAddressFromPodVlanSearch .entity ().getVlanId (),
@@ -755,34 +757,34 @@ public Boolean doInTransaction(TransactionStatus status) {
755757 @ Override
756758 public PublicIp assignPublicIpAddress (long dcId , Long podId , Account owner , VlanType type , Long networkId , String requestedIp , boolean isSystem , boolean forSystemVms )
757759 throws InsufficientAddressCapacityException {
758- return fetchNewPublicIp (dcId , podId , null , owner , type , networkId , false , true , requestedIp , isSystem , null , null , forSystemVms );
760+ return fetchNewPublicIp (dcId , podId , null , owner , type , networkId , false , true , requestedIp , null , isSystem , null , null , forSystemVms );
759761 }
760762
761763 @ Override
762- public PublicIp assignPublicIpAddressFromVlans (long dcId , Long podId , Account owner , VlanType type , List <Long > vlanDbIds , Long networkId , String requestedIp , boolean isSystem )
764+ public PublicIp assignPublicIpAddressFromVlans (long dcId , Long podId , Account owner , VlanType type , List <Long > vlanDbIds , Long networkId , String requestedIp , String requestedGateway , boolean isSystem )
763765 throws InsufficientAddressCapacityException {
764- return fetchNewPublicIp (dcId , podId , vlanDbIds , owner , type , networkId , false , true , requestedIp , isSystem , null , null , false );
766+ return fetchNewPublicIp (dcId , podId , vlanDbIds , owner , type , networkId , false , true , requestedIp , requestedGateway , isSystem , null , null , false );
765767 }
766768
767769 @ Override
768770 public PublicIp getAvailablePublicIpAddressFromVlans (long dcId , Long podId , Account owner , VlanType type , List <Long > vlanDbIds , Long networkId , String requestedIp , boolean isSystem )
769771 throws InsufficientAddressCapacityException {
770- return fetchNewPublicIp (dcId , podId , vlanDbIds , owner , type , networkId , false , false , false , requestedIp , isSystem , null , null , false );
772+ return fetchNewPublicIp (dcId , podId , vlanDbIds , owner , type , networkId , false , false , false , requestedIp , null , isSystem , null , null , false );
771773 }
772774
773775 @ DB
774776 public PublicIp fetchNewPublicIp (final long dcId , final Long podId , final List <Long > vlanDbIds , final Account owner , final VlanType vlanUse , final Long guestNetworkId ,
775- final boolean sourceNat , final boolean allocate , final String requestedIp , final boolean isSystem , final Long vpcId , final Boolean displayIp , final boolean forSystemVms )
777+ final boolean sourceNat , final boolean allocate , final String requestedIp , final String requestedGateway , final boolean isSystem , final Long vpcId , final Boolean displayIp , final boolean forSystemVms )
776778 throws InsufficientAddressCapacityException {
777779 return fetchNewPublicIp (dcId , podId , vlanDbIds , owner , vlanUse , guestNetworkId ,
778- sourceNat , true , allocate , requestedIp , isSystem , vpcId , displayIp , forSystemVms );
780+ sourceNat , true , allocate , requestedIp , requestedGateway , isSystem , vpcId , displayIp , forSystemVms );
779781 }
780782
781783 @ DB
782784 public PublicIp fetchNewPublicIp (final long dcId , final Long podId , final List <Long > vlanDbIds , final Account owner , final VlanType vlanUse , final Long guestNetworkId ,
783- final boolean sourceNat , final boolean assign , final boolean allocate , final String requestedIp , final boolean isSystem , final Long vpcId , final Boolean displayIp , final boolean forSystemVms )
785+ final boolean sourceNat , final boolean assign , final boolean allocate , final String requestedIp , final String requestedGateway , final boolean isSystem , final Long vpcId , final Boolean displayIp , final boolean forSystemVms )
784786 throws InsufficientAddressCapacityException {
785- List <IPAddressVO > addrs = listAvailablePublicIps (dcId , podId , vlanDbIds , owner , vlanUse , guestNetworkId , sourceNat , assign , allocate , requestedIp , isSystem , vpcId , displayIp , forSystemVms , true );
787+ List <IPAddressVO > addrs = listAvailablePublicIps (dcId , podId , vlanDbIds , owner , vlanUse , guestNetworkId , sourceNat , assign , allocate , requestedIp , requestedGateway , isSystem , vpcId , displayIp , forSystemVms , true );
786788 IPAddressVO addr = addrs .get (0 );
787789 if (vlanUse == VlanType .VirtualNetwork ) {
788790 _firewallMgr .addSystemFirewallRules (addr , owner );
@@ -793,7 +795,7 @@ public PublicIp fetchNewPublicIp(final long dcId, final Long podId, final List<L
793795
794796 @ Override
795797 public List <IPAddressVO > listAvailablePublicIps (final long dcId , final Long podId , final List <Long > vlanDbIds , final Account owner , final VlanType vlanUse , final Long guestNetworkId ,
796- final boolean sourceNat , final boolean assign , final boolean allocate , final String requestedIp , final boolean isSystem ,
798+ final boolean sourceNat , final boolean assign , final boolean allocate , final String requestedIp , final String requestedGateway , final boolean isSystem ,
797799 final Long vpcId , final Boolean displayIp , final boolean forSystemVms , final boolean lockOneRow ) throws InsufficientAddressCapacityException {
798800 return Transaction .execute (new TransactionCallbackWithException <List <IPAddressVO >, InsufficientAddressCapacityException >() {
799801 @ Override
@@ -864,6 +866,10 @@ public List<IPAddressVO> doInTransaction(TransactionStatus status) throws Insuff
864866 sc .setJoinParameters ("vlan" , "networkId" , guestNetworkId );
865867 errorMessage .append (", network id=" + guestNetworkId );
866868 }
869+ if (requestedGateway != null ) {
870+ sc .setJoinParameters ("vlan" , "vlanGateway" , requestedGateway );
871+ errorMessage .append (", requested gateway=" + requestedGateway );
872+ }
867873 sc .setJoinParameters ("vlan" , "type" , vlanUse );
868874
869875 if (requestedIp != null ) {
@@ -1023,7 +1029,7 @@ public PublicIp doInTransaction(TransactionStatus status) throws InsufficientAdd
10231029 VpcVO vpc = _vpcDao .findById (vpcId );
10241030 displayIp = vpc .isDisplay ();
10251031 }
1026- return fetchNewPublicIp (dcId , null , null , owner , VlanType .VirtualNetwork , guestNtwkId , isSourceNat , true , null , false , vpcId , displayIp , false );
1032+ return fetchNewPublicIp (dcId , null , null , owner , VlanType .VirtualNetwork , guestNtwkId , isSourceNat , true , null , null , false , vpcId , displayIp , false );
10271033 }
10281034 });
10291035 if (ip .getState () != State .Allocated ) {
@@ -1219,7 +1225,7 @@ public IpAddress allocateIp(final Account ipOwner, final boolean isSystem, Accou
12191225 ip = Transaction .execute (new TransactionCallbackWithException <PublicIp , InsufficientAddressCapacityException >() {
12201226 @ Override
12211227 public PublicIp doInTransaction (TransactionStatus status ) throws InsufficientAddressCapacityException {
1222- PublicIp ip = fetchNewPublicIp (zone .getId (), null , null , ipOwner , vlanType , null , false , assign , ipaddress , isSystem , null , displayIp , false );
1228+ PublicIp ip = fetchNewPublicIp (zone .getId (), null , null , ipOwner , vlanType , null , false , assign , ipaddress , null , isSystem , null , displayIp , false );
12231229
12241230 if (ip == null ) {
12251231 InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException ("Unable to find available public IP addresses" , DataCenter .class , zone
0 commit comments