changed back so everyone else can start the old way

This commit is contained in:
Alex Huang 2010-11-03 21:18:16 -07:00
parent 9bb05d3ef8
commit 0fdca8be9a
10 changed files with 38 additions and 35 deletions

View File

@ -25,6 +25,7 @@ import com.cloud.resource.Resource;
* Nic represents one nic on the VM.
*/
public interface Nic extends Resource {
boolean isDefaultNic();
String getIp4Address();

View File

@ -194,6 +194,10 @@ public class NicProfile {
this.macAddress = nic.getMacAddress();
this.reservationId = nic.getReservationId();
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) {

View File

@ -531,7 +531,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
@Override
public ConsoleProxyVO startProxy(long proxyVmId, long startEventId) {
try {
return start2(proxyVmId, startEventId);
return start(proxyVmId, startEventId);
} catch (StorageUnavailableException e) {
s_logger.warn("Exception while trying to start console proxy", e);
return null;
@ -887,7 +887,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
if (s_logger.isDebugEnabled())
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");
if (proxyVmId == 0) {
@ -927,7 +927,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
if (s_logger.isDebugEnabled())
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");
if (proxyVmId == 0) {
@ -1468,7 +1468,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
try {
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
try {
readyProxy = start2(readyProxy.getId(), 0);
readyProxy = start(readyProxy.getId(), 0);
} finally {
proxyLock.unlock();
}

View File

@ -57,7 +57,8 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
ServiceOffering offering = vmProfile.getServiceOffering();
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();
NicTO[] nics = new NicTO[nicProfiles.size()];

View File

@ -302,9 +302,9 @@ public interface NetworkManager extends Manager {
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);
DomainRouter upgradeRouter(UpgradeRouterCmd cmd);

View File

@ -17,6 +17,7 @@
*/
package com.cloud.network;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -1759,9 +1760,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
}
@Override @DB
public List<NicProfile> allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException {
List<NicProfile> nicProfiles = new ArrayList<NicProfile>(networks.size());
public void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException {
Transaction txn = Transaction.currentTxn();
txn.start();
@ -1809,7 +1808,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
deviceIds[devId] = true;
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) {
@ -1819,8 +1818,6 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
}
txn.commit();
return nicProfiles;
}
protected Integer applyProfileToNic(NicVO vo, NicProfile profile, Integer deviceId) {
@ -1933,7 +1930,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
}
@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());
for (NicVO nic : nics) {
Pair<NetworkGuru, NetworkConfigurationVO> implemented = implementNetworkConfiguration(nic.getNetworkConfigurationId(), dest, context);
@ -1943,7 +1940,14 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
nic.setState(Resource.State.Reserving);
_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);
nic.setIp4Address(profile.getIp4Address());
nic.setIp6Address(profile.getIp6Address());
@ -1967,7 +1971,6 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
vmProfile.addNic(profile);
}
return vmProfile.getNics();
}
@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) {
List<NicVO> nics = _nicDao.listBy(vmId);

View File

@ -140,7 +140,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm)
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm)
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
if (config.getTrafficType() != TrafficType.Guest) {
return null;

View File

@ -86,7 +86,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
DataCenter dc = dest.getDataCenter();
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);
if (ipAndVlan == null) {
throw new InsufficientVirtualNetworkCapcityException("Unable to get public ip address in " + dcId);

View File

@ -71,6 +71,7 @@ public class ItWorkVO {
this.managementServerId = managementServerId;
this.type = type;
this.threadName = Thread.currentThread().getName();
this.state = State.Working;
}
public String getId() {

View File

@ -150,8 +150,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Allocating nics for " + vm);
}
List<NicProfile> nics = _networkMgr.allocate(vmProfile, networks);
vmProfile.setNics(nics);
_networkMgr.allocate(vmProfile, networks);
if (dataDiskOfferings == null) {
dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>(0);
@ -161,14 +160,13 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
s_logger.debug("Allocaing disks for " + vm);
}
List<DiskProfile> disks = new ArrayList<DiskProfile>(dataDiskOfferings.size() + 1);
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 {
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) {
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);
@ -284,10 +282,12 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vm.getPodId(), null, null);
HypervisorGuru hvGuru = _hvGurus.get(template.getHypervisorType());
@SuppressWarnings("unchecked")
VirtualMachineGuru<T> vmGuru = (VirtualMachineGuru<T>)_vmGurus.get(vm.getType());
// Determine the VM's OS description
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)) {
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();
int retry = _retry;
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;
for (DeploymentPlanner planner : _planners) {
dest = planner.plan(vmProfile, plan, avoids);
@ -323,15 +324,13 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
}
_networkMgr.prepare(vmProfile, dest, context);
vmGuru.finalizeVirtualMachineProfile(vmProfile, dest, context);
VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
Commands cmds = new Commands(OnError.Revert);
cmds.addCommand(new Start2Command(vmTO));
@SuppressWarnings("unchecked")
VirtualMachineGuru<T> vmGuru = (VirtualMachineGuru<T>)_vmGurus.get(vm.getType());
vmGuru.finalizeDeployment(cmds, vmProfile, dest, context);
try {
Answer[] answers = _agentMgr.send(dest.getHost().getId(), cmds);
@ -352,7 +351,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Creation complete for VM " + vmProfile);
s_logger.debug("Creation complete for VM " + vm);
}
return null;