bug 10480, 10494: NPE fix in VirtualMachineManagerImpl, move keystore upgrade sql to upgrade225to226.sql

This commit is contained in:
Kelven Yang 2011-06-28 14:56:30 -07:00
parent 33624efd2f
commit 1edf772f92
4 changed files with 38 additions and 4 deletions

View File

@ -1525,7 +1525,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
}
if(trackExternalChange) {
if(hostId != vm.getHostId()) {
if(vm.getHostId() == null || hostId != vm.getHostId()) {
try {
stateTransitTo(vm, VirtualMachine.Event.AgentReportMigrated, hostId);
} catch (NoTransitionException e) {

View File

@ -9,5 +9,27 @@ ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `unique_name` varchar(64) NOT
UPDATE `cloud`.`network_offerings` SET unique_name=name;
ALTER TABLE `cloud`.`network_offerings` MODIFY `unique_name` varchar(64) NOT NULL UNIQUE COMMENT 'unique name of the network offering';
DROP TABLE IF EXISTS `cloud`.`certificate`;
CREATE TABLE IF NOT EXISTS `cloud`.`keystore` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(64) NOT NULL COMMENT 'unique name for the certifiation',
`certificate` text NOT NULL COMMENT 'the actual certificate being stored in the db',
`key` text NOT NULL COMMENT 'private key associated wih the certificate',
`domain_suffix` varchar(256) NOT NULL COMMENT 'DNS domain suffix associated with the certificate',
PRIMARY KEY (`id`),
UNIQUE(name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `cloud`.`cmd_exec_log` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`host_id` bigint unsigned NOT NULL COMMENT 'host id of the system VM agent that command is sent to',
`instance_id` bigint unsigned NOT NULL COMMENT 'instance id of the system VM that command is executed on',
`command_name` varchar(255) NOT NULL COMMENT 'command name',
`weight` integer NOT NULL DEFAULT 1 COMMENT 'command weight in consideration of the load factor added to host that is executing the command',
`created` datetime NOT NULL COMMENT 'date created',
PRIMARY KEY (`id`),
INDEX `i_cmd_exec_log__host_id`(`host_id`),
INDEX `i_cmd_exec_log__instance_id`(`instance_id`),
CONSTRAINT `fk_cmd_exec_log_ref__inst_id` FOREIGN KEY (`instance_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -11,7 +11,7 @@ ALTER TABLE `cloud`.`service_offering` ADD COLUMN `vm_type` varchar(32) COMMENT
ALTER TABLE `cloud`.`storage_pool` MODIFY `host_address` varchar(255) NOT NULL;
DROP TABLE IF EXISTS `cloud`.`certificate`;
CREATE TABLE `cloud`.`keystore` (
CREATE TABLE IF NOT EXISTS `cloud`.`keystore` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(64) NOT NULL COMMENT 'unique name for the certifiation',
`certificate` text NOT NULL COMMENT 'the actual certificate being stored in the db',
@ -21,7 +21,7 @@ CREATE TABLE `cloud`.`keystore` (
UNIQUE(name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`cmd_exec_log` (
CREATE TABLE IF NOT EXISTS `cloud`.`cmd_exec_log` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`host_id` bigint unsigned NOT NULL COMMENT 'host id of the system VM agent that command is sent to',
`instance_id` bigint unsigned NOT NULL COMMENT 'instance id of the system VM that command is executed on',
@ -34,7 +34,7 @@ CREATE TABLE `cloud`.`cmd_exec_log` (
CONSTRAINT `fk_cmd_exec_log_ref__inst_id` FOREIGN KEY (`instance_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`network_tags` (
CREATE TABLE IF NOT EXISTS `cloud`.`network_tags` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`network_id` bigint unsigned NOT NULL COMMENT 'id of the network',
`tag` varchar(255) NOT NULL COMMENT 'tag',

View File

@ -119,4 +119,16 @@ public class StringUtils {
}
return sb.toString();
}
public static String getMaskedPasswordForDisplay(String password) {
if(password == null || password.isEmpty())
return "*";
StringBuffer sb = new StringBuffer();
sb.append(password.charAt(0));
for(int i = 1; i < password.length(); i++)
sb.append("*");
return sb.toString();
}
}