console proxy started completely and running

This commit is contained in:
Alex Huang 2010-10-06 17:22:20 -07:00
parent dc7a723660
commit 9d1270b35f
8 changed files with 32 additions and 143 deletions

View File

@ -36,7 +36,6 @@ import com.cloud.exception.ResourceInUseException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.Volume.VolumeType;
@ -320,10 +319,10 @@ public interface StorageManager extends Manager {
<T extends VMInstanceVO> DiskProfile allocateRawVolume(VolumeType type, String name, DiskOfferingVO offering, Long size, T vm, AccountVO owner);
<T extends VMInstanceVO> DiskProfile allocateTemplatedVolume(VolumeType type, String name, DiskOfferingVO offering, VMTemplateVO template, T vm, AccountVO owner);
<T extends VMInstanceVO> void create(T vm);
Long findHostIdForStoragePool(StoragePool pool);
void createCapacityEntry(StoragePoolVO storagePool, long allocated);
VolumeTO[] prepare(VirtualMachineProfile vm, DeployDestination dest) throws StorageUnavailableException, InsufficientStorageCapacityException, ConcurrentOperationException;
void release(VirtualMachineProfile vm);
}

View File

@ -25,6 +25,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
@ -80,6 +81,10 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
@Column(name="dns")
String dns;
@Column(name="mac_address_seq", updatable=false, nullable=false)
@TableGenerator(name="mac_address_seq", table="network_configuration", pkColumnName="id", valueColumnName="mac_address_seq", allocationSize=1)
long macAddress = 1;
public NetworkConfigurationVO() {
}

View File

