mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
changed back so everyone else can start the old way
This commit is contained in:
parent
9bb05d3ef8
commit
0fdca8be9a
@ -25,6 +25,7 @@ import com.cloud.resource.Resource;
|
|||||||
* Nic represents one nic on the VM.
|
* Nic represents one nic on the VM.
|
||||||
*/
|
*/
|
||||||
public interface Nic extends Resource {
|
public interface Nic extends Resource {
|
||||||
|
boolean isDefaultNic();
|
||||||
|
|
||||||
String getIp4Address();
|
String getIp4Address();
|
||||||
|
|
||||||
|
|||||||
@ -194,6 +194,10 @@ public class NicProfile {
|
|||||||
this.macAddress = nic.getMacAddress();
|
this.macAddress = nic.getMacAddress();
|
||||||
this.reservationId = nic.getReservationId();
|
this.reservationId = nic.getReservationId();
|
||||||
this.strategy = nic.getReservationStrategy();
|
this.strategy = nic.getReservationStrategy();
|
||||||
|
this.deviceId = nic.getDeviceId();
|
||||||
|
this.defaultNic = nic.isDefaultNic();
|
||||||
|
this.broadcastUri = broadcastUri;
|
||||||
|
this.isolationUri = isolationUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NicProfile(long id, BroadcastDomainType type, Mode mode, long vmId) {
|
public NicProfile(long id, BroadcastDomainType type, Mode mode, long vmId) {
|
||||||
|
|||||||
@ -531,7 +531,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||||||
@Override
|
@Override
|
||||||
public ConsoleProxyVO startProxy(long proxyVmId, long startEventId) {
|
public ConsoleProxyVO startProxy(long proxyVmId, long startEventId) {
|
||||||
try {
|
try {
|
||||||
return start2(proxyVmId, startEventId);
|
return start(proxyVmId, startEventId);
|
||||||
} catch (StorageUnavailableException e) {
|
} catch (StorageUnavailableException e) {
|
||||||
s_logger.warn("Exception while trying to start console proxy", e);
|
s_logger.warn("Exception while trying to start console proxy", e);
|
||||||
return null;
|
return null;
|
||||||
@ -887,7 +887,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||||||
if (s_logger.isDebugEnabled())
|
if (s_logger.isDebugEnabled())
|
||||||
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
||||||
|
|
||||||
Map<String, Object> context = createProxyInstance2(dataCenterId);
|
Map<String, Object> context = createProxyInstance(dataCenterId);
|
||||||
|
|
||||||
long proxyVmId = (Long) context.get("proxyVmId");
|
long proxyVmId = (Long) context.get("proxyVmId");
|
||||||
if (proxyVmId == 0) {
|
if (proxyVmId == 0) {
|
||||||
@ -927,7 +927,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||||||
if (s_logger.isDebugEnabled())
|
if (s_logger.isDebugEnabled())
|
||||||
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
||||||
|
|
||||||
Map<String, Object> context = createProxyInstance2(dataCenterId);
|
Map<String, Object> context = createProxyInstance(dataCenterId);
|
||||||
|
|
||||||
long proxyVmId = (Long) context.get("proxyVmId");
|
long proxyVmId = (Long) context.get("proxyVmId");
|
||||||
if (proxyVmId == 0) {
|
if (proxyVmId == 0) {
|
||||||
@ -1468,7 +1468,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||||||
try {
|
try {
|
||||||
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||||
try {
|
try {
|
||||||
readyProxy = start2(readyProxy.getId(), 0);
|
readyProxy = start(readyProxy.getId(), 0);
|
||||||
} finally {
|
} finally {
|
||||||
proxyLock.unlock();
|
proxyLock.unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,8 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
|
|||||||
ServiceOffering offering = vmProfile.getServiceOffering();
|
ServiceOffering offering = vmProfile.getServiceOffering();
|
||||||
VirtualMachine vm = vmProfile.getVirtualMachine();
|
VirtualMachine vm = vmProfile.getVirtualMachine();
|
||||||
|
|
||||||
VirtualMachineTO to = new VirtualMachineTO(vm.getId(), vm.getInstanceName(), vm.getType(), offering.getCpu(), offering.getSpeed(), offering.getRamSize(), offering.getRamSize(), null, vmProfile.getOs());
|
VirtualMachineTO to = new VirtualMachineTO(vm.getId(), vm.getInstanceName(), vm.getType(), offering.getCpu(), offering.getSpeed(), offering.getRamSize() * 1024l * 1024l, offering.getRamSize() * 1024l * 1024l, null, vmProfile.getOs());
|
||||||
|
to.setBootArgs(vmProfile.getBootArgs());
|
||||||
|
|
||||||
List<NicProfile> nicProfiles = vmProfile.getNics();
|
List<NicProfile> nicProfiles = vmProfile.getNics();
|
||||||
NicTO[] nics = new NicTO[nicProfiles.size()];
|
NicTO[] nics = new NicTO[nicProfiles.size()];
|
||||||
|
|||||||
@ -302,9 +302,9 @@ public interface NetworkManager extends Manager {
|
|||||||
|
|
||||||
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
|
||||||
|
|
||||||
List<NicProfile> allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
|
void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
|
||||||
|
|
||||||
List<NicProfile> prepare(VirtualMachineProfile<? extends VMInstanceVO> profile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
void prepare(VirtualMachineProfile<? extends VMInstanceVO> profile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException;
|
||||||
void release(VirtualMachineProfile<? extends VMInstanceVO> vmProfile);
|
void release(VirtualMachineProfile<? extends VMInstanceVO> vmProfile);
|
||||||
|
|
||||||
DomainRouter upgradeRouter(UpgradeRouterCmd cmd);
|
DomainRouter upgradeRouter(UpgradeRouterCmd cmd);
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.cloud.network;
|
package com.cloud.network;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -1759,9 +1760,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
public List<NicProfile> allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException {
|
public void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException {
|
||||||
List<NicProfile> nicProfiles = new ArrayList<NicProfile>(networks.size());
|
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
|
|
||||||
@ -1809,7 +1808,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||||||
|
|
||||||
deviceIds[devId] = true;
|
deviceIds[devId] = true;
|
||||||
nics.add(vo);
|
nics.add(vo);
|
||||||
nicProfiles.add(new NicProfile(vo, network.first(), vo.getBroadcastUri(), vo.getIsolationUri()));
|
vm.addNic(new NicProfile(vo, network.first(), vo.getBroadcastUri(), vo.getIsolationUri()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultNic == null && nics.size() > 2) {
|
if (defaultNic == null && nics.size() > 2) {
|
||||||
@ -1819,8 +1818,6 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
return nicProfiles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Integer applyProfileToNic(NicVO vo, NicProfile profile, Integer deviceId) {
|
protected Integer applyProfileToNic(NicVO vo, NicProfile profile, Integer deviceId) {
|
||||||
@ -1933,7 +1930,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NicProfile> prepare(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
public void prepare(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException {
|
||||||
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
|
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
|
||||||
for (NicVO nic : nics) {
|
for (NicVO nic : nics) {
|
||||||
Pair<NetworkGuru, NetworkConfigurationVO> implemented = implementNetworkConfiguration(nic.getNetworkConfigurationId(), dest, context);
|
Pair<NetworkGuru, NetworkConfigurationVO> implemented = implementNetworkConfiguration(nic.getNetworkConfigurationId(), dest, context);
|
||||||
@ -1943,7 +1940,14 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||||||
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
|
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
|
||||||
nic.setState(Resource.State.Reserving);
|
nic.setState(Resource.State.Reserving);
|
||||||
_nicDao.update(nic.getId(), nic);
|
_nicDao.update(nic.getId(), nic);
|
||||||
profile = toNicProfile(nic);
|
URI broadcastUri = nic.getBroadcastUri();
|
||||||
|
if (broadcastUri == null) {
|
||||||
|
config.getBroadcastUri();
|
||||||
|
}
|
||||||
|
|
||||||
|
URI isolationUri = nic.getIsolationUri();
|
||||||
|
|
||||||
|
profile = new NicProfile(nic, config, broadcastUri, isolationUri);
|
||||||
String reservationId = concierge.reserve(profile, config, vmProfile, dest);
|
String reservationId = concierge.reserve(profile, config, vmProfile, dest);
|
||||||
nic.setIp4Address(profile.getIp4Address());
|
nic.setIp4Address(profile.getIp4Address());
|
||||||
nic.setIp6Address(profile.getIp6Address());
|
nic.setIp6Address(profile.getIp6Address());
|
||||||
@ -1967,7 +1971,6 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||||||
|
|
||||||
vmProfile.addNic(profile);
|
vmProfile.addNic(profile);
|
||||||
}
|
}
|
||||||
return vmProfile.getNics();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1984,12 +1987,6 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NicProfile toNicProfile(NicVO nic) {
|
|
||||||
NetworkConfiguration config = _networkConfigDao.findById(nic.getNetworkConfigurationId());
|
|
||||||
NicProfile profile = new NicProfile(nic, config, nic.getBroadcastUri(), nic.getIsolationUri());
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void release(long vmId) {
|
public void release(long vmId) {
|
||||||
List<NicVO> nics = _nicDao.listBy(vmId);
|
List<NicVO> nics = _nicDao.listBy(vmId);
|
||||||
|
|
||||||
|
|||||||
@ -140,7 +140,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm)
|
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm)
|
||||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
|
||||||
if (config.getTrafficType() != TrafficType.Guest) {
|
if (config.getTrafficType() != TrafficType.Guest) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -86,7 +86,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
DataCenter dc = dest.getDataCenter();
|
DataCenter dc = dest.getDataCenter();
|
||||||
long dcId = dc.getId();
|
long dcId = dc.getId();
|
||||||
|
|
||||||
if (ch.getIp4Address() != null) {
|
if (ch.getIp4Address() == null) {
|
||||||
Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, vm.getVirtualMachine().getAccountId(), vm.getVirtualMachine().getDomainId(), VlanType.VirtualNetwork, true);
|
Pair<String, VlanVO> ipAndVlan = _vlanDao.assignIpAddress(dcId, vm.getVirtualMachine().getAccountId(), vm.getVirtualMachine().getDomainId(), VlanType.VirtualNetwork, true);
|
||||||
if (ipAndVlan == null) {
|
if (ipAndVlan == null) {
|
||||||
throw new InsufficientVirtualNetworkCapcityException("Unable to get public ip address in " + dcId);
|
throw new InsufficientVirtualNetworkCapcityException("Unable to get public ip address in " + dcId);
|
||||||
|
|||||||
@ -71,6 +71,7 @@ public class ItWorkVO {
|
|||||||
this.managementServerId = managementServerId;
|
this.managementServerId = managementServerId;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.threadName = Thread.currentThread().getName();
|
this.threadName = Thread.currentThread().getName();
|
||||||
|
this.state = State.Working;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
|||||||
@ -150,8 +150,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
|||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Allocating nics for " + vm);
|
s_logger.debug("Allocating nics for " + vm);
|
||||||
}
|
}
|
||||||
List<NicProfile> nics = _networkMgr.allocate(vmProfile, networks);
|
_networkMgr.allocate(vmProfile, networks);
|
||||||
vmProfile.setNics(nics);
|
|
||||||
|
|
||||||
if (dataDiskOfferings == null) {
|
if (dataDiskOfferings == null) {
|
||||||
dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>(0);
|
dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>(0);
|
||||||
@ -161,14 +160,13 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
|||||||
s_logger.debug("Allocaing disks for " + vm);
|
s_logger.debug("Allocaing disks for " + vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DiskProfile> disks = new ArrayList<DiskProfile>(dataDiskOfferings.size() + 1);
|
|
||||||
if (template.getFormat() == ImageFormat.ISO) {
|
if (template.getFormat() == ImageFormat.ISO) {
|
||||||
disks.add(_storageMgr.allocateRawVolume(VolumeType.ROOT, "ROOT-" + vm.getId(), rootDiskOffering.first(), rootDiskOffering.second(), vm, owner));
|
_storageMgr.allocateRawVolume(VolumeType.ROOT, "ROOT-" + vm.getId(), rootDiskOffering.first(), rootDiskOffering.second(), vm, owner);
|
||||||
} else {
|
} else {
|
||||||
disks.add(_storageMgr.allocateTemplatedVolume(VolumeType.ROOT, "ROOT-" + vm.getId(), rootDiskOffering.first(), template, vm, owner));
|
_storageMgr.allocateTemplatedVolume(VolumeType.ROOT, "ROOT-" + vm.getId(), rootDiskOffering.first(), template, vm, owner);
|
||||||
}
|
}
|
||||||
for (Pair<DiskOfferingVO, Long> offering : dataDiskOfferings) {
|
for (Pair<DiskOfferingVO, Long> offering : dataDiskOfferings) {
|
||||||
disks.add(_storageMgr.allocateRawVolume(VolumeType.DATADISK, "DATA-" + vm.getId(), offering.first(), offering.second(), vm, owner));
|
_storageMgr.allocateRawVolume(VolumeType.DATADISK, "DATA-" + vm.getId(), offering.first(), offering.second(), vm, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
_vmDao.updateIf(vm, Event.OperationSucceeded, null);
|
_vmDao.updateIf(vm, Event.OperationSucceeded, null);
|
||||||
@ -284,10 +282,12 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
|||||||
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vm.getPodId(), null, null);
|
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vm.getPodId(), null, null);
|
||||||
|
|
||||||
HypervisorGuru hvGuru = _hvGurus.get(template.getHypervisorType());
|
HypervisorGuru hvGuru = _hvGurus.get(template.getHypervisorType());
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
VirtualMachineGuru<T> vmGuru = (VirtualMachineGuru<T>)_vmGurus.get(vm.getType());
|
||||||
|
|
||||||
|
|
||||||
// Determine the VM's OS description
|
// Determine the VM's OS description
|
||||||
GuestOSVO guestOS = _guestOsDao.findById(vm.getGuestOSId());
|
GuestOSVO guestOS = _guestOsDao.findById(vm.getGuestOSId());
|
||||||
VirtualMachineProfileImpl<T> vmProfile = new VirtualMachineProfileImpl<T>(vm, guestOS.getDisplayName(), template, offering, null, params);
|
|
||||||
if (!_vmDao.updateIf(vm, Event.StartRequested, null)) {
|
if (!_vmDao.updateIf(vm, Event.StartRequested, null)) {
|
||||||
throw new ConcurrentOperationException("Unable to start vm " + vm + " due to concurrent operations");
|
throw new ConcurrentOperationException("Unable to start vm " + vm + " due to concurrent operations");
|
||||||
}
|
}
|
||||||
@ -295,6 +295,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
|||||||
ExcludeList avoids = new ExcludeList();
|
ExcludeList avoids = new ExcludeList();
|
||||||
int retry = _retry;
|
int retry = _retry;
|
||||||
while (retry-- != 0) { // It's != so that it can match -1.
|
while (retry-- != 0) { // It's != so that it can match -1.
|
||||||
|
VirtualMachineProfileImpl<T> vmProfile = new VirtualMachineProfileImpl<T>(vm, guestOS.getDisplayName(), template, offering, null, params);
|
||||||
DeployDestination dest = null;
|
DeployDestination dest = null;
|
||||||
for (DeploymentPlanner planner : _planners) {
|
for (DeploymentPlanner planner : _planners) {
|
||||||
dest = planner.plan(vmProfile, plan, avoids);
|
dest = planner.plan(vmProfile, plan, avoids);
|
||||||
@ -323,15 +324,13 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
|||||||
}
|
}
|
||||||
_networkMgr.prepare(vmProfile, dest, context);
|
_networkMgr.prepare(vmProfile, dest, context);
|
||||||
|
|
||||||
|
vmGuru.finalizeVirtualMachineProfile(vmProfile, dest, context);
|
||||||
|
|
||||||
VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
|
VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
|
||||||
|
|
||||||
Commands cmds = new Commands(OnError.Revert);
|
Commands cmds = new Commands(OnError.Revert);
|
||||||
cmds.addCommand(new Start2Command(vmTO));
|
cmds.addCommand(new Start2Command(vmTO));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
VirtualMachineGuru<T> vmGuru = (VirtualMachineGuru<T>)_vmGurus.get(vm.getType());
|
|
||||||
|
|
||||||
vmGuru.finalizeDeployment(cmds, vmProfile, dest, context);
|
vmGuru.finalizeDeployment(cmds, vmProfile, dest, context);
|
||||||
try {
|
try {
|
||||||
Answer[] answers = _agentMgr.send(dest.getHost().getId(), cmds);
|
Answer[] answers = _agentMgr.send(dest.getHost().getId(), cmds);
|
||||||
@ -352,7 +351,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Creation complete for VM " + vmProfile);
|
s_logger.debug("Creation complete for VM " + vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user