bug 13306: remove sensive DB id info from VM display name

This commit is contained in:
Kelven Yang 2012-01-25 17:15:48 -08:00
parent 3b1db5fa20
commit 8083b29235
6 changed files with 14 additions and 9 deletions

View File

@ -72,7 +72,7 @@ public class ConsoleProxyVO extends VMInstanceVO implements ConsoleProxy {
*/
public ConsoleProxyVO(long id, long serviceOfferingId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long dataCenterId, long domainId, long accountId,
int activeSession, boolean haEnabled) {
super(id, serviceOfferingId, name, name, Type.ConsoleProxy, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
super(id, serviceOfferingId, null, name, Type.ConsoleProxy, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
this.activeSession = activeSession;
}

View File

@ -95,7 +95,7 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
boolean isPriorityBumpUp,
RedundantState redundantState,
boolean haEnabled, boolean stopPending) {
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
super(id, serviceOfferingId, null, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
this.elementId = elementId;
this.networkId = networkId;
this.isRedundantRouter = isRedundantRouter;

View File

@ -66,7 +66,7 @@ public class SecondaryStorageVmVO extends VMInstanceVO implements SecondaryStora
public SecondaryStorageVmVO(long id, long serviceOfferingId, String name, long templateId, HypervisorType hypervisorType, long guestOSId, long dataCenterId, long domainId, long accountId,
Role role, boolean haEnabled) {
super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
super(id, serviceOfferingId, null, name, Type.SecondaryStorageVm, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
this.role = role;
}

View File

@ -85,7 +85,7 @@ public class UserVmVO extends VMInstanceVO implements UserVm {
String name) {
super(id, serviceOfferingId, name, instanceName, Type.User, templateId, hypervisorType, guestOsId, domainId, accountId, haEnabled, limitCpuUse);
this.userData = userData;
this.displayName = displayName != null ? displayName : name != null ? name : instanceName;
this.displayName = displayName != null ? displayName : getUuid();
this.details = new HashMap<String, String>();
}

View File

@ -147,7 +147,8 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
Map<String, String> details;
@Column(name="uuid")
protected String uuid;
protected String uuid = UUID.randomUUID().toString();
;
public VMInstanceVO(long id,
long serviceOfferingId,
@ -161,7 +162,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
long accountId,
boolean haEnabled) {
this.id = id;
this.hostName = name != null ? name : instanceName;
this.hostName = name != null ? name : this.uuid;
if (vmTemplateId != null) {
this.templateId = vmTemplateId;
}
@ -176,7 +177,6 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
this.serviceOfferingId = serviceOfferingId;
this.hypervisorType = hypervisorType;
this.limitCpuUse = false;
this.uuid = UUID.randomUUID().toString();
}
public VMInstanceVO(long id,

View File

@ -2427,8 +2427,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
long id = _vmDao.getNextInSequence(Long.class, "id");
String instanceName = VirtualMachineName.getVmName(id, owner.getId(), _instance);
String uuidName = UUID.randomUUID().toString();
if (hostName == null) {
hostName = instanceName;
hostName = uuidName;
} else {
// verify hostName (hostname doesn't have to be unique)
if (!NetUtils.verifyDomainNameLabel(hostName, true)) {
@ -2436,6 +2438,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
+ "and the hyphen ('-'), must be between 1 and 63 characters long, and can't start or end with \"-\" and can't start with digit");
}
}
if(displayName == null)
displayName = uuidName;
HypervisorType hypervisorType = null;
if (template == null || template.getHypervisorType() == null || template.getHypervisorType() == HypervisorType.None) {
@ -2447,7 +2451,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
txn.start();
UserVmVO vm = new UserVmVO(id, instanceName, displayName, template.getId(), hypervisorType, template.getGuestOSId(), offering.getOfferHA(), offering.getLimitCpuUse(), owner.getDomainId(), owner.getId(),
offering.getId(), userData, hostName);
vm.setUuid(uuidName);
if (sshPublicKey != null) {
vm.setDetail("SSH.PublicKey", sshPublicKey);
}