|
24 | 24 | import org.apache.cloudstack.api.ApiCommandResourceType; |
25 | 25 | import org.apache.cloudstack.context.CallContext; |
26 | 26 | import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; |
27 | | -import org.apache.cloudstack.network.Ipv4GuestSubnetNetworkMap; |
28 | | -import org.apache.cloudstack.network.RoutedIpv4Manager; |
29 | 27 |
|
30 | 28 | import com.cloud.dc.DataCenter; |
31 | 29 | import com.cloud.dc.DataCenter.NetworkType; |
|
37 | 35 | import com.cloud.event.EventVO; |
38 | 36 | import com.cloud.exception.InsufficientAddressCapacityException; |
39 | 37 | import com.cloud.exception.InsufficientVirtualNetworkCapacityException; |
40 | | -import com.cloud.exception.InvalidParameterValueException; |
41 | 38 | import com.cloud.network.IpAddressManager; |
42 | 39 | import com.cloud.network.Network; |
43 | 40 | import com.cloud.network.Network.GuestType; |
@@ -90,8 +87,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru { |
90 | 87 | FirewallRulesDao _fwRulesDao; |
91 | 88 | @Inject |
92 | 89 | FirewallRulesCidrsDao _fwRulesCidrDao; |
93 | | - @Inject |
94 | | - RoutedIpv4Manager routedIpv4Manager; |
95 | 90 |
|
96 | 91 | public ExternalGuestNetworkGuru() { |
97 | 92 | super(); |
@@ -126,23 +121,9 @@ public Network design(NetworkOffering offering, DeploymentPlan plan, Network use |
126 | 121 | /* In order to revert userSpecified network setup */ |
127 | 122 | config.setState(State.Allocated); |
128 | 123 | } |
129 | | - if (NetworkOffering.NetworkMode.ROUTED.equals(offering.getNetworkMode()) && !offering.isForVpc()) { |
130 | | - if (userSpecified.getCidr() != null) { |
131 | | - routedIpv4Manager.getOrCreateIpv4SubnetForGuestNetwork(config, userSpecified.getCidr()); |
132 | | - } else { |
133 | | - if (userSpecified.getNetworkCidrSize() == null) { |
134 | | - throw new InvalidParameterValueException("The network CIDR or CIDR size must be specified."); |
135 | | - } |
136 | | - Ipv4GuestSubnetNetworkMap subnet = routedIpv4Manager.getOrCreateIpv4SubnetForGuestNetwork(owner.getDomainId(), owner.getAccountId(), config.getDataCenterId(), userSpecified.getNetworkCidrSize()); |
137 | | - if (subnet != null) { |
138 | | - final String[] cidrTuple = subnet.getSubnet().split("\\/"); |
139 | | - config.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1]))); |
140 | | - config.setCidr(subnet.getSubnet()); |
141 | | - } else { |
142 | | - throw new InvalidParameterValueException("Failed to allocate a CIDR with requested size."); |
143 | | - } |
144 | | - } |
145 | | - } |
| 124 | + |
| 125 | + getOrCreateIpv4SubnetForGuestNetwork(offering, config, userSpecified, owner); |
| 126 | + |
146 | 127 | return updateNetworkDesignForIPv6IfNeeded(config, userSpecified); |
147 | 128 | } |
148 | 129 |
|
|
0 commit comments