bug 10765: fix step 2 - programming VNC server to let it chose the right keyboard mapping to load into

This commit is contained in:
Kelven Yang 2011-08-04 18:27:45 -07:00
parent 83a9e74927
commit d10c8e2a1d
9 changed files with 50 additions and 13 deletions

View File

@ -192,4 +192,12 @@ public class VirtualMachineTO {
public void setVncPassword(String vncPassword) { public void setVncPassword(String vncPassword) {
this.vncPassword = vncPassword; this.vncPassword = vncPassword;
} }
public Map<String, String> getDetails() {
return params;
}
public void setDetails(Map<String, String> params) {
this.params = params;
}
} }

View File

@ -253,4 +253,5 @@ public class ApiConstants {
public static final String SNAPSHOT_RESERVATION = "snapshotreservation"; public static final String SNAPSHOT_RESERVATION = "snapshotreservation";
public static final String REDUNDANT_ROUTER = "redundantrouter"; public static final String REDUNDANT_ROUTER = "redundantrouter";
public static final String IP_NETWORK_LIST = "iptonetworklist"; public static final String IP_NETWORK_LIST = "iptonetworklist";
public static final String KEYBOARD="keyboard";
} }

View File

@ -121,6 +121,10 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="the ip address for default vm's network") @Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="the ip address for default vm's network")
private String ipAddress; private String ipAddress;
@Parameter(name=ApiConstants.KEYBOARD, type=CommandType.STRING, description="an optional keyboard device type for the virtual machine. valid value can be one of de,de-ch,es,fi,fr,fr-be,fr-ch,is,it,jp,nl-be,no,pt,uk,us")
private String keyboard;
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
/////////////////// Accessors /////////////////////// /////////////////// Accessors ///////////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@ -227,6 +231,10 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
return ipAddress; return ipAddress;
} }
private String getKeyboard() {
return keyboard;
}
private Map<Long, String> getIpToNetworkMap() { private Map<Long, String> getIpToNetworkMap() {
if ((networkIds != null || ipAddress != null) && ipToNetworkList != null) { if ((networkIds != null || ipAddress != null) && ipToNetworkList != null) {
throw new InvalidParameterValueException("NetworkIds and ipAddress can't be specified along with ipToNetworkMap parameter"); throw new InvalidParameterValueException("NetworkIds and ipAddress can't be specified along with ipToNetworkMap parameter");
@ -375,18 +383,18 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
throw new InvalidParameterValueException("Can't specify network Ids in Basic zone"); throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
} else { } else {
vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name, vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress); displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
} }
} else { } else {
if (zone.isSecurityGroupEnabled()) { if (zone.isSecurityGroupEnabled()) {
vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(), vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress); owner, name, displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
} else { } else {
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) { if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone"); throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
} }
vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName, vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress); diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
} }
} }
} }

View File

@ -185,7 +185,7 @@ public interface UserVmService {
* @throws InsufficientResourcesException * @throws InsufficientResourcesException
*/ */
UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner, String hostName, UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner, String hostName,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp) String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException; throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/** /**
@ -240,7 +240,7 @@ public interface UserVmService {
* @throws InsufficientResourcesException * @throws InsufficientResourcesException
*/ */
UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, List<Long> securityGroupIdList, UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, List<Long> securityGroupIdList,
Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp) Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException; throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/** /**
@ -293,7 +293,7 @@ public interface UserVmService {
* @throws InsufficientResourcesException * @throws InsufficientResourcesException
*/ */
UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName, UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp) String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException; throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/** /**

View File

@ -18,6 +18,7 @@
package com.cloud.vm; package com.cloud.vm;
import java.util.Date; import java.util.Date;
import java.util.Map;
import com.cloud.acl.ControlledEntity; import com.cloud.acl.ControlledEntity;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
@ -30,6 +31,9 @@ import com.cloud.utils.fsm.StateObject;
* *
*/ */
public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject<VirtualMachine.State> { public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject<VirtualMachine.State> {
public static final String PARAM_KEY_KEYBOARD = "keyboard";
public enum State { public enum State {
Starting(true, "VM is being started. At this state, you should find host id filled which means it's being started on that host."), Starting(true, "VM is being started. At this state, you should find host id filled which means it's being started on that host."),
Running(false, "VM is running. host id has the host that it is running on."), Running(false, "VM is running. host id has the host that it is running on."),
@ -275,4 +279,6 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject
Type getType(); Type getType();
HypervisorType getHypervisorType(); HypervisorType getHypervisorType();
public Map<String, String> getDetails();
} }

View File

@ -119,6 +119,7 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
this.displayName = displayName; this.displayName = displayName;
} }
@Override
public Map<String, String> getDetails() { public Map<String, String> getDetails() {
return details; return details;
} }