@ -230,6 +230,7 @@ public interface NetworkManager extends Manager {
List<NicProfile> allocate(VirtualMachineProfile vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
NicTO[] prepare(VirtualMachineProfile profile, DeployDestination dest) throws InsufficientAddressCapacityException, InsufficientVirtualNetworkCapcityException;
void release(VirtualMachineProfile vmProfile);
<K extends VMInstanceVO> void create(K vm);

View File

@ -2629,6 +2629,20 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
return nicTos;
}
@Override
public void release(VirtualMachineProfile vmProfile) {
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
for (NicVO nic : nics) {
NetworkConfigurationVO config = _networkProfileDao.findById(nic.getNetworkConfigurationId());
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
NetworkGuru concierge = _networkGurus.get(config.getGuruName());
nic.setState(Resource.State.Releasing);
_nicDao.update(nic.getId(), nic);
concierge.release(nic.getReservationId());
}
}
}
NicProfile toNicProfile(NicVO nic) {
NetworkConfiguration config = _networkProfileDao.findById(nic.getNetworkConfigurationId());
NicProfile profile = new NicProfile(nic, config, nic.getBroadcastUri(), nic.getIsolationUri());

View File

@ -30,6 +30,7 @@ import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.component.Inject;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.NicProfile;
import com.cloud.vm.VirtualMachineProfile;
@ -100,7 +101,7 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru {
InsufficientAddressCapacityException {
String ip = _dcDao.allocateLinkLocalPrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), vm.getId());
nic.setIp4Address(ip);
nic.setMacAddress("FE:FF:FF:FF:FF:FF");
nic.setMacAddress(NetUtils.long2Mac(NetUtils.ip2Long(ip) | (14l << 40)));
nic.setNetmask("255.255.0.0");
nic.setFormat(AddressFormat.Ip4);

View File

@ -2461,99 +2461,7 @@ public class StorageManagerImpl implements StorageManager {
}
@Override
public <T extends VMInstanceVO> void create(T vm) {
List<VolumeVO> vols = _volsDao.findByInstance(vm.getId());
assert vols.size() >= 1 : "Come on, what's with the zero volumes for " + vm;
for (VolumeVO vol : vols) {
DiskProfile dskCh = createDiskCharacteristics(vol);
int retry = _retry;
while (--retry >= 0) {
}
}
/*
StoragePoolVO pool = null;
final HashSet<StoragePool> avoidPools = new HashSet<StoragePool>(avoids);
VolumeType volType = volume.getVolumeType();
VolumeTO created = null;
int retry = _retry;
while (--retry >= 0) {
created = null;
txn.start();
long podId = pod.getId();
pod = _podDao.lock(podId, true);
if (pod == null) {
txn.rollback();
volume.setStatus(AsyncInstanceCreateStatus.Failed);
volume.setDestroyed(true);
_volsDao.persist(volume);
throw new CloudRuntimeException("Unable to acquire lock on the pod " + podId);
}
pool = findStoragePool(dskCh, dc, pod, clusterId, offering, vm, template, avoidPools);
if (pool == null) {
txn.rollback();
break;
}
avoidPools.add(pool);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Trying to create " + volume + " on " + pool);
}
volume.setPoolId(pool.getId());
_volsDao.persist(volume);
txn.commit();
CreateCommand cmd = null;
VMTemplateStoragePoolVO tmpltStoredOn = null;
if (volume.getVolumeType() == VolumeType.ROOT && Storage.ImageFormat.ISO != template.getFormat()) {
tmpltStoredOn = _tmpltMgr.prepareTemplateForCreate(template, pool);
if (tmpltStoredOn == null) {
continue;
}
cmd = new CreateCommand(volume, vm, dskCh, tmpltStoredOn.getLocalDownloadPath(), pool);
} else {
cmd = new CreateCommand(volume, vm, dskCh, pool, size);
}
Answer answer = sendToPool(pool, cmd);
if (answer != null && answer.getResult()) {
created = ((CreateAnswer)answer).getVolume();
break;
}
volume.setPoolId(null);
_volsDao.persist(volume);
s_logger.debug("Retrying the create because it failed on pool " + pool);
}
if (created == null) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to create a volume for " + volume);
}
volume.setStatus(AsyncInstanceCreateStatus.Failed);
volume.setDestroyed(true);
_volsDao.persist(volume);
return null;
}
volume.setStatus(AsyncInstanceCreateStatus.Created);
volume.setFolder(pool.getPath());
volume.setPath(created.getPath());
volume.setSize(created.getSize());
volume.setPoolType(pool.getPoolType());
volume.setPodId(pod.getId());
_volsDao.persist(volume);
return volume;
*/
public void release(VirtualMachineProfile profile) {
// Right now we don't do anything.
}
}

View File

@ -170,47 +170,6 @@ public class MauriceMoss implements VmManager {
return allocate(vm, template, serviceOffering, new Pair<DiskOfferingVO, Long>(serviceOffering, null), null, networks, plan, owner);
}
protected VirtualMachineProfile create(VirtualMachineProfile vmProfile, DeploymentPlan plan) throws InsufficientCapacityException {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Creating actual resources for VM " + vmProfile);
}
Journal journal = new Journal.LogJournal("Creating " + vmProfile, s_logger);
Set<DeployDestination> avoids = new HashSet<DeployDestination>();
int retry = _retry;
while (_retry-- > 0) {
DeployDestination context = null;
for (DeploymentPlanner dispatcher : _planners) {
context = dispatcher.plan(vmProfile, plan, avoids);
if (context != null) {
journal.record("Deployment found ", vmProfile, context);
break;
}
}
if (context == null) {
throw new CloudRuntimeException("Unable to create a deployment for " + vmProfile);
}
VMInstanceVO vm = _vmDao.findById(vmProfile.getId());
vm.setDataCenterId(context.getDataCenter().getId());
vm.setPodId(context.getPod().getId());
vm.setHostId(context.getHost().getId());
_vmDao.update(vm.getId(), vm);
_networkMgr.create(vm);
_storageMgr.create(vm);
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Creation complete for VM " + vmProfile);
}
return vmProfile;
}
@Override
public void destroy() {
// TODO Auto-generated method stub
@ -293,7 +252,6 @@ public class MauriceMoss implements VmManager {
vm.setDataCenterId(dest.getDataCenter().getId());
vm.setPodId(dest.getPod().getId());
_vmDao.updateIf(vm, Event.OperationRetry, dest.getHost().getId());
VirtualMachineTO vmTO = new VirtualMachineTO(vmProfile, bt);
VolumeTO[] volumes = null;
@ -317,11 +275,13 @@ public class MauriceMoss implements VmManager {
Start2Command cmd = new Start2Command(vmTO);
try {
Start2Answer answer = (Start2Answer)_agentMgr.send(dest.getHost().getId(), cmd);
if (!answer.getResult()) {
s_logger.info("Unable to start VM on " + dest.getHost() + " due to " + answer.getDetails());
continue;
if (answer.getResult()) {
if (!_vmDao.updateIf(vm, Event.OperationSucceeded, dest.getHost().getId())) {
throw new CloudRuntimeException("Unable to transition to a new state.");
}
return vm;
}
_vmDao.updateIf(vm, Event.OperationSucceeded, dest.getHost().getId());
s_logger.info("Unable to start VM on " + dest.getHost() + " due to " + answer.getDetails());
} catch (AgentUnavailableException e) {
s_logger.debug("Unable to send the start command to host " + dest.getHost());
continue;

View File

@ -104,6 +104,7 @@ CREATE TABLE `cloud`.`network_configurations` (
`data_center_id` bigint unsigned NOT NULL COMMENT 'data center id that this configuration is used in',
`guru_name` varchar(255) NOT NULL COMMENT 'who is responsible for this type of network configuration',
`state` varchar(32) NOT NULL COMMENT 'what state is this configuration in',
`mac_address_seq` bigint unsigned DEFAULT 1 COMMENT 'mac address seq number',
`dns` varchar(255) COMMENT 'comma separated DNS list',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;