Skip to content

Commit b0036dd

Browse files
committed
fix check
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 043dd32 commit b0036dd

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23-
import com.cloud.dc.DataCenter;
2423
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
2524
import org.apache.cloudstack.framework.config.ConfigKey;
2625
import org.apache.cloudstack.framework.config.ConfigKey.Scope;
2726

27+
import com.cloud.dc.DataCenter;
2828
import com.cloud.deploy.DataCenterDeployment;
2929
import com.cloud.deploy.DeployDestination;
3030
import com.cloud.deploy.DeploymentPlan;
@@ -50,8 +50,8 @@
5050
import com.cloud.offering.NetworkOffering;
5151
import com.cloud.user.Account;
5252
import com.cloud.user.User;
53-
import com.cloud.utils.fsm.NoTransitionException;
5453
import com.cloud.utils.Pair;
54+
import com.cloud.utils.fsm.NoTransitionException;
5555
import com.cloud.vm.Nic;
5656
import com.cloud.vm.NicProfile;
5757
import com.cloud.vm.ReservationContext;
@@ -348,4 +348,6 @@ void implementNetworkElementsAndResources(DeployDestination dest, ReservationCon
348348
Pair<NicProfile, Integer> importNic(final String macAddress, int deviceId, final Network network, final Boolean isDefaultNic, final VirtualMachine vm, final Network.IpAddresses ipAddresses, final DataCenter datacenter, boolean forced) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException;
349349

350350
void unmanageNics(VirtualMachineProfile vm);
351+
352+
boolean isNetworkImplemented(final Network network);
351353
}

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// under the License.
1717
package org.apache.cloudstack.engine.orchestration;
1818

19+
import static com.cloud.configuration.ConfigurationManager.MESSAGE_DELETE_VLAN_IP_RANGE_EVENT;
20+
1921
import java.net.URI;
2022
import java.util.ArrayList;
2123
import java.util.Arrays;
@@ -241,8 +243,8 @@
241243
import com.cloud.vm.UserVmVO;
242244
import com.cloud.vm.VMInstanceVO;
243245
import com.cloud.vm.VirtualMachine;
244-
import com.cloud.vm.VirtualMachineManager;
245246
import com.cloud.vm.VirtualMachine.Type;
247+
import com.cloud.vm.VirtualMachineManager;
246248
import com.cloud.vm.VirtualMachineProfile;
247249
import com.cloud.vm.dao.DomainRouterDao;
248250
import com.cloud.vm.dao.NicDao;
@@ -255,8 +257,6 @@
255257
import com.cloud.vm.dao.VMInstanceDao;
256258
import com.googlecode.ipv6.IPv6Address;
257259

258-
import static com.cloud.configuration.ConfigurationManager.MESSAGE_DELETE_VLAN_IP_RANGE_EVENT;
259-
260260
/**
261261
* NetworkManagerImpl implements NetworkManager.
262262
*/
@@ -1339,20 +1339,6 @@ protected NicTO toNicTO(final NicVO nic, final NicProfile profile, final Network
13391339
return to;
13401340
}
13411341

1342-
boolean isNetworkImplemented(final NetworkVO network) {
1343-
final Network.State state = network.getState();
1344-
final NetworkOfferingVO offeringVO = _networkOfferingDao.findById(network.getNetworkOfferingId());
1345-
if (state == Network.State.Implemented) {
1346-
return true;
1347-
} else if (state == Network.State.Setup) {
1348-
final DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
1349-
if ((!isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) && !offeringVO.isPersistent()) || zone.getNetworkType() == NetworkType.Basic) {
1350-
return true;
1351-
}
1352-
}
1353-
return false;
1354-
}
1355-
13561342
Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final DeployDestination dest, final ReservationContext context, final boolean isRouter) throws ConcurrentOperationException,
13571343
ResourceUnavailableException, InsufficientCapacityException {
13581344
Pair<NetworkGuru, NetworkVO> implemented = null;
@@ -1450,6 +1436,20 @@ private boolean networkMeetsPersistenceCriteria(NetworkVO network, NetworkOfferi
14501436
}
14511437
}
14521438

1439+
@Override
1440+
public boolean isNetworkImplemented(final Network network) {
1441+
final Network.State state = network.getState();
1442+
final NetworkOfferingVO offeringVO = _networkOfferingDao.findById(network.getNetworkOfferingId());
1443+
if (state == Network.State.Implemented) {
1444+
return true;
1445+
} else if (state == Network.State.Setup) {
1446+
final DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
1447+
return (!isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) && !offeringVO.isPersistent())
1448+
|| zone.getNetworkType() == NetworkType.Basic;
1449+
}
1450+
return false;
1451+
}
1452+
14531453
@Override
14541454
@DB
14551455
public Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException,

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,10 @@ private boolean updateVMPasswordInNetworkElement(VirtualMachine vm, VMTemplateVO
882882
return false;
883883
}
884884
Network defaultNetwork = _networkDao.findById(defaultNic.getNetworkId());
885-
if (State.Stopped.equals(vm.getState()) && !Network.State.Implemented.equals(defaultNetwork.getState())) {
886-
s_logger.debug("%s is not ready, skipping updating VM password");
885+
if (State.Stopped.equals(vm.getState()) &&
886+
Arrays.asList(GuestType.Shared, GuestType.Isolated).contains(defaultNetwork.getGuestType()) &&
887+
!_networkMgr.isNetworkImplemented(defaultNetwork)) {
888+
s_logger.debug(String.format("%s is not ready, skipping updating VM password", defaultNetwork));
887889
return true;
888890
}
889891
NicProfile defaultNicProfile = new NicProfile(defaultNic, defaultNetwork, null, null,

0 commit comments

Comments
 (0)