Skip to content

Commit

Permalink
Merge pull request #1 from schubergphilis/backport/cosmic-needed-for-…
Browse files Browse the repository at this point in the history
…upgrade

Restart+Cleanup backported from Cosmic
  • Loading branch information
neubauerf committed Apr 14, 2017
2 parents 969dc1a + e996c90 commit c4a69c2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface PrivateIpDao extends GenericDao<PrivateIpVO, Long> {
* @param requestedIp TODO
* @return
*/
PrivateIpVO allocateIpAddress(long dcId, long networkId, String requestedIp);
PrivateIpVO allocateIpAddress(long dcId, long networkId, Long vpcId, String requestedIp);

/**
* @param ipAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ protected PrivateIpDaoImpl() {
}

@Override
public PrivateIpVO allocateIpAddress(long dcId, long networkId, String requestedIp) {
public PrivateIpVO allocateIpAddress(long dcId, long networkId, final Long vpcId, String requestedIp) {
SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
sc.setParameters("networkId", networkId);
sc.setParameters("taken", (Date)null);

if (vpcId != null) {
sc.setParameters("vpc_id", vpcId);
}
if (requestedIp != null) {
sc.setParameters("ipAddress", requestedIp);
}
Expand Down
9 changes: 0 additions & 9 deletions server/src/com/cloud/network/NetworkServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1878,15 +1878,6 @@ public boolean restartNetwork(RestartNetworkCmd cmd, boolean cleanup) throws Con
+ Network.State.Setup);
}

if (network.getBroadcastDomainType() == BroadcastDomainType.Lswitch) {
/**
* Unable to restart these networks now.
* TODO Restarting a SDN based network requires updating the nics and the configuration
* in the controller. This requires a non-trivial rewrite of the restart procedure.
*/
throw new InvalidParameterException("Unable to restart a running SDN network.");
}

_accountMgr.checkAccess(callerAccount, null, true, network);

boolean success = _networkMgr.restartNetwork(networkId, callerAccount, callerUser, cleanup);
Expand Down
2 changes: 1 addition & 1 deletion server/src/com/cloud/network/guru/PrivateNetworkGuru.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfil

protected void getIp(NicProfile nic, DataCenter dc, Network network) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
if (nic.getIp4Address() == null) {
PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(network.getDataCenterId(), network.getId(), null);
PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(network.getDataCenterId(), network.getVpcId(), network.getId(), null);
String vlanTag = BroadcastDomainType.getValue(network.getBroadcastUri());
String netmask = NetUtils.getCidrNetmask(network.getCidr());
PrivateIpAddress ip =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ protected LinkedHashMap<Network, List<? extends NicProfile>> createVpcRouterNetw
@DB
protected NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway) {
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(), privateNetwork.getId(), privateGateway.getIp4Address());
PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(), privateNetwork.getId(), privateGateway.getVpcId(), privateGateway.getIp4Address());
Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(), privateNetwork.getId());

NicProfile privateNicProfile = new NicProfile();
Expand Down

0 comments on commit c4a69c2

Please sign in to comment.