fixed build for vmware

This commit is contained in:
Anthony Xu 2014-07-28 17:36:22 -07:00
parent f47cfc6eb1
commit ecf100e4ed
3 changed files with 13 additions and 15 deletions

View File

@ -1415,7 +1415,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
String vmName = cmd.getVmName();
Boolean snapshotMemory = cmd.getTarget().getType() == VMSnapshot.Type.DiskAndMemory;
List<VolumeObjectTO> listVolumeTo = cmd.getVolumeTOs();
VirtualMachine.State vmState = VirtualMachine.State.Running;
VirtualMachine.PowerState vmState = VirtualMachine.PowerState.PowerOn;
VirtualMachineMO vmMo = null;
VmwareContext context = hostService.getServiceContext(cmd);
@ -1468,7 +1468,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
setVolumeToPathAndSize(listVolumeTo, mapNewDisk, context, hyperHost, cmd.getVmName());
if (!snapshotMemory) {
vmState = VirtualMachine.State.Stopped;
vmState = VirtualMachine.PowerState.PowerOff;
}
return new RevertToVMSnapshotAnswer(cmd, listVolumeTo, vmState);

View File

@ -312,7 +312,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
protected static ThreadLocal<VmwareContext> s_serviceContext = new ThreadLocal<VmwareContext>();
protected String _hostName;
protected HashMap<String, State> _vms = new HashMap<String, State>(71);
protected List<PropertyMapDynamicBean> _cmdMBeans = new ArrayList<PropertyMapDynamicBean>();
protected Gson _gson;
@ -1295,7 +1294,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
String vmNameOnVcenter = names.second();
// Thus, vmInternalCSName always holds i-x-y, the cloudstack generated internal VM name.
State state = State.Stopped;
VmwareContext context = getServiceContext();
try {
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
@ -1691,8 +1689,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
throw new Exception("Failed to start VM. vmName: " + vmInternalCSName + " with hostname " + vmNameOnVcenter);
}
state = State.Running;
StartAnswer startAnswer = new StartAnswer(cmd);
startAnswer.setIqnToPath(iqnToPath);
@ -2544,7 +2540,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
HashMap<String, VmStatsEntry> vmStatsMap = null;
try {
HashMap<String, PowerState> vmPowerStates = getVmStates()
HashMap<String, PowerState> vmPowerStates = getVmStates();
// getVmNames should return all i-x-y values.
List<String> requestedVmNames = cmd.getVmNames();
@ -2732,7 +2728,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
final String vmName = cmd.getVmName();
PowerState powerState = PowerState.Unknown;
PowerState powerState = PowerState.PowerUnknown;
Integer vncPort = null;
VmwareContext context = getServiceContext();
@ -2806,10 +2802,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
String msg = "Failed to prepare secondary storage on host, secondary store url: " + secStoreUrl;
throw new Exception(msg);
}
synchronized (_vms) {
_vms.put(vm.getName(), State.Migrating);
}
return new PrepareForMigrationAnswer(cmd);
} catch (Throwable e) {
if (e instanceof RemoteException) {
@ -4332,7 +4324,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
// the internal CS name, but the custom field CLOUD_VM_INTERNAL_NAME always stores the internal CS name.
ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[] {"name", "runtime.powerState", "config.template", instanceNameCustomField});
HashMap<String, State> newStates = new HashMap<String, State>();
HashMap<String, PowerState> newStates = new HashMap<String, PowerState>();
if (ocs != null && ocs.length > 0) {
for (ObjectContent oc : ocs) {
List<DynamicProperty> objProps = oc.getPropSet();
@ -4592,6 +4584,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
return connect(vmname, ipAddress, 3922);
}
public static PowerState getVmState(VirtualMachineMO vmMo) throws Exception {
VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
return convertPowerState(runtimeInfo.getPowerState());
}
private static PowerState convertPowerState(VirtualMachinePowerState powerState) {
return s_powerStatesTable.get(powerState);
}

View File

@ -99,7 +99,7 @@ import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.VirtualMachine.PowerState;
public class VmwareStorageProcessor implements StorageProcessor {
private static final Logger s_logger = Logger.getLogger(VmwareStorageProcessor.class);
@ -1611,7 +1611,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
List<NetworkDetails> networks = vmMo.getNetworksWithDetails();
// tear down all devices first before we destroy the VM to avoid accidently delete disk backing files
if (VmwareResource.getVmState(vmMo) != State.Stopped) {
if (VmwareResource.getVmState(vmMo) != PowerState.PowerOff) {
vmMo.safePowerOff(_shutdownWaitMs);
}