From 971915a26a56aa5b9909aa2526a0eaac951650e4 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Wed, 30 Mar 2011 12:17:02 -0700 Subject: [PATCH] added missing changes from schema changes previously --- api/src/com/cloud/storage/Volume.java | 2 + core/src/com/cloud/storage/VolumeVO.java | 59 ++++++------------------ setup/db/data-21to22.sql | 31 ------------- setup/db/index-21to22.sql | 13 ------ setup/db/schema-21to22.sql | 50 ++++++++++++++++++-- 5 files changed, 64 insertions(+), 91 deletions(-) delete mode 100644 setup/db/data-21to22.sql delete mode 100644 setup/db/index-21to22.sql diff --git a/api/src/com/cloud/storage/Volume.java b/api/src/com/cloud/storage/Volume.java index 7f0a8eca1c9..ab6c5b0cccd 100755 --- a/api/src/com/cloud/storage/Volume.java +++ b/api/src/com/cloud/storage/Volume.java @@ -135,4 +135,6 @@ public interface Volume extends ControlledEntity, BasedOn { long getDiskOfferingId(); String getChainInfo(); + + boolean isRecreatable(); } diff --git a/core/src/com/cloud/storage/VolumeVO.java b/core/src/com/cloud/storage/VolumeVO.java index 1bb5c60cbd0..dd00f0174e9 100755 --- a/core/src/com/cloud/storage/VolumeVO.java +++ b/core/src/com/cloud/storage/VolumeVO.java @@ -125,31 +125,6 @@ public class VolumeVO implements Volume { @Column(name="chain_info") String chainInfo; - /** - * Constructor for data disk. - * @param type - * @param instanceId - * @param name - * @param dcId - * @param podId - * @param accountId - * @param domainId - * @param size - */ - public VolumeVO(Type type, long instanceId, String name, long dcId, long podId, long accountId, long domainId, long size) { - this.volumeType = type; - this.name = name; - this.dataCenterId = dcId; - this.podId = podId; - this.accountId = accountId; - this.domainId = domainId; - this.instanceId = instanceId; - this.size = size; - this.templateId = null; - this.storageResourceType = Storage.StorageResourceType.STORAGE_POOL; - this.poolType = null; - } - // Real Constructor public VolumeVO(Type type, String name, long dcId, long domainId, long accountId, long diskOfferingId, long size) { this.volumeType = type; @@ -162,25 +137,6 @@ public class VolumeVO implements Volume { this.state = State.Allocated; } - /** - * Constructor for volume based on a template. - * - * @param type - * @param instanceId - * @param templateId - * @param name - * @param dcId - * @param podId - * @param accountId - * @param domainId - */ - public VolumeVO(Type type, long instanceId, long templateId, String name, long dcId, long podId, long accountId, long domainId, boolean recreatable) { - this(type, instanceId, name, dcId, podId, accountId, domainId, 0l); - this.templateId = templateId; - this.recreatable = recreatable; - } - - public VolumeVO(String name, long dcId, long podId, long accountId, long domainId, Long instanceId, String folder, String path, long size, Volume.Type vType) { this.name = name; this.accountId = accountId; @@ -195,7 +151,22 @@ public class VolumeVO implements Volume { this.recreatable = false; } + // Copy Constructor + public VolumeVO(Volume that) { + this(that.getName(), that.getDataCenterId(), that.getPodId(), that.getAccountId(), that.getDomainId(), that.getInstanceId(), that.getFolder(), that.getPath(), that.getSize(), that.getVolumeType()); + this.recreatable = that.isRecreatable(); + this.state = that.getState(); + this.size = that.getSize(); + this.diskOfferingId = that.getDiskOfferingId(); + this.poolId = that.getPoolId(); + this.storageResourceType = that.getStorageResourceType(); + this.attached = that.getAttached(); + this.chainInfo = that.getChainInfo(); + this.templateId = that.getTemplateId(); + this.deviceId = that.getDeviceId(); + } + @Override public boolean isRecreatable() { return recreatable; } diff --git a/setup/db/data-21to22.sql b/setup/db/data-21to22.sql deleted file mode 100644 index 512b2a1c761..00000000000 --- a/setup/db/data-21to22.sql +++ /dev/null @@ -1,31 +0,0 @@ ---data upgrade from 21 to 22 -use cloud; - -START TRANSACTION; -DELETE FROM template_host_ref WHERE install_path LIKE '%xs-tools%' -DELETE FROM configuration where name='upgrade.url'; -DELETE FROM configuration where name='router.template.id'; -INSERT INTO configuration (category, instance, component, name, value, description) - VALUES ('Network', 'DEFAULT', 'AgentManager', 'remote.access.vpn.client.iprange', '10.1.2.1-10.1.2.8', 'The range of ips to be allocated to remote access vpn clients. The first ip in the range is used by the VPN server'); -INSERT INTO configuration (category, instance, component, name, value, description) - VALUES ('Network', 'DEFAULT', 'AgentManager', 'remote.access.vpn.psk.length', '48', 'The length of the ipsec preshared key (minimum 8, maximum 256)'); -INSERT INTO configuration (category, instance, component, name, value, description) - VALUES ('Network', 'DEFAULT', 'AgentManager', 'remote.access.vpn.user.limit', '8', 'The maximum number of VPN users that can be created per account'); -INSERT INTO configuration (category, instance, component, name, value, description) - VALUES ('Advanced', 'DEFAULT', 'management-server', 'management-server', NULL, 'The cidr of management server network'); -UPDATE vm_template set unique_name='routing_old' where id=1; -INSERT INTO vm_template (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones) - VALUES (10, 'routing', 'SystemVM Template', 0, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/releases/2.2/systemvm.vhd.bz2', 'bcc7f290f4c27ab4d0fe95d1012829ea', 0, 'SystemVM Template', 'VHD', 15, 0, 1); -Update configuration set name='storage.max.volume.size' where name='max.volume.size.mb'; -INSERT INTO sequence (name, value) - VALUES ('snapshots_seq', '1') -UPDATE cloud.sequence SET value=IF((SELECT COUNT(*) FROM cloud.snapshots) > 0, (SELECT max(id) FROM cloud.snapshots) + 1, 1) WHERE name='snapshots_seq' -UPDATE configuration set name='direct.attach.security.groups.enabled' where name='direct.attach.network.groups.enabled'; -UPDATE configuration set name='guest.domain.suffix' where name='domain.suffix'; -INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (132, 2, 'Debian GNU/Linux 6(32-bit)'); -INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (133, 2, 'Debian GNU/Linux 6(64-bit)'); -INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (134, 3, 'Oracle Enterprise Linux 5.5 (32-bit)'); -INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (135, 3, 'Oracle Enterprise Linux 5.5 (64-bit)'); -INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (136, 4, 'Red Hat Enterprise Linux 6.0 (32-bit)'); -INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (137, 4, 'Red Hat Enterprise Linux 6.0 (64-bit)'); -COMMIT; diff --git a/setup/db/index-21to22.sql b/setup/db/index-21to22.sql deleted file mode 100644 index 8d276e27730..00000000000 --- a/setup/db/index-21to22.sql +++ /dev/null @@ -1,13 +0,0 @@ -ALTER TABLE `cloud`.`instance_group` ADD CONSTRAINT `fk_instance_group__account_id` FOREIGN KEY `fk_instance_group__account_id` (`account_id`) REFERENCES `account` (`id`); - -ALTER TABLE `cloud`.`instance_group_vm_map` ADD CONSTRAINT `fk_instance_group_vm_map___group_id` FOREIGN KEY `fk_instance_group_vm_map___group_id` (`group_id`) REFERENCES `instance_group` (`id`) ON DELETE CASCADE; -ALTER TABLE `cloud`.`instance_group_vm_map` ADD CONSTRAINT `fk_instance_group_vm_map___instance_id` FOREIGN KEY `fk_instance_group_vm_map___instance_id` (`instance_id`) REFERENCES `user_vm` (`id`) ON DELETE CASCADE; - -ALTER TABLE `cloud`.`remote_access_vpn` ADD CONSTRAINT `fk_remote_access_vpn___account_id` FOREIGN KEY `fk_remote_access_vpn__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE; -ALTER TABLE `cloud`.`remote_access_vpn` ADD CONSTRAINT `fk_remote_access_vpn__zone_id` FOREIGN KEY `fk_remote_access_vpn__zone_id` (`zone_id`) REFERENCES `data_center` (`id`); -ALTER TABLE `cloud`.`remote_access_vpn` ADD CONSTRAINT `fk_remote_access_vpn__server_addr` FOREIGN KEY `fk_remote_access_vpn__server_addr` (`vpn_server_addr`) REFERENCES `user_ip_address` (`public_ip_address`); -ALTER TABLE `cloud`.`remote_access_vpn` ADD INDEX `i_remote_access_vpn_addr`(`vpn_server_addr`); - -ALTER TABLE `cloud`.`vpn_users` ADD CONSTRAINT `fk_vpn_users___account_id` FOREIGN KEY `fk_vpn_users__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE; -ALTER TABLE `cloud`.`vpn_users` ADD INDEX `i_vpn_users_username`(`username`); -ALTER TABLE `cloud`.`vpn_users` ADD UNIQUE `i_vpn_users__account_id__username`(`account_id`, `username`); diff --git a/setup/db/schema-21to22.sql b/setup/db/schema-21to22.sql index f5590b01f5f..cfd9f4e8bfd 100755 --- a/setup/db/schema-21to22.sql +++ b/setup/db/schema-21to22.sql @@ -74,7 +74,8 @@ CREATE TABLE `cloud`.`network_offerings` ( `userdata_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides user data service', `vpn_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides vpn service', `dhcp_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides dhcp service', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + INDEX `i_network_offerings__removed`(`removed`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`networks` ( @@ -110,7 +111,8 @@ CREATE TABLE `cloud`.`networks` ( CONSTRAINT `fk_networks__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`), CONSTRAINT `fk_networks__related` FOREIGN KEY(`related`) REFERENCES `networks`(`id`), CONSTRAINT `fk_networks__account_id` FOREIGN KEY(`account_id`) REFERENCES `account`(`id`), - CONSTRAINT `fk_networks__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`) + CONSTRAINT `fk_networks__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`), + INDEX `i_networks__removed`(`removed`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`op_networks`( @@ -167,7 +169,8 @@ CREATE TABLE `cloud`.`nics` ( `removed` datetime COMMENT 'date removed if not null', PRIMARY KEY (`id`), CONSTRAINT `fk_nics__instance_id` FOREIGN KEY `fk_nics__instance_id`(`instance_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE, - CONSTRAINT `fk_nics__networks_id` FOREIGN KEY `fk_nics__networks_id`(`network_id`) REFERENCES `networks`(`id`) + CONSTRAINT `fk_nics__networks_id` FOREIGN KEY `fk_nics__networks_id`(`network_id`) REFERENCES `networks`(`id`), + INDEX `i_nics__removed`(`removed`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `network_offerings` VALUES (1,'System-Public-Network','System Offering for System-Public-Network',NULL,NULL,NULL,'Public',NULL,1,0,NULL,now(),NULL,0,'Required',0,0,0,0,0,0,0),(2,'System-Management-Network','System Offering for System-Management-Network',NULL,NULL,NULL,'Management',NULL,1,0,NULL,now(),NULL,0,'Required',0,0,0,0,0,0,0),(3,'System-Control-Network','System Offering for System-Control-Network',NULL,NULL,NULL,'Control',NULL,1,0,NULL,now(),NULL,0,'Required',0,0,0,0,0,0,0),(4,'System-Storage-Network','System Offering for System-Storage-Network',NULL,NULL,NULL,'Storage',NULL,1,0,NULL,now(),NULL,0,'Required',0,0,0,0,0,0,0),(5,'System-Guest-Network','System-Guest-Network',NULL,NULL,NULL,'Guest',NULL,1,0,NULL,now(),NULL,1,'Required',1,0,0,0,1,0,1),(6,'DefaultVirtualizedNetworkOffering','Virtual Vlan',NULL,NULL,NULL,'Guest',NULL,0,0,NULL,now(),NULL,1,'Required',1,1,1,1,1,1,1),(7,'DefaultDirectNetworkOffering','Direct',NULL,NULL,NULL,'Public',NULL,0,0,NULL,now(),NULL,1,'Required',1,0,0,0,1,0,1); @@ -565,3 +568,44 @@ DELETE FROM `cloud`.`sync_queue`; DELETE FROM `cloud`.`sync_queue_item`; DELETE FROM `cloud`.`async_job`; UPDATE `cloud`.`vm_template` SET unique_name='routing-xenserver-2.4',type='SYSTEM' WHERE name='systemvm-xenserver-2.4'; +DELETE FROM template_host_ref WHERE install_path LIKE '%xs-tools%' +DELETE FROM configuration where name='upgrade.url'; +DELETE FROM configuration where name='router.template.id'; +INSERT INTO configuration (category, instance, component, name, value, description) + VALUES ('Network', 'DEFAULT', 'AgentManager', 'remote.access.vpn.client.iprange', '10.1.2.1-10.1.2.8', 'The range of ips to be allocated to remote access vpn clients. The first ip in the range is used by the VPN server'); +INSERT INTO configuration (category, instance, component, name, value, description) + VALUES ('Network', 'DEFAULT', 'AgentManager', 'remote.access.vpn.psk.length', '48', 'The length of the ipsec preshared key (minimum 8, maximum 256)'); +INSERT INTO configuration (category, instance, component, name, value, description) + VALUES ('Network', 'DEFAULT', 'AgentManager', 'remote.access.vpn.user.limit', '8', 'The maximum number of VPN users that can be created per account'); +INSERT INTO configuration (category, instance, component, name, value, description) + VALUES ('Advanced', 'DEFAULT', 'management-server', 'management-server', NULL, 'The cidr of management server network'); +UPDATE vm_template set unique_name='routing_old' where id=1; +INSERT INTO vm_template (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones) + VALUES (10, 'routing', 'SystemVM Template', 0, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/releases/2.2/systemvm.vhd.bz2', 'bcc7f290f4c27ab4d0fe95d1012829ea', 0, 'SystemVM Template', 'VHD', 15, 0, 1); +Update configuration set name='storage.max.volume.size' where name='max.volume.size.mb'; +INSERT INTO sequence (name, value) + VALUES ('snapshots_seq', '1') +UPDATE cloud.sequence SET value=IF((SELECT COUNT(*) FROM cloud.snapshots) > 0, (SELECT max(id) FROM cloud.snapshots) + 1, 1) WHERE name='snapshots_seq' +UPDATE configuration set name='direct.attach.security.groups.enabled' where name='direct.attach.network.groups.enabled'; +UPDATE configuration set name='guest.domain.suffix' where name='domain.suffix'; + +INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (132, 2, 'Debian GNU/Linux 6(32-bit)'); +INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (133, 2, 'Debian GNU/Linux 6(64-bit)'); +INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (134, 3, 'Oracle Enterprise Linux 5.5 (32-bit)'); +INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (135, 3, 'Oracle Enterprise Linux 5.5 (64-bit)'); +INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (136, 4, 'Red Hat Enterprise Linux 6.0 (32-bit)'); +INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (137, 4, 'Red Hat Enterprise Linux 6.0 (64-bit)'); + +ALTER TABLE `cloud`.`instance_group` ADD CONSTRAINT `fk_instance_group__account_id` FOREIGN KEY `fk_instance_group__account_id` (`account_id`) REFERENCES `account` (`id`); + +ALTER TABLE `cloud`.`instance_group_vm_map` ADD CONSTRAINT `fk_instance_group_vm_map___group_id` FOREIGN KEY `fk_instance_group_vm_map___group_id` (`group_id`) REFERENCES `instance_group` (`id`) ON DELETE CASCADE; +ALTER TABLE `cloud`.`instance_group_vm_map` ADD CONSTRAINT `fk_instance_group_vm_map___instance_id` FOREIGN KEY `fk_instance_group_vm_map___instance_id` (`instance_id`) REFERENCES `user_vm` (`id`) ON DELETE CASCADE; + +ALTER TABLE `cloud`.`remote_access_vpn` ADD CONSTRAINT `fk_remote_access_vpn___account_id` FOREIGN KEY `fk_remote_access_vpn__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE; +ALTER TABLE `cloud`.`remote_access_vpn` ADD CONSTRAINT `fk_remote_access_vpn__zone_id` FOREIGN KEY `fk_remote_access_vpn__zone_id` (`zone_id`) REFERENCES `data_center` (`id`); +ALTER TABLE `cloud`.`remote_access_vpn` ADD CONSTRAINT `fk_remote_access_vpn__server_addr` FOREIGN KEY `fk_remote_access_vpn__server_addr` (`vpn_server_addr`) REFERENCES `user_ip_address` (`public_ip_address`); +ALTER TABLE `cloud`.`remote_access_vpn` ADD INDEX `i_remote_access_vpn_addr`(`vpn_server_addr`); + +ALTER TABLE `cloud`.`vpn_users` ADD CONSTRAINT `fk_vpn_users___account_id` FOREIGN KEY `fk_vpn_users__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE; +ALTER TABLE `cloud`.`vpn_users` ADD INDEX `i_vpn_users_username`(`username`); +ALTER TABLE `cloud`.`vpn_users` ADD UNIQUE `i_vpn_users__account_id__username`(`account_id`, `username`); \ No newline at end of file