View File

@ -19,6 +19,7 @@
package com.cloud.vm; package com.cloud.vm;
import java.util.Date; import java.util.Date;
import java.util.Map;
import java.util.Random; import java.util.Random;
import javax.persistence.Column; import javax.persistence.Column;
@ -395,6 +396,10 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
return this.reservationId; return this.reservationId;
} }
public Map<String, String> getDetails() {
return null;
}
transient String toString; transient String toString;
@Override @Override
public String toString() { public String toString() {

View File

@ -80,6 +80,8 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
to.setArch("x86_64"); to.setArch("x86_64");
} }
to.setDetails(vm.getDetails());
return to; return to;
} }

View File

@ -2040,7 +2040,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
@Override @Override
public UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner, public UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> securityGroupIdList, Account owner,
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp) String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException {
Account caller = UserContext.current().getCaller(); Account caller = UserContext.current().getCaller();
@ -2092,13 +2092,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
} }
return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId, return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId,
diskSize, networkList, securityGroupIdList, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIp); diskSize, networkList, securityGroupIdList, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIp, keyboard);
} }
@Override @Override
public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList,
List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, List<Long> securityGroupIdList, Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData,
String sshKeyPair, Map<Long, String> requestedIps, String defaultIp) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException,
ResourceAllocationException { ResourceAllocationException {
Account caller = UserContext.current().getCaller(); Account caller = UserContext.current().getCaller();
@ -2203,12 +2203,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
} }
return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId, return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId,
diskSize, networkList, securityGroupIdList, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIp); diskSize, networkList, securityGroupIdList, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIp, keyboard);
} }
@Override @Override
public UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName, public UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List<Long> networkIdList, Account owner, String hostName,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp) String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map<Long, String> requestedIps, String defaultIp, String keyboard)
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException { throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException {
Account caller = UserContext.current().getCaller(); Account caller = UserContext.current().getCaller();
@ -2326,12 +2326,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
} }
} }
return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId, diskSize, networkList, null, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIp); return createVirtualMachine(zone, serviceOffering, template, hostName, displayName, owner, diskOfferingId, diskSize, networkList, null, group, userData, sshKeyPair, hypervisor, caller, requestedIps, defaultIp, keyboard);
} }
@DB @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", create = true) @DB @ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", create = true)
protected UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, String hostName, String displayName, Account owner, Long diskOfferingId, protected UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, String hostName, String displayName, Account owner, Long diskOfferingId,
Long diskSize, List<NetworkVO> networkList, List<Long> securityGroupIdList, String group, String userData, String sshKeyPair, HypervisorType hypervisor, Account caller, Map<Long, String> requestedIps, String defaultNetworkIp) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException, ResourceAllocationException { Long diskSize, List<NetworkVO> networkList, List<Long> securityGroupIdList, String group, String userData, String sshKeyPair, HypervisorType hypervisor, Account caller, Map<Long, String> requestedIps, String defaultNetworkIp, String keyboard) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException, ResourceAllocationException {
_accountMgr.checkAccess(caller, owner); _accountMgr.checkAccess(caller, owner);
long accountId = owner.getId(); long accountId = owner.getId();
@ -2515,6 +2515,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
vm.setDetail("SSH.PublicKey", sshPublicKey); vm.setDetail("SSH.PublicKey", sshPublicKey);
} }
if(keyboard != null && !keyboard.isEmpty())
vm.setDetail(VirtualMachine.PARAM_KEY_KEYBOARD, keyboard);
if (isIso) { if (isIso) {
vm.setIsoId(template.getId()); vm.setIsoId(template.getId());
} }
@ -2653,6 +2656,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
@Override @Override
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<UserVmVO> profile, DeployDestination dest, ReservationContext context) { public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<UserVmVO> profile, DeployDestination dest, ReservationContext context) {
UserVmVO vm = profile.getVirtualMachine(); UserVmVO vm = profile.getVirtualMachine();
Map<String, String> details = _vmDetailsDao.findDetails(vm.getId());
vm.setDetails(details);
Account owner = _accountDao.findById(vm.getAccountId()); Account owner = _accountDao.findById(vm.getAccountId());
if (owner == null) { if (owner == null) {