mirror of https://github.com/apache/cloudstack.git
removed unused domain_router_id from uservm
This commit is contained in:
parent
4589446930
commit
2466589e2f
|
|
@ -62,7 +62,7 @@ public class InvestigatorImpl implements Investigator {
|
|||
if (vm.getType() == VirtualMachine.Type.User) {
|
||||
// to verify that the VM is alive, we ask the domR (router) to ping the VM (private IP)
|
||||
UserVmVO userVm = _userVmDao.findById(vm.getId());
|
||||
Long routerId = userVm.getDomainRouterId();
|
||||
Long routerId = null; // FIXME: This doesn't work. Need to grab the domain router from the network.
|
||||
if (routerId == null) {
|
||||
/*TODO: checking vm status for external dhcp mode*/
|
||||
s_logger.debug("It's external dhcp mode, how to checking the vm is alive?");
|
||||
|
|
|
|||
|
|
@ -32,26 +32,25 @@ import com.cloud.deploy.DeployDestination;
|
|||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.network.LoadBalancerVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.vpn.RemoteAccessVpnElement;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
|
|
@ -65,8 +64,8 @@ import com.cloud.vm.NicProfile;
|
|||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
|
|
@ -115,30 +114,6 @@ public class VirtualRouterElement extends AdapterBase implements NetworkElement,
|
|||
@SuppressWarnings("unchecked")
|
||||
VirtualMachineProfile<UserVm> uservm = (VirtualMachineProfile<UserVm>)vm;
|
||||
|
||||
DomainRouterVO router = _routerDao.findById(uservm.getVirtualMachine().getDomainRouterId());
|
||||
if(router != null) {
|
||||
State state = router.getState();
|
||||
if ( state == State.Starting ) {
|
||||
// wait 300 seconds
|
||||
for ( int i = 0; i < 300; ) {
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
i += 2;
|
||||
|
||||
state = router.getState();
|
||||
if ( state != State.Starting ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: need to find a better exception to throw!
|
||||
if(state != State.Running)
|
||||
throw new ResourceUnavailableException("Virtual router is not available", Host.class, router.getHostId());
|
||||
}
|
||||
|
||||
return _routerMgr.addVirtualMachineIntoNetwork(config, nic, uservm, dest, context, false) != null;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
|
|||
|
||||
boolean getRouterStatistics(long vmId, Map<String, long[]> netStats, Map<String, long[]> diskStats);
|
||||
|
||||
@Override
|
||||
VirtualRouter upgradeRouter(UpgradeRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||
|
||||
DomainRouterVO getRouter(long accountId, long zoneId);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ import com.cloud.network.dao.VpnUserDao;
|
|||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.ovs.GreTunnelException;
|
||||
import com.cloud.network.ovs.OvsNetworkManager;
|
||||
import com.cloud.network.ovs.OvsTunnelManager;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
|
|
|
|||
|
|
@ -313,40 +313,41 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
return userVm;
|
||||
}
|
||||
|
||||
private boolean resetVMPasswordInternal(ResetVMPasswordCmd cmd, String password) {
|
||||
Long vmId = cmd.getId();
|
||||
Long userId = UserContext.current().getCallerUserId();
|
||||
UserVmVO vmInstance = _vmDao.findById(vmId);
|
||||
|
||||
if (password == null || password.equals("")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
VMTemplateVO template = _templateDao.findById(vmInstance.getTemplateId());
|
||||
if (template.getEnablePassword()) {
|
||||
if (vmInstance.getDomainRouterId() == null) {
|
||||
/*TODO: add it for external dhcp mode*/
|
||||
return true;
|
||||
}
|
||||
if (_routerMgr.savePasswordToRouter(vmInstance.getDomainRouterId(), vmInstance.getPrivateIpAddress(), password)) {
|
||||
// Need to reboot the virtual machine so that the password gets redownloaded from the DomR, and reset on the VM
|
||||
if (!rebootVirtualMachine(userId, vmId)) {
|
||||
if (vmInstance.getState() == State.Stopped) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Reset password called for a vm that is not using a password enabled template");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private boolean resetVMPasswordInternal(ResetVMPasswordCmd cmd, String password) {
|
||||
return true;
|
||||
// Long vmId = cmd.getId();
|
||||
// Long userId = UserContext.current().getCallerUserId();
|
||||
// UserVmVO vmInstance = _vmDao.findById(vmId);
|
||||
//
|
||||
// if (password == null || password.equals("")) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// VMTemplateVO template = _templateDao.findById(vmInstance.getTemplateId());
|
||||
// if (template.getEnablePassword()) {
|
||||
// if (vmInstance.getDomainRouterId() == null) {
|
||||
// /*TODO: add it for external dhcp mode*/
|
||||
// return true;
|
||||
// }
|
||||
// if (_routerMgr.savePasswordToRouter(vmInstance.getDomainRouterId(), vmInstance.getPrivateIpAddress(), password)) {
|
||||
// // Need to reboot the virtual machine so that the password gets redownloaded from the DomR, and reset on the VM
|
||||
// if (!rebootVirtualMachine(userId, vmId)) {
|
||||
// if (vmInstance.getState() == State.Stopped) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// } else {
|
||||
// return true;
|
||||
// }
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// } else {
|
||||
// if (s_logger.isDebugEnabled()) {
|
||||
// s_logger.debug("Reset password called for a vm that is not using a password enabled template");
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import java.util.List;
|
|||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
public interface UserVmDao extends GenericDao<UserVmVO, Long> {
|
||||
List<UserVmVO> listByAccountId(long id);
|
||||
|
|
@ -34,14 +33,6 @@ public interface UserVmDao extends GenericDao<UserVmVO, Long> {
|
|||
List<UserVmVO> listByLastHostId(Long hostId);
|
||||
List<UserVmVO> listUpByHostId(Long hostId);
|
||||
|
||||
/**
|
||||
* Find vms under the same router in the state.
|
||||
* @param routerId id of the router.
|
||||
* @param state state that it's in.
|
||||
* @return list of userVmVO
|
||||
*/
|
||||
List<UserVmVO> listBy(long routerId, State... state);
|
||||
|
||||
UserVmVO findByName(String name);
|
||||
|
||||
/**
|
||||
|
|
@ -53,13 +44,6 @@ public interface UserVmDao extends GenericDao<UserVmVO, Long> {
|
|||
|
||||
List<UserVmVO> findDestroyedVms(Date date);
|
||||
|
||||
/**
|
||||
* Find all vms that use a domain router
|
||||
* @param routerId
|
||||
* @return
|
||||
*/
|
||||
List<UserVmVO> listByRouterId(long routerId);
|
||||
|
||||
/**
|
||||
* List running VMs on the specified host
|
||||
* @param id
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ import com.cloud.vm.VirtualMachine.State;
|
|||
public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements UserVmDao {
|
||||
public static final Logger s_logger = Logger.getLogger(UserVmDaoImpl.class);
|
||||
|
||||
protected final SearchBuilder<UserVmVO> RouterStateSearch;
|
||||
protected final SearchBuilder<UserVmVO> RouterIdSearch;
|
||||
protected final SearchBuilder<UserVmVO> AccountPodSearch;
|
||||
protected final SearchBuilder<UserVmVO> AccountDataCenterSearch;
|
||||
protected final SearchBuilder<UserVmVO> AccountSearch;
|
||||
|
|
@ -89,14 +87,6 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
|||
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
NameSearch.done();
|
||||
|
||||
RouterStateSearch = createSearchBuilder();
|
||||
RouterStateSearch.and("router", RouterStateSearch.entity().getDomainRouterId(), SearchCriteria.Op.EQ);
|
||||
RouterStateSearch.done();
|
||||
|
||||
RouterIdSearch = createSearchBuilder();
|
||||
RouterIdSearch.and("router", RouterIdSearch.entity().getDomainRouterId(), SearchCriteria.Op.EQ);
|
||||
RouterIdSearch.done();
|
||||
|
||||
AccountPodSearch = createSearchBuilder();
|
||||
AccountPodSearch.and("account", AccountPodSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
|
||||
AccountPodSearch.and("pod", AccountPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -151,19 +141,6 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
|||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmVO> listBy(long routerId, State... states) {
|
||||
SearchCriteria<UserVmVO> sc = RouterStateSearch.create();
|
||||
SearchCriteria<UserVmVO> ssc = createSearchCriteria();
|
||||
|
||||
sc.setParameters("router", routerId);
|
||||
for (State state: states) {
|
||||
ssc.addOr("state", SearchCriteria.Op.EQ, state.toString());
|
||||
}
|
||||
sc.addAnd("state", SearchCriteria.Op.SC, ssc);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateVM(long id, String displayName, boolean enable, Long osTypeId) {
|
||||
UserVmVO vo = createForUpdate();
|
||||
|
|
@ -173,15 +150,6 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
|||
update(id, vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmVO> listByRouterId(long routerId) {
|
||||
SearchCriteria<UserVmVO> sc = RouterIdSearch.create();
|
||||
|
||||
sc.setParameters("router", routerId);
|
||||
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmVO> findDestroyedVms(Date date) {
|
||||
SearchCriteria<UserVmVO> sc = DestroySearch.create();
|
||||
|
|
|
|||
Loading…
Reference in New Issue