mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
start vm not working again
This commit is contained in:
parent
fcdd20ca06
commit
f147bf5f94
@ -1,10 +1,11 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.configuration;
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.Network;
|
||||
@ -43,7 +44,7 @@ public interface NetworkGuru extends Adapter {
|
||||
* @throws InsufficientVirtualNetworkCapcityException
|
||||
* @throws InsufficientAddressCapacityException
|
||||
*/
|
||||
NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Fully implement the network configuration as specified.
|
||||
@ -63,8 +64,9 @@ public interface NetworkGuru extends Adapter {
|
||||
* @return
|
||||
* @throws InsufficientVirtualNetworkCapcityException
|
||||
* @throws InsufficientAddressCapacityException
|
||||
* @throws ConcurrentOperationException
|
||||
*/
|
||||
void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
|
||||
void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
boolean release(NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String reservationId);
|
||||
|
||||
@ -39,11 +39,11 @@
|
||||
<adapters key="com.cloud.consoleproxy.ConsoleProxyAllocator">
|
||||
<adapter name="Balance" class="com.cloud.consoleproxy.ConsoleProxyBalanceAllocator"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.network.configuration.NetworkGuru">
|
||||
<adapter name="GuestNetworkGuru" class="com.cloud.network.configuration.GuestNetworkGuru"/>
|
||||
<adapter name="PublicNetworkGuru" class="com.cloud.network.configuration.PublicNetworkGuru"/>
|
||||
<adapter name="PodBasedNetworkGuru" class="com.cloud.network.configuration.PodBasedNetworkGuru"/>
|
||||
<adapter name="ControlNetworkGuru" class="com.cloud.network.configuration.ControlNetworkGuru"/>
|
||||
<adapters key="com.cloud.network.guru.NetworkGuru">
|
||||
<adapter name="GuestNetworkGuru" class="com.cloud.network.guru.GuestNetworkGuru"/>
|
||||
<adapter name="PublicNetworkGuru" class="com.cloud.network.guru.PublicNetworkGuru"/>
|
||||
<adapter name="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru"/>
|
||||
<adapter name="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru"/>
|
||||
</adapters>
|
||||
<adapters key="com.cloud.storage.secondary.SecondaryStorageVmAllocator">
|
||||
<adapter name="Balance" class="com.cloud.storage.secondary.SecondaryStorageVmDefaultAllocator"/>
|
||||
|
||||
@ -88,7 +88,6 @@ import com.cloud.event.EventUtils;
|
||||
import com.cloud.event.EventVO;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
@ -552,16 +551,13 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
} catch (InsufficientCapacityException e) {
|
||||
s_logger.warn("Exception while trying to start console proxy", e);
|
||||
return null;
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.warn("Exception while trying to start console proxy", e);
|
||||
return null;
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Exception while trying to start console proxy", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ConsoleProxyVO start2(long proxyVmId, long startEventId) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
|
||||
public ConsoleProxyVO start2(long proxyVmId, long startEventId) throws ResourceUnavailableException, InsufficientCapacityException {
|
||||
if (!_useNewNetworking) {
|
||||
return start(proxyVmId, startEventId);
|
||||
}
|
||||
@ -574,7 +570,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
@Override
|
||||
@DB
|
||||
public ConsoleProxyVO start(long proxyId, long startEventId) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, StorageUnavailableException {
|
||||
StorageUnavailableException {
|
||||
|
||||
AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
||||
if (asyncExecutor != null) {
|
||||
@ -843,8 +839,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
|
||||
if (thr instanceof StorageUnavailableException) {
|
||||
throw (StorageUnavailableException) thr;
|
||||
} else if (thr instanceof ConcurrentOperationException) {
|
||||
throw (ConcurrentOperationException) thr;
|
||||
} else if (thr instanceof ExecutionException) {
|
||||
s_logger.error("Error while starting console proxy due to " + thr.getMessage());
|
||||
} else {
|
||||
@ -1114,6 +1108,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.warn("Unable to contact storage", e);
|
||||
throw new CloudRuntimeException("Unable to contact storage", e);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to contact resource", e);
|
||||
throw new CloudRuntimeException("Unable to contact resource", e);
|
||||
}
|
||||
|
||||
Map<String, Object> context = new HashMap<String, Object>();
|
||||
@ -1539,8 +1536,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
s_logger.warn("Storage unavailable", e);
|
||||
} catch (InsufficientCapacityException e) {
|
||||
s_logger.warn("insuffiient capacity", e);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.debug("Concurrent operation: " + e.getMessage());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.debug("Concurrent operation: " + e.getMessage());
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public interface NetworkManager extends NetworkService {
|
||||
|
||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||
|
||||
void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks) throws InsufficientCapacityException;
|
||||
void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks) throws InsufficientCapacityException, ConcurrentOperationException;
|
||||
|
||||
void prepare(VirtualMachineProfile<? extends VMInstanceVO> profile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
void release(VirtualMachineProfile<? extends VMInstanceVO> vmProfile);
|
||||
|
||||
@ -92,7 +92,6 @@ import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.configuration.NetworkGuru;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
@ -102,6 +101,7 @@ import com.cloud.network.dao.NetworkRuleConfigDao;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDao;
|
||||
import com.cloud.network.dao.VpnUserDao;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.guru.NetworkGuru;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.router.DomainRouterManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
@ -228,7 +228,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
txn.start();
|
||||
SearchCriteria<IPAddressVO> sc = AssignIpAddressSearch.create();
|
||||
sc.setParameters("dc", dcId);
|
||||
sc.setJoinParameters("vlan", "vlanType", vlanUse);
|
||||
sc.setJoinParameters("vlan", "type", vlanUse);
|
||||
|
||||
Filter filter = new Filter(IPAddressVO.class, "vlanId", true, 0l, 1l);
|
||||
|
||||
@ -891,7 +891,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
public void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks) throws InsufficientCapacityException {
|
||||
public void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks) throws InsufficientCapacityException, ConcurrentOperationException {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.configuration;
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -21,6 +21,7 @@ import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.guru.NetworkGuru;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.configuration;
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@ -39,6 +39,7 @@ import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.guru.NetworkGuru;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.configuration;
|
||||
package com.cloud.network.guru;
|
||||
|
||||
public final class GuruUtils {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.configuration;
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -18,6 +18,7 @@ import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.guru.NetworkGuru;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
@ -1,7 +1,9 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.cloud.network.configuration;
|
||||
package com.cloud.network.guru;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@ -9,12 +11,11 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.Network;
|
||||
@ -28,12 +29,13 @@ import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
@ -47,49 +49,51 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
@Inject VlanDao _vlanDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject IPAddressDao _ipAddressDao;
|
||||
Random _rand = new Random(System.currentTimeMillis());
|
||||
|
||||
@Override
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network config, Account owner) {
|
||||
if (offering.getTrafficType() != TrafficType.Public) {
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network network, Account owner) {
|
||||
if (offering.getTrafficType() != TrafficType.Public || (offering.getTrafficType() == TrafficType.Guest && offering.getGuestIpType() != GuestIpType.Direct)) {
|
||||
s_logger.trace("We only take care of two types of networks. Public or Guest direct so this is no ours");
|
||||
return null;
|
||||
}
|
||||
|
||||
NetworkVO network = new NetworkVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
|
||||
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
|
||||
network.setDns1(dc.getDns1());
|
||||
network.setDns2(dc.getDns2());
|
||||
return network;
|
||||
if (offering.getTrafficType() == TrafficType.Public) {
|
||||
NetworkVO network = new NetworkVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
|
||||
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
|
||||
network.setDns1(dc.getDns1());
|
||||
network.setDns2(dc.getDns2());
|
||||
return network;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected PublicNetworkGuru() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected void getIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException {
|
||||
protected void getIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
if (nic.getIp4Address() == null) {
|
||||
PublicIp ip = _networkMgr.assignSourceNatIpAddress(dc, vm.getOwner(), network, UserContext.current().getUserId());
|
||||
Pair<String, VlanVO> ipAndVlan = __vlanDao.assignIpAddress(dc.getId(), vm.getVirtualMachine().getAccountId(), vm.getVirtualMachine().getDomainId(), VlanType.VirtualNetwork, true);
|
||||
if (ipAndVlan == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to get public ip address in " + dc.getId(), DataCenter.class, dc.getId());
|
||||
}
|
||||
VlanVO vlan = ipAndVlan.second();
|
||||
nic.setIp4Address(ipAndVlan.first());
|
||||
nic.setGateway(vlan.getVlanGateway());
|
||||
nic.setNetmask(vlan.getVlanNetmask());
|
||||
nic.setIsolationUri(IsolationType.Vlan.toUri(vlan.getVlanId()));
|
||||
PublicIp ip = _networkMgr.assignSourceNatIpAddress(vm.getOwner(), network, UserContext.current().getUserId());
|
||||
nic.setIp4Address(ip.getAddress());
|
||||
nic.setGateway(ip.getGateway());
|
||||
nic.setNetmask(ip.getNetmask());
|
||||
nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
|
||||
nic.setBroadcastType(BroadcastDomainType.Vlan);
|
||||
nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vlan.getVlanId()));
|
||||
nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag()));
|
||||
nic.setFormat(AddressFormat.Ip4);
|
||||
nic.setReservationId(Long.toString(vlan.getId()));
|
||||
nic.setReservationId(ip.getVlanTag());
|
||||
nic.setMacAddress(NetUtils.long2Mac(ip.getMacAddress() | 0x060000000000l | (((long)_rand.nextInt(32768) << 25) & 0x00fffe000000l)));
|
||||
}
|
||||
nic.setDns1(dc.getDns1());
|
||||
nic.setDns2(dc.getDns2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
if (config.getTrafficType() != TrafficType.Public) {
|
||||
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
if (network.getTrafficType() != TrafficType.Public) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -97,11 +101,8 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
nic = new NicProfile(ReservationStrategy.Create, null, null, null, null);
|
||||
}
|
||||
|
||||
String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId());
|
||||
nic.setMacAddress(mac);
|
||||
|
||||
DataCenter dc = _dcDao.findById(config.getDataCenterId());
|
||||
getIp(nic, dc, vm);
|
||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||
getIp(nic, dc, vm, network);
|
||||
|
||||
if (nic.getIp4Address() == null) {
|
||||
nic.setStrategy(ReservationStrategy.Start);
|
||||
@ -113,9 +114,9 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reserve(NicProfile nic, Network configuration, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
if (nic.getIp4Address() == null) {
|
||||
getIp(nic, dest.getDataCenter(), vm);
|
||||
getIp(nic, dest.getDataCenter(), vm, network);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,20 +127,20 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Network implement(Network config, NetworkOffering offering, DeployDestination destination, ReservationContext context) {
|
||||
return config;
|
||||
public Network implement(Network network, NetworkOffering offering, DeployDestination destination, ReservationContext context) {
|
||||
return network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deallocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
|
||||
public void deallocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy(Network config, NetworkOffering offering) {
|
||||
public void destroy(Network network, NetworkOffering offering) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network config, NetworkOffering offering, Account owner) {
|
||||
public boolean trash(Network network, NetworkOffering offering, Account owner) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -2421,14 +2421,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
|
||||
UserVO user = _userDao.findById(context.getUserId());
|
||||
|
||||
try {
|
||||
if (!_itMgr.stop(router, user, account)) {
|
||||
return null;
|
||||
}
|
||||
} catch (AgentUnavailableException e) {
|
||||
throw new ResourceUnavailableException("Unable to reach the server to stop the vm", e);
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new ResourceUnavailableException("Stop operation timed out", e);
|
||||
if (!_itMgr.stop(router, user, account)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return router;
|
||||
|
||||
@ -62,14 +62,11 @@ import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.event.Event;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
@ -772,9 +769,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
} catch (InsufficientCapacityException e) {
|
||||
s_logger.warn("InsufficientCapacity", e);
|
||||
throw new CloudRuntimeException("Insufficient capacity exception", e);
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.warn("Unable to contact storage", e);
|
||||
throw new CloudRuntimeException("Unable to contact storage", e);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to contact resource", e);
|
||||
throw new CloudRuntimeException("Unable to contact resource", e);
|
||||
}
|
||||
|
||||
Map<String, Object> context = new HashMap<String, Object>();
|
||||
@ -923,21 +920,21 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
return net;
|
||||
}
|
||||
|
||||
Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN, VlanType.VirtualNetwork, true);
|
||||
|
||||
if (ipAndVlan == null) {
|
||||
s_logger.debug("Unable to get public ip address (type=Virtual) for secondary storage vm for data center : " + dcId);
|
||||
ipAndVlan = _vlanDao.assignPodDirectAttachIpAddress(dcId, podId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN);
|
||||
if (ipAndVlan == null) {
|
||||
s_logger.debug("Unable to get public ip address (type=DirectAttach) for secondary storage vm for data center : " + dcId);
|
||||
}
|
||||
|
||||
}
|
||||
if (ipAndVlan != null) {
|
||||
VlanVO vlan = ipAndVlan.second();
|
||||
networkInfo net = new networkInfo(ipAndVlan.first(), vlan.getVlanNetmask(), vlan.getVlanGateway(), vlan.getId(), vlan.getVlanId());
|
||||
return net;
|
||||
}
|
||||
//FIXME am I even needed any more? Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN, VlanType.VirtualNetwork, true);
|
||||
//
|
||||
// if (ipAndVlan == null) {
|
||||
// s_logger.debug("Unable to get public ip address (type=Virtual) for secondary storage vm for data center : " + dcId);
|
||||
// ipAndVlan = _vlanDao.assignPodDirectAttachIpAddress(dcId, podId, Account.ACCOUNT_ID_SYSTEM, DomainVO.ROOT_DOMAIN);
|
||||
// if (ipAndVlan == null) {
|
||||
// s_logger.debug("Unable to get public ip address (type=DirectAttach) for secondary storage vm for data center : " + dcId);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if (ipAndVlan != null) {
|
||||
// VlanVO vlan = ipAndVlan.second();
|
||||
// networkInfo net = new networkInfo(ipAndVlan.first(), vlan.getVlanNetmask(), vlan.getVlanGateway(), vlan.getId(), vlan.getVlanId());
|
||||
// return net;
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@ package com.cloud.vm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -32,7 +31,6 @@ import org.apache.log4j.Logger;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.AgentManager.OnError;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.PrepareForMigrationCommand;
|
||||
import com.cloud.agent.api.Start2Command;
|
||||
import com.cloud.agent.api.StopAnswer;
|
||||
import com.cloud.agent.api.StopCommand;
|
||||
@ -45,8 +43,6 @@ import com.cloud.cluster.ManagementServerHostVO;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
@ -62,20 +58,16 @@ import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.Volume.VolumeType;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.user.Account;
|
||||
@ -172,7 +164,11 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Allocating nics for " + vm);
|
||||
}
|
||||
_networkMgr.allocate(vmProfile, networks);
|
||||
try {
|
||||
_networkMgr.allocate(vmProfile, networks);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
throw new CloudRuntimeException("Concurrent operation while trying to allocate resources for the VM", e);
|
||||
}
|
||||
|
||||
if (dataDiskOfferings == null) {
|
||||
dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>(0);
|
||||
@ -232,7 +228,18 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean destroy(T vm, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
public <T extends VMInstanceVO> boolean destroy(T vm, User caller, Account account) throws ResourceUnavailableException {
|
||||
try {
|
||||
return advanceDestroy(vm, caller, account);
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new CloudRuntimeException("Operation timed out", e);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
throw new CloudRuntimeException("Concurrent operation ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean advanceDestroy(T vm, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
if (vm == null || vm.getState() == State.Destroyed || vm.getState() == State.Expunging || vm.getRemoved() != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to find vm or vm is destroyed: " + vm);
|
||||
@ -307,9 +314,18 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
||||
|
||||
protected MauriceMoss() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T start(T vm, Map<String, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException {
|
||||
try {
|
||||
return advanceStart(vm, params, caller, account);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T start(T vm, Map<String, Object> params, User caller, Account account) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
public <T extends VMInstanceVO> T advanceStart(T vm, Map<String, Object> params, User caller, Account account) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||
State state = vm.getState();
|
||||
if (state == State.Starting || state == State.Running) {
|
||||
s_logger.debug("VM is already started: " + vm);
|
||||
@ -422,9 +438,20 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean stop(T vm, User user, Account account) throws ResourceUnavailableException {
|
||||
try {
|
||||
return advanceStop(vm, user, account);
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new ResourceUnavailableException("Unable to stop vm because the operation to stop timed out", e);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
throw new CloudRuntimeException("Unable to stop vm because of a concurrent operation", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean stop(T vm, User user, Account account) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
public <T extends VMInstanceVO> boolean advanceStop(T vm, User user, Account account) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
State state = vm.getState();
|
||||
if (state == State.Stopped) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
||||
@ -3856,10 +3856,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
|
||||
try {
|
||||
_itMgr.stop(vm, user, caller);
|
||||
} catch (AgentUnavailableException e) {
|
||||
} catch (ResourceUnavailableException e) {
|
||||
throw new CloudRuntimeException("Unable to contact the agent to stop the virtual machine " + vm, e);
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new CloudRuntimeException("Waiting too long for agent to stop the virtual machine " + vm, e);
|
||||
}
|
||||
|
||||
return _vmDao.findById(vmId);
|
||||
@ -3915,11 +3913,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
EventUtils.saveScheduledEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_DESTROY, "Destroying Vm with Id: "+vmId);
|
||||
|
||||
boolean status;
|
||||
try {
|
||||
status = _itMgr.destroy(vm, caller, account);
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new ResourceUnavailableException("Resource not available to complete the command", e);
|
||||
}
|
||||
status = _itMgr.destroy(vm, caller, account);
|
||||
|
||||
if (status) {
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_DESTROY, "Successfully destroyed vm with id:"+vmId);
|
||||
|
||||
@ -21,13 +21,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
@ -51,7 +48,7 @@ public interface VmManager extends Manager {
|
||||
List<Pair<NetworkVO, NicProfile>> networks,
|
||||
Map<String, Object> params,
|
||||
DeploymentPlan plan,
|
||||
Account owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
Account owner) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> T allocate(T vm,
|
||||
VMTemplateVO template,
|
||||
@ -60,25 +57,29 @@ public interface VmManager extends Manager {
|
||||
Pair<DiskOfferingVO, Long> dataDiskOffering,
|
||||
List<Pair<NetworkVO, NicProfile>> networks,
|
||||
DeploymentPlan plan,
|
||||
Account owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
Account owner) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> T allocate(T vm,
|
||||
VMTemplateVO template,
|
||||
ServiceOfferingVO serviceOffering,
|
||||
List<Pair<NetworkVO, NicProfile>> networkProfiles,
|
||||
DeploymentPlan plan,
|
||||
Account owner) throws InsufficientCapacityException, StorageUnavailableException;
|
||||
Account owner) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> T start(T vm, Map<String, Object> params, User caller, Account account) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException;
|
||||
<T extends VMInstanceVO> T start(T vm, Map<String, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> boolean stop(T vm, User caller, Account account) throws AgentUnavailableException, ConcurrentOperationException, OperationTimedoutException;
|
||||
<T extends VMInstanceVO> boolean stop(T vm, User caller, Account account) throws ResourceUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> boolean destroy(T vm, User caller, Account account) throws ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
|
||||
;
|
||||
<T extends VMInstanceVO> boolean destroy(T vm, User caller, Account account) throws ResourceUnavailableException;
|
||||
|
||||
<T extends VMInstanceVO> void registerGuru(VirtualMachine.Type type, VirtualMachineGuru<T> guru);
|
||||
|
||||
boolean stateTransitTo(VMInstanceVO vm, Event e, Long id);
|
||||
|
||||
|
||||
<T extends VMInstanceVO> T advanceStart(T vm, Map<String, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
|
||||
|
||||
<T extends VMInstanceVO> boolean advanceStop(T vm, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
|
||||
|
||||
<T extends VMInstanceVO> boolean advanceDestroy(T vm, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
|
||||
}
|
||||
|
||||
@ -140,6 +140,7 @@ CREATE TABLE `cloud`.`networks` (
|
||||
`set_fields` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'which fields are set already',
|
||||
`guest_type` char(32) COMMENT 'type of guest network',
|
||||
`shared` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '0 if network is shared, 1 if network dedicated',
|
||||
`network_domain` varchar(255) COMMENT 'domain',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user