You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by vi...@apache.org on 2013/08/10 03:25:24 UTC
[1/9] CLOUDSTACK-4167: Put in upgrade paths in master for 4.1.2 and
4.2
Updated Branches:
refs/heads/4.2 e61a38087 -> 0185c2f47
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d47b4a99/setup/db/db/schema-412to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-412to420.sql b/setup/db/db/schema-412to420.sql
new file mode 100644
index 0000000..cbd4fac
--- /dev/null
+++ b/setup/db/db/schema-412to420.sql
@@ -0,0 +1,2291 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied. See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+--;
+-- Schema upgrade from 4.1.0 to 4.2.0;
+--;
+
+-- Disable foreign key checking
+SET foreign_key_checks = 0;
+
+
+ALTER TABLE volumes ADD COLUMN vm_snapshot_chain_size bigint(20) unsigned;
+ALTER TABLE volumes ADD COLUMN iso_id bigint(20) unsigned;
+
+-- All new inserts to the hypervisor_capabilities table should be after this
+ALTER TABLE `cloud`.`hypervisor_capabilities` ADD CONSTRAINT `uc_hypervisor` UNIQUE (`hypervisor_type`, `hypervisor_version`);
+
+ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `max_hosts_per_cluster` int unsigned DEFAULT NULL COMMENT 'Max. hosts in cluster supported by hypervisor';
+ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `storage_motion_supported` int(1) unsigned DEFAULT 0 COMMENT 'Is storage motion supported';
+UPDATE `cloud`.`hypervisor_capabilities` SET `max_hosts_per_cluster`=32 WHERE `hypervisor_type`='VMware';
+INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, storage_motion_supported) VALUES (UUID(), 'XenServer', '6.1.0', 50, 1, 13, 1);
+INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, storage_motion_supported) VALUES (UUID(), 'XenServer', '6.2.0', 50, 1, 13, 1);
+INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES (UUID(), 'VMware', '5.1', 128, 0, 32);
+UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported`=true WHERE `hypervisor_type`='VMware' AND `hypervisor_version`='5.1';
+UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported`=true WHERE `hypervisor_type`='VMware' AND `hypervisor_version`='5.0';
+UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported`=true WHERE `hypervisor_type`='XenServer' AND `hypervisor_version`='6.1.0';
+UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported`=true WHERE `hypervisor_type`='XenServer' AND `hypervisor_version`='6.2.0';
+DELETE FROM `cloud`.`configuration` where name='vmware.percluster.host.max';
+DELETE FROM `cloud`.`configuration` where name='router.template.id';
+DELETE FROM `cloud`.`configuration` where name='swift.enable';
+DELETE FROM `cloud`.`configuration` where name='s3.enable';
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'AgentManager', 'xen.nics.max', '7', 'Maximum allowed nics for Vms created on Xen');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'vmware.use.dvswitch', 'false', 'Enable/Disable Nexus/Vmware dvSwitch in VMware environment');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'vmware.ports.per.dvportgroup', '256', 'Default number of ports per Vmware dvPortGroup in VMware environment');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'midonet.apiserver.address', 'http://localhost:8081', 'Specify the address at which the Midonet API server can be contacted (if using Midonet)');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'midonet.providerrouter.id', 'd7c5e6a3-e2f4-426b-b728-b7ce6a0448e5', 'Specifies the UUID of the Midonet provider router (if using Midonet)');
+ALTER TABLE `cloud`.`load_balancer_vm_map` ADD state VARCHAR(40) NULL COMMENT 'service status updated by LB healthcheck manager';
+
+ALTER TABLE `cloud`.`vm_template` ADD COLUMN `dynamically_scalable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory';
+ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `dynamically_scalable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if VM contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory';
+UPDATE `cloud`.`vm_template` SET dynamically_scalable = 1 WHERE name = "CentOS 5.6(64-bit) no GUI (XenServer)" AND type = "BUILTIN";
+UPDATE `cloud`.`vm_template` SET dynamically_scalable = 1 WHERE name = "SystemVM Template (vSphere)" AND type = "SYSTEM";
+
+alter table storage_pool add hypervisor varchar(32);
+alter table storage_pool change storage_provider_id storage_provider_name varchar(255);
+alter table storage_pool change available_bytes used_bytes bigint unsigned;
+-- alter table template_host_ref add state varchar(255);
+-- alter table template_host_ref add update_count bigint unsigned;
+-- alter table template_host_ref add updated datetime;
+-- alter table volume_host_ref add state varchar(255);
+-- alter table volume_host_ref add update_count bigint unsigned;
+-- alter table volume_host_ref add updated datetime;
+alter table template_spool_ref add updated datetime;
+UPDATE `cloud`.`template_spool_ref` set state='Ready' WHERE download_state = 'DOWNLOADED';
+UPDATE `cloud`.`template_spool_ref` set update_count=0;
+
+
+CREATE TABLE `cloud`.`object_datastore_ref` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `datastore_uuid` varchar(255) NOT NULL,
+ `datastore_role` varchar(255) NOT NULL,
+ `object_uuid` varchar(255) NOT NULL,
+ `object_type` varchar(255) NOT NULL,
+ `created` DATETIME NOT NULL,
+ `last_updated` DATETIME,
+ `job_id` varchar(255),
+ `download_pct` int(10) unsigned,
+ `download_state` varchar(255),
+ `url` varchar(255),
+ `format` varchar(255),
+ `checksum` varchar(255),
+ `error_str` varchar(255),
+ `local_path` varchar(255),
+ `install_path` varchar(255),
+ `size` bigint unsigned COMMENT 'the size of the template on the pool',
+ `state` varchar(255) NOT NULL,
+ `update_count` bigint unsigned NOT NULL,
+ `updated` DATETIME,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+
+-- CREATE TABLE `cloud`.`data_store_provider` (
+-- `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+-- `name` varchar(255) NOT NULL COMMENT 'name of primary data store provider',
+-- `uuid` varchar(255) NOT NULL COMMENT 'uuid of primary data store provider',
+-- PRIMARY KEY(`id`)
+-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 's3.rrs.enabled', 'false', 'enable s3 reduced redundancy storage');
+
+CREATE TABLE `cloud`.`image_store` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `name` varchar(255) NOT NULL COMMENT 'name of data store',
+ `image_provider_name` varchar(255) NOT NULL COMMENT 'id of image_store_provider',
+ `protocol` varchar(255) NOT NULL COMMENT 'protocol of data store',
+ `url` varchar(255) COMMENT 'url for image data store',
+ `data_center_id` bigint unsigned COMMENT 'datacenter id of data store',
+ `scope` varchar(255) COMMENT 'scope of data store',
+ `role` varchar(255) COMMENT 'role of data store',
+ `uuid` varchar(255) COMMENT 'uuid of data store',
+ `parent` varchar(255) COMMENT 'parent path for the storage server',
+ `created` datetime COMMENT 'date the image store first signed on',
+ `removed` datetime COMMENT 'date removed if not null',
+ `total_size` bigint unsigned COMMENT 'storage total size statistics',
+ `used_bytes` bigint unsigned COMMENT 'storage available bytes statistics',
+ PRIMARY KEY(`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`image_store_details` (
+ `id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `store_id` bigint unsigned NOT NULL COMMENT 'store the detail is related to',
+ `name` varchar(255) NOT NULL COMMENT 'name of the detail',
+ `value` varchar(255) NOT NULL COMMENT 'value of the detail',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_image_store_details__store_id` FOREIGN KEY `fk_image_store__store_id`(`store_id`) REFERENCES `image_store`(`id`) ON DELETE CASCADE,
+ INDEX `i_image_store__name__value`(`name`(128), `value`(128))
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP VIEW IF EXISTS `cloud`.`image_store_view`;
+CREATE VIEW `cloud`.`image_store_view` AS
+ select
+ image_store.id,
+ image_store.uuid,
+ image_store.name,
+ image_store.image_provider_name,
+ image_store.protocol,
+ image_store.url,
+ image_store.scope,
+ image_store.role,
+ image_store.removed,
+ data_center.id data_center_id,
+ data_center.uuid data_center_uuid,
+ data_center.name data_center_name,
+ image_store_details.name detail_name,
+ image_store_details.value detail_value
+ from
+ `cloud`.`image_store`
+ left join
+ `cloud`.`data_center` ON image_store.data_center_id = data_center.id
+ left join
+ `cloud`.`image_store_details` ON image_store_details.store_id = image_store.id;
+
+
+-- here we have to allow null for store_id to accomodate baremetal case to search for ready templates since template state is only stored in this table
+-- FK also commented out due to this
+CREATE TABLE `cloud`.`template_store_ref` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `store_id` bigint unsigned,
+ `template_id` bigint unsigned NOT NULL,
+ `created` DATETIME NOT NULL,
+ `last_updated` DATETIME,
+ `job_id` varchar(255),
+ `download_pct` int(10) unsigned,
+ `size` bigint unsigned,
+ `store_role` varchar(255),
+ `physical_size` bigint unsigned DEFAULT 0,
+ `download_state` varchar(255),
+ `error_str` varchar(255),
+ `local_path` varchar(255),
+ `install_path` varchar(255),
+ `url` varchar(255),
+ `download_url` varchar(255),
+ `download_url_created` datetime,
+ `state` varchar(255) NOT NULL,
+ `destroyed` tinyint(1) COMMENT 'indicates whether the template_store entry was destroyed by the user or not',
+ `is_copy` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates whether this was copied ',
+ `update_count` bigint unsigned,
+ `ref_cnt` bigint unsigned DEFAULT 0,
+ `updated` datetime,
+ PRIMARY KEY (`id`),
+-- CONSTRAINT `fk_template_store_ref__store_id` FOREIGN KEY `fk_template_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
+ INDEX `i_template_store_ref__store_id`(`store_id`),
+ CONSTRAINT `fk_template_store_ref__template_id` FOREIGN KEY `fk_template_store_ref__template_id` (`template_id`) REFERENCES `vm_template` (`id`),
+ INDEX `i_template_store_ref__template_id`(`template_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+-- ALTER TABLE `cloud`.`vm_template` ADD COLUMN `image_data_store_id` bigint unsigned;
+
+-- Do we still need these columns? TODO, to delete them, remove FK constraints from snapshots table
+-- ALTER TABLE `cloud`.`snapshots` DROP COLUMN `swift_id`;
+-- ALTER TABLE `cloud`.`snapshots` DROP COLUMN `s3_id`;
+-- ALTER TABLE `cloud`.`snapshots` DROP COLUMN `sechost_id`;
+
+-- change upload host_id FK to point to image_store table
+ALTER TABLE `cloud`.`upload` DROP FOREIGN KEY `fk_upload__host_id`;
+ALTER TABLE `cloud`.`upload` ADD CONSTRAINT `fk_upload__store_id` FOREIGN KEY(`host_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE;
+
+CREATE TABLE `cloud`.`snapshot_store_ref` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `store_id` bigint unsigned NOT NULL,
+ `snapshot_id` bigint unsigned NOT NULL,
+ `created` DATETIME NOT NULL,
+ `last_updated` DATETIME,
+ `job_id` varchar(255),
+ `store_role` varchar(255),
+ `size` bigint unsigned,
+ `physical_size` bigint unsigned DEFAULT 0,
+ `parent_snapshot_id` bigint unsigned DEFAULT 0,
+ `install_path` varchar(255),
+ `state` varchar(255) NOT NULL,
+ -- `removed` datetime COMMENT 'date removed if not null',
+ `update_count` bigint unsigned,
+ `ref_cnt` bigint unsigned,
+ `updated` datetime,
+ `volume_id` bigint unsigned,
+ PRIMARY KEY (`id`),
+ INDEX `i_snapshot_store_ref__store_id`(`store_id`),
+ CONSTRAINT `fk_snapshot_store_ref__snapshot_id` FOREIGN KEY `fk_snapshot_store_ref__snapshot_id` (`snapshot_id`) REFERENCES `snapshots` (`id`),
+ INDEX `i_snapshot_store_ref__snapshot_id`(`snapshot_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`volume_store_ref` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `store_id` bigint unsigned NOT NULL,
+ `volume_id` bigint unsigned NOT NULL,
+ `zone_id` bigint unsigned NOT NULL,
+ `created` DATETIME NOT NULL,
+ `last_updated` DATETIME,
+ `job_id` varchar(255),
+ `download_pct` int(10) unsigned,
+ `size` bigint unsigned,
+ `physical_size` bigint unsigned DEFAULT 0,
+ `download_state` varchar(255),
+ `checksum` varchar(255) COMMENT 'checksum for the data disk',
+ `error_str` varchar(255),
+ `local_path` varchar(255),
+ `install_path` varchar(255),
+ `url` varchar(255),
+ `download_url` varchar(255),
+ `download_url_created` datetime,
+ `state` varchar(255) NOT NULL,
+ `destroyed` tinyint(1) COMMENT 'indicates whether the volume_host entry was destroyed by the user or not',
+ `update_count` bigint unsigned,
+ `ref_cnt` bigint unsigned,
+ `updated` datetime,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_volume_store_ref__store_id` FOREIGN KEY `fk_volume_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
+ INDEX `i_volume_store_ref__store_id`(`store_id`),
+ CONSTRAINT `fk_volume_store_ref__volume_id` FOREIGN KEY `fk_volume_store_ref__volume_id` (`volume_id`) REFERENCES `volumes` (`id`),
+ INDEX `i_volume_store_ref__volume_id`(`volume_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
+
+
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `is_volatile` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the vm needs to be volatile, i.e., on every reboot of vm from API root disk is discarded and creates a new root disk';
+
+ALTER TABLE `cloud`.`networks` ADD COLUMN `network_cidr` VARCHAR(18) COMMENT 'The network cidr for the isolated guest network which uses IP Reservation facility.For networks not using IP reservation, network_cidr is always null.';
+ALTER TABLE `cloud`.`networks` CHANGE `cidr` `cidr` varchar(18) COMMENT 'CloudStack managed vms get IP address from cidr.In general this cidr also serves as the network CIDR. But in case IP reservation feature is being used by a Guest network, networkcidr is the Effective network CIDR for that network';
+
+
+CREATE TABLE `vpc_service_map` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `vpc_id` bigint unsigned NOT NULL COMMENT 'vpc_id',
+ `service` varchar(255) NOT NULL COMMENT 'service',
+ `provider` varchar(255) COMMENT 'service provider',
+ `created` datetime COMMENT 'date created',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_vpc_service_map__vpc_id` FOREIGN KEY(`vpc_id`) REFERENCES `vpc`(`id`) ON DELETE CASCADE,
+ UNIQUE (`vpc_id`, `service`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`load_balancer_healthcheck_policies` (
+ `id` bigint(20) NOT NULL auto_increment,
+ `uuid` varchar(40),
+ `load_balancer_id` bigint unsigned NOT NULL,
+ `pingpath` varchar(225) NULL DEFAULT '/',
+ `description` varchar(4096) NULL,
+ `response_time` int(11) DEFAULT 5,
+ `healthcheck_interval` int(11) DEFAULT 5,
+ `healthcheck_thresshold` int(11) DEFAULT 2,
+ `unhealth_thresshold` int(11) DEFAULT 10,
+ `revoke` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 is when rule is set for Revoke',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `id_UNIQUE` (`id`),
+ CONSTRAINT `fk_load_balancer_healthcheck_policies_loadbalancer_id` FOREIGN KEY(`load_balancer_id`) REFERENCES `load_balancing_rules`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.instancename.flag', 'false', 'If set to true, will set guest VM\'s name as it appears on the hypervisor, to its hostname');
+
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (165, UUID(), 6, 'Windows 8 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (166, UUID(), 6, 'Windows 8 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (167, UUID(), 6, 'Windows Server 2012 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (168, UUID(), 6, 'Windows Server 8 (64-bit)');
+
+# clean up row added in 3.0.6.
+UPDATE `cloud`.`guest_os_hypervisor` set guest_os_id = 166 where guest_os_id = 206;
+UPDATE `cloud`.`vm_template` set guest_os_id = 166 where guest_os_id = 206;
+UPDATE `cloud`.`vm_instance` set guest_os_id = 166 where guest_os_id = 206;
+DELETE IGNORE FROM `cloud`.`guest_os` where id=206;
+
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (141, UUID(), 1, 'CentOS 5.6 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (142, UUID(), 1, 'CentOS 5.6 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (169, UUID(), 10, 'Ubuntu 11.04 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (170, UUID(), 10, 'Ubuntu 11.04 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (171, UUID(), 1, 'CentOS 6.3 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (172, UUID(), 1, 'CentOS 6.3 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (173, UUID(), 1, 'CentOS 5.8 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (174, UUID(), 1, 'CentOS 5.8 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (175, UUID(), 1, 'CentOS 5.9 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (176, UUID(), 1, 'CentOS 5.9 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (177, UUID(), 1, 'CentOS 6.1 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (178, UUID(), 1, 'CentOS 6.1 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (179, UUID(), 1, 'CentOS 6.2 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (180, UUID(), 1, 'CentOS 6.2 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (181, UUID(), 1, 'CentOS 6.4 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (182, UUID(), 1, 'CentOS 6.4 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (183, UUID(), 2, 'Debian GNU/Linux 7(32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (184, UUID(), 2, 'Debian GNU/Linux 7(64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (185, UUID(), 5, 'SUSE Linux Enterprise Server 11 SP2 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (186, UUID(), 5, 'SUSE Linux Enterprise Server 11 SP2 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (187, UUID(), 5, 'SUSE Linux Enterprise Server 11 SP3 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (188, UUID(), 5, 'SUSE Linux Enterprise Server 11 SP3 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (189, UUID(), 4, 'Red Hat Enterprise Linux 5.7 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (190, UUID(), 4, 'Red Hat Enterprise Linux 5.7 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (191, UUID(), 4, 'Red Hat Enterprise Linux 5.8 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (192, UUID(), 4, 'Red Hat Enterprise Linux 5.8 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (193, UUID(), 4, 'Red Hat Enterprise Linux 5.9 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (194, UUID(), 4, 'Red Hat Enterprise Linux 5.9 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (195, UUID(), 4, 'Red Hat Enterprise Linux 6.1 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (196, UUID(), 4, 'Red Hat Enterprise Linux 6.1 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (197, UUID(), 4, 'Red Hat Enterprise Linux 6.2 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (198, UUID(), 4, 'Red Hat Enterprise Linux 6.2 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (199, UUID(), 4, 'Red Hat Enterprise Linux 6.3 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (204, UUID(), 4, 'Red Hat Enterprise Linux 6.3 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (205, UUID(), 4, 'Red Hat Enterprise Linux 6.4 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (206, UUID(), 4, 'Red Hat Enterprise Linux 6.4 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (207, UUID(), 3, 'Oracle Enterprise Linux 5.7 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (208, UUID(), 3, 'Oracle Enterprise Linux 5.7 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (209, UUID(), 3, 'Oracle Enterprise Linux 5.8 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (210, UUID(), 3, 'Oracle Enterprise Linux 5.8 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (211, UUID(), 3, 'Oracle Enterprise Linux 5.9 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (212, UUID(), 3, 'Oracle Enterprise Linux 5.9 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (213, UUID(), 3, 'Oracle Enterprise Linux 6.1 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (214, UUID(), 3, 'Oracle Enterprise Linux 6.1 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (215, UUID(), 3, 'Oracle Enterprise Linux 6.2 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (216, UUID(), 3, 'Oracle Enterprise Linux 6.2 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (217, UUID(), 3, 'Oracle Enterprise Linux 6.3 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (218, UUID(), 3, 'Oracle Enterprise Linux 6.3 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (219, UUID(), 3, 'Oracle Enterprise Linux 6.4 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (220, UUID(), 3, 'Oracle Enterprise Linux 6.4 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (221, UUID(), 7, 'Apple Mac OS X 10.6 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (222, UUID(), 7, 'Apple Mac OS X 10.6 (64-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (223, UUID(), 7, 'Apple Mac OS X 10.7 (32-bit)');
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (224, UUID(), 7, 'Apple Mac OS X 10.7 (64-bit)');
+
+
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows 8 (32-bit)', 165);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows 8 (64-bit)', 166);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows Server 2012 (64-bit)', 167);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows Server 8 (64-bit)', 168);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows 8 (32-bit)', 165);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows 8 (64-bit)', 166);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows Server 2012 (64-bit)', 167);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows Server 8 (64-bit)', 168);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.5 (32-bit)', 111);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.5 (64-bit)', 112);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.6 (32-bit)', 141);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.6 (64-bit)', 142);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.7 (32-bit)', 161);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.7 (64-bit)', 162);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.8 (32-bit)', 173);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.8 (64-bit)', 174);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.9 (32-bit)', 175);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.9 (64-bit)', 176);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.0 (32-bit)', 143);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.0 (64-bit)', 144);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.1 (32-bit)', 177);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.1 (64-bit)', 178);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.2 (32-bit)', 179);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.2 (64-bit)', 180);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.3 (32-bit)', 171);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.3 (64-bit)', 172);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.4 (32-bit)', 181);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.4 (64-bit)', 182);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Debian GNU/Linux 7(32-bit)', 183);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Debian GNU/Linux 7(64-bit)', 184);
+
+INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Apple Mac OS X 10.6 (32-bit)', 221);
+INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Apple Mac OS X 10.6 (64-bit)', 222);
+INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Apple Mac OS X 10.7 (32-bit)', 223);
+INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Apple Mac OS X 10.7 (64-bit)', 224);
+
+CREATE TABLE `cloud`.`user_vm_clone_setting` (
+ `vm_id` bigint unsigned NOT NULL COMMENT 'guest VM id',
+ `clone_type` varchar(10) NOT NULL COMMENT 'Full or Linked Clone (applicable to VMs on ESX)',
+ PRIMARY KEY (`vm_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'UserVmManager', 'vmware.create.full.clone' , 'false', 'If set to true, creates VMs as full clones on ESX hypervisor');
+
+CREATE TABLE `cloud`.`affinity_group` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `name` varchar(255) NOT NULL,
+ `type` varchar(255) NOT NULL,
+ `uuid` varchar(40),
+ `description` varchar(4096) NULL,
+ `domain_id` bigint unsigned NOT NULL,
+ `account_id` bigint unsigned NOT NULL,
+ UNIQUE (`name`, `account_id`),
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_affinity_group__account_id` FOREIGN KEY(`account_id`) REFERENCES `account`(`id`),
+ CONSTRAINT `fk_affinity_group__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`),
+ CONSTRAINT `uc_affinity_group__uuid` UNIQUE (`uuid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`affinity_group_vm_map` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `affinity_group_id` bigint unsigned NOT NULL,
+ `instance_id` bigint unsigned NOT NULL,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_agvm__group_id` FOREIGN KEY(`affinity_group_id`) REFERENCES `affinity_group`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_affinity_group_vm_map___instance_id` FOREIGN KEY(`instance_id`) REFERENCES `user_vm` (`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+
+CREATE TABLE `cloud`.`dedicated_resources` (
+ `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
+ `uuid` varchar(40),
+ `data_center_id` bigint unsigned COMMENT 'data center id',
+ `pod_id` bigint unsigned COMMENT 'pod id',
+ `cluster_id` bigint unsigned COMMENT 'cluster id',
+ `host_id` bigint unsigned COMMENT 'host id',
+ `domain_id` bigint unsigned COMMENT 'domain id of the domain to which resource is dedicated',
+ `account_id` bigint unsigned COMMENT 'account id of the account to which resource is dedicated',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_dedicated_resources__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `cloud`.`data_center`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_dedicated_resources__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`),
+ CONSTRAINT `fk_dedicated_resources__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cloud`.`cluster`(`id`),
+ CONSTRAINT `fk_dedicated_resources__host_id` FOREIGN KEY (`host_id`) REFERENCES `cloud`.`host`(`id`),
+ CONSTRAINT `fk_dedicated_resources__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`),
+ CONSTRAINT `fk_dedicated_resources__account_id` FOREIGN KEY (`account_id`) REFERENCES `account`(`id`),
+ INDEX `i_dedicated_resources_domain_id`(`domain_id`),
+ INDEX `i_dedicated_resources_account_id`(`account_id`),
+ CONSTRAINT `uc_dedicated_resources__uuid` UNIQUE (`uuid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE nic_secondary_ips (
+ `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT,
+ `uuid` varchar(40),
+ `vmId` bigint unsigned COMMENT 'vm instance id',
+ `nicId` bigint unsigned NOT NULL,
+ `ip4_address` char(40) COMMENT 'ip4 address',
+ `ip6_address` char(40) COMMENT 'ip6 address',
+ `network_id` bigint unsigned NOT NULL COMMENT 'network configuration id',
+ `created` datetime NOT NULL COMMENT 'date created',
+ `account_id` bigint unsigned NOT NULL COMMENT 'owner. foreign key to account table',
+ `domain_id` bigint unsigned NOT NULL COMMENT 'the domain that the owner belongs to',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_nic_secondary_ip__vmId` FOREIGN KEY `fk_nic_secondary_ip__vmId`(`vmId`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_nic_secondary_ip__networks_id` FOREIGN KEY `fk_nic_secondary_ip__networks_id`(`network_id`) REFERENCES `networks`(`id`),
+ CONSTRAINT `uc_nic_secondary_ip__uuid` UNIQUE (`uuid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+ALTER TABLE `cloud`.`nics` ADD COLUMN secondary_ip SMALLINT DEFAULT '0' COMMENT 'secondary ips configured for the nic';
+ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN dnat_vmip VARCHAR(40);
+UPDATE `cloud`.`user_ip_address`,`cloud`.`nics` SET `user_ip_address`.`dnat_vmip` = `nics`.`ip4_address`
+ WHERE `user_ip_address`.`vm_id` = `nics`.`instance_id` AND `user_ip_address`.`network_id` = `nics`.`network_id` AND `user_ip_address`.`one_to_one_nat` = 1;
+
+ALTER TABLE `cloud`.`alert` ADD COLUMN `archived` tinyint(1) unsigned NOT NULL DEFAULT 0;
+ALTER TABLE `cloud`.`event` ADD COLUMN `archived` tinyint(1) unsigned NOT NULL DEFAULT 0;
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'alert.purge.interval', '86400', 'The interval (in seconds) to wait before running the alert purge thread');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'alert.purge.delay', '0', 'Alerts older than specified number days will be purged. Set this value to 0 to never delete alerts');
+
+INSERT INTO `cloud`.`dedicated_resources` (`data_center_id`, `domain_id`) SELECT `id`, `domain_id` FROM `cloud`.`data_center` WHERE `domain_id` IS NOT NULL;
+UPDATE `cloud`.`data_center` SET `domain_id` = NULL WHERE `domain_id` IS NOT NULL;
+
+DROP VIEW IF EXISTS `cloud`.`event_view`;
+CREATE VIEW `cloud`.`event_view` AS
+ select
+ event.id,
+ event.uuid,
+ event.type,
+ event.state,
+ event.description,
+ event.created,
+ event.level,
+ event.parameters,
+ event.start_id,
+ eve.uuid start_uuid,
+ event.user_id,
+ event.archived,
+ user.username user_name,
+ account.id account_id,
+ account.uuid account_uuid,
+ account.account_name account_name,
+ account.type account_type,
+ domain.id domain_id,
+ domain.uuid domain_uuid,
+ domain.name domain_name,
+ domain.path domain_path,
+ projects.id project_id,
+ projects.uuid project_uuid,
+ projects.name project_name
+ from
+ `cloud`.`event`
+ inner join
+ `cloud`.`account` ON event.account_id = account.id
+ inner join
+ `cloud`.`domain` ON event.domain_id = domain.id
+ inner join
+ `cloud`.`user` ON event.user_id = user.id
+ left join
+ `cloud`.`projects` ON projects.project_account_id = event.account_id
+ left join
+ `cloud`.`event` eve ON event.start_id = eve.id;
+
+ALTER TABLE `cloud`.`region` ADD COLUMN `gslb_service_enabled` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT 'Is GSLB service enalbed in the Region';
+
+ALTER TABLE `cloud`.`external_load_balancer_devices` ADD COLUMN `is_gslb_provider` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if load balancer appliance is acting as gslb service provider in the zone';
+
+ALTER TABLE `cloud`.`external_load_balancer_devices` ADD COLUMN `gslb_site_publicip` varchar(255) DEFAULT NULL COMMENT 'GSLB service Provider site public ip';
+
+ALTER TABLE `cloud`.`external_load_balancer_devices` ADD COLUMN `gslb_site_privateip` varchar(255) DEFAULT NULL COMMENT 'GSLB service Provider site private ip';
+
+ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `display_vm` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should vm instance be displayed to the end user';
+
+ALTER TABLE `cloud`.`user_vm_details` ADD COLUMN `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should vm detail instance be displayed to the end user';
+
+ALTER TABLE `cloud`.`volumes` ADD COLUMN `display_volume` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should volume be displayed to the end user';
+
+ALTER TABLE `cloud`.`volumes` ADD COLUMN `format` varchar(255) COMMENT 'volume format';
+update `cloud`.`volumes` v, `cloud`.`storage_pool` s, `cloud`.`cluster` c set v.format='VHD' where v.pool_id=s.id and s.cluster_id=c.id and c.hypervisor_type='XenServer';
+update `cloud`.`volumes` v, `cloud`.`storage_pool` s, `cloud`.`cluster` c set v.format='OVA' where v.pool_id=s.id and s.cluster_id=c.id and c.hypervisor_type='VMware';
+update `cloud`.`volumes` v, `cloud`.`storage_pool` s, `cloud`.`cluster` c set v.format='QCOW2' where v.pool_id=s.id and s.cluster_id=c.id and c.hypervisor_type='KVM';
+update `cloud`.`volumes` v, `cloud`.`storage_pool` s, `cloud`.`cluster` c set v.format='RAW' where v.pool_id=s.id and s.cluster_id=c.id and c.hypervisor_type='Ovm';
+
+ALTER TABLE `cloud`.`networks` ADD COLUMN `display_network` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should network be displayed to the end user';
+
+ALTER TABLE `cloud`.`nics` ADD COLUMN `display_nic` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should nic be displayed to the end user';
+
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `display_offering` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should disk offering be displayed to the end user';
+
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `customized_iops` tinyint(1) unsigned COMMENT 'Should customized IOPS be displayed to the end user';
+
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `min_iops` bigint(20) unsigned COMMENT 'Minimum IOPS';
+
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `max_iops` bigint(20) unsigned COMMENT 'Maximum IOPS';
+
+ALTER TABLE `cloud`.`volumes` ADD COLUMN `min_iops` bigint(20) unsigned COMMENT 'Minimum IOPS';
+
+ALTER TABLE `cloud`.`volumes` ADD COLUMN `max_iops` bigint(20) unsigned COMMENT 'Maximum IOPS';
+
+ALTER TABLE `cloud`.`storage_pool` ADD COLUMN `managed` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Should CloudStack manage this storage';
+
+ALTER TABLE `cloud`.`storage_pool` ADD COLUMN `capacity_iops` bigint(20) unsigned DEFAULT NULL COMMENT 'IOPS CloudStack can provision from this storage pool';
+
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_read_rate` bigint(20);
+
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_write_rate` bigint(20);
+
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_read_rate` bigint(20);
+
+ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_write_rate` bigint(20);
+
+CREATE TABLE `cloud`.`volume_details` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `volume_id` bigint unsigned NOT NULL COMMENT 'volume id',
+ `name` varchar(255) NOT NULL,
+ `value` varchar(1024) NOT NULL,
+ `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_volume_details__volume_id` FOREIGN KEY `fk_volume_details__volume_id`(`volume_id`) REFERENCES `volumes`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`network_details` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `network_id` bigint unsigned NOT NULL COMMENT 'network id',
+ `name` varchar(255) NOT NULL,
+ `value` varchar(1024) NOT NULL,
+ `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_network_details__network_id` FOREIGN KEY `fk_network_details__network_id`(`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`nic_details` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `nic_id` bigint unsigned NOT NULL COMMENT 'nic id',
+ `name` varchar(255) NOT NULL,
+ `value` varchar(1024) NOT NULL,
+ `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_nic_details__nic_id` FOREIGN KEY `fk_nic_details__nic_id`(`nic_id`) REFERENCES `nics`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`disk_offering_details` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `offering_id` bigint unsigned NOT NULL COMMENT 'offering id',
+ `name` varchar(255) NOT NULL,
+ `value` varchar(1024) NOT NULL,
+ `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_offering_details__offering_id` FOREIGN KEY `fk_offering_details__offering_id`(`offering_id`) REFERENCES `disk_offering`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`global_load_balancing_rules` (
+ `id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
+ `uuid` varchar(40),
+ `account_id` bigint unsigned NOT NULL COMMENT 'account id',
+ `domain_id` bigint unsigned NOT NULL COMMENT 'domain id',
+ `region_id` int unsigned NOT NULL,
+ `name` varchar(255) NOT NULL,
+ `description` varchar(4096) NULL COMMENT 'description',
+ `state` char(32) NOT NULL COMMENT 'current state of this rule',
+ `algorithm` varchar(255) NOT NULL COMMENT 'load balancing algorithm used to distribbute traffic across zones',
+ `persistence` varchar(255) NOT NULL COMMENT 'session persistence used across the zone',
+ `service_type` varchar(255) NOT NULL COMMENT 'GSLB service type (tcp/udp)',
+ `gslb_domain_name` varchar(255) NOT NULL COMMENT 'DNS name for the GSLB service that is used to provide a FQDN for the GSLB service',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_global_load_balancing_rules_account_id` FOREIGN KEY (`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_global_load_balancing_rules_region_id` FOREIGN KEY(`region_id`) REFERENCES `region`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`global_load_balancer_lb_rule_map` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `gslb_rule_id` bigint unsigned NOT NULL,
+ `lb_rule_id` bigint unsigned NOT NULL,
+ `weight` bigint unsigned NOT NULL DEFAULT 1 COMMENT 'weight of the site in gslb',
+ `revoke` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 is when rule is set for Revoke',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY (`gslb_rule_id`, `lb_rule_id`),
+ CONSTRAINT `fk_gslb_rule_id` FOREIGN KEY(`gslb_rule_id`) REFERENCES `global_load_balancing_rules`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_lb_rule_id` FOREIGN KEY(`lb_rule_id`) REFERENCES `load_balancing_rules`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'cloud.dns.name', null, 'DNS name of the cloud for the GSLB service');
+
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT', 'management-server', 'max.account.cpus', '40', 'The default maximum number of cpu cores that can be used for an account');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT', 'management-server', 'max.account.memory', '40960', 'The default maximum memory (in MiB) that can be used for an account');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT', 'management-server', 'max.account.primary.storage', '200', 'The default maximum primary storage space (in GiB) that can be used for an account');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT', 'management-server', 'max.account.secondary.storage', '400', 'The default maximum secondary storage space (in GiB) that can be used for an account');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Project Defaults', 'DEFAULT', 'management-server', 'max.project.cpus', '40', 'The default maximum number of cpu cores that can be used for a project');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Project Defaults', 'DEFAULT', 'management-server', 'max.project.memory', '40960', 'The default maximum memory (in MiB) that can be used for a project');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Project Defaults', 'DEFAULT', 'management-server', 'max.project.primary.storage', '200', 'The default maximum primary storage space (in GiB) that can be used for a project');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Project Defaults', 'DEFAULT', 'management-server', 'max.project.secondary.storage', '400', 'The default maximum secondary storage space (in GiB) that can be used for a project');
+
+
+
+ALTER TABLE `cloud`.`remote_access_vpn` ADD COLUMN `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id';
+ALTER TABLE `cloud`.`remote_access_vpn` ADD COLUMN `uuid` varchar(40) UNIQUE;
+
+-- START: support for LXC
+
+INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES (UUID(), 'LXC', 'default', 50, 1);
+ALTER TABLE `cloud`.`physical_network_traffic_types` ADD COLUMN `lxc_network_label` varchar(255) DEFAULT 'cloudbr0' COMMENT 'The network name label of the physical device dedicated to this traffic on a LXC host';
+
+UPDATE configuration SET value='KVM,XenServer,VMware,BareMetal,Ovm,LXC' WHERE name='hypervisor.list';
+
+INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type)
+ VALUES (10, UUID(), 'routing-10', 'SystemVM Template (LXC)', 0, now(), 'SYSTEM', 0, 64, 1, 'http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2', '2755de1f9ef2ce4d6f2bee2efbb4da92', 0, 'SystemVM Template (LXC)', 'QCOW2', 15, 0, 1, 'LXC');
+
+ALTER TABLE `cloud`.`user_vm` MODIFY user_data TEXT(32768);
+
+-- END: support for LXC
+
+CREATE TABLE `cloud`.`vm_snapshots` (
+ `id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Primary Key',
+ `uuid` varchar(40) NOT NULL,
+ `name` varchar(255) NOT NULL,
+ `display_name` varchar(255) default NULL,
+ `description` varchar(255) default NULL,
+ `vm_id` bigint(20) unsigned NOT NULL,
+ `account_id` bigint(20) unsigned NOT NULL,
+ `domain_id` bigint(20) unsigned NOT NULL,
+ `vm_snapshot_type` varchar(32) default NULL,
+ `state` varchar(32) NOT NULL,
+ `parent` bigint unsigned default NULL,
+ `current` int(1) unsigned default NULL,
+ `update_count` bigint unsigned NOT NULL DEFAULT 0,
+ `updated` datetime default NULL,
+ `created` datetime default NULL,
+ `removed` datetime default NULL,
+ PRIMARY KEY (`id`),
+ CONSTRAINT UNIQUE KEY `uc_vm_snapshots_uuid` (`uuid`),
+ INDEX `vm_snapshots_name` (`name`),
+ INDEX `vm_snapshots_vm_id` (`vm_id`),
+ INDEX `vm_snapshots_account_id` (`account_id`),
+ INDEX `vm_snapshots_display_name` (`display_name`),
+ INDEX `vm_snapshots_removed` (`removed`),
+ INDEX `vm_snapshots_parent` (`parent`),
+ CONSTRAINT `fk_vm_snapshots_vm_id__vm_instance_id` FOREIGN KEY `fk_vm_snapshots_vm_id__vm_instance_id` (`vm_id`) REFERENCES `vm_instance` (`id`),
+ CONSTRAINT `fk_vm_snapshots_account_id__account_id` FOREIGN KEY `fk_vm_snapshots_account_id__account_id` (`account_id`) REFERENCES `account` (`id`),
+ CONSTRAINT `fk_vm_snapshots_domain_id__domain_id` FOREIGN KEY `fk_vm_snapshots_domain_id__domain_id` (`domain_id`) REFERENCES `domain` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `vm_snapshot_enabled` tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Whether VM snapshot is supported by hypervisor';
+UPDATE `cloud`.`hypervisor_capabilities` SET `vm_snapshot_enabled`=1 WHERE `hypervisor_type` in ('VMware', 'XenServer');
+
+CREATE TABLE `cloud`.`service_offering_details` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `service_offering_id` bigint unsigned NOT NULL COMMENT 'service offering id',
+ `name` varchar(255) NOT NULL,
+ `value` varchar(255) NOT NULL,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_service_offering_details__service_offering_id` FOREIGN KEY (`service_offering_id`) REFERENCES `service_offering`(`id`) ON DELETE CASCADE,
+ CONSTRAINT UNIQUE KEY `uk_service_offering_id_name` (`service_offering_id`, `name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+DROP VIEW IF EXISTS `cloud`.`user_vm_view`;
+CREATE VIEW `cloud`.`user_vm_view` AS
+ select
+ vm_instance.id id,
+ vm_instance.name name,
+ user_vm.display_name display_name,
+ user_vm.user_data user_data,
+ account.id account_id,
+ account.uuid account_uuid,
+ account.account_name account_name,
+ account.type account_type,
+ domain.id domain_id,
+ domain.uuid domain_uuid,
+ domain.name domain_name,
+ domain.path domain_path,
+ projects.id project_id,
+ projects.uuid project_uuid,
+ projects.name project_name,
+ instance_group.id instance_group_id,
+ instance_group.uuid instance_group_uuid,
+ instance_group.name instance_group_name,
+ vm_instance.uuid uuid,
+ vm_instance.last_host_id last_host_id,
+ vm_instance.vm_type type,
+ vm_instance.vnc_password vnc_password,
+ vm_instance.limit_cpu_use limit_cpu_use,
+ vm_instance.created created,
+ vm_instance.state state,
+ vm_instance.removed removed,
+ vm_instance.ha_enabled ha_enabled,
+ vm_instance.hypervisor_type hypervisor_type,
+ vm_instance.instance_name instance_name,
+ vm_instance.guest_os_id guest_os_id,
+ guest_os.uuid guest_os_uuid,
+ vm_instance.pod_id pod_id,
+ host_pod_ref.uuid pod_uuid,
+ vm_instance.private_ip_address private_ip_address,
+ vm_instance.private_mac_address private_mac_address,
+ vm_instance.vm_type vm_type,
+ data_center.id data_center_id,
+ data_center.uuid data_center_uuid,
+ data_center.name data_center_name,
+ data_center.networktype data_center_type,
+ data_center.is_security_group_enabled security_group_enabled,
+ host.id host_id,
+ host.uuid host_uuid,
+ host.name host_name,
+ vm_template.id template_id,
+ vm_template.uuid template_uuid,
+ vm_template.name template_name,
+ vm_template.display_text template_display_text,
+ vm_template.enable_password password_enabled,
+ iso.id iso_id,
+ iso.uuid iso_uuid,
+ iso.name iso_name,
+ iso.display_text iso_display_text,
+ service_offering.id service_offering_id,
+ disk_offering.uuid service_offering_uuid,
+ service_offering.cpu cpu,
+ service_offering.speed speed,
+ service_offering.ram_size ram_size,
+ disk_offering.name service_offering_name,
+ storage_pool.id pool_id,
+ storage_pool.uuid pool_uuid,
+ storage_pool.pool_type pool_type,
+ volumes.id volume_id,
+ volumes.uuid volume_uuid,
+ volumes.device_id volume_device_id,
+ volumes.volume_type volume_type,
+ security_group.id security_group_id,
+ security_group.uuid security_group_uuid,
+ security_group.name security_group_name,
+ security_group.description security_group_description,
+ nics.id nic_id,
+ nics.uuid nic_uuid,
+ nics.network_id network_id,
+ nics.ip4_address ip_address,
+ nics.ip6_address ip6_address,
+ nics.ip6_gateway ip6_gateway,
+ nics.ip6_cidr ip6_cidr,
+ nics.default_nic is_default_nic,
+ nics.gateway gateway,
+ nics.netmask netmask,
+ nics.mac_address mac_address,
+ nics.broadcast_uri broadcast_uri,
+ nics.isolation_uri isolation_uri,
+ vpc.id vpc_id,
+ vpc.uuid vpc_uuid,
+ networks.uuid network_uuid,
+ networks.name network_name,
+ networks.traffic_type traffic_type,
+ networks.guest_type guest_type,
+ user_ip_address.id public_ip_id,
+ user_ip_address.uuid public_ip_uuid,
+ user_ip_address.public_ip_address public_ip_address,
+ ssh_keypairs.keypair_name keypair_name,
+ resource_tags.id tag_id,
+ resource_tags.uuid tag_uuid,
+ resource_tags.key tag_key,
+ resource_tags.value tag_value,
+ resource_tags.domain_id tag_domain_id,
+ resource_tags.account_id tag_account_id,
+ resource_tags.resource_id tag_resource_id,
+ resource_tags.resource_uuid tag_resource_uuid,
+ resource_tags.resource_type tag_resource_type,
+ resource_tags.customer tag_customer,
+ async_job.id job_id,
+ async_job.uuid job_uuid,
+ async_job.job_status job_status,
+ async_job.account_id job_account_id,
+ affinity_group.id affinity_group_id,
+ affinity_group.uuid affinity_group_uuid,
+ affinity_group.name affinity_group_name,
+ affinity_group.description affinity_group_description
+ from
+ `cloud`.`user_vm`
+ inner join
+ `cloud`.`vm_instance` ON vm_instance.id = user_vm.id
+ and vm_instance.removed is NULL
+ inner join
+ `cloud`.`account` ON vm_instance.account_id = account.id
+ inner join
+ `cloud`.`domain` ON vm_instance.domain_id = domain.id
+ left join
+ `cloud`.`guest_os` ON vm_instance.guest_os_id = guest_os.id
+ left join
+ `cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
+ left join
+ `cloud`.`projects` ON projects.project_account_id = account.id
+ left join
+ `cloud`.`instance_group_vm_map` ON vm_instance.id = instance_group_vm_map.instance_id
+ left join
+ `cloud`.`instance_group` ON instance_group_vm_map.group_id = instance_group.id
+ left join
+ `cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
+ left join
+ `cloud`.`host` ON vm_instance.host_id = host.id
+ left join
+ `cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
+ left join
+ `cloud`.`vm_template` iso ON iso.id = user_vm.iso_id
+ left join
+ `cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
+ left join
+ `cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id
+ left join
+ `cloud`.`volumes` ON vm_instance.id = volumes.instance_id
+ left join
+ `cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id
+ left join
+ `cloud`.`security_group_vm_map` ON vm_instance.id = security_group_vm_map.instance_id
+ left join
+ `cloud`.`security_group` ON security_group_vm_map.security_group_id = security_group.id
+ left join
+ `cloud`.`nics` ON vm_instance.id = nics.instance_id
+ left join
+ `cloud`.`networks` ON nics.network_id = networks.id
+ left join
+ `cloud`.`vpc` ON networks.vpc_id = vpc.id
+ left join
+ `cloud`.`user_ip_address` ON user_ip_address.vm_id = vm_instance.id
+ left join
+ `cloud`.`user_vm_details` ON user_vm_details.vm_id = vm_instance.id
+ and user_vm_details.name = 'SSH.PublicKey'
+ left join
+ `cloud`.`ssh_keypairs` ON ssh_keypairs.public_key = user_vm_details.value
+ left join
+ `cloud`.`resource_tags` ON resource_tags.resource_id = vm_instance.id
+ and resource_tags.resource_type = 'UserVm'
+ left join
+ `cloud`.`async_job` ON async_job.instance_id = vm_instance.id
+ and async_job.instance_type = 'VirtualMachine'
+ and async_job.job_status = 0
+ left join
+ `cloud`.`affinity_group_vm_map` ON vm_instance.id = affinity_group_vm_map.instance_id
+ left join
+ `cloud`.`affinity_group` ON affinity_group_vm_map.affinity_group_id = affinity_group.id;
+
+DROP VIEW IF EXISTS `cloud`.`affinity_group_view`;
+CREATE VIEW `cloud`.`affinity_group_view` AS
+ select
+ affinity_group.id id,
+ affinity_group.name name,
+ affinity_group.type type,
+ affinity_group.description description,
+ affinity_group.uuid uuid,
+ account.id account_id,
+ account.uuid account_uuid,
+ account.account_name account_name,
+ account.type account_type,
+ domain.id domain_id,
+ domain.uuid domain_uuid,
+ domain.name domain_name,
+ domain.path domain_path,
+ vm_instance.id vm_id,
+ vm_instance.uuid vm_uuid,
+ vm_instance.name vm_name,
+ vm_instance.state vm_state,
+ user_vm.display_name vm_display_name
+ from
+ `cloud`.`affinity_group`
+ inner join
+ `cloud`.`account` ON affinity_group.account_id = account.id
+ inner join
+ `cloud`.`domain` ON affinity_group.domain_id = domain.id
+ left join
+ `cloud`.`affinity_group_vm_map` ON affinity_group.id = affinity_group_vm_map.affinity_group_id
+ left join
+ `cloud`.`vm_instance` ON vm_instance.id = affinity_group_vm_map.instance_id
+ left join
+ `cloud`.`user_vm` ON user_vm.id = vm_instance.id;
+
+DROP VIEW IF EXISTS `cloud`.`host_view`;
+CREATE VIEW `cloud`.`host_view` AS
+ select
+ host.id,
+ host.uuid,
+ host.name,
+ host.status,
+ host.disconnected,
+ host.type,
+ host.private_ip_address,
+ host.version,
+ host.hypervisor_type,
+ host.hypervisor_version,
+ host.capabilities,
+ host.last_ping,
+ host.created,
+ host.removed,
+ host.resource_state,
+ host.mgmt_server_id,
+ host.cpus,
+ host.speed,
+ host.ram,
+ cluster.id cluster_id,
+ cluster.uuid cluster_uuid,
+ cluster.name cluster_name,
+ cluster.cluster_type,
+ data_center.id data_center_id,
+ data_center.uuid data_center_uuid,
+ data_center.name data_center_name,
+ data_center.networktype data_center_type,
+ host_pod_ref.id pod_id,
+ host_pod_ref.uuid pod_uuid,
+ host_pod_ref.name pod_name,
+ host_tags.tag,
+ guest_os_category.id guest_os_category_id,
+ guest_os_category.uuid guest_os_category_uuid,
+ guest_os_category.name guest_os_category_name,
+ mem_caps.used_capacity memory_used_capacity,
+ mem_caps.reserved_capacity memory_reserved_capacity,
+ cpu_caps.used_capacity cpu_used_capacity,
+ cpu_caps.reserved_capacity cpu_reserved_capacity,
+ async_job.id job_id,
+ async_job.uuid job_uuid,
+ async_job.job_status job_status,
+ async_job.account_id job_account_id
+ from
+ `cloud`.`host`
+ left join
+ `cloud`.`cluster` ON host.cluster_id = cluster.id
+ left join
+ `cloud`.`data_center` ON host.data_center_id = data_center.id
+ left join
+ `cloud`.`host_pod_ref` ON host.pod_id = host_pod_ref.id
+ left join
+ `cloud`.`host_details` ON host.id = host_details.id
+ and host_details.name = 'guest.os.category.id'
+ left join
+ `cloud`.`guest_os_category` ON guest_os_category.id = CONVERT( host_details.value , UNSIGNED)
+ left join
+ `cloud`.`host_tags` ON host_tags.host_id = host.id
+ left join
+ `cloud`.`op_host_capacity` mem_caps ON host.id = mem_caps.host_id
+ and mem_caps.capacity_type = 0
+ left join
+ `cloud`.`op_host_capacity` cpu_caps ON host.id = cpu_caps.host_id
+ and cpu_caps.capacity_type = 1
+ left join
+ `cloud`.`async_job` ON async_job.instance_id = host.id
+ and async_job.instance_type = 'Host'
+ and async_job.job_status = 0;
+
+DROP VIEW IF EXISTS `cloud`.`storage_pool_view`;
+CREATE VIEW `cloud`.`storage_pool_view` AS
+ select
+ storage_pool.id,
+ storage_pool.uuid,
+ storage_pool.name,
+ storage_pool.status,
+ storage_pool.path,
+ storage_pool.pool_type,
+ storage_pool.host_address,
+ storage_pool.created,
+ storage_pool.removed,
+ storage_pool.capacity_bytes,
+ storage_pool.capacity_iops,
+ storage_pool.scope,
+ storage_pool.hypervisor,
+ cluster.id cluster_id,
+ cluster.uuid cluster_uuid,
+ cluster.name cluster_name,
+ cluster.cluster_type,
+ data_center.id data_center_id,
+ data_center.uuid data_center_uuid,
+ data_center.name data_center_name,
+ data_center.networktype data_center_type,
+ host_pod_ref.id pod_id,
+ host_pod_ref.uuid pod_uuid,
+ host_pod_ref.name pod_name,
+ storage_pool_details.name tag,
+ op_host_capacity.used_capacity disk_used_capacity,
+ op_host_capacity.reserved_capacity disk_reserved_capacity,
+ async_job.id job_id,
+ async_job.uuid job_uuid,
+ async_job.job_status job_status,
+ async_job.account_id job_account_id
+ from
+ `cloud`.`storage_pool`
+ left join
+ `cloud`.`cluster` ON storage_pool.cluster_id = cluster.id
+ left join
+ `cloud`.`data_center` ON storage_pool.data_center_id = data_center.id
+ left join
+ `cloud`.`host_pod_ref` ON storage_pool.pod_id = host_pod_ref.id
+ left join
+ `cloud`.`storage_pool_details` ON storage_pool_details.pool_id = storage_pool.id
+ and storage_pool_details.value = 'true'
+ left join
+ `cloud`.`op_host_capacity` ON storage_pool.id = op_host_capacity.host_id
+ and op_host_capacity.capacity_type = 3
+ left join
+ `cloud`.`async_job` ON async_job.instance_id = storage_pool.id
+ and async_job.instance_type = 'StoragePool'
+ and async_job.job_status = 0;
+
+
+DROP VIEW IF EXISTS `cloud`.`domain_router_view`;
+CREATE VIEW `cloud`.`domain_router_view` AS
+ select
+ vm_instance.id id,
+ vm_instance.name name,
+ account.id account_id,
+ account.uuid account_uuid,
+ account.account_name account_name,
+ account.type account_type,
+ domain.id domain_id,
+ domain.uuid domain_uuid,
+ domain.name domain_name,
+ domain.path domain_path,
+ projects.id project_id,
+ projects.uuid project_uuid,
+ projects.name project_name,
+ vm_instance.uuid uuid,
+ vm_instance.created created,
+ vm_instance.state state,
+ vm_instance.removed removed,
+ vm_instance.pod_id pod_id,
+ vm_instance.instance_name instance_name,
+ host_pod_ref.uuid pod_uuid,
+ data_center.id data_center_id,
+ data_center.uuid data_center_uuid,
+ data_center.name data_center_name,
+ data_center.networktype data_center_type,
+ data_center.dns1 dns1,
+ data_center.dns2 dns2,
+ data_center.ip6_dns1 ip6_dns1,
+ data_center.ip6_dns2 ip6_dns2,
+ host.id host_id,
+ host.uuid host_uuid,
+ host.name host_name,
+ vm_template.id template_id,
+ vm_template.uuid template_uuid,
+ service_offering.id service_offering_id,
+ disk_offering.uuid service_offering_uuid,
+ disk_offering.name service_offering_name,
+ nics.id nic_id,
+ nics.uuid nic_uuid,
+ nics.network_id network_id,
+ nics.ip4_address ip_address,
+ nics.ip6_address ip6_address,
+ nics.ip6_gateway ip6_gateway,
+ nics.ip6_cidr ip6_cidr,
+ nics.default_nic is_default_nic,
+ nics.gateway gateway,
+ nics.netmask netmask,
+ nics.mac_address mac_address,
+ nics.broadcast_uri broadcast_uri,
+ nics.isolation_uri isolation_uri,
+ vpc.id vpc_id,
+ vpc.uuid vpc_uuid,
+ networks.uuid network_uuid,
+ networks.name network_name,
+ networks.network_domain network_domain,
+ networks.traffic_type traffic_type,
+ networks.guest_type guest_type,
+ async_job.id job_id,
+ async_job.uuid job_uuid,
+ async_job.job_status job_status,
+ async_job.account_id job_account_id,
+ domain_router.template_version template_version,
+ domain_router.scripts_version scripts_version,
+ domain_router.is_redundant_router is_redundant_router,
+ domain_router.redundant_state redundant_state,
+ domain_router.stop_pending stop_pending,
+ domain_router.role role
+ from
+ `cloud`.`domain_router`
+ inner join
+ `cloud`.`vm_instance` ON vm_instance.id = domain_router.id
+ inner join
+ `cloud`.`account` ON vm_instance.account_id = account.id
+ inner join
+ `cloud`.`domain` ON vm_instance.domain_id = domain.id
+ left join
+ `cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
+ left join
+ `cloud`.`projects` ON projects.project_account_id = account.id
+ left join
+ `cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
+ left join
+ `cloud`.`host` ON vm_instance.host_id = host.id
+ left join
+ `cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
+ left join
+ `cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
+ left join
+ `cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id
+ left join
+ `cloud`.`nics` ON vm_instance.id = nics.instance_id and nics.removed is null
+ left join
+ `cloud`.`networks` ON nics.network_id = networks.id
+ left join
+ `cloud`.`vpc` ON domain_router.vpc_id = vpc.id and vpc.removed is null
+ left join
+ `cloud`.`async_job` ON async_job.instance_id = vm_instance.id
+ and async_job.instance_type = 'DomainRouter'
+ and async_job.job_status = 0;
+
+CREATE TABLE `cloud`.`external_cisco_vnmc_devices` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `uuid` varchar(255) UNIQUE,
+ `physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network in to which cisco vnmc device is added',
+ `provider_name` varchar(255) NOT NULL COMMENT 'Service Provider name corresponding to this cisco vnmc device',
+ `device_name` varchar(255) NOT NULL COMMENT 'name of the cisco vnmc device',
+ `host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the external cisco vnmc device',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_external_cisco_vnmc_devices__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_external_cisco_vnmc_devices__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`external_cisco_asa1000v_devices` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `uuid` varchar(255) UNIQUE,
+ `physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network in to which cisco asa1kv device is added',
+ `management_ip` varchar(255) UNIQUE NOT NULL COMMENT 'mgmt. ip of cisco asa1kv device',
+ `in_port_profile` varchar(255) NOT NULL COMMENT 'inside port profile name of cisco asa1kv device',
+ `cluster_id` bigint unsigned NOT NULL COMMENT 'id of the Vmware cluster to which cisco asa1kv device is attached (cisco n1kv switch)',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_external_cisco_asa1000v_devices__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_external_cisco_asa1000v_devices__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cluster`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`network_asa1000v_map` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `network_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of guest network',
+ `asa1000v_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of asa1000v device',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_network_asa1000v_map__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_network_asa1000v_map__asa1000v_id` FOREIGN KEY (`asa1000v_id`) REFERENCES `external_cisco_asa1000v_devices`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`vmware_data_center` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `uuid` varchar(255) UNIQUE,
+ `name` varchar(255) NOT NULL COMMENT 'Name of VMware datacenter',
+ `guid` varchar(255) NOT NULL UNIQUE COMMENT 'id of VMware datacenter',
+ `vcenter_host` varchar(255) NOT NULL COMMENT 'vCenter host containing this VMware datacenter',
+ `username` varchar(255) NOT NULL COMMENT 'Name of vCenter host user',
+ `password` varchar(255) NOT NULL COMMENT 'Password of vCenter host user',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`vmware_data_center_zone_map` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `zone_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of CloudStack zone',
+ `vmware_data_center_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of VMware datacenter',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_vmware_data_center_zone_map__vmware_data_center_id` FOREIGN KEY (`vmware_data_center_id`) REFERENCES `vmware_data_center`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`legacy_zones` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `zone_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of CloudStack zone',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_legacy_zones__zone_id` FOREIGN KEY (`zone_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.' AFTER `elastic_ip_service`;
+
+
+CREATE TABLE `cloud`.`op_host_planner_reservation` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `data_center_id` bigint unsigned NOT NULL,
+ `pod_id` bigint unsigned,
+ `cluster_id` bigint unsigned,
+ `host_id` bigint unsigned,
+ `resource_usage` varchar(255) COMMENT 'Shared(between planners) Vs Dedicated (exclusive usage to a planner)',
+ PRIMARY KEY (`id`),
+ INDEX `i_op_host_planner_reservation__host_resource_usage`(`host_id`, `resource_usage`),
+ CONSTRAINT `fk_planner_reservation__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_planner_reservation__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `cloud`.`data_center`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_planner_reservation__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_planner_reservation__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cloud`.`cluster`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+ALTER TABLE `cloud`.`service_offering` ADD COLUMN `deployment_planner` varchar(255) COMMENT 'Planner heuristics used to deploy a VM of this offering; if null global config vm.deployment.planner is used';
+
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.deployment.planner', 'FirstFitPlanner', '[''FirstFitPlanner'', ''UserDispersingPlanner'', ''UserConcentratedPodPlanner'']: DeploymentPlanner heuristic that will be used for VM deployment.');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'host.reservation.release.period', '300000', 'The interval in milliseconds between host reservation release checks');
+
+DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
+CREATE VIEW `cloud`.`service_offering_view` AS
+ select
+ service_offering.id,
+ disk_offering.uuid,
+ disk_offering.name,
+ disk_offering.display_text,
+ disk_offering.created,
+ disk_offering.tags,
+ disk_offering.removed,
+ disk_offering.use_local_storage,
+ disk_offering.system_use,
+ disk_offering.bytes_read_rate,
+ disk_offering.bytes_write_rate,
+ disk_offering.iops_read_rate,
+ disk_offering.iops_write_rate,
+ service_offering.cpu,
+ service_offering.speed,
+ service_offering.ram_size,
+ service_offering.nw_rate,
+ service_offering.mc_rate,
+ service_offering.ha_enabled,
+ service_offering.limit_cpu_use,
+ service_offering.host_tag,
+ service_offering.default_use,
+ service_offering.vm_type,
+ service_offering.sort_key,
+ service_offering.is_volatile,
+ service_offering.deployment_planner,
+ domain.id domain_id,
+ domain.uuid domain_uuid,
+ domain.name domain_name,
+ domain.path domain_path
+ from
+ `cloud`.`service_offering`
+ inner join
+ `cloud`.`disk_offering` ON service_offering.id = disk_offering.id
+ left join
+ `cloud`.`domain` ON disk_offering.domain_id = domain.id;
+
+-- Add "default" field to account/user tables
+ALTER TABLE `cloud`.`account` ADD COLUMN `default` int(1) unsigned NOT NULL DEFAULT '0' COMMENT '1 if account is default';
+ALTER TABLE `cloud_usage`.`account` ADD COLUMN `default` int(1) unsigned NOT NULL DEFAULT '0' COMMENT '1 if account is default';
+ALTER TABLE `cloud`.`user` ADD COLUMN `default` int(1) unsigned NOT NULL DEFAULT '0' COMMENT '1 if user is default';
+UPDATE `cloud`.`account` SET `cloud`.`account`.`default`=1 WHERE id IN (1,2);
+UPDATE `cloud_usage`.`account` SET `default`=1 WHERE id IN (1,2);
+UPDATE `cloud`.`user` SET `cloud`.`user`.`default`=1 WHERE id IN (1,2);
+
+ALTER VIEW `cloud`.`user_view` AS
+ select
+ user.id,
+ user.uuid,
+ user.username,
+ user.password,
+ user.firstname,
+ user.lastname,
+ user.email,
+ user.state,
+ user.api_key,
+ user.secret_key,
+ user.created,
+ user.removed,
+ user.timezone,
+ user.registration_token,
+ user.is_registered,
+ user.incorrect_login_attempts,
+ user.default,
+ account.id account_id,
+ account.uuid account_uuid,
+ account.account_name account_name,
+ account.type account_type,
+ domain.id domain_id,
+ domain.uuid domain_uuid,
+ domain.name domain_name,
+ domain.path domain_path,
+ async_job.id job_id,
+ async_job.uuid job_uuid,
+ async_job.job_status job_status,
+ async_job.account_id job_account_id
+ from
+ `cloud`.`user`
+ inner join
+ `cloud`.`account` ON user.account_id = account.id
+ inner join
+ `cloud`.`domain` ON account.domain_id = domain.id
+ left join
+ `cloud`.`async_job` ON async_job.instance_id = user.id
+ and async_job.instance_type = 'User'
+ and async_job.job_status = 0;
+
+
+DROP VIEW IF EXISTS `cloud`.`account_view`;
+CREATE VIEW `cloud`.`account_view` AS
+ select
+ account.id,
+ account.uuid,
+ account.account_name,
+ account.type,
+ account.state,
+ account.removed,
+ account.cleanup_needed,
+ account.network_domain,
+ account.default,
+ domain.id domain_id,
+ domain.uuid domain_uuid,
+ domain.name domain_name,
+ domain.path domain_path,
+ data_center.id data_center_id,
+ data_center.uuid data_center_uuid,
+ data_center.name data_center_name,
+ account_netstats_view.bytesReceived,
+ account_netstats_view.bytesSent,
+ vmlimit.max vmLimit,
+ vmcount.count vmTotal,
+ runningvm.vmcount runningVms,
+ stoppedvm.vmcount stoppedVms,
+ iplimit.max ipLimit,
+ ipcount.count ipTotal,
+ free_ip_view.free_ip ipFree,
+ volumelimit.max volumeLimit,
+ volumecount.count volumeTotal,
+ snapshotlimit.max snapshotLimit,
+ snapshotcount.count snapshotTotal,
+ templatelimit.max templateLimit,
+ templatecount.count templateTotal,
+ vpclimit.max vpcLimit,
+ vpccount.count vpcTotal,
+ projectlimit.max projectLimit,
+ projectcount.count projectTotal,
+ networklimit.max networkLimit,
+ networkcount.count networkTotal,
+ cpulimit.max cpuLimit,
+ cpucount.count cpuTotal,
+ memorylimit.max memoryLimit,
+ memorycount.count memoryTotal,
+ primary_storage_limit.max primaryStorageLimit,
+ primary_storage_count.count primaryStorageTotal,
+ secondary_storage_limit.max secondaryStorageLimit,
+ secondary_storage_count.count secondaryStorageTotal,
+ async_job.id job_id,
+ async_job.uuid job_uuid,
+ async_job.job_status job_status,
+ async_job.account_id job_account_id
+ from
+ `cloud`.`free_ip_view`,
+ `cloud`.`account`
+ inner join
+ `cloud`.`domain` ON account.domain_id = domain.id
+ left join
+ `cloud`.`data_center` ON account.default_zone_id = data_center.id
+ left join
+ `cloud`.`account_netstats_view` ON account.id = account_netstats_view.account_id
+ left join
+ `cloud`.`resource_limit` vmlimit ON account.id = vmlimit.account_id
+ and vmlimit.type = 'user_vm'
+ left join
+ `cloud`.`resource_count` vmcount ON account.id = vmcount.account_id
+ and vmcount.type = 'user_vm'
+ left join
+ `cloud`.`account_vmstats_view` runningvm ON account.id = runningvm.account_id
+ and runningvm.state = 'Running'
+ left join
+ `cloud`.`account_vmstats_view` stoppedvm ON account.id = stoppedvm.account_id
+ and stoppedvm.state = 'Stopped'
+ left join
+ `cloud`.`resource_limit` iplimit ON account.id = iplimit.account_id
+ and iplimit.type = 'public_ip'
+ left join
+ `cloud`.`resource_count` ipcount ON account.id = ipcount.account_id
+ and ipcount.type = 'public_ip'
+ left join
+ `cloud`.`resource_limit` volumelimit ON account.id = volumelimit.account_id
+ and volumelimit.type = 'volume'
+ left join
+ `cloud`.`resource_count` volumecount ON account.id = volumecount.account_id
+ and volumecount.type = 'volume'
+ left join
+ `cloud`.`resource_limit` snapshotlimit ON account.id = snapshotlimit.account_id
+ and snapshotlimit.type = 'snapshot'
+ left join
+ `cloud`.`resource_count` snapshotcount ON account.id = snapshotcount.account_id
+ and snapshotcount.type = 'snapshot'
+ left join
+ `cloud`.`resource_limit` templatelimit ON account.id = templatelimit.account_id
+ and templatelimit.type = 'template'
+ left join
+ `cloud`.`resource_count` templatecount ON account.id = templatecount.account_id
+ and templatecount.type = 'template'
+ left join
+ `cloud`.`resource_limit` vpclimit ON account.id = vpclimit.account_id
+ and vpclimit.type = 'vpc'
+ left join
+ `cloud`.`resource_count` vpccount ON account.id = vpccount.account_id
+ and vpccount.type = 'vpc'
+ left join
+ `cloud`.`resource_limit` projectlimit ON account.id = projectlimit.account_id
+ and projectlimit.type = 'project'
+ left join
+ `cloud`.`resource_count` projectcount ON account.id = projectcount.account_id
+ and projectcount.type = 'project'
+ left join
+ `cloud`.`resource_limit` networklimit ON account.id = networklimit.account_id
+ and networklimit.type = 'network'
+ left join
+ `cloud`.`resource_count` networkcount ON account.id = networkcount.account_id
+ and networkcount.type = 'network'
+ left join
+ `cloud`.`resource_limit` cpulimit ON account.id = cpulimit.account_id
+ and cpulimit.type = 'cpu'
+ left join
+ `cloud`.`resource_count` cpucount ON account.id = cpucount.account_id
+ and cpucount.type = 'cpu'
+ left join
+ `cloud`.`resource_limit` memorylimit ON account.id = memorylimit.account_id
+ and memorylimit.type = 'memory'
+ left join
+ `cloud`.`resource_count` memorycount ON account.id = memorycount.account_id
+ and memorycount.type = 'memory'
+ left join
+ `cloud`.`resource_limit` primary_storage_limit ON account.id = primary_storage_limit.account_id
+ and primary_storage_limit.type = 'primary_storage'
+ left join
+ `cloud`.`resource_count` primary_storage_count ON account.id = primary_storage_count.account_id
+ and primary_storage_count.type = 'primary_storage'
+ left join
+ `cloud`.`resource_limit` secondary_storage_limit ON account.id = secondary_storage_limit.account_id
+ and secondary_storage_limit.type = 'secondary_storage'
+ left join
+ `cloud`.`resource_count` secondary_storage_count ON account.id = secondary_storage_count.account_id
+ and secondary_storage_count.type = 'secondary_storage'
+ left join
+ `cloud`.`async_job` ON async_job.instance_id = account.id
+ and async_job.instance_type = 'Account'
+ and async_job.job_status = 0;
+
+
+
+ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `source_ip_address` varchar(40) COMMENT 'source ip address for the load balancer rule';
+ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `source_ip_address_network_id` bigint unsigned COMMENT 'the id of the network where source ip belongs to';
+ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `scheme` varchar(40) NOT NULL COMMENT 'load balancer scheme; can be Internal or Public';
+UPDATE `cloud`.`load_balancing_rules` SET `scheme`='Public';
+
+
+
+-- Add details talbe for the network offering
+CREATE TABLE `cloud`.`network_offering_details` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `network_offering_id` bigint unsigned NOT NULL COMMENT 'network offering id',
+ `name` varchar(255) NOT NULL,
+ `value` varchar(1024) NOT NULL,
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_network_offering_details__network_offering_id` FOREIGN KEY `fk_network_offering_details__network_offering_id`(`network_offering_id`) REFERENCES `network_offerings`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- Change the constraint for the network service map table. Now we support multiple provider for the same service
+ALTER TABLE `cloud`.`ntwk_service_map` DROP FOREIGN KEY `fk_ntwk_service_map__network_id`;
+ALTER TABLE `cloud`.`ntwk_service_map` DROP INDEX `network_id`;
+
+ALTER TABLE `cloud`.`ntwk_service_map` ADD UNIQUE `network_id` (`network_id`,`service`,`provider`);
+ALTER TABLE `cloud`.`ntwk_service_map` ADD CONSTRAINT `fk_ntwk_service_map__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE;
+
+
+ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `internal_lb` int(1) unsigned NOT NULL DEFAULT '0' COMMENT 'true if the network offering supports Internal lb service';
+ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `public_lb` int(1) unsigned NOT NULL DEFAULT '0' COMMENT 'true if the network offering supports Public lb service';
+UPDATE `cloud`.`network_offerings` SET public_lb=1 where id IN (SELECT DISTINCT network_offering_id FROM `cloud`.`ntwk_offering_service_map` WHERE service='Lb');
+
+
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'internallbvm.service.offering', null, 'Uuid of the service offering used by internal lb vm; if NULL - default system internal lb offering will be used');
+
+
+alter table `cloud_usage`.`usage_network_offering` add column nic_id bigint(20) unsigned NOT NULL;
+
+CREATE TABLE `cloud`.`portable_ip_range` (
+ `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT,
+ `uuid` varchar(40),
+ `region_id` int unsigned NOT NULL,
+ `vlan_id` varchar(255),
+ `gateway` varchar(255),
+ `netmask` varchar(255),
+ `start_ip` varchar(255),
+ `end_ip` varchar(255),
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_portableip__region_id` FOREIGN KEY (`region_id`) REFERENCES `region`(`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`portable_ip_address` (
+ `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT,
+ `account_id` bigint unsigned NULL,
+ `domain_id` bigint unsigned NULL,
+ `allocated` datetime NULL COMMENT 'Date portable ip was allocated',
+ `state` char(32) NOT NULL default 'Free' COMMENT 'state of the portable ip address',
+ `region_id` int unsigned NOT NULL,
+ `vlan` varchar(255),
+ `gateway` varchar(255),
+ `netmask` varchar(255),
+ `portable_ip_address` varchar(255),
+ `portable_ip_range_id` bigint unsigned NOT NULL,
+ `data_center_id` bigint unsigned NULL COMMENT 'zone to which portable IP is associated',
+ `physical_network_id` bigint unsigned NULL COMMENT 'physical network id in the zone to which portable IP is associated',
+ `network_id` bigint unsigned NULL COMMENT 'guest network to which portable ip address is associated with',
+ `vpc_id` bigint unsigned COMMENT 'vpc to which portable ip address is associated with',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_portable_ip_address__portable_ip_range_id` FOREIGN KEY (`portable_ip_range_id`) REFERENCES `portable_ip_range`(`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_portable_ip_address__region_id` FOREIGN KEY (`region_id`) REFERENCES `region`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN is_portable int(1) unsigned NOT NULL default '0';
+
+DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
+CREATE VIEW `cloud`.`disk_offering_view` AS
+ select
+ disk_offering.id,
+ disk_offering.uuid,
+ disk_offering.name,
+ disk_offering.display_text,
+ disk_offering.disk_size,
+ disk_offering.min_iops,
+ disk_offering.max_iops,
+ disk_offering.created,
+ disk_offering.tags,
+ disk_offering.customized,
+ disk_offering.customized_iops,
+ disk_offering.removed,
+ disk_offering.use_local_storage,
+ disk_offering.system_use,
+ disk_offering.bytes_read_rate,
+ disk_offering.bytes_write_rate,
+ disk_offering.iops_read_rate,
+ disk_offering.iops_write_rate,
+ disk_offering.sort_key,
+ disk_offering.type,
+ disk_offering.display_offering,
+ domain.id domain_id,
+ domain.uuid domain_uuid,
+ domain.name domain_name,
+ domain.path domain_path
+ from
+ `clou
<TRUNCATED>
[3/9] CLOUDSTACK-4167: Put in upgrade paths in master for 4.1.2 and
4.2
Posted by vi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d47b4a99/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
deleted file mode 100644
index 6033531..0000000
--- a/setup/db/db/schema-410to420.sql
+++ /dev/null
@@ -1,2291 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements. See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership. The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License. You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied. See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
---;
--- Schema upgrade from 4.1.0 to 4.2.0;
---;
-
--- Disable foreign key checking
-SET foreign_key_checks = 0;
-
-
-ALTER TABLE volumes ADD COLUMN vm_snapshot_chain_size bigint(20) unsigned;
-ALTER TABLE volumes ADD COLUMN iso_id bigint(20) unsigned;
-
--- All new inserts to the hypervisor_capabilities table should be after this
-ALTER TABLE `cloud`.`hypervisor_capabilities` ADD CONSTRAINT `uc_hypervisor` UNIQUE (`hypervisor_type`, `hypervisor_version`);
-
-ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `max_hosts_per_cluster` int unsigned DEFAULT NULL COMMENT 'Max. hosts in cluster supported by hypervisor';
-ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `storage_motion_supported` int(1) unsigned DEFAULT 0 COMMENT 'Is storage motion supported';
-UPDATE `cloud`.`hypervisor_capabilities` SET `max_hosts_per_cluster`=32 WHERE `hypervisor_type`='VMware';
-INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, storage_motion_supported) VALUES (UUID(), 'XenServer', '6.1.0', 50, 1, 13, 1);
-INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, storage_motion_supported) VALUES (UUID(), 'XenServer', '6.2.0', 50, 1, 13, 1);
-INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES (UUID(), 'VMware', '5.1', 128, 0, 32);
-UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported`=true WHERE `hypervisor_type`='VMware' AND `hypervisor_version`='5.1';
-UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported`=true WHERE `hypervisor_type`='VMware' AND `hypervisor_version`='5.0';
-UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported`=true WHERE `hypervisor_type`='XenServer' AND `hypervisor_version`='6.1.0';
-UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported`=true WHERE `hypervisor_type`='XenServer' AND `hypervisor_version`='6.2.0';
-DELETE FROM `cloud`.`configuration` where name='vmware.percluster.host.max';
-DELETE FROM `cloud`.`configuration` where name='router.template.id';
-DELETE FROM `cloud`.`configuration` where name='swift.enable';
-DELETE FROM `cloud`.`configuration` where name='s3.enable';
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'AgentManager', 'xen.nics.max', '7', 'Maximum allowed nics for Vms created on Xen');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'vmware.use.dvswitch', 'false', 'Enable/Disable Nexus/Vmware dvSwitch in VMware environment');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'vmware.ports.per.dvportgroup', '256', 'Default number of ports per Vmware dvPortGroup in VMware environment');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'midonet.apiserver.address', 'http://localhost:8081', 'Specify the address at which the Midonet API server can be contacted (if using Midonet)');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'midonet.providerrouter.id', 'd7c5e6a3-e2f4-426b-b728-b7ce6a0448e5', 'Specifies the UUID of the Midonet provider router (if using Midonet)');
-ALTER TABLE `cloud`.`load_balancer_vm_map` ADD state VARCHAR(40) NULL COMMENT 'service status updated by LB healthcheck manager';
-
-ALTER TABLE `cloud`.`vm_template` ADD COLUMN `dynamically_scalable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory';
-ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `dynamically_scalable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if VM contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory';
-UPDATE `cloud`.`vm_template` SET dynamically_scalable = 1 WHERE name = "CentOS 5.6(64-bit) no GUI (XenServer)" AND type = "BUILTIN";
-UPDATE `cloud`.`vm_template` SET dynamically_scalable = 1 WHERE name = "SystemVM Template (vSphere)" AND type = "SYSTEM";
-
-alter table storage_pool add hypervisor varchar(32);
-alter table storage_pool change storage_provider_id storage_provider_name varchar(255);
-alter table storage_pool change available_bytes used_bytes bigint unsigned;
--- alter table template_host_ref add state varchar(255);
--- alter table template_host_ref add update_count bigint unsigned;
--- alter table template_host_ref add updated datetime;
--- alter table volume_host_ref add state varchar(255);
--- alter table volume_host_ref add update_count bigint unsigned;
--- alter table volume_host_ref add updated datetime;
-alter table template_spool_ref add updated datetime;
-UPDATE `cloud`.`template_spool_ref` set state='Ready' WHERE download_state = 'DOWNLOADED';
-UPDATE `cloud`.`template_spool_ref` set update_count=0;
-
-
-CREATE TABLE `cloud`.`object_datastore_ref` (
- `id` bigint unsigned NOT NULL auto_increment,
- `datastore_uuid` varchar(255) NOT NULL,
- `datastore_role` varchar(255) NOT NULL,
- `object_uuid` varchar(255) NOT NULL,
- `object_type` varchar(255) NOT NULL,
- `created` DATETIME NOT NULL,
- `last_updated` DATETIME,
- `job_id` varchar(255),
- `download_pct` int(10) unsigned,
- `download_state` varchar(255),
- `url` varchar(255),
- `format` varchar(255),
- `checksum` varchar(255),
- `error_str` varchar(255),
- `local_path` varchar(255),
- `install_path` varchar(255),
- `size` bigint unsigned COMMENT 'the size of the template on the pool',
- `state` varchar(255) NOT NULL,
- `update_count` bigint unsigned NOT NULL,
- `updated` DATETIME,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-
-
--- CREATE TABLE `cloud`.`data_store_provider` (
--- `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
--- `name` varchar(255) NOT NULL COMMENT 'name of primary data store provider',
--- `uuid` varchar(255) NOT NULL COMMENT 'uuid of primary data store provider',
--- PRIMARY KEY(`id`)
--- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 's3.rrs.enabled', 'false', 'enable s3 reduced redundancy storage');
-
-CREATE TABLE `cloud`.`image_store` (
- `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
- `name` varchar(255) NOT NULL COMMENT 'name of data store',
- `image_provider_name` varchar(255) NOT NULL COMMENT 'id of image_store_provider',
- `protocol` varchar(255) NOT NULL COMMENT 'protocol of data store',
- `url` varchar(255) COMMENT 'url for image data store',
- `data_center_id` bigint unsigned COMMENT 'datacenter id of data store',
- `scope` varchar(255) COMMENT 'scope of data store',
- `role` varchar(255) COMMENT 'role of data store',
- `uuid` varchar(255) COMMENT 'uuid of data store',
- `parent` varchar(255) COMMENT 'parent path for the storage server',
- `created` datetime COMMENT 'date the image store first signed on',
- `removed` datetime COMMENT 'date removed if not null',
- `total_size` bigint unsigned COMMENT 'storage total size statistics',
- `used_bytes` bigint unsigned COMMENT 'storage available bytes statistics',
- PRIMARY KEY(`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`image_store_details` (
- `id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id',
- `store_id` bigint unsigned NOT NULL COMMENT 'store the detail is related to',
- `name` varchar(255) NOT NULL COMMENT 'name of the detail',
- `value` varchar(255) NOT NULL COMMENT 'value of the detail',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_image_store_details__store_id` FOREIGN KEY `fk_image_store__store_id`(`store_id`) REFERENCES `image_store`(`id`) ON DELETE CASCADE,
- INDEX `i_image_store__name__value`(`name`(128), `value`(128))
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-DROP VIEW IF EXISTS `cloud`.`image_store_view`;
-CREATE VIEW `cloud`.`image_store_view` AS
- select
- image_store.id,
- image_store.uuid,
- image_store.name,
- image_store.image_provider_name,
- image_store.protocol,
- image_store.url,
- image_store.scope,
- image_store.role,
- image_store.removed,
- data_center.id data_center_id,
- data_center.uuid data_center_uuid,
- data_center.name data_center_name,
- image_store_details.name detail_name,
- image_store_details.value detail_value
- from
- `cloud`.`image_store`
- left join
- `cloud`.`data_center` ON image_store.data_center_id = data_center.id
- left join
- `cloud`.`image_store_details` ON image_store_details.store_id = image_store.id;
-
-
--- here we have to allow null for store_id to accomodate baremetal case to search for ready templates since template state is only stored in this table
--- FK also commented out due to this
-CREATE TABLE `cloud`.`template_store_ref` (
- `id` bigint unsigned NOT NULL auto_increment,
- `store_id` bigint unsigned,
- `template_id` bigint unsigned NOT NULL,
- `created` DATETIME NOT NULL,
- `last_updated` DATETIME,
- `job_id` varchar(255),
- `download_pct` int(10) unsigned,
- `size` bigint unsigned,
- `store_role` varchar(255),
- `physical_size` bigint unsigned DEFAULT 0,
- `download_state` varchar(255),
- `error_str` varchar(255),
- `local_path` varchar(255),
- `install_path` varchar(255),
- `url` varchar(255),
- `download_url` varchar(255),
- `download_url_created` datetime,
- `state` varchar(255) NOT NULL,
- `destroyed` tinyint(1) COMMENT 'indicates whether the template_store entry was destroyed by the user or not',
- `is_copy` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates whether this was copied ',
- `update_count` bigint unsigned,
- `ref_cnt` bigint unsigned DEFAULT 0,
- `updated` datetime,
- PRIMARY KEY (`id`),
--- CONSTRAINT `fk_template_store_ref__store_id` FOREIGN KEY `fk_template_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
- INDEX `i_template_store_ref__store_id`(`store_id`),
- CONSTRAINT `fk_template_store_ref__template_id` FOREIGN KEY `fk_template_store_ref__template_id` (`template_id`) REFERENCES `vm_template` (`id`),
- INDEX `i_template_store_ref__template_id`(`template_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-
--- ALTER TABLE `cloud`.`vm_template` ADD COLUMN `image_data_store_id` bigint unsigned;
-
--- Do we still need these columns? TODO, to delete them, remove FK constraints from snapshots table
--- ALTER TABLE `cloud`.`snapshots` DROP COLUMN `swift_id`;
--- ALTER TABLE `cloud`.`snapshots` DROP COLUMN `s3_id`;
--- ALTER TABLE `cloud`.`snapshots` DROP COLUMN `sechost_id`;
-
--- change upload host_id FK to point to image_store table
-ALTER TABLE `cloud`.`upload` DROP FOREIGN KEY `fk_upload__host_id`;
-ALTER TABLE `cloud`.`upload` ADD CONSTRAINT `fk_upload__store_id` FOREIGN KEY(`host_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE;
-
-CREATE TABLE `cloud`.`snapshot_store_ref` (
- `id` bigint unsigned NOT NULL auto_increment,
- `store_id` bigint unsigned NOT NULL,
- `snapshot_id` bigint unsigned NOT NULL,
- `created` DATETIME NOT NULL,
- `last_updated` DATETIME,
- `job_id` varchar(255),
- `store_role` varchar(255),
- `size` bigint unsigned,
- `physical_size` bigint unsigned DEFAULT 0,
- `parent_snapshot_id` bigint unsigned DEFAULT 0,
- `install_path` varchar(255),
- `state` varchar(255) NOT NULL,
- -- `removed` datetime COMMENT 'date removed if not null',
- `update_count` bigint unsigned,
- `ref_cnt` bigint unsigned,
- `updated` datetime,
- `volume_id` bigint unsigned,
- PRIMARY KEY (`id`),
- INDEX `i_snapshot_store_ref__store_id`(`store_id`),
- CONSTRAINT `fk_snapshot_store_ref__snapshot_id` FOREIGN KEY `fk_snapshot_store_ref__snapshot_id` (`snapshot_id`) REFERENCES `snapshots` (`id`),
- INDEX `i_snapshot_store_ref__snapshot_id`(`snapshot_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`volume_store_ref` (
- `id` bigint unsigned NOT NULL auto_increment,
- `store_id` bigint unsigned NOT NULL,
- `volume_id` bigint unsigned NOT NULL,
- `zone_id` bigint unsigned NOT NULL,
- `created` DATETIME NOT NULL,
- `last_updated` DATETIME,
- `job_id` varchar(255),
- `download_pct` int(10) unsigned,
- `size` bigint unsigned,
- `physical_size` bigint unsigned DEFAULT 0,
- `download_state` varchar(255),
- `checksum` varchar(255) COMMENT 'checksum for the data disk',
- `error_str` varchar(255),
- `local_path` varchar(255),
- `install_path` varchar(255),
- `url` varchar(255),
- `download_url` varchar(255),
- `download_url_created` datetime,
- `state` varchar(255) NOT NULL,
- `destroyed` tinyint(1) COMMENT 'indicates whether the volume_host entry was destroyed by the user or not',
- `update_count` bigint unsigned,
- `ref_cnt` bigint unsigned,
- `updated` datetime,
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_volume_store_ref__store_id` FOREIGN KEY `fk_volume_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
- INDEX `i_volume_store_ref__store_id`(`store_id`),
- CONSTRAINT `fk_volume_store_ref__volume_id` FOREIGN KEY `fk_volume_store_ref__volume_id` (`volume_id`) REFERENCES `volumes` (`id`),
- INDEX `i_volume_store_ref__volume_id`(`volume_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-
-
-ALTER TABLE `cloud`.`service_offering` ADD COLUMN `is_volatile` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the vm needs to be volatile, i.e., on every reboot of vm from API root disk is discarded and creates a new root disk';
-
-ALTER TABLE `cloud`.`networks` ADD COLUMN `network_cidr` VARCHAR(18) COMMENT 'The network cidr for the isolated guest network which uses IP Reservation facility.For networks not using IP reservation, network_cidr is always null.';
-ALTER TABLE `cloud`.`networks` CHANGE `cidr` `cidr` varchar(18) COMMENT 'CloudStack managed vms get IP address from cidr.In general this cidr also serves as the network CIDR. But in case IP reservation feature is being used by a Guest network, networkcidr is the Effective network CIDR for that network';
-
-
-CREATE TABLE `vpc_service_map` (
- `id` bigint unsigned NOT NULL auto_increment,
- `vpc_id` bigint unsigned NOT NULL COMMENT 'vpc_id',
- `service` varchar(255) NOT NULL COMMENT 'service',
- `provider` varchar(255) COMMENT 'service provider',
- `created` datetime COMMENT 'date created',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_vpc_service_map__vpc_id` FOREIGN KEY(`vpc_id`) REFERENCES `vpc`(`id`) ON DELETE CASCADE,
- UNIQUE (`vpc_id`, `service`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`load_balancer_healthcheck_policies` (
- `id` bigint(20) NOT NULL auto_increment,
- `uuid` varchar(40),
- `load_balancer_id` bigint unsigned NOT NULL,
- `pingpath` varchar(225) NULL DEFAULT '/',
- `description` varchar(4096) NULL,
- `response_time` int(11) DEFAULT 5,
- `healthcheck_interval` int(11) DEFAULT 5,
- `healthcheck_thresshold` int(11) DEFAULT 2,
- `unhealth_thresshold` int(11) DEFAULT 10,
- `revoke` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 is when rule is set for Revoke',
- PRIMARY KEY (`id`),
- UNIQUE KEY `id_UNIQUE` (`id`),
- CONSTRAINT `fk_load_balancer_healthcheck_policies_loadbalancer_id` FOREIGN KEY(`load_balancer_id`) REFERENCES `load_balancing_rules`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.instancename.flag', 'false', 'If set to true, will set guest VM\'s name as it appears on the hypervisor, to its hostname');
-
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (165, UUID(), 6, 'Windows 8 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (166, UUID(), 6, 'Windows 8 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (167, UUID(), 6, 'Windows Server 2012 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (168, UUID(), 6, 'Windows Server 8 (64-bit)');
-
-# clean up row added in 3.0.6.
-UPDATE `cloud`.`guest_os_hypervisor` set guest_os_id = 166 where guest_os_id = 206;
-UPDATE `cloud`.`vm_template` set guest_os_id = 166 where guest_os_id = 206;
-UPDATE `cloud`.`vm_instance` set guest_os_id = 166 where guest_os_id = 206;
-DELETE IGNORE FROM `cloud`.`guest_os` where id=206;
-
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (141, UUID(), 1, 'CentOS 5.6 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (142, UUID(), 1, 'CentOS 5.6 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (169, UUID(), 10, 'Ubuntu 11.04 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (170, UUID(), 10, 'Ubuntu 11.04 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (171, UUID(), 1, 'CentOS 6.3 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (172, UUID(), 1, 'CentOS 6.3 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (173, UUID(), 1, 'CentOS 5.8 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (174, UUID(), 1, 'CentOS 5.8 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (175, UUID(), 1, 'CentOS 5.9 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (176, UUID(), 1, 'CentOS 5.9 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (177, UUID(), 1, 'CentOS 6.1 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (178, UUID(), 1, 'CentOS 6.1 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (179, UUID(), 1, 'CentOS 6.2 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (180, UUID(), 1, 'CentOS 6.2 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (181, UUID(), 1, 'CentOS 6.4 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (182, UUID(), 1, 'CentOS 6.4 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (183, UUID(), 2, 'Debian GNU/Linux 7(32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (184, UUID(), 2, 'Debian GNU/Linux 7(64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (185, UUID(), 5, 'SUSE Linux Enterprise Server 11 SP2 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (186, UUID(), 5, 'SUSE Linux Enterprise Server 11 SP2 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (187, UUID(), 5, 'SUSE Linux Enterprise Server 11 SP3 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (188, UUID(), 5, 'SUSE Linux Enterprise Server 11 SP3 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (189, UUID(), 4, 'Red Hat Enterprise Linux 5.7 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (190, UUID(), 4, 'Red Hat Enterprise Linux 5.7 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (191, UUID(), 4, 'Red Hat Enterprise Linux 5.8 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (192, UUID(), 4, 'Red Hat Enterprise Linux 5.8 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (193, UUID(), 4, 'Red Hat Enterprise Linux 5.9 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (194, UUID(), 4, 'Red Hat Enterprise Linux 5.9 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (195, UUID(), 4, 'Red Hat Enterprise Linux 6.1 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (196, UUID(), 4, 'Red Hat Enterprise Linux 6.1 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (197, UUID(), 4, 'Red Hat Enterprise Linux 6.2 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (198, UUID(), 4, 'Red Hat Enterprise Linux 6.2 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (199, UUID(), 4, 'Red Hat Enterprise Linux 6.3 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (204, UUID(), 4, 'Red Hat Enterprise Linux 6.3 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (205, UUID(), 4, 'Red Hat Enterprise Linux 6.4 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (206, UUID(), 4, 'Red Hat Enterprise Linux 6.4 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (207, UUID(), 3, 'Oracle Enterprise Linux 5.7 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (208, UUID(), 3, 'Oracle Enterprise Linux 5.7 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (209, UUID(), 3, 'Oracle Enterprise Linux 5.8 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (210, UUID(), 3, 'Oracle Enterprise Linux 5.8 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (211, UUID(), 3, 'Oracle Enterprise Linux 5.9 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (212, UUID(), 3, 'Oracle Enterprise Linux 5.9 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (213, UUID(), 3, 'Oracle Enterprise Linux 6.1 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (214, UUID(), 3, 'Oracle Enterprise Linux 6.1 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (215, UUID(), 3, 'Oracle Enterprise Linux 6.2 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (216, UUID(), 3, 'Oracle Enterprise Linux 6.2 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (217, UUID(), 3, 'Oracle Enterprise Linux 6.3 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (218, UUID(), 3, 'Oracle Enterprise Linux 6.3 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (219, UUID(), 3, 'Oracle Enterprise Linux 6.4 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (220, UUID(), 3, 'Oracle Enterprise Linux 6.4 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (221, UUID(), 7, 'Apple Mac OS X 10.6 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (222, UUID(), 7, 'Apple Mac OS X 10.6 (64-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (223, UUID(), 7, 'Apple Mac OS X 10.7 (32-bit)');
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (224, UUID(), 7, 'Apple Mac OS X 10.7 (64-bit)');
-
-
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows 8 (32-bit)', 165);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows 8 (64-bit)', 166);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows Server 2012 (64-bit)', 167);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows Server 8 (64-bit)', 168);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows 8 (32-bit)', 165);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows 8 (64-bit)', 166);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows Server 2012 (64-bit)', 167);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows Server 8 (64-bit)', 168);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.5 (32-bit)', 111);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.5 (64-bit)', 112);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.6 (32-bit)', 141);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.6 (64-bit)', 142);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.7 (32-bit)', 161);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.7 (64-bit)', 162);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.8 (32-bit)', 173);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.8 (64-bit)', 174);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.9 (32-bit)', 175);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 5.9 (64-bit)', 176);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.0 (32-bit)', 143);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.0 (64-bit)', 144);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.1 (32-bit)', 177);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.1 (64-bit)', 178);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.2 (32-bit)', 179);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.2 (64-bit)', 180);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.3 (32-bit)', 171);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.3 (64-bit)', 172);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.4 (32-bit)', 181);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 6.4 (64-bit)', 182);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Debian GNU/Linux 7(32-bit)', 183);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Debian GNU/Linux 7(64-bit)', 184);
-
-INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Apple Mac OS X 10.6 (32-bit)', 221);
-INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Apple Mac OS X 10.6 (64-bit)', 222);
-INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Apple Mac OS X 10.7 (32-bit)', 223);
-INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Apple Mac OS X 10.7 (64-bit)', 224);
-
-CREATE TABLE `cloud`.`user_vm_clone_setting` (
- `vm_id` bigint unsigned NOT NULL COMMENT 'guest VM id',
- `clone_type` varchar(10) NOT NULL COMMENT 'Full or Linked Clone (applicable to VMs on ESX)',
- PRIMARY KEY (`vm_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'UserVmManager', 'vmware.create.full.clone' , 'false', 'If set to true, creates VMs as full clones on ESX hypervisor');
-
-CREATE TABLE `cloud`.`affinity_group` (
- `id` bigint unsigned NOT NULL auto_increment,
- `name` varchar(255) NOT NULL,
- `type` varchar(255) NOT NULL,
- `uuid` varchar(40),
- `description` varchar(4096) NULL,
- `domain_id` bigint unsigned NOT NULL,
- `account_id` bigint unsigned NOT NULL,
- UNIQUE (`name`, `account_id`),
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_affinity_group__account_id` FOREIGN KEY(`account_id`) REFERENCES `account`(`id`),
- CONSTRAINT `fk_affinity_group__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`),
- CONSTRAINT `uc_affinity_group__uuid` UNIQUE (`uuid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`affinity_group_vm_map` (
- `id` bigint unsigned NOT NULL auto_increment,
- `affinity_group_id` bigint unsigned NOT NULL,
- `instance_id` bigint unsigned NOT NULL,
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_agvm__group_id` FOREIGN KEY(`affinity_group_id`) REFERENCES `affinity_group`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_affinity_group_vm_map___instance_id` FOREIGN KEY(`instance_id`) REFERENCES `user_vm` (`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-
-
-CREATE TABLE `cloud`.`dedicated_resources` (
- `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
- `uuid` varchar(40),
- `data_center_id` bigint unsigned COMMENT 'data center id',
- `pod_id` bigint unsigned COMMENT 'pod id',
- `cluster_id` bigint unsigned COMMENT 'cluster id',
- `host_id` bigint unsigned COMMENT 'host id',
- `domain_id` bigint unsigned COMMENT 'domain id of the domain to which resource is dedicated',
- `account_id` bigint unsigned COMMENT 'account id of the account to which resource is dedicated',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_dedicated_resources__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `cloud`.`data_center`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_dedicated_resources__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`),
- CONSTRAINT `fk_dedicated_resources__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cloud`.`cluster`(`id`),
- CONSTRAINT `fk_dedicated_resources__host_id` FOREIGN KEY (`host_id`) REFERENCES `cloud`.`host`(`id`),
- CONSTRAINT `fk_dedicated_resources__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`),
- CONSTRAINT `fk_dedicated_resources__account_id` FOREIGN KEY (`account_id`) REFERENCES `account`(`id`),
- INDEX `i_dedicated_resources_domain_id`(`domain_id`),
- INDEX `i_dedicated_resources_account_id`(`account_id`),
- CONSTRAINT `uc_dedicated_resources__uuid` UNIQUE (`uuid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE nic_secondary_ips (
- `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT,
- `uuid` varchar(40),
- `vmId` bigint unsigned COMMENT 'vm instance id',
- `nicId` bigint unsigned NOT NULL,
- `ip4_address` char(40) COMMENT 'ip4 address',
- `ip6_address` char(40) COMMENT 'ip6 address',
- `network_id` bigint unsigned NOT NULL COMMENT 'network configuration id',
- `created` datetime NOT NULL COMMENT 'date created',
- `account_id` bigint unsigned NOT NULL COMMENT 'owner. foreign key to account table',
- `domain_id` bigint unsigned NOT NULL COMMENT 'the domain that the owner belongs to',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_nic_secondary_ip__vmId` FOREIGN KEY `fk_nic_secondary_ip__vmId`(`vmId`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_nic_secondary_ip__networks_id` FOREIGN KEY `fk_nic_secondary_ip__networks_id`(`network_id`) REFERENCES `networks`(`id`),
- CONSTRAINT `uc_nic_secondary_ip__uuid` UNIQUE (`uuid`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-ALTER TABLE `cloud`.`nics` ADD COLUMN secondary_ip SMALLINT DEFAULT '0' COMMENT 'secondary ips configured for the nic';
-ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN dnat_vmip VARCHAR(40);
-UPDATE `cloud`.`user_ip_address`,`cloud`.`nics` SET `user_ip_address`.`dnat_vmip` = `nics`.`ip4_address`
- WHERE `user_ip_address`.`vm_id` = `nics`.`instance_id` AND `user_ip_address`.`network_id` = `nics`.`network_id` AND `user_ip_address`.`one_to_one_nat` = 1;
-
-ALTER TABLE `cloud`.`alert` ADD COLUMN `archived` tinyint(1) unsigned NOT NULL DEFAULT 0;
-ALTER TABLE `cloud`.`event` ADD COLUMN `archived` tinyint(1) unsigned NOT NULL DEFAULT 0;
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'alert.purge.interval', '86400', 'The interval (in seconds) to wait before running the alert purge thread');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'alert.purge.delay', '0', 'Alerts older than specified number days will be purged. Set this value to 0 to never delete alerts');
-
-INSERT INTO `cloud`.`dedicated_resources` (`data_center_id`, `domain_id`) SELECT `id`, `domain_id` FROM `cloud`.`data_center` WHERE `domain_id` IS NOT NULL;
-UPDATE `cloud`.`data_center` SET `domain_id` = NULL WHERE `domain_id` IS NOT NULL;
-
-DROP VIEW IF EXISTS `cloud`.`event_view`;
-CREATE VIEW `cloud`.`event_view` AS
- select
- event.id,
- event.uuid,
- event.type,
- event.state,
- event.description,
- event.created,
- event.level,
- event.parameters,
- event.start_id,
- eve.uuid start_uuid,
- event.user_id,
- event.archived,
- user.username user_name,
- account.id account_id,
- account.uuid account_uuid,
- account.account_name account_name,
- account.type account_type,
- domain.id domain_id,
- domain.uuid domain_uuid,
- domain.name domain_name,
- domain.path domain_path,
- projects.id project_id,
- projects.uuid project_uuid,
- projects.name project_name
- from
- `cloud`.`event`
- inner join
- `cloud`.`account` ON event.account_id = account.id
- inner join
- `cloud`.`domain` ON event.domain_id = domain.id
- inner join
- `cloud`.`user` ON event.user_id = user.id
- left join
- `cloud`.`projects` ON projects.project_account_id = event.account_id
- left join
- `cloud`.`event` eve ON event.start_id = eve.id;
-
-ALTER TABLE `cloud`.`region` ADD COLUMN `gslb_service_enabled` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT 'Is GSLB service enalbed in the Region';
-
-ALTER TABLE `cloud`.`external_load_balancer_devices` ADD COLUMN `is_gslb_provider` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if load balancer appliance is acting as gslb service provider in the zone';
-
-ALTER TABLE `cloud`.`external_load_balancer_devices` ADD COLUMN `gslb_site_publicip` varchar(255) DEFAULT NULL COMMENT 'GSLB service Provider site public ip';
-
-ALTER TABLE `cloud`.`external_load_balancer_devices` ADD COLUMN `gslb_site_privateip` varchar(255) DEFAULT NULL COMMENT 'GSLB service Provider site private ip';
-
-ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `display_vm` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should vm instance be displayed to the end user';
-
-ALTER TABLE `cloud`.`user_vm_details` ADD COLUMN `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should vm detail instance be displayed to the end user';
-
-ALTER TABLE `cloud`.`volumes` ADD COLUMN `display_volume` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should volume be displayed to the end user';
-
-ALTER TABLE `cloud`.`volumes` ADD COLUMN `format` varchar(255) COMMENT 'volume format';
-update `cloud`.`volumes` v, `cloud`.`storage_pool` s, `cloud`.`cluster` c set v.format='VHD' where v.pool_id=s.id and s.cluster_id=c.id and c.hypervisor_type='XenServer';
-update `cloud`.`volumes` v, `cloud`.`storage_pool` s, `cloud`.`cluster` c set v.format='OVA' where v.pool_id=s.id and s.cluster_id=c.id and c.hypervisor_type='VMware';
-update `cloud`.`volumes` v, `cloud`.`storage_pool` s, `cloud`.`cluster` c set v.format='QCOW2' where v.pool_id=s.id and s.cluster_id=c.id and c.hypervisor_type='KVM';
-update `cloud`.`volumes` v, `cloud`.`storage_pool` s, `cloud`.`cluster` c set v.format='RAW' where v.pool_id=s.id and s.cluster_id=c.id and c.hypervisor_type='Ovm';
-
-ALTER TABLE `cloud`.`networks` ADD COLUMN `display_network` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should network be displayed to the end user';
-
-ALTER TABLE `cloud`.`nics` ADD COLUMN `display_nic` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should nic be displayed to the end user';
-
-ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `display_offering` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should disk offering be displayed to the end user';
-
-ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `customized_iops` tinyint(1) unsigned COMMENT 'Should customized IOPS be displayed to the end user';
-
-ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `min_iops` bigint(20) unsigned COMMENT 'Minimum IOPS';
-
-ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `max_iops` bigint(20) unsigned COMMENT 'Maximum IOPS';
-
-ALTER TABLE `cloud`.`volumes` ADD COLUMN `min_iops` bigint(20) unsigned COMMENT 'Minimum IOPS';
-
-ALTER TABLE `cloud`.`volumes` ADD COLUMN `max_iops` bigint(20) unsigned COMMENT 'Maximum IOPS';
-
-ALTER TABLE `cloud`.`storage_pool` ADD COLUMN `managed` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Should CloudStack manage this storage';
-
-ALTER TABLE `cloud`.`storage_pool` ADD COLUMN `capacity_iops` bigint(20) unsigned DEFAULT NULL COMMENT 'IOPS CloudStack can provision from this storage pool';
-
-ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_read_rate` bigint(20);
-
-ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_write_rate` bigint(20);
-
-ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_read_rate` bigint(20);
-
-ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_write_rate` bigint(20);
-
-CREATE TABLE `cloud`.`volume_details` (
- `id` bigint unsigned NOT NULL auto_increment,
- `volume_id` bigint unsigned NOT NULL COMMENT 'volume id',
- `name` varchar(255) NOT NULL,
- `value` varchar(1024) NOT NULL,
- `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_volume_details__volume_id` FOREIGN KEY `fk_volume_details__volume_id`(`volume_id`) REFERENCES `volumes`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`network_details` (
- `id` bigint unsigned NOT NULL auto_increment,
- `network_id` bigint unsigned NOT NULL COMMENT 'network id',
- `name` varchar(255) NOT NULL,
- `value` varchar(1024) NOT NULL,
- `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_network_details__network_id` FOREIGN KEY `fk_network_details__network_id`(`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`nic_details` (
- `id` bigint unsigned NOT NULL auto_increment,
- `nic_id` bigint unsigned NOT NULL COMMENT 'nic id',
- `name` varchar(255) NOT NULL,
- `value` varchar(1024) NOT NULL,
- `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_nic_details__nic_id` FOREIGN KEY `fk_nic_details__nic_id`(`nic_id`) REFERENCES `nics`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`disk_offering_details` (
- `id` bigint unsigned NOT NULL auto_increment,
- `offering_id` bigint unsigned NOT NULL COMMENT 'offering id',
- `name` varchar(255) NOT NULL,
- `value` varchar(1024) NOT NULL,
- `display_detail` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_offering_details__offering_id` FOREIGN KEY `fk_offering_details__offering_id`(`offering_id`) REFERENCES `disk_offering`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`global_load_balancing_rules` (
- `id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
- `uuid` varchar(40),
- `account_id` bigint unsigned NOT NULL COMMENT 'account id',
- `domain_id` bigint unsigned NOT NULL COMMENT 'domain id',
- `region_id` int unsigned NOT NULL,
- `name` varchar(255) NOT NULL,
- `description` varchar(4096) NULL COMMENT 'description',
- `state` char(32) NOT NULL COMMENT 'current state of this rule',
- `algorithm` varchar(255) NOT NULL COMMENT 'load balancing algorithm used to distribbute traffic across zones',
- `persistence` varchar(255) NOT NULL COMMENT 'session persistence used across the zone',
- `service_type` varchar(255) NOT NULL COMMENT 'GSLB service type (tcp/udp)',
- `gslb_domain_name` varchar(255) NOT NULL COMMENT 'DNS name for the GSLB service that is used to provide a FQDN for the GSLB service',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_global_load_balancing_rules_account_id` FOREIGN KEY (`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_global_load_balancing_rules_region_id` FOREIGN KEY(`region_id`) REFERENCES `region`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`global_load_balancer_lb_rule_map` (
- `id` bigint unsigned NOT NULL auto_increment,
- `gslb_rule_id` bigint unsigned NOT NULL,
- `lb_rule_id` bigint unsigned NOT NULL,
- `weight` bigint unsigned NOT NULL DEFAULT 1 COMMENT 'weight of the site in gslb',
- `revoke` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 is when rule is set for Revoke',
- PRIMARY KEY (`id`),
- UNIQUE KEY (`gslb_rule_id`, `lb_rule_id`),
- CONSTRAINT `fk_gslb_rule_id` FOREIGN KEY(`gslb_rule_id`) REFERENCES `global_load_balancing_rules`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_lb_rule_id` FOREIGN KEY(`lb_rule_id`) REFERENCES `load_balancing_rules`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'cloud.dns.name', null, 'DNS name of the cloud for the GSLB service');
-
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT', 'management-server', 'max.account.cpus', '40', 'The default maximum number of cpu cores that can be used for an account');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT', 'management-server', 'max.account.memory', '40960', 'The default maximum memory (in MiB) that can be used for an account');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT', 'management-server', 'max.account.primary.storage', '200', 'The default maximum primary storage space (in GiB) that can be used for an account');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT', 'management-server', 'max.account.secondary.storage', '400', 'The default maximum secondary storage space (in GiB) that can be used for an account');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Project Defaults', 'DEFAULT', 'management-server', 'max.project.cpus', '40', 'The default maximum number of cpu cores that can be used for a project');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Project Defaults', 'DEFAULT', 'management-server', 'max.project.memory', '40960', 'The default maximum memory (in MiB) that can be used for a project');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Project Defaults', 'DEFAULT', 'management-server', 'max.project.primary.storage', '200', 'The default maximum primary storage space (in GiB) that can be used for a project');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Project Defaults', 'DEFAULT', 'management-server', 'max.project.secondary.storage', '400', 'The default maximum secondary storage space (in GiB) that can be used for a project');
-
-
-
-ALTER TABLE `cloud`.`remote_access_vpn` ADD COLUMN `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id';
-ALTER TABLE `cloud`.`remote_access_vpn` ADD COLUMN `uuid` varchar(40) UNIQUE;
-
--- START: support for LXC
-
-INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled) VALUES (UUID(), 'LXC', 'default', 50, 1);
-ALTER TABLE `cloud`.`physical_network_traffic_types` ADD COLUMN `lxc_network_label` varchar(255) DEFAULT 'cloudbr0' COMMENT 'The network name label of the physical device dedicated to this traffic on a LXC host';
-
-UPDATE configuration SET value='KVM,XenServer,VMware,BareMetal,Ovm,LXC' WHERE name='hypervisor.list';
-
-INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type)
- VALUES (10, UUID(), 'routing-10', 'SystemVM Template (LXC)', 0, now(), 'SYSTEM', 0, 64, 1, 'http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2', '2755de1f9ef2ce4d6f2bee2efbb4da92', 0, 'SystemVM Template (LXC)', 'QCOW2', 15, 0, 1, 'LXC');
-
-ALTER TABLE `cloud`.`user_vm` MODIFY user_data TEXT(32768);
-
--- END: support for LXC
-
-CREATE TABLE `cloud`.`vm_snapshots` (
- `id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Primary Key',
- `uuid` varchar(40) NOT NULL,
- `name` varchar(255) NOT NULL,
- `display_name` varchar(255) default NULL,
- `description` varchar(255) default NULL,
- `vm_id` bigint(20) unsigned NOT NULL,
- `account_id` bigint(20) unsigned NOT NULL,
- `domain_id` bigint(20) unsigned NOT NULL,
- `vm_snapshot_type` varchar(32) default NULL,
- `state` varchar(32) NOT NULL,
- `parent` bigint unsigned default NULL,
- `current` int(1) unsigned default NULL,
- `update_count` bigint unsigned NOT NULL DEFAULT 0,
- `updated` datetime default NULL,
- `created` datetime default NULL,
- `removed` datetime default NULL,
- PRIMARY KEY (`id`),
- CONSTRAINT UNIQUE KEY `uc_vm_snapshots_uuid` (`uuid`),
- INDEX `vm_snapshots_name` (`name`),
- INDEX `vm_snapshots_vm_id` (`vm_id`),
- INDEX `vm_snapshots_account_id` (`account_id`),
- INDEX `vm_snapshots_display_name` (`display_name`),
- INDEX `vm_snapshots_removed` (`removed`),
- INDEX `vm_snapshots_parent` (`parent`),
- CONSTRAINT `fk_vm_snapshots_vm_id__vm_instance_id` FOREIGN KEY `fk_vm_snapshots_vm_id__vm_instance_id` (`vm_id`) REFERENCES `vm_instance` (`id`),
- CONSTRAINT `fk_vm_snapshots_account_id__account_id` FOREIGN KEY `fk_vm_snapshots_account_id__account_id` (`account_id`) REFERENCES `account` (`id`),
- CONSTRAINT `fk_vm_snapshots_domain_id__domain_id` FOREIGN KEY `fk_vm_snapshots_domain_id__domain_id` (`domain_id`) REFERENCES `domain` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `vm_snapshot_enabled` tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Whether VM snapshot is supported by hypervisor';
-UPDATE `cloud`.`hypervisor_capabilities` SET `vm_snapshot_enabled`=1 WHERE `hypervisor_type` in ('VMware', 'XenServer');
-
-CREATE TABLE `cloud`.`service_offering_details` (
- `id` bigint unsigned NOT NULL auto_increment,
- `service_offering_id` bigint unsigned NOT NULL COMMENT 'service offering id',
- `name` varchar(255) NOT NULL,
- `value` varchar(255) NOT NULL,
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_service_offering_details__service_offering_id` FOREIGN KEY (`service_offering_id`) REFERENCES `service_offering`(`id`) ON DELETE CASCADE,
- CONSTRAINT UNIQUE KEY `uk_service_offering_id_name` (`service_offering_id`, `name`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-DROP VIEW IF EXISTS `cloud`.`user_vm_view`;
-CREATE VIEW `cloud`.`user_vm_view` AS
- select
- vm_instance.id id,
- vm_instance.name name,
- user_vm.display_name display_name,
- user_vm.user_data user_data,
- account.id account_id,
- account.uuid account_uuid,
- account.account_name account_name,
- account.type account_type,
- domain.id domain_id,
- domain.uuid domain_uuid,
- domain.name domain_name,
- domain.path domain_path,
- projects.id project_id,
- projects.uuid project_uuid,
- projects.name project_name,
- instance_group.id instance_group_id,
- instance_group.uuid instance_group_uuid,
- instance_group.name instance_group_name,
- vm_instance.uuid uuid,
- vm_instance.last_host_id last_host_id,
- vm_instance.vm_type type,
- vm_instance.vnc_password vnc_password,
- vm_instance.limit_cpu_use limit_cpu_use,
- vm_instance.created created,
- vm_instance.state state,
- vm_instance.removed removed,
- vm_instance.ha_enabled ha_enabled,
- vm_instance.hypervisor_type hypervisor_type,
- vm_instance.instance_name instance_name,
- vm_instance.guest_os_id guest_os_id,
- guest_os.uuid guest_os_uuid,
- vm_instance.pod_id pod_id,
- host_pod_ref.uuid pod_uuid,
- vm_instance.private_ip_address private_ip_address,
- vm_instance.private_mac_address private_mac_address,
- vm_instance.vm_type vm_type,
- data_center.id data_center_id,
- data_center.uuid data_center_uuid,
- data_center.name data_center_name,
- data_center.networktype data_center_type,
- data_center.is_security_group_enabled security_group_enabled,
- host.id host_id,
- host.uuid host_uuid,
- host.name host_name,
- vm_template.id template_id,
- vm_template.uuid template_uuid,
- vm_template.name template_name,
- vm_template.display_text template_display_text,
- vm_template.enable_password password_enabled,
- iso.id iso_id,
- iso.uuid iso_uuid,
- iso.name iso_name,
- iso.display_text iso_display_text,
- service_offering.id service_offering_id,
- disk_offering.uuid service_offering_uuid,
- service_offering.cpu cpu,
- service_offering.speed speed,
- service_offering.ram_size ram_size,
- disk_offering.name service_offering_name,
- storage_pool.id pool_id,
- storage_pool.uuid pool_uuid,
- storage_pool.pool_type pool_type,
- volumes.id volume_id,
- volumes.uuid volume_uuid,
- volumes.device_id volume_device_id,
- volumes.volume_type volume_type,
- security_group.id security_group_id,
- security_group.uuid security_group_uuid,
- security_group.name security_group_name,
- security_group.description security_group_description,
- nics.id nic_id,
- nics.uuid nic_uuid,
- nics.network_id network_id,
- nics.ip4_address ip_address,
- nics.ip6_address ip6_address,
- nics.ip6_gateway ip6_gateway,
- nics.ip6_cidr ip6_cidr,
- nics.default_nic is_default_nic,
- nics.gateway gateway,
- nics.netmask netmask,
- nics.mac_address mac_address,
- nics.broadcast_uri broadcast_uri,
- nics.isolation_uri isolation_uri,
- vpc.id vpc_id,
- vpc.uuid vpc_uuid,
- networks.uuid network_uuid,
- networks.name network_name,
- networks.traffic_type traffic_type,
- networks.guest_type guest_type,
- user_ip_address.id public_ip_id,
- user_ip_address.uuid public_ip_uuid,
- user_ip_address.public_ip_address public_ip_address,
- ssh_keypairs.keypair_name keypair_name,
- resource_tags.id tag_id,
- resource_tags.uuid tag_uuid,
- resource_tags.key tag_key,
- resource_tags.value tag_value,
- resource_tags.domain_id tag_domain_id,
- resource_tags.account_id tag_account_id,
- resource_tags.resource_id tag_resource_id,
- resource_tags.resource_uuid tag_resource_uuid,
- resource_tags.resource_type tag_resource_type,
- resource_tags.customer tag_customer,
- async_job.id job_id,
- async_job.uuid job_uuid,
- async_job.job_status job_status,
- async_job.account_id job_account_id,
- affinity_group.id affinity_group_id,
- affinity_group.uuid affinity_group_uuid,
- affinity_group.name affinity_group_name,
- affinity_group.description affinity_group_description
- from
- `cloud`.`user_vm`
- inner join
- `cloud`.`vm_instance` ON vm_instance.id = user_vm.id
- and vm_instance.removed is NULL
- inner join
- `cloud`.`account` ON vm_instance.account_id = account.id
- inner join
- `cloud`.`domain` ON vm_instance.domain_id = domain.id
- left join
- `cloud`.`guest_os` ON vm_instance.guest_os_id = guest_os.id
- left join
- `cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
- left join
- `cloud`.`projects` ON projects.project_account_id = account.id
- left join
- `cloud`.`instance_group_vm_map` ON vm_instance.id = instance_group_vm_map.instance_id
- left join
- `cloud`.`instance_group` ON instance_group_vm_map.group_id = instance_group.id
- left join
- `cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
- left join
- `cloud`.`host` ON vm_instance.host_id = host.id
- left join
- `cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
- left join
- `cloud`.`vm_template` iso ON iso.id = user_vm.iso_id
- left join
- `cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
- left join
- `cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id
- left join
- `cloud`.`volumes` ON vm_instance.id = volumes.instance_id
- left join
- `cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id
- left join
- `cloud`.`security_group_vm_map` ON vm_instance.id = security_group_vm_map.instance_id
- left join
- `cloud`.`security_group` ON security_group_vm_map.security_group_id = security_group.id
- left join
- `cloud`.`nics` ON vm_instance.id = nics.instance_id
- left join
- `cloud`.`networks` ON nics.network_id = networks.id
- left join
- `cloud`.`vpc` ON networks.vpc_id = vpc.id
- left join
- `cloud`.`user_ip_address` ON user_ip_address.vm_id = vm_instance.id
- left join
- `cloud`.`user_vm_details` ON user_vm_details.vm_id = vm_instance.id
- and user_vm_details.name = 'SSH.PublicKey'
- left join
- `cloud`.`ssh_keypairs` ON ssh_keypairs.public_key = user_vm_details.value
- left join
- `cloud`.`resource_tags` ON resource_tags.resource_id = vm_instance.id
- and resource_tags.resource_type = 'UserVm'
- left join
- `cloud`.`async_job` ON async_job.instance_id = vm_instance.id
- and async_job.instance_type = 'VirtualMachine'
- and async_job.job_status = 0
- left join
- `cloud`.`affinity_group_vm_map` ON vm_instance.id = affinity_group_vm_map.instance_id
- left join
- `cloud`.`affinity_group` ON affinity_group_vm_map.affinity_group_id = affinity_group.id;
-
-DROP VIEW IF EXISTS `cloud`.`affinity_group_view`;
-CREATE VIEW `cloud`.`affinity_group_view` AS
- select
- affinity_group.id id,
- affinity_group.name name,
- affinity_group.type type,
- affinity_group.description description,
- affinity_group.uuid uuid,
- account.id account_id,
- account.uuid account_uuid,
- account.account_name account_name,
- account.type account_type,
- domain.id domain_id,
- domain.uuid domain_uuid,
- domain.name domain_name,
- domain.path domain_path,
- vm_instance.id vm_id,
- vm_instance.uuid vm_uuid,
- vm_instance.name vm_name,
- vm_instance.state vm_state,
- user_vm.display_name vm_display_name
- from
- `cloud`.`affinity_group`
- inner join
- `cloud`.`account` ON affinity_group.account_id = account.id
- inner join
- `cloud`.`domain` ON affinity_group.domain_id = domain.id
- left join
- `cloud`.`affinity_group_vm_map` ON affinity_group.id = affinity_group_vm_map.affinity_group_id
- left join
- `cloud`.`vm_instance` ON vm_instance.id = affinity_group_vm_map.instance_id
- left join
- `cloud`.`user_vm` ON user_vm.id = vm_instance.id;
-
-DROP VIEW IF EXISTS `cloud`.`host_view`;
-CREATE VIEW `cloud`.`host_view` AS
- select
- host.id,
- host.uuid,
- host.name,
- host.status,
- host.disconnected,
- host.type,
- host.private_ip_address,
- host.version,
- host.hypervisor_type,
- host.hypervisor_version,
- host.capabilities,
- host.last_ping,
- host.created,
- host.removed,
- host.resource_state,
- host.mgmt_server_id,
- host.cpus,
- host.speed,
- host.ram,
- cluster.id cluster_id,
- cluster.uuid cluster_uuid,
- cluster.name cluster_name,
- cluster.cluster_type,
- data_center.id data_center_id,
- data_center.uuid data_center_uuid,
- data_center.name data_center_name,
- data_center.networktype data_center_type,
- host_pod_ref.id pod_id,
- host_pod_ref.uuid pod_uuid,
- host_pod_ref.name pod_name,
- host_tags.tag,
- guest_os_category.id guest_os_category_id,
- guest_os_category.uuid guest_os_category_uuid,
- guest_os_category.name guest_os_category_name,
- mem_caps.used_capacity memory_used_capacity,
- mem_caps.reserved_capacity memory_reserved_capacity,
- cpu_caps.used_capacity cpu_used_capacity,
- cpu_caps.reserved_capacity cpu_reserved_capacity,
- async_job.id job_id,
- async_job.uuid job_uuid,
- async_job.job_status job_status,
- async_job.account_id job_account_id
- from
- `cloud`.`host`
- left join
- `cloud`.`cluster` ON host.cluster_id = cluster.id
- left join
- `cloud`.`data_center` ON host.data_center_id = data_center.id
- left join
- `cloud`.`host_pod_ref` ON host.pod_id = host_pod_ref.id
- left join
- `cloud`.`host_details` ON host.id = host_details.id
- and host_details.name = 'guest.os.category.id'
- left join
- `cloud`.`guest_os_category` ON guest_os_category.id = CONVERT( host_details.value , UNSIGNED)
- left join
- `cloud`.`host_tags` ON host_tags.host_id = host.id
- left join
- `cloud`.`op_host_capacity` mem_caps ON host.id = mem_caps.host_id
- and mem_caps.capacity_type = 0
- left join
- `cloud`.`op_host_capacity` cpu_caps ON host.id = cpu_caps.host_id
- and cpu_caps.capacity_type = 1
- left join
- `cloud`.`async_job` ON async_job.instance_id = host.id
- and async_job.instance_type = 'Host'
- and async_job.job_status = 0;
-
-DROP VIEW IF EXISTS `cloud`.`storage_pool_view`;
-CREATE VIEW `cloud`.`storage_pool_view` AS
- select
- storage_pool.id,
- storage_pool.uuid,
- storage_pool.name,
- storage_pool.status,
- storage_pool.path,
- storage_pool.pool_type,
- storage_pool.host_address,
- storage_pool.created,
- storage_pool.removed,
- storage_pool.capacity_bytes,
- storage_pool.capacity_iops,
- storage_pool.scope,
- storage_pool.hypervisor,
- cluster.id cluster_id,
- cluster.uuid cluster_uuid,
- cluster.name cluster_name,
- cluster.cluster_type,
- data_center.id data_center_id,
- data_center.uuid data_center_uuid,
- data_center.name data_center_name,
- data_center.networktype data_center_type,
- host_pod_ref.id pod_id,
- host_pod_ref.uuid pod_uuid,
- host_pod_ref.name pod_name,
- storage_pool_details.name tag,
- op_host_capacity.used_capacity disk_used_capacity,
- op_host_capacity.reserved_capacity disk_reserved_capacity,
- async_job.id job_id,
- async_job.uuid job_uuid,
- async_job.job_status job_status,
- async_job.account_id job_account_id
- from
- `cloud`.`storage_pool`
- left join
- `cloud`.`cluster` ON storage_pool.cluster_id = cluster.id
- left join
- `cloud`.`data_center` ON storage_pool.data_center_id = data_center.id
- left join
- `cloud`.`host_pod_ref` ON storage_pool.pod_id = host_pod_ref.id
- left join
- `cloud`.`storage_pool_details` ON storage_pool_details.pool_id = storage_pool.id
- and storage_pool_details.value = 'true'
- left join
- `cloud`.`op_host_capacity` ON storage_pool.id = op_host_capacity.host_id
- and op_host_capacity.capacity_type = 3
- left join
- `cloud`.`async_job` ON async_job.instance_id = storage_pool.id
- and async_job.instance_type = 'StoragePool'
- and async_job.job_status = 0;
-
-
-DROP VIEW IF EXISTS `cloud`.`domain_router_view`;
-CREATE VIEW `cloud`.`domain_router_view` AS
- select
- vm_instance.id id,
- vm_instance.name name,
- account.id account_id,
- account.uuid account_uuid,
- account.account_name account_name,
- account.type account_type,
- domain.id domain_id,
- domain.uuid domain_uuid,
- domain.name domain_name,
- domain.path domain_path,
- projects.id project_id,
- projects.uuid project_uuid,
- projects.name project_name,
- vm_instance.uuid uuid,
- vm_instance.created created,
- vm_instance.state state,
- vm_instance.removed removed,
- vm_instance.pod_id pod_id,
- vm_instance.instance_name instance_name,
- host_pod_ref.uuid pod_uuid,
- data_center.id data_center_id,
- data_center.uuid data_center_uuid,
- data_center.name data_center_name,
- data_center.networktype data_center_type,
- data_center.dns1 dns1,
- data_center.dns2 dns2,
- data_center.ip6_dns1 ip6_dns1,
- data_center.ip6_dns2 ip6_dns2,
- host.id host_id,
- host.uuid host_uuid,
- host.name host_name,
- vm_template.id template_id,
- vm_template.uuid template_uuid,
- service_offering.id service_offering_id,
- disk_offering.uuid service_offering_uuid,
- disk_offering.name service_offering_name,
- nics.id nic_id,
- nics.uuid nic_uuid,
- nics.network_id network_id,
- nics.ip4_address ip_address,
- nics.ip6_address ip6_address,
- nics.ip6_gateway ip6_gateway,
- nics.ip6_cidr ip6_cidr,
- nics.default_nic is_default_nic,
- nics.gateway gateway,
- nics.netmask netmask,
- nics.mac_address mac_address,
- nics.broadcast_uri broadcast_uri,
- nics.isolation_uri isolation_uri,
- vpc.id vpc_id,
- vpc.uuid vpc_uuid,
- networks.uuid network_uuid,
- networks.name network_name,
- networks.network_domain network_domain,
- networks.traffic_type traffic_type,
- networks.guest_type guest_type,
- async_job.id job_id,
- async_job.uuid job_uuid,
- async_job.job_status job_status,
- async_job.account_id job_account_id,
- domain_router.template_version template_version,
- domain_router.scripts_version scripts_version,
- domain_router.is_redundant_router is_redundant_router,
- domain_router.redundant_state redundant_state,
- domain_router.stop_pending stop_pending,
- domain_router.role role
- from
- `cloud`.`domain_router`
- inner join
- `cloud`.`vm_instance` ON vm_instance.id = domain_router.id
- inner join
- `cloud`.`account` ON vm_instance.account_id = account.id
- inner join
- `cloud`.`domain` ON vm_instance.domain_id = domain.id
- left join
- `cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
- left join
- `cloud`.`projects` ON projects.project_account_id = account.id
- left join
- `cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
- left join
- `cloud`.`host` ON vm_instance.host_id = host.id
- left join
- `cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
- left join
- `cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
- left join
- `cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id
- left join
- `cloud`.`nics` ON vm_instance.id = nics.instance_id and nics.removed is null
- left join
- `cloud`.`networks` ON nics.network_id = networks.id
- left join
- `cloud`.`vpc` ON domain_router.vpc_id = vpc.id and vpc.removed is null
- left join
- `cloud`.`async_job` ON async_job.instance_id = vm_instance.id
- and async_job.instance_type = 'DomainRouter'
- and async_job.job_status = 0;
-
-CREATE TABLE `cloud`.`external_cisco_vnmc_devices` (
- `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
- `uuid` varchar(255) UNIQUE,
- `physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network in to which cisco vnmc device is added',
- `provider_name` varchar(255) NOT NULL COMMENT 'Service Provider name corresponding to this cisco vnmc device',
- `device_name` varchar(255) NOT NULL COMMENT 'name of the cisco vnmc device',
- `host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the external cisco vnmc device',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_external_cisco_vnmc_devices__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_external_cisco_vnmc_devices__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`external_cisco_asa1000v_devices` (
- `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
- `uuid` varchar(255) UNIQUE,
- `physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network in to which cisco asa1kv device is added',
- `management_ip` varchar(255) UNIQUE NOT NULL COMMENT 'mgmt. ip of cisco asa1kv device',
- `in_port_profile` varchar(255) NOT NULL COMMENT 'inside port profile name of cisco asa1kv device',
- `cluster_id` bigint unsigned NOT NULL COMMENT 'id of the Vmware cluster to which cisco asa1kv device is attached (cisco n1kv switch)',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_external_cisco_asa1000v_devices__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_external_cisco_asa1000v_devices__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cluster`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`network_asa1000v_map` (
- `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
- `network_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of guest network',
- `asa1000v_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of asa1000v device',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_network_asa1000v_map__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_network_asa1000v_map__asa1000v_id` FOREIGN KEY (`asa1000v_id`) REFERENCES `external_cisco_asa1000v_devices`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`vmware_data_center` (
- `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
- `uuid` varchar(255) UNIQUE,
- `name` varchar(255) NOT NULL COMMENT 'Name of VMware datacenter',
- `guid` varchar(255) NOT NULL UNIQUE COMMENT 'id of VMware datacenter',
- `vcenter_host` varchar(255) NOT NULL COMMENT 'vCenter host containing this VMware datacenter',
- `username` varchar(255) NOT NULL COMMENT 'Name of vCenter host user',
- `password` varchar(255) NOT NULL COMMENT 'Password of vCenter host user',
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`vmware_data_center_zone_map` (
- `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
- `zone_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of CloudStack zone',
- `vmware_data_center_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of VMware datacenter',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_vmware_data_center_zone_map__vmware_data_center_id` FOREIGN KEY (`vmware_data_center_id`) REFERENCES `vmware_data_center`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`legacy_zones` (
- `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
- `zone_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of CloudStack zone',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_legacy_zones__zone_id` FOREIGN KEY (`zone_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.' AFTER `elastic_ip_service`;
-
-
-CREATE TABLE `cloud`.`op_host_planner_reservation` (
- `id` bigint unsigned NOT NULL auto_increment,
- `data_center_id` bigint unsigned NOT NULL,
- `pod_id` bigint unsigned,
- `cluster_id` bigint unsigned,
- `host_id` bigint unsigned,
- `resource_usage` varchar(255) COMMENT 'Shared(between planners) Vs Dedicated (exclusive usage to a planner)',
- PRIMARY KEY (`id`),
- INDEX `i_op_host_planner_reservation__host_resource_usage`(`host_id`, `resource_usage`),
- CONSTRAINT `fk_planner_reservation__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_planner_reservation__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `cloud`.`data_center`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_planner_reservation__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_planner_reservation__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cloud`.`cluster`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-ALTER TABLE `cloud`.`service_offering` ADD COLUMN `deployment_planner` varchar(255) COMMENT 'Planner heuristics used to deploy a VM of this offering; if null global config vm.deployment.planner is used';
-
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'vm.deployment.planner', 'FirstFitPlanner', '[''FirstFitPlanner'', ''UserDispersingPlanner'', ''UserConcentratedPodPlanner'']: DeploymentPlanner heuristic that will be used for VM deployment.');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'host.reservation.release.period', '300000', 'The interval in milliseconds between host reservation release checks');
-
-DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
-CREATE VIEW `cloud`.`service_offering_view` AS
- select
- service_offering.id,
- disk_offering.uuid,
- disk_offering.name,
- disk_offering.display_text,
- disk_offering.created,
- disk_offering.tags,
- disk_offering.removed,
- disk_offering.use_local_storage,
- disk_offering.system_use,
- disk_offering.bytes_read_rate,
- disk_offering.bytes_write_rate,
- disk_offering.iops_read_rate,
- disk_offering.iops_write_rate,
- service_offering.cpu,
- service_offering.speed,
- service_offering.ram_size,
- service_offering.nw_rate,
- service_offering.mc_rate,
- service_offering.ha_enabled,
- service_offering.limit_cpu_use,
- service_offering.host_tag,
- service_offering.default_use,
- service_offering.vm_type,
- service_offering.sort_key,
- service_offering.is_volatile,
- service_offering.deployment_planner,
- domain.id domain_id,
- domain.uuid domain_uuid,
- domain.name domain_name,
- domain.path domain_path
- from
- `cloud`.`service_offering`
- inner join
- `cloud`.`disk_offering` ON service_offering.id = disk_offering.id
- left join
- `cloud`.`domain` ON disk_offering.domain_id = domain.id;
-
--- Add "default" field to account/user tables
-ALTER TABLE `cloud`.`account` ADD COLUMN `default` int(1) unsigned NOT NULL DEFAULT '0' COMMENT '1 if account is default';
-ALTER TABLE `cloud_usage`.`account` ADD COLUMN `default` int(1) unsigned NOT NULL DEFAULT '0' COMMENT '1 if account is default';
-ALTER TABLE `cloud`.`user` ADD COLUMN `default` int(1) unsigned NOT NULL DEFAULT '0' COMMENT '1 if user is default';
-UPDATE `cloud`.`account` SET `cloud`.`account`.`default`=1 WHERE id IN (1,2);
-UPDATE `cloud_usage`.`account` SET `default`=1 WHERE id IN (1,2);
-UPDATE `cloud`.`user` SET `cloud`.`user`.`default`=1 WHERE id IN (1,2);
-
-ALTER VIEW `cloud`.`user_view` AS
- select
- user.id,
- user.uuid,
- user.username,
- user.password,
- user.firstname,
- user.lastname,
- user.email,
- user.state,
- user.api_key,
- user.secret_key,
- user.created,
- user.removed,
- user.timezone,
- user.registration_token,
- user.is_registered,
- user.incorrect_login_attempts,
- user.default,
- account.id account_id,
- account.uuid account_uuid,
- account.account_name account_name,
- account.type account_type,
- domain.id domain_id,
- domain.uuid domain_uuid,
- domain.name domain_name,
- domain.path domain_path,
- async_job.id job_id,
- async_job.uuid job_uuid,
- async_job.job_status job_status,
- async_job.account_id job_account_id
- from
- `cloud`.`user`
- inner join
- `cloud`.`account` ON user.account_id = account.id
- inner join
- `cloud`.`domain` ON account.domain_id = domain.id
- left join
- `cloud`.`async_job` ON async_job.instance_id = user.id
- and async_job.instance_type = 'User'
- and async_job.job_status = 0;
-
-
-DROP VIEW IF EXISTS `cloud`.`account_view`;
-CREATE VIEW `cloud`.`account_view` AS
- select
- account.id,
- account.uuid,
- account.account_name,
- account.type,
- account.state,
- account.removed,
- account.cleanup_needed,
- account.network_domain,
- account.default,
- domain.id domain_id,
- domain.uuid domain_uuid,
- domain.name domain_name,
- domain.path domain_path,
- data_center.id data_center_id,
- data_center.uuid data_center_uuid,
- data_center.name data_center_name,
- account_netstats_view.bytesReceived,
- account_netstats_view.bytesSent,
- vmlimit.max vmLimit,
- vmcount.count vmTotal,
- runningvm.vmcount runningVms,
- stoppedvm.vmcount stoppedVms,
- iplimit.max ipLimit,
- ipcount.count ipTotal,
- free_ip_view.free_ip ipFree,
- volumelimit.max volumeLimit,
- volumecount.count volumeTotal,
- snapshotlimit.max snapshotLimit,
- snapshotcount.count snapshotTotal,
- templatelimit.max templateLimit,
- templatecount.count templateTotal,
- vpclimit.max vpcLimit,
- vpccount.count vpcTotal,
- projectlimit.max projectLimit,
- projectcount.count projectTotal,
- networklimit.max networkLimit,
- networkcount.count networkTotal,
- cpulimit.max cpuLimit,
- cpucount.count cpuTotal,
- memorylimit.max memoryLimit,
- memorycount.count memoryTotal,
- primary_storage_limit.max primaryStorageLimit,
- primary_storage_count.count primaryStorageTotal,
- secondary_storage_limit.max secondaryStorageLimit,
- secondary_storage_count.count secondaryStorageTotal,
- async_job.id job_id,
- async_job.uuid job_uuid,
- async_job.job_status job_status,
- async_job.account_id job_account_id
- from
- `cloud`.`free_ip_view`,
- `cloud`.`account`
- inner join
- `cloud`.`domain` ON account.domain_id = domain.id
- left join
- `cloud`.`data_center` ON account.default_zone_id = data_center.id
- left join
- `cloud`.`account_netstats_view` ON account.id = account_netstats_view.account_id
- left join
- `cloud`.`resource_limit` vmlimit ON account.id = vmlimit.account_id
- and vmlimit.type = 'user_vm'
- left join
- `cloud`.`resource_count` vmcount ON account.id = vmcount.account_id
- and vmcount.type = 'user_vm'
- left join
- `cloud`.`account_vmstats_view` runningvm ON account.id = runningvm.account_id
- and runningvm.state = 'Running'
- left join
- `cloud`.`account_vmstats_view` stoppedvm ON account.id = stoppedvm.account_id
- and stoppedvm.state = 'Stopped'
- left join
- `cloud`.`resource_limit` iplimit ON account.id = iplimit.account_id
- and iplimit.type = 'public_ip'
- left join
- `cloud`.`resource_count` ipcount ON account.id = ipcount.account_id
- and ipcount.type = 'public_ip'
- left join
- `cloud`.`resource_limit` volumelimit ON account.id = volumelimit.account_id
- and volumelimit.type = 'volume'
- left join
- `cloud`.`resource_count` volumecount ON account.id = volumecount.account_id
- and volumecount.type = 'volume'
- left join
- `cloud`.`resource_limit` snapshotlimit ON account.id = snapshotlimit.account_id
- and snapshotlimit.type = 'snapshot'
- left join
- `cloud`.`resource_count` snapshotcount ON account.id = snapshotcount.account_id
- and snapshotcount.type = 'snapshot'
- left join
- `cloud`.`resource_limit` templatelimit ON account.id = templatelimit.account_id
- and templatelimit.type = 'template'
- left join
- `cloud`.`resource_count` templatecount ON account.id = templatecount.account_id
- and templatecount.type = 'template'
- left join
- `cloud`.`resource_limit` vpclimit ON account.id = vpclimit.account_id
- and vpclimit.type = 'vpc'
- left join
- `cloud`.`resource_count` vpccount ON account.id = vpccount.account_id
- and vpccount.type = 'vpc'
- left join
- `cloud`.`resource_limit` projectlimit ON account.id = projectlimit.account_id
- and projectlimit.type = 'project'
- left join
- `cloud`.`resource_count` projectcount ON account.id = projectcount.account_id
- and projectcount.type = 'project'
- left join
- `cloud`.`resource_limit` networklimit ON account.id = networklimit.account_id
- and networklimit.type = 'network'
- left join
- `cloud`.`resource_count` networkcount ON account.id = networkcount.account_id
- and networkcount.type = 'network'
- left join
- `cloud`.`resource_limit` cpulimit ON account.id = cpulimit.account_id
- and cpulimit.type = 'cpu'
- left join
- `cloud`.`resource_count` cpucount ON account.id = cpucount.account_id
- and cpucount.type = 'cpu'
- left join
- `cloud`.`resource_limit` memorylimit ON account.id = memorylimit.account_id
- and memorylimit.type = 'memory'
- left join
- `cloud`.`resource_count` memorycount ON account.id = memorycount.account_id
- and memorycount.type = 'memory'
- left join
- `cloud`.`resource_limit` primary_storage_limit ON account.id = primary_storage_limit.account_id
- and primary_storage_limit.type = 'primary_storage'
- left join
- `cloud`.`resource_count` primary_storage_count ON account.id = primary_storage_count.account_id
- and primary_storage_count.type = 'primary_storage'
- left join
- `cloud`.`resource_limit` secondary_storage_limit ON account.id = secondary_storage_limit.account_id
- and secondary_storage_limit.type = 'secondary_storage'
- left join
- `cloud`.`resource_count` secondary_storage_count ON account.id = secondary_storage_count.account_id
- and secondary_storage_count.type = 'secondary_storage'
- left join
- `cloud`.`async_job` ON async_job.instance_id = account.id
- and async_job.instance_type = 'Account'
- and async_job.job_status = 0;
-
-
-
-ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `source_ip_address` varchar(40) COMMENT 'source ip address for the load balancer rule';
-ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `source_ip_address_network_id` bigint unsigned COMMENT 'the id of the network where source ip belongs to';
-ALTER TABLE `cloud`.`load_balancing_rules` ADD COLUMN `scheme` varchar(40) NOT NULL COMMENT 'load balancer scheme; can be Internal or Public';
-UPDATE `cloud`.`load_balancing_rules` SET `scheme`='Public';
-
-
-
--- Add details talbe for the network offering
-CREATE TABLE `cloud`.`network_offering_details` (
- `id` bigint unsigned NOT NULL auto_increment,
- `network_offering_id` bigint unsigned NOT NULL COMMENT 'network offering id',
- `name` varchar(255) NOT NULL,
- `value` varchar(1024) NOT NULL,
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_network_offering_details__network_offering_id` FOREIGN KEY `fk_network_offering_details__network_offering_id`(`network_offering_id`) REFERENCES `network_offerings`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
--- Change the constraint for the network service map table. Now we support multiple provider for the same service
-ALTER TABLE `cloud`.`ntwk_service_map` DROP FOREIGN KEY `fk_ntwk_service_map__network_id`;
-ALTER TABLE `cloud`.`ntwk_service_map` DROP INDEX `network_id`;
-
-ALTER TABLE `cloud`.`ntwk_service_map` ADD UNIQUE `network_id` (`network_id`,`service`,`provider`);
-ALTER TABLE `cloud`.`ntwk_service_map` ADD CONSTRAINT `fk_ntwk_service_map__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE;
-
-
-ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `internal_lb` int(1) unsigned NOT NULL DEFAULT '0' COMMENT 'true if the network offering supports Internal lb service';
-ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `public_lb` int(1) unsigned NOT NULL DEFAULT '0' COMMENT 'true if the network offering supports Public lb service';
-UPDATE `cloud`.`network_offerings` SET public_lb=1 where id IN (SELECT DISTINCT network_offering_id FROM `cloud`.`ntwk_offering_service_map` WHERE service='Lb');
-
-
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'NetworkManager', 'internallbvm.service.offering', null, 'Uuid of the service offering used by internal lb vm; if NULL - default system internal lb offering will be used');
-
-
-alter table `cloud_usage`.`usage_network_offering` add column nic_id bigint(20) unsigned NOT NULL;
-
-CREATE TABLE `cloud`.`portable_ip_range` (
- `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT,
- `uuid` varchar(40),
- `region_id` int unsigned NOT NULL,
- `vlan_id` varchar(255),
- `gateway` varchar(255),
- `netmask` varchar(255),
- `start_ip` varchar(255),
- `end_ip` varchar(255),
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_portableip__region_id` FOREIGN KEY (`region_id`) REFERENCES `region`(`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `cloud`.`portable_ip_address` (
- `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT,
- `account_id` bigint unsigned NULL,
- `domain_id` bigint unsigned NULL,
- `allocated` datetime NULL COMMENT 'Date portable ip was allocated',
- `state` char(32) NOT NULL default 'Free' COMMENT 'state of the portable ip address',
- `region_id` int unsigned NOT NULL,
- `vlan` varchar(255),
- `gateway` varchar(255),
- `netmask` varchar(255),
- `portable_ip_address` varchar(255),
- `portable_ip_range_id` bigint unsigned NOT NULL,
- `data_center_id` bigint unsigned NULL COMMENT 'zone to which portable IP is associated',
- `physical_network_id` bigint unsigned NULL COMMENT 'physical network id in the zone to which portable IP is associated',
- `network_id` bigint unsigned NULL COMMENT 'guest network to which portable ip address is associated with',
- `vpc_id` bigint unsigned COMMENT 'vpc to which portable ip address is associated with',
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_portable_ip_address__portable_ip_range_id` FOREIGN KEY (`portable_ip_range_id`) REFERENCES `portable_ip_range`(`id`) ON DELETE CASCADE,
- CONSTRAINT `fk_portable_ip_address__region_id` FOREIGN KEY (`region_id`) REFERENCES `region`(`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN is_portable int(1) unsigned NOT NULL default '0';
-
-DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
-CREATE VIEW `cloud`.`disk_offering_view` AS
- select
- disk_offering.id,
- disk_offering.uuid,
- disk_offering.name,
- disk_offering.display_text,
- disk_offering.disk_size,
- disk_offering.min_iops,
- disk_offering.max_iops,
- disk_offering.created,
- disk_offering.tags,
- disk_offering.customized,
- disk_offering.customized_iops,
- disk_offering.removed,
- disk_offering.use_local_storage,
- disk_offering.system_use,
- disk_offering.bytes_read_rate,
- disk_offering.bytes_write_rate,
- disk_offering.iops_read_rate,
- disk_offering.iops_write_rate,
- disk_offering.sort_key,
- disk_offering.type,
- disk_offering.display_offering,
- domain.id domain_id,
- domain
<TRUNCATED>
[8/9] git commit: updated refs/heads/4.2 to 0185c2f
Posted by vi...@apache.org.
CLOUDSTACK-4167: Put in upgrade paths in master for 4.1.2 and 4.2
Description:
Define upgrade paths from 4.1.0 to 4.1.1, and 4.1.1 to 4.1.2,
and 4.1.2 to 4.2.0. This new path will replace the existing
4.1.0 to 4.2.0 path. This is required to allow upgrades from
4.1.2 installations to 4.2.0. The 4.1.2 installation will have
that db version upon installation from the 4.1 branch. Please
note that these new upgrade paths are empty and don't make
any SQL schema modifications.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d47b4a99
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d47b4a99
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d47b4a99
Branch: refs/heads/4.2
Commit: d47b4a994923246225131624ab806485987ee01f
Parents: e61a380
Author: Vijayendra Bhamidipati <vi...@citrix.com>
Authored: Wed Aug 7 11:53:42 2013 -0700
Committer: Vijayendra <vi...@citrix.com>
Committed: Fri Aug 9 18:23:58 2013 -0700
----------------------------------------------------------------------
.../cloud/upgrade/DatabaseUpgradeChecker.java | 104 +-
.../com/cloud/upgrade/dao/Upgrade410to411.java | 77 +
.../com/cloud/upgrade/dao/Upgrade410to420.java | 2115 ----------------
.../com/cloud/upgrade/dao/Upgrade411to412.java | 77 +
.../com/cloud/upgrade/dao/Upgrade412to420.java | 2115 ++++++++++++++++
setup/db/db/schema-410to420-cleanup.sql | 28 -
setup/db/db/schema-410to420.sql | 2291 ------------------
setup/db/db/schema-412to420-cleanup.sql | 26 +
setup/db/db/schema-412to420.sql | 2291 ++++++++++++++++++
9 files changed, 4657 insertions(+), 4467 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d47b4a99/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java b/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java
index 7232058..d49a884 100755
--- a/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java
+++ b/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java
@@ -61,7 +61,9 @@ import com.cloud.upgrade.dao.Upgrade306to307;
import com.cloud.upgrade.dao.Upgrade307to410;
import com.cloud.upgrade.dao.Upgrade30to301;
import com.cloud.upgrade.dao.Upgrade40to41;
-import com.cloud.upgrade.dao.Upgrade410to420;
+import com.cloud.upgrade.dao.Upgrade410to411;
+import com.cloud.upgrade.dao.Upgrade411to412;
+import com.cloud.upgrade.dao.Upgrade412to420;
import com.cloud.upgrade.dao.UpgradeSnapshot217to224;
import com.cloud.upgrade.dao.UpgradeSnapshot223to224;
import com.cloud.upgrade.dao.VersionDao;
@@ -88,108 +90,144 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
new UpgradeSnapshot217to224(), new Upgrade222to224(), new Upgrade224to225(), new Upgrade225to226(),
new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(),
new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(),
- new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.1.8", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(),
new Upgrade222to224(), new Upgrade218to224DomainVlans(), new Upgrade224to225(), new Upgrade225to226(),
new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(),
new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(),
- new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.1.9", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(),
new Upgrade222to224(), new Upgrade218to224DomainVlans(), new Upgrade224to225(), new Upgrade225to226(),
new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(),
new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(),
- new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.1", new DbUpgrade[] { new Upgrade221to222(), new UpgradeSnapshot223to224(), new Upgrade222to224(),
new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(),
new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(),
- new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.2", new DbUpgrade[] { new Upgrade222to224(), new UpgradeSnapshot223to224(), new Upgrade224to225(),
new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(),
new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(),
- new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.3", new DbUpgrade[] { new Upgrade222to224(), new UpgradeSnapshot223to224(), new Upgrade224to225(),
new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(),
new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(),
- new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.4", new DbUpgrade[] { new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(),
new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(),
new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(),
- new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.5", new DbUpgrade[] { new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(),
new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(),
new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(),
- new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.6", new DbUpgrade[] { new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(),
new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(),
- new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.7", new DbUpgrade[] { new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(),
new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(),
- new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.8", new DbUpgrade[] { new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(),
- new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30()
- , new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(),
+ new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.9", new DbUpgrade[] { new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(),
new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(),
- new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.10", new DbUpgrade[] { new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(),
- new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.11", new DbUpgrade[] { new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(),
- new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.12", new DbUpgrade[] { new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(),
- new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.13", new DbUpgrade[] { new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(),
- new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.14", new DbUpgrade[] { new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(),
- new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
- _upgradeMap.put("3.0.0", new DbUpgrade[] { new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ _upgradeMap.put("3.0.0", new DbUpgrade[] { new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
+
+ _upgradeMap.put("3.0.1", new DbUpgrade[] { new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
+
+ _upgradeMap.put("3.0.2", new DbUpgrade[] { new Upgrade302to40(), new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
+
+ _upgradeMap.put("4.0.0", new DbUpgrade[] { new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
- _upgradeMap.put("3.0.1", new DbUpgrade[] { new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ _upgradeMap.put("4.0.1", new DbUpgrade[] { new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
- _upgradeMap.put("3.0.2", new DbUpgrade[] { new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420() });
+ _upgradeMap.put("4.0.2", new DbUpgrade[] { new Upgrade40to41(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
- _upgradeMap.put("4.0.0", new DbUpgrade[] { new Upgrade40to41(), new Upgrade410to420() });
+ _upgradeMap.put("4.1.0", new DbUpgrade[] { new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
- _upgradeMap.put("4.0.1", new DbUpgrade[] { new Upgrade40to41(), new Upgrade410to420() });
+ _upgradeMap.put("4.1.1", new DbUpgrade[] { new Upgrade411to412(), new Upgrade412to420() });
- _upgradeMap.put("4.0.2", new DbUpgrade[] { new Upgrade40to41(), new Upgrade410to420() });
+ _upgradeMap.put("4.1.2", new DbUpgrade[] { new Upgrade412to420() });
- _upgradeMap.put("4.1.0", new DbUpgrade[] { new Upgrade410to420() });
+ //_upgradeMap.put("4.1.0", new DbUpgrade[] { new Upgrade410to420() });
//CP Upgrades
- _upgradeMap.put("3.0.3", new DbUpgrade[] { new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420() });
+ _upgradeMap.put("3.0.3", new DbUpgrade[] { new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
- _upgradeMap.put("3.0.4", new DbUpgrade[] { new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420() });
+ _upgradeMap.put("3.0.4", new DbUpgrade[] { new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
- _upgradeMap.put("3.0.5", new DbUpgrade[] { new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420() });
+ _upgradeMap.put("3.0.5", new DbUpgrade[] { new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
- _upgradeMap.put("3.0.6", new DbUpgrade[] { new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420() });
+ _upgradeMap.put("3.0.6", new DbUpgrade[] { new Upgrade306to307(), new Upgrade307to410(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
- _upgradeMap.put("3.0.7", new DbUpgrade[] { new Upgrade307to410(), new Upgrade410to420() });
+ _upgradeMap.put("3.0.7", new DbUpgrade[] { new Upgrade307to410(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.15", new DbUpgrade[] { new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(),
- new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(),new Upgrade307to410(), new Upgrade410to420()});
+ new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(),new Upgrade307to410(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
_upgradeMap.put("2.2.16", new DbUpgrade[] { new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(),
- new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(),new Upgrade307to410(), new Upgrade410to420()});
+ new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(),new Upgrade307to410(),
+ new Upgrade410to411(), new Upgrade411to412(), new Upgrade412to420() });
}
protected void runScript(Connection conn, File file) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d47b4a99/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to411.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to411.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to411.java
new file mode 100644
index 0000000..916e830
--- /dev/null
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to411.java
@@ -0,0 +1,77 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.upgrade.dao;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+import org.apache.log4j.Logger;
+
+import com.cloud.deploy.DeploymentPlanner;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.network.vpc.NetworkACL;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+
+public class Upgrade410to411 implements DbUpgrade {
+ final static Logger s_logger = Logger.getLogger(Upgrade410to411.class);
+
+ @Override
+ public String[] getUpgradableVersionRange() {
+ return new String[] { "4.1.0", "4.1.1" };
+ }
+
+ @Override
+ public String getUpgradedVersion() {
+ return "4.1.1";
+ }
+
+ @Override
+ public boolean supportsRollingUpgrade() {
+ return false;
+ }
+
+ @Override
+ public File[] getPrepareScripts() {
+ // Do nothing.
+ return null;
+ }
+
+ @Override
+ public void performDataMigration(Connection conn) {
+ // Nothing to be done
+ }
+
+ @Override
+ public File[] getCleanupScripts() {
+ return null;
+ }
+}
[7/9] CLOUDSTACK-4167: Put in upgrade paths in master for 4.1.2 and
4.2
Posted by vi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d47b4a99/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
deleted file mode 100644
index 991a54e..0000000
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ /dev/null
@@ -1,2115 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package com.cloud.upgrade.dao;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.Date;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
-import org.apache.log4j.Logger;
-
-import com.cloud.deploy.DeploymentPlanner;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.network.vpc.NetworkACL;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.script.Script;
-
-public class Upgrade410to420 implements DbUpgrade {
- final static Logger s_logger = Logger.getLogger(Upgrade410to420.class);
-
-
- @Override
- public String[] getUpgradableVersionRange() {
- return new String[] { "4.1.0", "4.2.0" };
- }
-
- @Override
- public String getUpgradedVersion() {
- return "4.2.0";
- }
-
- @Override
- public boolean supportsRollingUpgrade() {
- return false;
- }
-
- @Override
- public File[] getPrepareScripts() {
- String script = Script.findScript("", "db/schema-410to420.sql");
- if (script == null) {
- throw new CloudRuntimeException("Unable to find db/schema-410to420.sql");
- }
-
- return new File[] { new File(script) };
- }
-
- @Override
- public void performDataMigration(Connection conn) {
- upgradeVmwareLabels(conn);
- persistLegacyZones(conn);
- createPlaceHolderNics(conn);
- updateRemoteAccessVpn(conn);
- updateSystemVmTemplates(conn);
- updateCluster_details(conn);
- updatePrimaryStore(conn);
- addEgressFwRulesForSRXGuestNw(conn);
- upgradeEIPNetworkOfferings(conn);
- updateGlobalDeploymentPlanner(conn);
- upgradeDefaultVpcOffering(conn);
- upgradePhysicalNtwksWithInternalLbProvider(conn);
- updateNetworkACLs(conn);
- addHostDetailsIndex(conn);
- updateNetworksForPrivateGateways(conn);
- correctExternalNetworkDevicesSetup(conn);
- removeFirewallServiceFromSharedNetworkOfferingWithSGService(conn);
- fix22xKVMSnapshots(conn);
- setKVMSnapshotFlag(conn);
- addIndexForAlert(conn);
- fixBaremetalForeignKeys(conn);
- // storage refactor related migration
- // TODO: add clean-up scripts to delete the deprecated table.
- migrateSecondaryStorageToImageStore(conn);
- migrateVolumeHostRef(conn);
- migrateTemplateHostRef(conn);
- migrateSnapshotStoreRef(conn);
- fixNiciraKeys(conn);
- fixRouterKeys(conn);
- updateConcurrentConnectionsInNetworkOfferings(conn);
- migrateDatafromIsoIdInVolumesTable(conn);
- }
-
- private void fixBaremetalForeignKeys(Connection conn) {
- List<String> keys = new ArrayList<String>();
- keys.add("fk_external_dhcp_devices_nsp_id");
- keys.add("fk_external_dhcp_devices_host_id");
- keys.add("fk_external_dhcp_devices_pod_id");
- keys.add("fk_external_dhcp_devices_physical_network_id");
- DbUpgradeUtils.dropKeysIfExist(conn, "baremetal_dhcp_devices", keys, true);
-
- keys.add("fk_external_pxe_devices_nsp_id");
- keys.add("fk_external_pxe_devices_host_id");
- keys.add("fk_external_pxe_devices_physical_network_id");
- DbUpgradeUtils.dropKeysIfExist(conn, "baremetal_pxe_devices", keys, true);
-
- PreparedStatement pstmt = null;
- try {
- pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE");
- pstmt.executeUpdate();
- pstmt.close();
- pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE");
- pstmt.executeUpdate();
- pstmt.close();
- pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_pod_id` FOREIGN KEY (`pod_id`) REFERENCES `host_pod_ref`(`id`) ON DELETE CASCADE");
- pstmt.executeUpdate();
- pstmt.close();
- pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE");
- pstmt.executeUpdate();
- pstmt.close();
- s_logger.debug("Added foreign keys for table baremetal_dhcp_devices");
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to add foreign keys to baremetal_dhcp_devices table", e);
- }
-
- try {
- pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE");
- pstmt.executeUpdate();
- pstmt.close();
- pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE");
- pstmt.executeUpdate();
- pstmt.close();
- pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE");
- pstmt.executeUpdate();
- pstmt.close();
- s_logger.debug("Added foreign keys for table baremetal_pxe_devices");
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to add foreign keys to baremetal_pxe_devices table", e);
- }
- }
-
- private void addIndexForAlert(Connection conn) {
-
- //First drop if it exists. (Due to patches shipped to customers some will have the index and some wont.)
- List<String> indexList = new ArrayList<String>();
- s_logger.debug("Dropping index i_alert__last_sent if it exists");
- indexList.add("last_sent"); // in 4.1, we created this index that is not in convention.
- indexList.add("i_alert__last_sent");
- DbUpgradeUtils.dropKeysIfExist(conn, "alert", indexList, false);
-
- //Now add index.
- PreparedStatement pstmt = null;
- try {
- pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`alert` ADD INDEX `i_alert__last_sent`(`last_sent`)");
- pstmt.executeUpdate();
- s_logger.debug("Added index i_alert__last_sent for table alert");
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to add index i_alert__last_sent to alert table for the column last_sent", e);
- } finally {
- try {
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
-
- }
-
- private void dropUploadTable(Connection conn) {
-
- PreparedStatement pstmt0 = null;
- PreparedStatement pstmt1 = null;
- PreparedStatement pstmt2 = null;
- PreparedStatement pstmt3 = null;
-
- ResultSet rs0 = null;
- ResultSet rs2 = null;
-
- try {
- // Read upload table - Templates
- s_logger.debug("Populating template_store_ref table");
- pstmt0 = conn.prepareStatement("SELECT url, created, type_id, host_id from upload where type=?");
- pstmt0.setString(1, "TEMPLATE");
- rs0 = pstmt0.executeQuery();
- pstmt1 = conn.prepareStatement("UPDATE template_store_ref SET download_url=?, download_url_created=? where template_id=? and store_id=?");
-
- //Update template_store_ref
- while(rs0.next()){
- pstmt1.setString(1, rs0.getString("url"));
- pstmt1.setDate(2, rs0.getDate("created"));
- pstmt1.setLong(3, rs0.getLong("type_id"));
- pstmt1.setLong(4, rs0.getLong("host_id"));
- pstmt1.executeUpdate();
- }
-
-
-
- // Read upload table - Volumes
- s_logger.debug("Populating volume store ref table");
- pstmt2 = conn.prepareStatement("SELECT url, created, type_id, host_id, install_path from upload where type=?");
- pstmt2.setString(1, "VOLUME");
- rs2 = pstmt2.executeQuery();
-
- pstmt3 = conn.prepareStatement("INSERT IGNORE INTO volume_store_ref (volume_id, store_id, zone_id, created, state, download_url, download_url_created, install_path) VALUES (?,?,?,?,?,?,?,?)");
- //insert into template_store_ref
- while(rs2.next()){
- pstmt3.setLong(1, rs2.getLong("type_id"));
- pstmt3.setLong(2, rs2.getLong("host_id"));
- pstmt3.setLong(3, 1l);// ???
- pstmt3.setDate(4, rs2.getDate("created"));
- pstmt3.setString(5, "Ready");
- pstmt3.setString(6, rs2.getString("url"));
- pstmt3.setDate(7, rs2.getDate("created"));
- pstmt3.setString(8, rs2.getString("install_path"));
- pstmt3.executeUpdate();
- }
-
-
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable add date into template/volume store ref from upload table.", e);
- } finally {
- try {
- if (pstmt0 != null) {
- pstmt0.close();
- }
- if (pstmt1 != null) {
- pstmt1.close();
- }
- if (pstmt2 != null) {
- pstmt2.close();
- }
- if (pstmt3 != null) {
- pstmt3.close();
- }
- } catch (SQLException e) {
- }
- }
-
- }
-
-
- private void updateSystemVmTemplates(Connection conn) {
- // TODO: system vm template migration after storage refactoring
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- s_logger.debug("Updating System Vm template IDs");
- try{
- //Get all hypervisors in use
- Set<HypervisorType> hypervisorsListInUse = new HashSet<HypervisorType>();
- try {
- pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null");
- rs = pstmt.executeQuery();
- while(rs.next()){
- switch (HypervisorType.getType(rs.getString(1))) {
- case XenServer: hypervisorsListInUse.add(HypervisorType.XenServer);
- break;
- case KVM: hypervisorsListInUse.add(HypervisorType.KVM);
- break;
- case VMware: hypervisorsListInUse.add(HypervisorType.VMware);
- break;
- case Hyperv: hypervisorsListInUse.add(HypervisorType.Hyperv);
- break;
- case LXC: hypervisorsListInUse.add(HypervisorType.LXC);
- break;
- }
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Error while listing hypervisors in use", e);
- }
-
- Map<HypervisorType, String> NewTemplateNameList = new HashMap<HypervisorType, String>(){
- { put(HypervisorType.XenServer, "systemvm-xenserver-4.2");
- put(HypervisorType.VMware, "systemvm-vmware-4.2");
- put(HypervisorType.KVM, "systemvm-kvm-4.2");
- put(HypervisorType.LXC, "systemvm-lxc-4.2");
- put(HypervisorType.Hyperv, "systemvm-hyperv-4.2");
- }
- };
-
- Map<HypervisorType, String> routerTemplateConfigurationNames = new HashMap<HypervisorType, String>(){
- { put(HypervisorType.XenServer, "router.template.xen");
- put(HypervisorType.VMware, "router.template.vmware");
- put(HypervisorType.KVM, "router.template.kvm");
- put(HypervisorType.LXC, "router.template.lxc");
- put(HypervisorType.Hyperv, "router.template.hyperv");
- }
- };
-
- for (Map.Entry<HypervisorType, String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()){
- s_logger.debug("Updating " + hypervisorAndTemplateName.getKey() + " System Vms");
- try {
- //Get 4.2.0 system Vm template Id for corresponding hypervisor
- pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = ? and removed is null order by id desc limit 1");
- pstmt.setString(1, hypervisorAndTemplateName.getValue());
- rs = pstmt.executeQuery();
- if(rs.next()){
- long templateId = rs.getLong(1);
- rs.close();
- pstmt.close();
- // change template type to SYSTEM
- pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");
- pstmt.setLong(1, templateId);
- pstmt.executeUpdate();
- pstmt.close();
- // update templete ID of system Vms
- pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = ?");
- pstmt.setLong(1, templateId);
- pstmt.setString(2, hypervisorAndTemplateName.getKey().toString());
- pstmt.executeUpdate();
- pstmt.close();
- // Change value of global configuration parameter router.template.* for the corresponding hypervisor
- pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");
- pstmt.setString(1, hypervisorAndTemplateName.getValue());
- pstmt.setString(2, routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()));
- pstmt.executeUpdate();
- pstmt.close();
- } else {
- if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())){
- throw new CloudRuntimeException("4.2.0 " + hypervisorAndTemplateName.getKey() + " SystemVm template not found. Cannot upgrade system Vms");
- } else {
- s_logger.warn("4.2.0 " + hypervisorAndTemplateName.getKey() + " SystemVm template not found. " + hypervisorAndTemplateName.getKey() + " hypervisor is not used, so not failing upgrade");
- }
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Error while updating "+ hypervisorAndTemplateName.getKey() +" systemVm template", e);
- }
- }
- try {
- pstmt = conn.prepareStatement("UPDATE `cloud`.`vm_template` set dynamically_scalable = 1 where name = ? and type = 'SYSTEM'");
- pstmt.setString(1, NewTemplateNameList.get(HypervisorType.VMware));
- pstmt.executeUpdate();
- pstmt.close();
- } catch (SQLException e) {
- throw new CloudRuntimeException("Error while updating dynamically_scalable flag to 1 for SYSTEM template systemvm-vmware-4.2");
- }
- s_logger.debug("Updating System Vm Template IDs Complete");
- }
- finally {
- try {
- if (rs != null) {
- rs.close();
- }
-
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- /*
- pstmt = null;
- try {
- pstmt = conn.prepareStatement("update vm_template set image_data_store_id = 1 where type = 'SYSTEM' or type = 'BUILTIN'");
- pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new CloudRuntimeException("Failed to upgrade vm template data store uuid: " + e.toString());
- } finally {
- if (pstmt != null) {
- try {
- pstmt.close();
- } catch (SQLException e) {
- }
- }
- }
- */
- }
-
- //KVM snapshot flag: only turn on if Customers is using snapshot;
- private void setKVMSnapshotFlag(Connection conn) {
- s_logger.debug("Verify and set the KVM snapshot flag if snapshot was used. ");
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- int numRows = 0;
- pstmt = conn.prepareStatement("select count(*) from `cloud`.`snapshots` where hypervisor_type = 'KVM'");
- rs = pstmt.executeQuery();
- if(rs.next()){
- numRows = rs.getInt(1);
- }
- rs.close();
- pstmt.close();
- if (numRows > 0){
- //Add the configuration flag
- pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = 'kvm.snapshot.enabled'");
- pstmt.setString(1, "true");
- pstmt.executeUpdate();
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Failed to read the snapshot table for KVM upgrade. ", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
-
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- s_logger.debug("Done set KVM snapshot flag. ");
- }
-
- private void updatePrimaryStore(Connection conn) {
- PreparedStatement sql = null;
- PreparedStatement sql2 = null;
- try {
- sql = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type = 'Filesystem' or pool_type = 'LVM'");
- sql.setString(1, DataStoreProvider.DEFAULT_PRIMARY);
- sql.setString(2, "HOST");
- sql.executeUpdate();
-
- sql2 = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type != 'Filesystem' and pool_type != 'LVM'");
- sql2.setString(1, DataStoreProvider.DEFAULT_PRIMARY);
- sql2.setString(2, "CLUSTER");
- sql2.executeUpdate();
- } catch (SQLException e) {
- throw new CloudRuntimeException("Failed to upgrade vm template data store uuid: " + e.toString());
- } finally {
- if (sql != null) {
- try {
- sql.close();
- } catch (SQLException e) {
- }
- }
-
- if (sql2 != null) {
- try {
- sql2.close();
- } catch (SQLException e) {
- }
- }
- }
- }
-
- //update the cluster_details table with default overcommit ratios.
- private void updateCluster_details(Connection conn) {
- PreparedStatement pstmt = null;
- PreparedStatement pstmt1 = null;
- PreparedStatement pstmt2 =null;
- ResultSet rs = null;
-
- try {
- pstmt = conn.prepareStatement("select id from `cloud`.`cluster`");
- pstmt1=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value) VALUES(?, 'cpuOvercommitRatio', '1')");
- pstmt2=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value) VALUES(?, 'memoryOvercommitRatio', '1')");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- long id = rs.getLong(1);
- //update cluster_details table with the default overcommit ratios.
- pstmt1.setLong(1,id);
- pstmt1.execute();
- pstmt2.setLong(1,id);
- pstmt2.execute();
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to update cluster_details with default overcommit ratios.", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
-
- @Override
- public File[] getCleanupScripts() {
- String script = Script.findScript("", "db/schema-410to420-cleanup.sql");
- if (script == null) {
- throw new CloudRuntimeException("Unable to find db/schema-410to420-cleanup.sql");
- }
-
- return new File[] { new File(script) };
- }
-
- private String getNewLabel(ResultSet rs, String oldParamValue) {
- int separatorIndex;
- String oldGuestLabel;
- String newGuestLabel = oldParamValue;
- try {
- // No need to iterate because the global param setting applies to all physical networks irrespective of traffic type
- if (rs.next()) {
- oldGuestLabel = rs.getString("vmware_network_label");
- // guestLabel is in format [[<VSWITCHNAME>],VLANID]
- separatorIndex = oldGuestLabel.indexOf(",");
- if(separatorIndex > -1) {
- newGuestLabel += oldGuestLabel.substring(separatorIndex);
- }
- }
- } catch (SQLException e) {
- s_logger.error(new CloudRuntimeException("Failed to read vmware_network_label : " + e));
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- } catch (SQLException e) {
- }
- }
- return newGuestLabel;
- }
-
- private void upgradeVmwareLabels(Connection conn) {
- PreparedStatement pstmt = null;
- ResultSet rsParams = null;
- ResultSet rsLabel = null;
- String newLabel;
- String trafficType = null;
- String trafficTypeVswitchParam;
- String trafficTypeVswitchParamValue;
-
- try {
- // update the existing vmware traffic labels
- pstmt = conn.prepareStatement("select name,value from `cloud`.`configuration` where category='Hidden' and value is not NULL and name REGEXP 'vmware\\.*\\.vswitch';");
- rsParams = pstmt.executeQuery();
- while (rsParams.next()) {
- trafficTypeVswitchParam = rsParams.getString("name");
- trafficTypeVswitchParamValue = rsParams.getString("value");
- // When upgraded from 4.0 to 4.1 update physical network traffic label with trafficTypeVswitchParam
- if (trafficTypeVswitchParam.equals("vmware.private.vswitch")) {
- trafficType = "Management"; //TODO(sateesh): Ignore storage traffic, as required physical network already implemented, anything else tobe done?
- } else if (trafficTypeVswitchParam.equals("vmware.public.vswitch")) {
- trafficType = "Public";
- } else if (trafficTypeVswitchParam.equals("vmware.guest.vswitch")) {
- trafficType = "Guest";
- }
- s_logger.debug("Updating vmware label for " + trafficType + " traffic. Update SQL statement is " + pstmt);
- pstmt = conn.prepareStatement("select physical_network_id, traffic_type, vmware_network_label from physical_network_traffic_types where vmware_network_label is not NULL and traffic_type='" + trafficType + "';");
- rsLabel = pstmt.executeQuery();
- newLabel = getNewLabel(rsLabel, trafficTypeVswitchParamValue);
- pstmt = conn.prepareStatement("update physical_network_traffic_types set vmware_network_label = " + newLabel + " where traffic_type = '" + trafficType + "' and vmware_network_label is not NULL;");
- pstmt.executeUpdate();
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to set vmware traffic labels ", e);
- } finally {
- try {
- if (rsParams != null) {
- rsParams.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
- private void persistLegacyZones(Connection conn) {
- List<Long> listOfLegacyZones = new ArrayList<Long>();
- PreparedStatement pstmt = null;
- PreparedStatement clustersQuery = null;
- PreparedStatement clusterDetailsQuery = null;
- ResultSet rs = null;
- ResultSet clusters = null;
- ResultSet clusterDetails = null;
- ResultSet dcInfo = null;
- Long vmwareDcId = 1L;
- Long zoneId;
- Long clusterId;
- String clusterHypervisorType;
- boolean legacyZone;
- boolean ignoreZone;
- Long count;
- String dcOfPreviousCluster = null;
- String dcOfCurrentCluster = null;
- String[] tokens;
- String url;
- String user = "";
- String password = "";
- String vc = "";
- String dcName = "";
- String guid;
- String key;
- String value;
-
- try {
- clustersQuery = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster` where removed is NULL");
- pstmt = conn.prepareStatement("select id from `cloud`.`data_center` where removed is NULL");
- rs = pstmt.executeQuery();
-
- while (rs.next()) {
- zoneId = rs.getLong("id");
- legacyZone = false;
- ignoreZone = true;
- count = 0L;
- // Legacy zone term is meant only for VMware
- // Legacy zone is a zone with atleast 2 clusters & with multiple DCs or VCs
- clusters = clustersQuery.executeQuery();
- if (!clusters.next()) {
- continue; // Ignore the zone without any clusters
- } else {
- dcOfPreviousCluster = null;
- dcOfCurrentCluster = null;
- do {
- clusterHypervisorType = clusters.getString("hypervisor_type");
- clusterId = clusters.getLong("id");
- if (clusterHypervisorType.equalsIgnoreCase("VMware")) {
- ignoreZone = false;
- clusterDetailsQuery = conn.prepareStatement("select value from `cloud`.`cluster_details` where name='url' and cluster_id=?");
- clusterDetailsQuery.setLong(1, clusterId);
- clusterDetails = clusterDetailsQuery.executeQuery();
- clusterDetails.next();
- url = clusterDetails.getString("value");
- tokens = url.split("/"); // url format - http://vcenter/dc/cluster
- vc = tokens[2];
- dcName = tokens[3];
- dcOfPreviousCluster = dcOfCurrentCluster;
- dcOfCurrentCluster = dcName + "@" + vc;
- if (count > 0) {
- if (!dcOfPreviousCluster.equalsIgnoreCase(dcOfCurrentCluster)) {
- legacyZone = true;
- s_logger.debug("Marking the zone " + zoneId + " as legacy zone.");
- }
- }
- } else {
- s_logger.debug("Ignoring zone " + zoneId + " with hypervisor type " + clusterHypervisorType);
- break;
- }
- count++;
- } while (clusters.next());
- if (ignoreZone) {
- continue; // Ignore the zone with hypervisors other than VMware
- }
- }
- if (legacyZone) {
- listOfLegacyZones.add(zoneId);
- } else {
- assert(clusterDetails != null) : "Couldn't retrieve details of cluster!";
- s_logger.debug("Discovered non-legacy zone " + zoneId + ". Processing the zone to associate with VMware datacenter.");
-
- clusterDetailsQuery = conn.prepareStatement("select name, value from `cloud`.`cluster_details` where cluster_id=?");
- clusterDetailsQuery.setLong(1, clusterId);
- clusterDetails = clusterDetailsQuery.executeQuery();
- while (clusterDetails.next()) {
- key = clusterDetails.getString(1);
- value = clusterDetails.getString(2);
- if (key.equalsIgnoreCase("username")) {
- user = value;
- } else if (key.equalsIgnoreCase("password")) {
- password = value;
- }
- }
- guid = dcName + "@" + vc;
-
- pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vmware_data_center` (uuid, name, guid, vcenter_host, username, password) values(?, ?, ?, ?, ?, ?)");
- pstmt.setString(1, UUID.randomUUID().toString());
- pstmt.setString(2, dcName);
- pstmt.setString(3, guid);
- pstmt.setString(4, vc);
- pstmt.setString(5, user);
- pstmt.setString(6, password);
- pstmt.executeUpdate();
-
- pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`vmware_data_center` where guid=?");
- pstmt.setString(1, guid);
- dcInfo = pstmt.executeQuery();
- if(dcInfo.next()) {
- vmwareDcId = dcInfo.getLong("id");
- }
-
- pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vmware_data_center_zone_map` (zone_id, vmware_data_center_id) values(?, ?)");
- pstmt.setLong(1, zoneId);
- pstmt.setLong(2, vmwareDcId);
- pstmt.executeUpdate();
- }
- }
- updateLegacyZones(conn, listOfLegacyZones);
- } catch (SQLException e) {
- String msg = "Unable to discover legacy zones." + e.getMessage();
- s_logger.error(msg);
- throw new CloudRuntimeException(msg, e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- if (dcInfo != null) {
- dcInfo.close();
- }
- if (clusters != null) {
- clusters.close();
- }
- if (clusterDetails != null) {
- clusterDetails.close();
- }
- if (clustersQuery != null) {
- clustersQuery.close();
- }
- if (clusterDetailsQuery != null) {
- clusterDetailsQuery.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
- private void updateLegacyZones(Connection conn, List<Long> zones) {
- PreparedStatement legacyZonesQuery = null;
- //Insert legacy zones into table for legacy zones.
- try {
- legacyZonesQuery = conn.prepareStatement("INSERT INTO `cloud`.`legacy_zones` (zone_id) VALUES (?)");
- for(Long zoneId : zones) {
- legacyZonesQuery.setLong(1, zoneId);
- legacyZonesQuery.executeUpdate();
- s_logger.debug("Inserted zone " + zoneId + " into cloud.legacyzones table");
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable add zones to cloud.legacyzones table.", e);
- } finally {
- try {
- if (legacyZonesQuery != null) {
- legacyZonesQuery.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
- private void createPlaceHolderNics(Connection conn) {
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try {
- pstmt = conn.prepareStatement("SELECT network_id, gateway, ip4_address FROM `cloud`.`nics` WHERE reserver_name IN ('DirectNetworkGuru','DirectPodBasedNetworkGuru') and vm_type='DomainRouter' AND removed IS null");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- Long networkId = rs.getLong(1);
- String gateway = rs.getString(2);
- String ip = rs.getString(3);
- String uuid = UUID.randomUUID().toString();
- //Insert placeholder nic for each Domain router nic in Shared network
- pstmt = conn.prepareStatement("INSERT INTO `cloud`.`nics` (uuid, ip4_address, gateway, network_id, state, strategy, vm_type, default_nic, created) VALUES (?, ?, ?, ?, 'Reserved', 'PlaceHolder', 'DomainRouter', 0, now())");
- pstmt.setString(1, uuid);
- pstmt.setString(2, ip);
- pstmt.setString(3, gateway);
- pstmt.setLong(4, networkId);
- pstmt.executeUpdate();
- s_logger.debug("Created placeholder nic for the ipAddress " + ip + " and network " + networkId);
-
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to create placeholder nics", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
-
- private void updateRemoteAccessVpn(Connection conn) {
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try {
- pstmt = conn.prepareStatement("SELECT vpn_server_addr_id FROM `cloud`.`remote_access_vpn`");
- rs = pstmt.executeQuery();
- long id=1;
- while (rs.next()) {
- String uuid = UUID.randomUUID().toString();
- Long ipId = rs.getLong(1);
- pstmt = conn.prepareStatement("UPDATE `cloud`.`remote_access_vpn` set uuid=?, id=? where vpn_server_addr_id=?");
- pstmt.setString(1, uuid);
- pstmt.setLong(2, id);
- pstmt.setLong(3, ipId);
- pstmt.executeUpdate();
- id++;
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to update id/uuid of remote_access_vpn table", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
- private void addEgressFwRulesForSRXGuestNw(Connection conn) {
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- ResultSet rsId = null;
- ResultSet rsNw = null;
- try {
- pstmt = conn.prepareStatement("select network_id FROM `cloud`.`ntwk_service_map` where service='Firewall' and provider='JuniperSRX' ");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- long netId = rs.getLong(1);
- //checking for Isolated OR Virtual
- pstmt = conn.prepareStatement("select account_id, domain_id FROM `cloud`.`networks` where (guest_type='Isolated' OR guest_type='Virtual') and traffic_type='Guest' and vpc_id is NULL and (state='implemented' OR state='Shutdown') and id=? ");
- pstmt.setLong(1, netId);
- s_logger.debug("Getting account_id, domain_id from networks table: " + pstmt);
- rsNw = pstmt.executeQuery();
-
- if(rsNw.next()) {
- long accountId = rsNw.getLong(1);
- long domainId = rsNw.getLong(2);
-
- //Add new rule for the existing networks
- s_logger.debug("Adding default egress firewall rule for network " + netId);
- pstmt = conn.prepareStatement("INSERT INTO firewall_rules (uuid, state, protocol, purpose, account_id, domain_id, network_id, xid, created, traffic_type) VALUES (?, 'Active', 'all', 'Firewall', ?, ?, ?, ?, now(), 'Egress')");
- pstmt.setString(1, UUID.randomUUID().toString());
- pstmt.setLong(2, accountId);
- pstmt.setLong(3, domainId);
- pstmt.setLong(4, netId);
- pstmt.setString(5, UUID.randomUUID().toString());
- s_logger.debug("Inserting default egress firewall rule " + pstmt);
- pstmt.executeUpdate();
-
- pstmt = conn.prepareStatement("select id from firewall_rules where protocol='all' and network_id=?");
- pstmt.setLong(1, netId);
- rsId = pstmt.executeQuery();
-
- long firewallRuleId;
- if(rsId.next()) {
- firewallRuleId = rsId.getLong(1);
- pstmt = conn.prepareStatement("insert into firewall_rules_cidrs (firewall_rule_id,source_cidr) values (?, '0.0.0.0/0')");
- pstmt.setLong(1, firewallRuleId);
- s_logger.debug("Inserting rule for cidr 0.0.0.0/0 for the new Firewall rule id=" + firewallRuleId + " with statement " + pstmt);
- pstmt.executeUpdate();
- }
- }
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to set egress firewall rules ", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
- private void upgradeEIPNetworkOfferings(Connection conn) {
-
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try {
- pstmt = conn.prepareStatement("select id, elastic_ip_service from `cloud`.`network_offerings` where traffic_type='Guest'");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- long id = rs.getLong(1);
- // check if elastic IP service is enabled for network offering
- if (rs.getLong(2) != 0) {
- //update network offering with eip_associate_public_ip set to true
- pstmt = conn.prepareStatement("UPDATE `cloud`.`network_offerings` set eip_associate_public_ip=? where id=?");
- pstmt.setBoolean(1, true);
- pstmt.setLong(2, id);
- pstmt.executeUpdate();
- }
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to set elastic_ip_service for network offerings with EIP service enabled.", e);
- }
- }
-
- private void updateNetworkACLs(Connection conn) {
- //Fetch all VPC Tiers
- //For each tier create a network ACL and move all the acl_items to network_acl_item table
- // If there are no acl_items for a tier, associate it with default ACL
-
- s_logger.debug("Updating network ACLs");
-
- PreparedStatement pstmt = null;
- PreparedStatement pstmtDelete = null;
- ResultSet rs = null;
- ResultSet rsAcls = null;
- ResultSet rsCidr = null;
-
- //1,2 are default acl Ids, start acl Ids from 3
- long nextAclId = 3;
-
- try {
- //Get all VPC tiers
- pstmt = conn.prepareStatement("SELECT id, vpc_id, uuid FROM `cloud`.`networks` where vpc_id is not null and removed is null");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- Long networkId = rs.getLong(1);
- s_logger.debug("Updating network ACLs for network: "+networkId);
- Long vpcId = rs.getLong(2);
- String tierUuid = rs.getString(3);
- pstmt = conn.prepareStatement("SELECT id, uuid, start_port, end_port, state, protocol, icmp_code, icmp_type, created, traffic_type FROM `cloud`.`firewall_rules` where network_id = ? and purpose = 'NetworkACL'");
- pstmt.setLong(1, networkId);
- rsAcls = pstmt.executeQuery();
- boolean hasAcls = false;
- Long aclId = null;
- int number = 1;
- while(rsAcls.next()){
- if(!hasAcls){
- hasAcls = true;
- aclId = nextAclId++;
- //create ACL for the tier
- s_logger.debug("Creating network ACL for tier: "+tierUuid);
- pstmt = conn.prepareStatement("INSERT INTO `cloud`.`network_acl` (id, uuid, vpc_id, description, name) values (?, UUID(), ? , ?, ?)");
- pstmt.setLong(1, aclId);
- pstmt.setLong(2, vpcId);
- pstmt.setString(3, "ACL for tier " + tierUuid);
- pstmt.setString(4, "tier_" + tierUuid);
- pstmt.executeUpdate();
- }
-
- Long fwRuleId = rsAcls.getLong(1);
- String cidr = null;
- //get cidr from firewall_rules_cidrs
- pstmt = conn.prepareStatement("SELECT id, source_cidr FROM `cloud`.`firewall_rules_cidrs` where firewall_rule_id = ?");
- pstmt.setLong(1, fwRuleId);
- rsCidr = pstmt.executeQuery();
- while(rsCidr.next()){
- Long cidrId = rsCidr.getLong(1);
- String sourceCidr = rsCidr.getString(2);
- if(cidr == null){
- cidr = sourceCidr;
- } else {
- cidr += ","+sourceCidr;
- }
- //Delete cidr entry
- pstmtDelete = conn.prepareStatement("DELETE FROM `cloud`.`firewall_rules_cidrs` where id = ?");
- pstmtDelete.setLong(1, cidrId);
- pstmtDelete.executeUpdate();
- }
-
-
- String aclItemUuid = rsAcls.getString(2);
- //Move acl to network_acl_item table
- s_logger.debug("Moving firewall rule: "+aclItemUuid);
- pstmt = conn.prepareStatement("INSERT INTO `cloud`.`network_acl_item` (uuid, acl_id, start_port, end_port, state, protocol, icmp_code, icmp_type, created, traffic_type, cidr, number, action) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
- //uuid
- pstmt.setString(1, aclItemUuid);
- //aclId
- pstmt.setLong(2, aclId);
- //Start port
- Integer startPort = rsAcls.getInt(3);
- if(rsAcls.wasNull()){
- pstmt.setNull(3, Types.INTEGER);
- } else {
- pstmt.setLong(3, startPort);
- }
- //End port
- Integer endPort = rsAcls.getInt(4);
- if(rsAcls.wasNull()){
- pstmt.setNull(4, Types.INTEGER);
- } else {
- pstmt.setLong(4, endPort);
- }
- //State
- String state = rsAcls.getString(5);
- pstmt.setString(5, state);
- //protocol
- String protocol = rsAcls.getString(6);
- pstmt.setString(6, protocol);
- //icmp_code
- Integer icmpCode = rsAcls.getInt(7);
- if(rsAcls.wasNull()){
- pstmt.setNull(7, Types.INTEGER);
- } else {
- pstmt.setLong(7, icmpCode);
- }
-
- //icmp_type
- Integer icmpType = rsAcls.getInt(8);
- if(rsAcls.wasNull()){
- pstmt.setNull(8, Types.INTEGER);
- } else {
- pstmt.setLong(8, icmpType);
- }
-
- //created
- Date created = rsAcls.getDate(9);
- pstmt.setDate(9, created);
- //traffic type
- String trafficType = rsAcls.getString(10);
- pstmt.setString(10, trafficType);
-
- //cidr
- pstmt.setString(11, cidr);
- //number
- pstmt.setInt(12, number++);
- //action
- pstmt.setString(13, "Allow");
- pstmt.executeUpdate();
-
- //Delete firewall rule
- pstmtDelete = conn.prepareStatement("DELETE FROM `cloud`.`firewall_rules` where id = ?");
- pstmtDelete.setLong(1, fwRuleId);
- pstmtDelete.executeUpdate();
- }
- if(!hasAcls){
- //no network ACls for this network.
- // Assign default Deny ACL
- aclId = NetworkACL.DEFAULT_DENY;
- }
- //Assign acl to network
- pstmt = conn.prepareStatement("UPDATE `cloud`.`networks` set network_acl_id=? where id=?");
- pstmt.setLong(1, aclId);
- pstmt.setLong(2, networkId);
- pstmt.executeUpdate();
- }
- s_logger.debug("Done updating network ACLs ");
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to move network acls from firewall rules table to network_acl_item table", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (rsAcls != null) {
- rsAcls.close();
- }
- if (rsCidr != null) {
- rsCidr.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
- private void updateGlobalDeploymentPlanner(Connection conn) {
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try {
- pstmt = conn
- .prepareStatement("select value from `cloud`.`configuration` where name = 'vm.allocation.algorithm'");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- String globalValue = rs.getString(1);
- String plannerName = "FirstFitPlanner";
-
- if (globalValue != null) {
- if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.random.toString())) {
- plannerName = "FirstFitPlanner";
- } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.firstfit.toString())) {
- plannerName = "FirstFitPlanner";
- } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userconcentratedpod_firstfit
- .toString())) {
- plannerName = "UserConcentratedPodPlanner";
- } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userconcentratedpod_random
- .toString())) {
- plannerName = "UserConcentratedPodPlanner";
- } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userdispersing.toString())) {
- plannerName = "UserDispersingPlanner";
- }
- }
- // update vm.deployment.planner global config
- pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` set value=? where name = 'vm.deployment.planner'");
- pstmt.setString(1, plannerName);
- pstmt.executeUpdate();
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to set vm.deployment.planner global config", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
-
- private void upgradeDefaultVpcOffering(Connection conn) {
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try {
- pstmt = conn.prepareStatement("select distinct map.vpc_offering_id from `cloud`.`vpc_offering_service_map` map, `cloud`.`vpc_offerings` off where off.id=map.vpc_offering_id AND service='Lb'");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- long id = rs.getLong(1);
- //Add internal LB vm as a supported provider for the load balancer service
- pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vpc_offering_service_map` (vpc_offering_id, service, provider) VALUES (?,?,?)");
- pstmt.setLong(1, id);
- pstmt.setString(2, "Lb");
- pstmt.setString(3, "InternalLbVm");
- pstmt.executeUpdate();
- }
-
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable update the default VPC offering with the internal lb service", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
- private void upgradePhysicalNtwksWithInternalLbProvider(Connection conn) {
-
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try {
- pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network` where removed is null");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- long pNtwkId = rs.getLong(1);
- String uuid = UUID.randomUUID().toString();
- //Add internal LB VM to the list of physical network service providers
- pstmt = conn.prepareStatement("INSERT INTO `cloud`.`physical_network_service_providers` " +
- "(uuid, physical_network_id, provider_name, state, load_balance_service_provided, destination_physical_network_id)" +
- " VALUES (?, ?, 'InternalLbVm', 'Enabled', 1, 0)");
- pstmt.setString(1, uuid);
- pstmt.setLong(2, pNtwkId);
- pstmt.executeUpdate();
-
- //Add internal lb vm to the list of physical network elements
- PreparedStatement pstmt1 = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network_service_providers`" +
- " WHERE physical_network_id=? AND provider_name='InternalLbVm'");
- pstmt1.setLong(1, pNtwkId);
- ResultSet rs1 = pstmt1.executeQuery();
- while (rs1.next()) {
- long providerId = rs1.getLong(1);
- uuid = UUID.randomUUID().toString();
- pstmt1 = conn.prepareStatement("INSERT INTO `cloud`.`virtual_router_providers` (nsp_id, uuid, type, enabled) VALUES (?, ?, 'InternalLbVm', 1)");
- pstmt1.setLong(1, providerId);
- pstmt1.setString(2, uuid);
- pstmt1.executeUpdate();
- }
- }
-
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to update existing physical networks with internal lb provider", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
- private void addHostDetailsIndex(Connection conn) {
- s_logger.debug("Checking if host_details index exists, if not we will add it");
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- pstmt = conn.prepareStatement("SHOW INDEX FROM `cloud`.`host_details` where KEY_NAME = 'fk_host_details__host_id'");
- rs = pstmt.executeQuery();
- if (rs.next()) {
- s_logger.debug("Index already exists on host_details - not adding new one");
- } else {
- // add the index
- PreparedStatement pstmtUpdate = conn.prepareStatement("ALTER IGNORE TABLE `cloud`.`host_details` ADD INDEX `fk_host_details__host_id` (`host_id`)");
- pstmtUpdate.executeUpdate();
- s_logger.debug("Index did not exist on host_details - added new one");
- pstmtUpdate.close();
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Failed to check/update the host_details index ", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
-
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
-
- private void updateNetworksForPrivateGateways(Connection conn) {
-
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try {
- //1) get all non removed gateways
- pstmt = conn.prepareStatement("SELECT network_id, vpc_id FROM `cloud`.`vpc_gateways` WHERE type='Private' AND removed IS null");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- Long networkId = rs.getLong(1);
- Long vpcId = rs.getLong(2);
- //2) Update networks with vpc_id if its set to NULL
- pstmt = conn.prepareStatement("UPDATE `cloud`.`networks` set vpc_id=? where id=? and vpc_id is NULL and removed is NULL");
- pstmt.setLong(1, vpcId);
- pstmt.setLong(2, networkId);
- pstmt.executeUpdate();
-
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Failed to update private networks with VPC id.", e);
- }
- }
-
- private void removeFirewallServiceFromSharedNetworkOfferingWithSGService(Connection conn) {
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try {
- pstmt = conn.prepareStatement("select id from `cloud`.`network_offerings` where unique_name='DefaultSharedNetworkOfferingWithSGService'");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- long id = rs.getLong(1);
- // remove Firewall service for SG shared network offering
- pstmt = conn.prepareStatement("DELETE from `cloud`.`ntwk_offering_service_map` where network_offering_id=? and service='Firewall'");
- pstmt.setLong(1, id);
- pstmt.executeUpdate();
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to remove Firewall service for SG shared network offering.", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
-
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
- private void fix22xKVMSnapshots(Connection conn) {
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- s_logger.debug("Updating KVM snapshots");
- try {
- pstmt = conn.prepareStatement("select id, backup_snap_id from `cloud`.`snapshots` where hypervisor_type='KVM' and removed is null and backup_snap_id is not null");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- long id = rs.getLong(1);
- String backUpPath = rs.getString(2);
- // Update Backup Path. Remove anything before /snapshots/
- // e.g 22x Path /mnt/0f14da63-7033-3ca5-bdbe-fa62f4e2f38a/snapshots/1/2/6/i-2-6-VM_ROOT-6_20121219072022
- // Above path should change to /snapshots/1/2/6/i-2-6-VM_ROOT-6_20121219072022
- int index = backUpPath.indexOf("snapshots"+File.separator);
- if (index > 1){
- String correctedPath = backUpPath.substring(index);
- s_logger.debug("Updating Snapshot with id: "+id+" original backup path: "+backUpPath+ " updated backup path: "+correctedPath);
- pstmt = conn.prepareStatement("UPDATE `cloud`.`snapshots` set backup_snap_id=? where id = ?");
- pstmt.setString(1, correctedPath);
- pstmt.setLong(2, id);
- pstmt.executeUpdate();
- }
- }
- s_logger.debug("Done updating KVM snapshots");
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to update backup id for KVM snapshots", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
-
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- }
-
- // Corrects upgrade for deployment with F5 and SRX devices (pre 3.0) to network offering &
- // network service provider paradigm
- private void correctExternalNetworkDevicesSetup(Connection conn) {
- PreparedStatement zoneSearchStmt = null, pNetworkStmt = null, f5DevicesStmt = null, srxDevicesStmt = null;
- ResultSet zoneResults = null, pNetworksResults = null, f5DevicesResult = null, srxDevicesResult = null;
-
- try {
- zoneSearchStmt = conn.prepareStatement("SELECT id, networktype FROM `cloud`.`data_center`");
- zoneResults = zoneSearchStmt.executeQuery();
- while (zoneResults.next()) {
- long zoneId = zoneResults.getLong(1);
- String networkType = zoneResults.getString(2);
-
- if (!com.cloud.dc.DataCenter.NetworkType.Advanced.toString().equalsIgnoreCase(networkType)) {
- continue;
- }
-
- pNetworkStmt = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network` where data_center_id=?");
- pNetworkStmt.setLong(1, zoneId);
- pNetworksResults = pNetworkStmt.executeQuery();
- while (pNetworksResults.next()) {
- long physicalNetworkId = pNetworksResults.getLong(1);
- PreparedStatement fetchF5NspStmt = conn.prepareStatement("SELECT id from `cloud`.`physical_network_service_providers` where physical_network_id=" + physicalNetworkId
- + " and provider_name = 'F5BigIp'");
- ResultSet rsF5NSP = fetchF5NspStmt.executeQuery();
- boolean hasF5Nsp = rsF5NSP.next();
- fetchF5NspStmt.close();
-
- // if there is no 'F5BigIP' physical network service provider added into physical network then
- // add 'F5BigIP' as network service provider and add the entry in 'external_load_balancer_devices'
- if (!hasF5Nsp) {
- f5DevicesStmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalLoadBalancer' AND removed IS NULL");
- f5DevicesStmt.setLong(1, zoneId);
- f5DevicesResult = f5DevicesStmt.executeQuery();
- // add F5BigIP provider and provider instance to physical network if there are any external load
- // balancers added in the zone
- while (f5DevicesResult.next()) {
- long f5HostId = f5DevicesResult.getLong(1);;
- addF5ServiceProvider(conn, physicalNetworkId, zoneId);
- addF5LoadBalancer(conn, f5HostId, physicalNetworkId);
- }
- }
-
- PreparedStatement fetchSRXNspStmt = conn.prepareStatement("SELECT id from `cloud`.`physical_network_service_providers` where physical_network_id=" + physicalNetworkId
- + " and provider_name = 'JuniperSRX'");
- ResultSet rsSRXNSP = fetchSRXNspStmt.executeQuery();
- boolean hasSrxNsp = rsSRXNSP.next();
- fetchSRXNspStmt.close();
-
- // if there is no 'JuniperSRX' physical network service provider added into physical network then
- // add 'JuniperSRX' as network service provider and add the entry in 'external_firewall_devices'
- if (!hasSrxNsp) {
- srxDevicesStmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalFirewall' AND removed IS NULL");
- srxDevicesStmt.setLong(1, zoneId);
- srxDevicesResult = srxDevicesStmt.executeQuery();
- // add JuniperSRX provider and provider instance to physical network if there are any external
- // firewall instances added in to the zone
- while (srxDevicesResult.next()) {
- long srxHostId = srxDevicesResult.getLong(1);
- // add SRX provider and provider instance to physical network
- addSrxServiceProvider(conn, physicalNetworkId, zoneId);
- addSrxFirewall(conn, srxHostId, physicalNetworkId);
- }
- }
- }
- }
-
- // not the network service provider has been provisioned in to physical network, mark all guest network
- // to be using network offering 'Isolated with external providers'
- fixZoneUsingExternalDevices(conn);
-
- if (zoneResults != null) {
- try {
- zoneResults.close();
- } catch (SQLException e) {
- }
- }
-
- if (zoneSearchStmt != null) {
- try {
- zoneSearchStmt.close();
- } catch (SQLException e) {
- }
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Exception while adding PhysicalNetworks", e);
- } finally {
-
- }
- }
-
- private void addF5LoadBalancer(Connection conn, long hostId, long physicalNetworkId){
- PreparedStatement pstmtUpdate = null;
- try{
- s_logger.debug("Adding F5 Big IP load balancer with host id " + hostId + " in to physical network" + physicalNetworkId);
- String insertF5 = "INSERT INTO `cloud`.`external_load_balancer_devices` (physical_network_id, host_id, provider_name, " +
- "device_name, capacity, is_dedicated, device_state, allocation_state, is_managed, uuid) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
- pstmtUpdate = conn.prepareStatement(insertF5);
- pstmtUpdate.setLong(1, physicalNetworkId);
- pstmtUpdate.setLong(2, hostId);
- pstmtUpdate.setString(3, "F5BigIp");
- pstmtUpdate.setString(4, "F5BigIpLoadBalancer");
- pstmtUpdate.setLong(5, 0);
- pstmtUpdate.setBoolean(6, false);
- pstmtUpdate.setString(7, "Enabled");
- pstmtUpdate.setString(8, "Shared");
- pstmtUpdate.setBoolean(9, false);
- pstmtUpdate.setString(10, UUID.randomUUID().toString());
- pstmtUpdate.executeUpdate();
- }catch (SQLException e) {
- throw new CloudRuntimeException("Exception while adding F5 load balancer device" , e);
- } finally {
- if (pstmtUpdate != null) {
- try {
- pstmtUpdate.close();
- } catch (SQLException e) {
- }
- }
- }
- }
-
- private void addSrxFirewall(Connection conn, long hostId, long physicalNetworkId){
- PreparedStatement pstmtUpdate = null;
- try{
- s_logger.debug("Adding SRX firewall device with host id " + hostId + " in to physical network" + physicalNetworkId);
- String insertSrx = "INSERT INTO `cloud`.`external_firewall_devices` (physical_network_id, host_id, provider_name, " +
- "device_name, capacity, is_dedicated, device_state, allocation_state, uuid) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?)";
- pstmtUpdate = conn.prepareStatement(insertSrx);
- pstmtUpdate.setLong(1, physicalNetworkId);
- pstmtUpdate.setLong(2, hostId);
- pstmtUpdate.setString(3, "JuniperSRX");
- pstmtUpdate.setString(4, "JuniperSRXFirewall");
- pstmtUpdate.setLong(5, 0);
- pstmtUpdate.setBoolean(6, false);
- pstmtUpdate.setString(7, "Enabled");
- pstmtUpdate.setString(8, "Shared");
- pstmtUpdate.setString(9, UUID.randomUUID().toString());
- pstmtUpdate.executeUpdate();
- }catch (SQLException e) {
- throw new CloudRuntimeException("Exception while adding SRX firewall device ", e);
- } finally {
- if (pstmtUpdate != null) {
- try {
- pstmtUpdate.close();
- } catch (SQLException e) {
- }
- }
- }
- }
-
- private void addF5ServiceProvider(Connection conn, long physicalNetworkId, long zoneId){
- PreparedStatement pstmtUpdate = null;
- try{
- // add physical network service provider - F5BigIp
- s_logger.debug("Adding PhysicalNetworkServiceProvider F5BigIp" + " in to physical network" + physicalNetworkId);
- String insertPNSP = "INSERT INTO `cloud`.`physical_network_service_providers` (`uuid`, `physical_network_id` , `provider_name`, `state` ," +
- "`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," +
- "`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," +
- "`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,0,0,0,0,0,0,0,1,0,0,0,0)";
-
- pstmtUpdate = conn.prepareStatement(insertPNSP);
- pstmtUpdate.setString(1, UUID.randomUUID().toString());
- pstmtUpdate.setLong(2, physicalNetworkId);
- pstmtUpdate.setString(3, "F5BigIp");
- pstmtUpdate.setString(4, "Enabled");
- pstmtUpdate.executeUpdate();
- }catch (SQLException e) {
- throw new CloudRuntimeException("Exception while adding PhysicalNetworkServiceProvider F5BigIp", e);
- } finally {
- if (pstmtUpdate != null) {
- try {
- pstmtUpdate.close();
- } catch (SQLException e) {
- }
- }
- }
- }
-
- private void addSrxServiceProvider(Connection conn, long physicalNetworkId, long zoneId){
- PreparedStatement pstmtUpdate = null;
- try{
- // add physical network service provider - JuniperSRX
- s_logger.debug("Adding PhysicalNetworkServiceProvider JuniperSRX");
- String insertPNSP = "INSERT INTO `cloud`.`physical_network_service_providers` (`uuid`, `physical_network_id` , `provider_name`, `state` ," +
- "`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," +
- "`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," +
- "`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,0,0,0,0,1,1,1,0,1,1,0,0)";
-
- pstmtUpdate = conn.prepareStatement(insertPNSP);
- pstmtUpdate.setString(1, UUID.randomUUID().toString());
- pstmtUpdate.setLong(2, physicalNetworkId);
- pstmtUpdate.setString(3, "JuniperSRX");
- pstmtUpdate.setString(4, "Enabled");
- pstmtUpdate.executeUpdate();
- }catch (SQLException e) {
- throw new CloudRuntimeException("Exception while adding PhysicalNetworkServiceProvider JuniperSRX" , e);
- } finally {
- if (pstmtUpdate != null) {
- try {
- pstmtUpdate.close();
- } catch (SQLException e) {
- }
- }
- }
- }
-
- // This method does two things
- //
- // 1) ensure that networks using external load balancer/firewall in deployments prior to release 3.0
- // has entry in network_external_lb_device_map and network_external_firewall_device_map
- //
- // 2) Some keys of host details for F5 and SRX devices were stored in Camel Case in 2.x releases. From 3.0
- // they are made in lowercase. On upgrade change the host details name to lower case
- private void fixZoneUsingExternalDevices(Connection conn) {
- //Get zones to upgrade
- List<Long> zoneIds = new ArrayList<Long>();
- PreparedStatement pstmt = null;
- PreparedStatement pstmtUpdate = null;
- ResultSet rs = null;
- long networkOfferingId, networkId;
- long f5DeviceId, f5HostId;
- long srxDevivceId, srxHostId;
-
- try {
- pstmt = conn.prepareStatement("select id from `cloud`.`data_center` where lb_provider='F5BigIp' or firewall_provider='JuniperSRX' or gateway_provider='JuniperSRX'");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- zoneIds.add(rs.getLong(1));
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to create network to LB & firewall device mapping for networks that use them", e);
- }
-
- if (zoneIds.size() == 0) {
- return; // no zones using F5 and SRX devices so return
- }
-
- // find the default network offering created for external devices during upgrade from 2.2.14
- try {
- pstmt = conn.prepareStatement("select id from `cloud`.`network_offerings` where unique_name='Isolated with external providers' ");
- rs = pstmt.executeQuery();
- if (rs.first()) {
- networkOfferingId = rs.getLong(1);
- } else {
- throw new CloudRuntimeException("Cannot upgrade as there is no 'Isolated with external providers' network offering crearted .");
- }
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to create network to LB & firewalla device mapping for networks that use them", e);
- }
-
- for (Long zoneId : zoneIds) {
- try {
- // find the F5 device id in the zone
- pstmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalLoadBalancer' AND removed IS NULL");
- pstmt.setLong(1, zoneId);
- rs = pstmt.executeQuery();
- if (rs.first()) {
- f5HostId = rs.getLong(1);
- } else {
- throw new CloudRuntimeException("Cannot upgrade as there is no F5 load balancer device found in data center " + zoneId);
- }
- pstmt = conn.prepareStatement("SELECT id FROM external_load_balancer_devices WHERE host_id=?");
- pstmt.setLong(1, f5HostId);
- rs = pstmt.executeQuery();
- if (rs.first()) {
- f5DeviceId = rs.getLong(1);
- } else {
- throw new CloudRuntimeException("Cannot upgrade as there is no F5 load balancer device with host ID " + f5HostId + " found in external_load_balancer_device");
- }
-
- // find the SRX device id in the zone
- pstmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalFirewall' AND removed IS NULL");
- pstmt.setLong(1, zoneId);
- rs = pstmt.executeQuery();
- if (rs.first()) {
- srxHostId = rs.getLong(1);
- } else {
- throw new CloudRuntimeException("Cannot upgrade as there is no SRX firewall device found in data center " + zoneId);
- }
- pstmt = conn.prepareStatement("SELECT id FROM external_firewall_devices WHERE host_id=?");
- pstmt.setLong(1, srxHostId);
- rs = pstmt.executeQuery();
- if (rs.first()) {
- srxDevivceId = rs.getLong(1);
- } else {
- throw new CloudRuntimeException("Cannot upgrade as there is no SRX firewall device found with host ID " + srxHostId + " found in external_firewall_devices");
- }
-
- // check if network any uses F5 or SRX devices in the zone
- pstmt = conn.prepareStatement("select id from `cloud`.`networks` where guest_type='Virtual' and data_center_id=? and network_offering_id=? and removed IS NULL");
- pstmt.setLong(1, zoneId);
- pstmt.setLong(2, networkOfferingId);
- rs = pstmt.executeQuery();
- while (rs.next()) {
- // get the network Id
- networkId = rs.getLong(1);
-
- // add mapping for the network in network_external_lb_device_map
- String insertLbMapping = "INSERT INTO `cloud`.`network_external_lb_device_map` (uuid, network_id, external_load_balancer_device_id, created) VALUES ( ?, ?, ?, now())";
- pstmtUpdate = conn.prepareStatement(insertLbMapping);
- pstmtUpdate.setString(1, UUID.randomUUID().toString());
- pstmtUpdate.setLong(2, networkId);
- pstmtUpdate.setLong(3, f5DeviceId);
- pstmtUpdate.executeUpdate();
- s_logger.debug("Successfully added entry in network_external_lb_device_map for network " + networkId + " and F5 device ID " + f5DeviceId);
-
- // add mapping for the network in network_external_firewall_device_map
- String insertFwMapping = "INSERT INTO `cloud`.`network_external_firewall_device_map` (uuid, network_id, external_firewall_device_id, created) VALUES ( ?, ?, ?, now())";
- pstmtUpdate = conn.prepareStatement(insertFwMapping);
- pstmtUpdate.setString(1, UUID.randomUUID().toString());
- pstmtUpdate.setLong(2, networkId);
- pstmtUpdate.setLong(3, srxDevivceId);
- pstmtUpdate.executeUpdate();
- s_logger.debug("Successfully added entry in network_external_firewall_device_map for network " + networkId + " and SRX device ID " + srxDevivceId);
- }
-
- // update host details for F5 and SRX devices
- s_logger.debug("Updating the host details for F5 and SRX devices");
- pstmt = conn.prepareStatement("SELECT host_id, name FROM `cloud`.`host_details` WHERE host_id=? OR host_id=?");
- pstmt.setLong(1, f5HostId);
- pstmt.setLong(2, srxHostId);
- rs = pstmt.executeQuery();
- while (rs.next()) {
- long hostId = rs.getLong(1);
- String camlCaseName = rs.getString(2);
- if (!(camlCaseName.equalsIgnoreCase("numRetries") ||
- camlCaseName.equalsIgnoreCase("publicZone") ||
- camlCaseName.equalsIgnoreCase("privateZone") ||
- camlCaseName.equalsIgnoreCase("publicInterface") ||
- camlCaseName.equalsIgnoreCase("privateInterface") ||
- camlCaseName.equalsIgnoreCase("usageInterface") )) {
- continue;
- }
- String lowerCaseName = camlCaseName.toLowerCase();
- pstmt = conn.prepareStatement("update `cloud`.`host_details` set name=? where host_id=? AND name=?");
- pstmt.setString(1, lowerCaseName);
- pstmt.setLong(2, hostId);
- pstmt.setString(3, camlCaseName);
- pstmt.executeUpdate();
- }
- s_logger.debug("Successfully updated host details for F5 and SRX devices");
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable create a mapping for the networks in network_external_lb_device_map and network_external_firewall_device_map", e);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (pstmt != null) {
- pstmt.close();
- }
- } catch (SQLException e) {
- }
- }
- s_logger.info("Successfully upgraded network using F5 and SRX devices to have a entry in the network_external_lb_device_map and network_external_firewall_device_map");
- }
- }
-
- // migrate secondary storages (NFS, S3, Swift) from host, s3, swift tables to image_store table
- private void migrateSecondaryStorageToImageStore(Connection conn) {
- PreparedStatement storeInsert = null;
- PreparedStatement storeDetailInsert = null;
- PreparedStatement storeQuery = null;
- PreparedStatement s3Query = null;
- PreparedStatement swiftQuery = null;
- PreparedStatement nfsQuery = null;
- ResultSet rs = null;
- ResultSet storeInfo = null;
- Long storeId = null;
-
- s_logger.debug("Migrating secondary storage to image store");
- try {
- storeQuery = conn.prepareStatement("select id from `cloud`.`image_store` where uuid = ?");
- storeDetailInsert = conn
- .prepareStatement("INSERT INTO `cloud`.`image_store_details` (store_id, name, value) values(?, ?, ?)");
-
- /*
- // migrate S3 secondary storage
- storeInsert = conn
- .prepareStatement("INSERT INTO `cloud`.`image_store` (uuid, name, image_provider_name, protocol, scope, role, created) values(?, ?, 'S3', ?, 'REGION', 'Image', ?)");
- s3Query = conn
- .prepareStatement("select id, uuid, access_key, secret_key, end_point, bucket, https, connection_timeout, max_error_retry, socket_timeout, created from `cloud`.`s3`");
- rs = s3Query.executeQuery();
-
- while (rs.next()) {
- Long s3_id = rs.getLong("id");
- String s3_uuid = rs.getString("uuid");
- String s3_accesskey = rs.getString("access_key");
- String s3_secretkey = rs.getString("secret_key");
- String s3_endpoint = rs.getString("end_point");
- String s3_bucket = rs.getString("bucket");
- boolean s3_https = rs.getObject("https") != null ? (rs.getInt("https") == 0 ? false : true) : false;
- Integer s3_connectiontimeout = rs.getObject("connection_timeout") != null ? rs
- .getInt("connection_timeout") : null;
- Integer s3_retry = rs.getObject("max_error_retry") != null ? rs.getInt("max_error_retry") : null;
- Integer s3_sockettimeout = rs.getObject("socket_timeout") != null ? rs.getInt("socket_timeout") : null;
- Date s3_created = rs.getDate("created");
-
- // insert entry in image_store table and image_store_details
- // table and store s3_id and store_id mapping
-
- storeInsert.setString(1, s3_uuid);
- storeInsert.setString(2, s3_uuid);
- storeInsert.setString(3, s3_https ? "https" : "http");
- storeInsert.setDate(4, s3_created);
- storeInsert.executeUpdate();
-
- storeQuery.setString(1, s3_uuid);
- storeInfo = storeQuery.executeQuery();
- if (storeInfo.next()) {
- storeId = storeInfo.getLong("id");
- }
-
- Map<String, String> detailMap = new HashMap<String, String>();
- detailMap.put(ApiConstants.S3_ACCESS_KEY, s3_accesskey);
- detailMap.put(ApiConstants.S3_SECRET_KEY, s3_secretkey);
- detailMap.put(ApiConstants.S3_BUCKET_NAME, s3_bucket);
- detailMap.put(ApiConstants.S3_END_POINT, s3_endpoint);
- detailMap.put(ApiConstants.S3_HTTPS_FLAG, String.valueOf(s3_https));
- if (s3_connectiontimeout != null) {
- detailMap.put(ApiConstants.S3_CONNECTION_TIMEOUT, String.valueOf(s3_connectiontimeout));
- }
- if (s3_retry != null) {
- detailMap.put(ApiConstants.S3_MAX_ERROR_RETRY, String.valueOf(s3_retry));
- }
- if (s3_sockettimeout != null) {
- detailMap.put(ApiConstants.S3_SOCKET_TIMEOUT, String.valueOf(s3_sockettimeout));
- }
-
- Iterator<String> keyIt = detailMap.keySet().iterator();
- while (keyIt.hasNext()) {
- String key = keyIt.next();
- String val = detailMap.get(key);
- storeDetailInsert.setLong(1, storeId);
- storeDetailInsert.setString(2, key);
- storeDetailInsert.setString(3, val);
- storeDetailInsert.executeUpdate();
- }
- s3_store_id_map.put(s3_id, storeId);
- }
-
- // migrate SWIFT secondary storage
- storeInsert = conn
- .prepareStatement("INSERT INTO `cloud`.`image_store` (uuid, name, image_provider_name, protocol, url, scope, role, created) values(?, ?, 'Swift', 'http', ?, 'REGION', 'Image', ?)");
- swiftQuery = conn
- .prepareStatement("select id, uuid, url, account, username, key, created from `cloud`.`swift`");
- rs = swiftQuery.executeQuery();
-
- while (rs.next()) {
- Long swift_id = rs.getLong("id");
- String swift_uuid = rs.getString("uuid");
- String swift_url = rs.getString("url");
- String swift_account = rs.getString("account");
- String swift_username = rs.getString("username");
- String swift_key = rs.getString("key");
- Date swift_created = rs.getDate("created");
-
- // insert entry in image_store table and image_store_details
- // table and store swift_id and store_id mapping
- storeInsert.setString(1, swift_uuid);
- storeInsert.setString(2, swift_uuid);
- storeInsert.setString(3, swift_url);
- storeInsert.setDate(4, swift_created);
- storeInsert.executeUpdate();
-
- storeQuery.setString(1, swift_uuid);
- storeInfo = storeQuery.executeQuery();
- if (storeInfo.next()) {
- storeId = storeInfo.getLong("id");
- }
-
- Map<String, String> detailMap = new HashMap<String, String>();
- detailMap.put(ApiConstants.ACCOUNT, swift_account);
- detailMap.put(ApiConstants.USERNAME, swift_username);
- detailMap.put(ApiConstants.KEY, swift_key);
-
- Iterator<String> keyIt = detailMap.keySet().iterator();
- while (keyIt.hasNext()) {
- String key = keyIt.next();
- String val = detailMap.get(key);
- storeDetailInsert.setLong(1, storeId);
- storeDetailInsert.setString(2, key);
- storeDetailInsert.setString(3, val);
- storeDetailInsert.executeUpdate();
- }
- swift_store_id_map.put(swift_id, storeId);
- }
- */
-
- // migrate NFS secondary storage, for nfs, keep previous host_id as the store_id
- storeInsert = conn
- .prepareStatement("INSERT INTO `cloud`.`image_store` (id, uuid, name, image_provider_name, protocol, url, data_center_id, scope, role, parent, total_size, created) values(?, ?, ?, 'NFS', 'nfs', ?, ?, 'ZONE', 'Image', ?, ?, ?)");
- nfsQuery = conn
- .prepareStatement("select id, uuid, url, data_center_id, parent, total_size, created from `cloud`.`host` where type = 'SecondaryStorage' and removed is null");
- rs = nfsQuery.executeQuery();
-
- while (rs.next()) {
- Long nfs_id = rs.getLong("id");
- String nfs_uuid = rs.getString("uuid");
- String nfs_url = rs.ge
<TRUNCATED>
[5/9] CLOUDSTACK-4167: Put in upgrade paths in master for 4.1.2 and
4.2
Posted by vi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d47b4a99/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
new file mode 100644
index 0000000..d703cc3
--- /dev/null
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
@@ -0,0 +1,2115 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.upgrade.dao;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+import org.apache.log4j.Logger;
+
+import com.cloud.deploy.DeploymentPlanner;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.network.vpc.NetworkACL;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+
+public class Upgrade412to420 implements DbUpgrade {
+ final static Logger s_logger = Logger.getLogger(Upgrade412to420.class);
+
+
+ @Override
+ public String[] getUpgradableVersionRange() {
+ return new String[] { "4.1.2", "4.2.0" };
+ }
+
+ @Override
+ public String getUpgradedVersion() {
+ return "4.2.0";
+ }
+
+ @Override
+ public boolean supportsRollingUpgrade() {
+ return false;
+ }
+
+ @Override
+ public File[] getPrepareScripts() {
+ String script = Script.findScript("", "db/schema-412to420.sql");
+ if (script == null) {
+ throw new CloudRuntimeException("Unable to find db/schema-412to420.sql");
+ }
+
+ return new File[] { new File(script) };
+ }
+
+ @Override
+ public void performDataMigration(Connection conn) {
+ upgradeVmwareLabels(conn);
+ persistLegacyZones(conn);
+ createPlaceHolderNics(conn);
+ updateRemoteAccessVpn(conn);
+ updateSystemVmTemplates(conn);
+ updateCluster_details(conn);
+ updatePrimaryStore(conn);
+ addEgressFwRulesForSRXGuestNw(conn);
+ upgradeEIPNetworkOfferings(conn);
+ updateGlobalDeploymentPlanner(conn);
+ upgradeDefaultVpcOffering(conn);
+ upgradePhysicalNtwksWithInternalLbProvider(conn);
+ updateNetworkACLs(conn);
+ addHostDetailsIndex(conn);
+ updateNetworksForPrivateGateways(conn);
+ correctExternalNetworkDevicesSetup(conn);
+ removeFirewallServiceFromSharedNetworkOfferingWithSGService(conn);
+ fix22xKVMSnapshots(conn);
+ setKVMSnapshotFlag(conn);
+ addIndexForAlert(conn);
+ fixBaremetalForeignKeys(conn);
+ // storage refactor related migration
+ // TODO: add clean-up scripts to delete the deprecated table.
+ migrateSecondaryStorageToImageStore(conn);
+ migrateVolumeHostRef(conn);
+ migrateTemplateHostRef(conn);
+ migrateSnapshotStoreRef(conn);
+ fixNiciraKeys(conn);
+ fixRouterKeys(conn);
+ updateConcurrentConnectionsInNetworkOfferings(conn);
+ migrateDatafromIsoIdInVolumesTable(conn);
+ }
+
+ private void fixBaremetalForeignKeys(Connection conn) {
+ List<String> keys = new ArrayList<String>();
+ keys.add("fk_external_dhcp_devices_nsp_id");
+ keys.add("fk_external_dhcp_devices_host_id");
+ keys.add("fk_external_dhcp_devices_pod_id");
+ keys.add("fk_external_dhcp_devices_physical_network_id");
+ DbUpgradeUtils.dropKeysIfExist(conn, "baremetal_dhcp_devices", keys, true);
+
+ keys.add("fk_external_pxe_devices_nsp_id");
+ keys.add("fk_external_pxe_devices_host_id");
+ keys.add("fk_external_pxe_devices_physical_network_id");
+ DbUpgradeUtils.dropKeysIfExist(conn, "baremetal_pxe_devices", keys, true);
+
+ PreparedStatement pstmt = null;
+ try {
+ pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE");
+ pstmt.executeUpdate();
+ pstmt.close();
+ pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE");
+ pstmt.executeUpdate();
+ pstmt.close();
+ pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_pod_id` FOREIGN KEY (`pod_id`) REFERENCES `host_pod_ref`(`id`) ON DELETE CASCADE");
+ pstmt.executeUpdate();
+ pstmt.close();
+ pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE");
+ pstmt.executeUpdate();
+ pstmt.close();
+ s_logger.debug("Added foreign keys for table baremetal_dhcp_devices");
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to add foreign keys to baremetal_dhcp_devices table", e);
+ }
+
+ try {
+ pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE");
+ pstmt.executeUpdate();
+ pstmt.close();
+ pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE");
+ pstmt.executeUpdate();
+ pstmt.close();
+ pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE");
+ pstmt.executeUpdate();
+ pstmt.close();
+ s_logger.debug("Added foreign keys for table baremetal_pxe_devices");
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to add foreign keys to baremetal_pxe_devices table", e);
+ }
+ }
+
+ private void addIndexForAlert(Connection conn) {
+
+ //First drop if it exists. (Due to patches shipped to customers some will have the index and some wont.)
+ List<String> indexList = new ArrayList<String>();
+ s_logger.debug("Dropping index i_alert__last_sent if it exists");
+ indexList.add("last_sent"); // in 4.1, we created this index that is not in convention.
+ indexList.add("i_alert__last_sent");
+ DbUpgradeUtils.dropKeysIfExist(conn, "alert", indexList, false);
+
+ //Now add index.
+ PreparedStatement pstmt = null;
+ try {
+ pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`alert` ADD INDEX `i_alert__last_sent`(`last_sent`)");
+ pstmt.executeUpdate();
+ s_logger.debug("Added index i_alert__last_sent for table alert");
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to add index i_alert__last_sent to alert table for the column last_sent", e);
+ } finally {
+ try {
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+
+ }
+
+ private void dropUploadTable(Connection conn) {
+
+ PreparedStatement pstmt0 = null;
+ PreparedStatement pstmt1 = null;
+ PreparedStatement pstmt2 = null;
+ PreparedStatement pstmt3 = null;
+
+ ResultSet rs0 = null;
+ ResultSet rs2 = null;
+
+ try {
+ // Read upload table - Templates
+ s_logger.debug("Populating template_store_ref table");
+ pstmt0 = conn.prepareStatement("SELECT url, created, type_id, host_id from upload where type=?");
+ pstmt0.setString(1, "TEMPLATE");
+ rs0 = pstmt0.executeQuery();
+ pstmt1 = conn.prepareStatement("UPDATE template_store_ref SET download_url=?, download_url_created=? where template_id=? and store_id=?");
+
+ //Update template_store_ref
+ while(rs0.next()){
+ pstmt1.setString(1, rs0.getString("url"));
+ pstmt1.setDate(2, rs0.getDate("created"));
+ pstmt1.setLong(3, rs0.getLong("type_id"));
+ pstmt1.setLong(4, rs0.getLong("host_id"));
+ pstmt1.executeUpdate();
+ }
+
+
+
+ // Read upload table - Volumes
+ s_logger.debug("Populating volume store ref table");
+ pstmt2 = conn.prepareStatement("SELECT url, created, type_id, host_id, install_path from upload where type=?");
+ pstmt2.setString(1, "VOLUME");
+ rs2 = pstmt2.executeQuery();
+
+ pstmt3 = conn.prepareStatement("INSERT IGNORE INTO volume_store_ref (volume_id, store_id, zone_id, created, state, download_url, download_url_created, install_path) VALUES (?,?,?,?,?,?,?,?)");
+ //insert into template_store_ref
+ while(rs2.next()){
+ pstmt3.setLong(1, rs2.getLong("type_id"));
+ pstmt3.setLong(2, rs2.getLong("host_id"));
+ pstmt3.setLong(3, 1l);// ???
+ pstmt3.setDate(4, rs2.getDate("created"));
+ pstmt3.setString(5, "Ready");
+ pstmt3.setString(6, rs2.getString("url"));
+ pstmt3.setDate(7, rs2.getDate("created"));
+ pstmt3.setString(8, rs2.getString("install_path"));
+ pstmt3.executeUpdate();
+ }
+
+
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable add date into template/volume store ref from upload table.", e);
+ } finally {
+ try {
+ if (pstmt0 != null) {
+ pstmt0.close();
+ }
+ if (pstmt1 != null) {
+ pstmt1.close();
+ }
+ if (pstmt2 != null) {
+ pstmt2.close();
+ }
+ if (pstmt3 != null) {
+ pstmt3.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+
+ }
+
+
+ private void updateSystemVmTemplates(Connection conn) {
+ // TODO: system vm template migration after storage refactoring
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ s_logger.debug("Updating System Vm template IDs");
+ try{
+ //Get all hypervisors in use
+ Set<HypervisorType> hypervisorsListInUse = new HashSet<HypervisorType>();
+ try {
+ pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null");
+ rs = pstmt.executeQuery();
+ while(rs.next()){
+ switch (HypervisorType.getType(rs.getString(1))) {
+ case XenServer: hypervisorsListInUse.add(HypervisorType.XenServer);
+ break;
+ case KVM: hypervisorsListInUse.add(HypervisorType.KVM);
+ break;
+ case VMware: hypervisorsListInUse.add(HypervisorType.VMware);
+ break;
+ case Hyperv: hypervisorsListInUse.add(HypervisorType.Hyperv);
+ break;
+ case LXC: hypervisorsListInUse.add(HypervisorType.LXC);
+ break;
+ }
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Error while listing hypervisors in use", e);
+ }
+
+ Map<HypervisorType, String> NewTemplateNameList = new HashMap<HypervisorType, String>(){
+ { put(HypervisorType.XenServer, "systemvm-xenserver-4.2");
+ put(HypervisorType.VMware, "systemvm-vmware-4.2");
+ put(HypervisorType.KVM, "systemvm-kvm-4.2");
+ put(HypervisorType.LXC, "systemvm-lxc-4.2");
+ put(HypervisorType.Hyperv, "systemvm-hyperv-4.2");
+ }
+ };
+
+ Map<HypervisorType, String> routerTemplateConfigurationNames = new HashMap<HypervisorType, String>(){
+ { put(HypervisorType.XenServer, "router.template.xen");
+ put(HypervisorType.VMware, "router.template.vmware");
+ put(HypervisorType.KVM, "router.template.kvm");
+ put(HypervisorType.LXC, "router.template.lxc");
+ put(HypervisorType.Hyperv, "router.template.hyperv");
+ }
+ };
+
+ for (Map.Entry<HypervisorType, String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()){
+ s_logger.debug("Updating " + hypervisorAndTemplateName.getKey() + " System Vms");
+ try {
+ //Get 4.2.0 system Vm template Id for corresponding hypervisor
+ pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = ? and removed is null order by id desc limit 1");
+ pstmt.setString(1, hypervisorAndTemplateName.getValue());
+ rs = pstmt.executeQuery();
+ if(rs.next()){
+ long templateId = rs.getLong(1);
+ rs.close();
+ pstmt.close();
+ // change template type to SYSTEM
+ pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");
+ pstmt.setLong(1, templateId);
+ pstmt.executeUpdate();
+ pstmt.close();
+ // update templete ID of system Vms
+ pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = ?");
+ pstmt.setLong(1, templateId);
+ pstmt.setString(2, hypervisorAndTemplateName.getKey().toString());
+ pstmt.executeUpdate();
+ pstmt.close();
+ // Change value of global configuration parameter router.template.* for the corresponding hypervisor
+ pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");
+ pstmt.setString(1, hypervisorAndTemplateName.getValue());
+ pstmt.setString(2, routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()));
+ pstmt.executeUpdate();
+ pstmt.close();
+ } else {
+ if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())){
+ throw new CloudRuntimeException("4.2.0 " + hypervisorAndTemplateName.getKey() + " SystemVm template not found. Cannot upgrade system Vms");
+ } else {
+ s_logger.warn("4.2.0 " + hypervisorAndTemplateName.getKey() + " SystemVm template not found. " + hypervisorAndTemplateName.getKey() + " hypervisor is not used, so not failing upgrade");
+ }
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Error while updating "+ hypervisorAndTemplateName.getKey() +" systemVm template", e);
+ }
+ }
+ try {
+ pstmt = conn.prepareStatement("UPDATE `cloud`.`vm_template` set dynamically_scalable = 1 where name = ? and type = 'SYSTEM'");
+ pstmt.setString(1, NewTemplateNameList.get(HypervisorType.VMware));
+ pstmt.executeUpdate();
+ pstmt.close();
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Error while updating dynamically_scalable flag to 1 for SYSTEM template systemvm-vmware-4.2");
+ }
+ s_logger.debug("Updating System Vm Template IDs Complete");
+ }
+ finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ /*
+ pstmt = null;
+ try {
+ pstmt = conn.prepareStatement("update vm_template set image_data_store_id = 1 where type = 'SYSTEM' or type = 'BUILTIN'");
+ pstmt.executeUpdate();
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Failed to upgrade vm template data store uuid: " + e.toString());
+ } finally {
+ if (pstmt != null) {
+ try {
+ pstmt.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+ */
+ }
+
+ //KVM snapshot flag: only turn on if Customers is using snapshot;
+ private void setKVMSnapshotFlag(Connection conn) {
+ s_logger.debug("Verify and set the KVM snapshot flag if snapshot was used. ");
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ try {
+ int numRows = 0;
+ pstmt = conn.prepareStatement("select count(*) from `cloud`.`snapshots` where hypervisor_type = 'KVM'");
+ rs = pstmt.executeQuery();
+ if(rs.next()){
+ numRows = rs.getInt(1);
+ }
+ rs.close();
+ pstmt.close();
+ if (numRows > 0){
+ //Add the configuration flag
+ pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = 'kvm.snapshot.enabled'");
+ pstmt.setString(1, "true");
+ pstmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Failed to read the snapshot table for KVM upgrade. ", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ s_logger.debug("Done set KVM snapshot flag. ");
+ }
+
+ private void updatePrimaryStore(Connection conn) {
+ PreparedStatement sql = null;
+ PreparedStatement sql2 = null;
+ try {
+ sql = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type = 'Filesystem' or pool_type = 'LVM'");
+ sql.setString(1, DataStoreProvider.DEFAULT_PRIMARY);
+ sql.setString(2, "HOST");
+ sql.executeUpdate();
+
+ sql2 = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type != 'Filesystem' and pool_type != 'LVM'");
+ sql2.setString(1, DataStoreProvider.DEFAULT_PRIMARY);
+ sql2.setString(2, "CLUSTER");
+ sql2.executeUpdate();
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Failed to upgrade vm template data store uuid: " + e.toString());
+ } finally {
+ if (sql != null) {
+ try {
+ sql.close();
+ } catch (SQLException e) {
+ }
+ }
+
+ if (sql2 != null) {
+ try {
+ sql2.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+ }
+
+ //update the cluster_details table with default overcommit ratios.
+ private void updateCluster_details(Connection conn) {
+ PreparedStatement pstmt = null;
+ PreparedStatement pstmt1 = null;
+ PreparedStatement pstmt2 =null;
+ ResultSet rs = null;
+
+ try {
+ pstmt = conn.prepareStatement("select id from `cloud`.`cluster`");
+ pstmt1=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value) VALUES(?, 'cpuOvercommitRatio', '1')");
+ pstmt2=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value) VALUES(?, 'memoryOvercommitRatio', '1')");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long id = rs.getLong(1);
+ //update cluster_details table with the default overcommit ratios.
+ pstmt1.setLong(1,id);
+ pstmt1.execute();
+ pstmt2.setLong(1,id);
+ pstmt2.execute();
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to update cluster_details with default overcommit ratios.", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+
+ @Override
+ public File[] getCleanupScripts() {
+ String script = Script.findScript("", "db/schema-412to420-cleanup.sql");
+ if (script == null) {
+ throw new CloudRuntimeException("Unable to find db/schema-412to420-cleanup.sql");
+ }
+
+ return new File[] { new File(script) };
+ }
+
+ private String getNewLabel(ResultSet rs, String oldParamValue) {
+ int separatorIndex;
+ String oldGuestLabel;
+ String newGuestLabel = oldParamValue;
+ try {
+ // No need to iterate because the global param setting applies to all physical networks irrespective of traffic type
+ if (rs.next()) {
+ oldGuestLabel = rs.getString("vmware_network_label");
+ // guestLabel is in format [[<VSWITCHNAME>],VLANID]
+ separatorIndex = oldGuestLabel.indexOf(",");
+ if(separatorIndex > -1) {
+ newGuestLabel += oldGuestLabel.substring(separatorIndex);
+ }
+ }
+ } catch (SQLException e) {
+ s_logger.error(new CloudRuntimeException("Failed to read vmware_network_label : " + e));
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ return newGuestLabel;
+ }
+
+ private void upgradeVmwareLabels(Connection conn) {
+ PreparedStatement pstmt = null;
+ ResultSet rsParams = null;
+ ResultSet rsLabel = null;
+ String newLabel;
+ String trafficType = null;
+ String trafficTypeVswitchParam;
+ String trafficTypeVswitchParamValue;
+
+ try {
+ // update the existing vmware traffic labels
+ pstmt = conn.prepareStatement("select name,value from `cloud`.`configuration` where category='Hidden' and value is not NULL and name REGEXP 'vmware\\.*\\.vswitch';");
+ rsParams = pstmt.executeQuery();
+ while (rsParams.next()) {
+ trafficTypeVswitchParam = rsParams.getString("name");
+ trafficTypeVswitchParamValue = rsParams.getString("value");
+ // When upgraded from 4.0 to 4.1 update physical network traffic label with trafficTypeVswitchParam
+ if (trafficTypeVswitchParam.equals("vmware.private.vswitch")) {
+ trafficType = "Management"; //TODO(sateesh): Ignore storage traffic, as required physical network already implemented, anything else tobe done?
+ } else if (trafficTypeVswitchParam.equals("vmware.public.vswitch")) {
+ trafficType = "Public";
+ } else if (trafficTypeVswitchParam.equals("vmware.guest.vswitch")) {
+ trafficType = "Guest";
+ }
+ s_logger.debug("Updating vmware label for " + trafficType + " traffic. Update SQL statement is " + pstmt);
+ pstmt = conn.prepareStatement("select physical_network_id, traffic_type, vmware_network_label from physical_network_traffic_types where vmware_network_label is not NULL and traffic_type='" + trafficType + "';");
+ rsLabel = pstmt.executeQuery();
+ newLabel = getNewLabel(rsLabel, trafficTypeVswitchParamValue);
+ pstmt = conn.prepareStatement("update physical_network_traffic_types set vmware_network_label = " + newLabel + " where traffic_type = '" + trafficType + "' and vmware_network_label is not NULL;");
+ pstmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to set vmware traffic labels ", e);
+ } finally {
+ try {
+ if (rsParams != null) {
+ rsParams.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ private void persistLegacyZones(Connection conn) {
+ List<Long> listOfLegacyZones = new ArrayList<Long>();
+ PreparedStatement pstmt = null;
+ PreparedStatement clustersQuery = null;
+ PreparedStatement clusterDetailsQuery = null;
+ ResultSet rs = null;
+ ResultSet clusters = null;
+ ResultSet clusterDetails = null;
+ ResultSet dcInfo = null;
+ Long vmwareDcId = 1L;
+ Long zoneId;
+ Long clusterId;
+ String clusterHypervisorType;
+ boolean legacyZone;
+ boolean ignoreZone;
+ Long count;
+ String dcOfPreviousCluster = null;
+ String dcOfCurrentCluster = null;
+ String[] tokens;
+ String url;
+ String user = "";
+ String password = "";
+ String vc = "";
+ String dcName = "";
+ String guid;
+ String key;
+ String value;
+
+ try {
+ clustersQuery = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster` where removed is NULL");
+ pstmt = conn.prepareStatement("select id from `cloud`.`data_center` where removed is NULL");
+ rs = pstmt.executeQuery();
+
+ while (rs.next()) {
+ zoneId = rs.getLong("id");
+ legacyZone = false;
+ ignoreZone = true;
+ count = 0L;
+ // Legacy zone term is meant only for VMware
+ // Legacy zone is a zone with atleast 2 clusters & with multiple DCs or VCs
+ clusters = clustersQuery.executeQuery();
+ if (!clusters.next()) {
+ continue; // Ignore the zone without any clusters
+ } else {
+ dcOfPreviousCluster = null;
+ dcOfCurrentCluster = null;
+ do {
+ clusterHypervisorType = clusters.getString("hypervisor_type");
+ clusterId = clusters.getLong("id");
+ if (clusterHypervisorType.equalsIgnoreCase("VMware")) {
+ ignoreZone = false;
+ clusterDetailsQuery = conn.prepareStatement("select value from `cloud`.`cluster_details` where name='url' and cluster_id=?");
+ clusterDetailsQuery.setLong(1, clusterId);
+ clusterDetails = clusterDetailsQuery.executeQuery();
+ clusterDetails.next();
+ url = clusterDetails.getString("value");
+ tokens = url.split("/"); // url format - http://vcenter/dc/cluster
+ vc = tokens[2];
+ dcName = tokens[3];
+ dcOfPreviousCluster = dcOfCurrentCluster;
+ dcOfCurrentCluster = dcName + "@" + vc;
+ if (count > 0) {
+ if (!dcOfPreviousCluster.equalsIgnoreCase(dcOfCurrentCluster)) {
+ legacyZone = true;
+ s_logger.debug("Marking the zone " + zoneId + " as legacy zone.");
+ }
+ }
+ } else {
+ s_logger.debug("Ignoring zone " + zoneId + " with hypervisor type " + clusterHypervisorType);
+ break;
+ }
+ count++;
+ } while (clusters.next());
+ if (ignoreZone) {
+ continue; // Ignore the zone with hypervisors other than VMware
+ }
+ }
+ if (legacyZone) {
+ listOfLegacyZones.add(zoneId);
+ } else {
+ assert(clusterDetails != null) : "Couldn't retrieve details of cluster!";
+ s_logger.debug("Discovered non-legacy zone " + zoneId + ". Processing the zone to associate with VMware datacenter.");
+
+ clusterDetailsQuery = conn.prepareStatement("select name, value from `cloud`.`cluster_details` where cluster_id=?");
+ clusterDetailsQuery.setLong(1, clusterId);
+ clusterDetails = clusterDetailsQuery.executeQuery();
+ while (clusterDetails.next()) {
+ key = clusterDetails.getString(1);
+ value = clusterDetails.getString(2);
+ if (key.equalsIgnoreCase("username")) {
+ user = value;
+ } else if (key.equalsIgnoreCase("password")) {
+ password = value;
+ }
+ }
+ guid = dcName + "@" + vc;
+
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vmware_data_center` (uuid, name, guid, vcenter_host, username, password) values(?, ?, ?, ?, ?, ?)");
+ pstmt.setString(1, UUID.randomUUID().toString());
+ pstmt.setString(2, dcName);
+ pstmt.setString(3, guid);
+ pstmt.setString(4, vc);
+ pstmt.setString(5, user);
+ pstmt.setString(6, password);
+ pstmt.executeUpdate();
+
+ pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`vmware_data_center` where guid=?");
+ pstmt.setString(1, guid);
+ dcInfo = pstmt.executeQuery();
+ if(dcInfo.next()) {
+ vmwareDcId = dcInfo.getLong("id");
+ }
+
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vmware_data_center_zone_map` (zone_id, vmware_data_center_id) values(?, ?)");
+ pstmt.setLong(1, zoneId);
+ pstmt.setLong(2, vmwareDcId);
+ pstmt.executeUpdate();
+ }
+ }
+ updateLegacyZones(conn, listOfLegacyZones);
+ } catch (SQLException e) {
+ String msg = "Unable to discover legacy zones." + e.getMessage();
+ s_logger.error(msg);
+ throw new CloudRuntimeException(msg, e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ if (dcInfo != null) {
+ dcInfo.close();
+ }
+ if (clusters != null) {
+ clusters.close();
+ }
+ if (clusterDetails != null) {
+ clusterDetails.close();
+ }
+ if (clustersQuery != null) {
+ clustersQuery.close();
+ }
+ if (clusterDetailsQuery != null) {
+ clusterDetailsQuery.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ private void updateLegacyZones(Connection conn, List<Long> zones) {
+ PreparedStatement legacyZonesQuery = null;
+ //Insert legacy zones into table for legacy zones.
+ try {
+ legacyZonesQuery = conn.prepareStatement("INSERT INTO `cloud`.`legacy_zones` (zone_id) VALUES (?)");
+ for(Long zoneId : zones) {
+ legacyZonesQuery.setLong(1, zoneId);
+ legacyZonesQuery.executeUpdate();
+ s_logger.debug("Inserted zone " + zoneId + " into cloud.legacyzones table");
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable add zones to cloud.legacyzones table.", e);
+ } finally {
+ try {
+ if (legacyZonesQuery != null) {
+ legacyZonesQuery.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ private void createPlaceHolderNics(Connection conn) {
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ pstmt = conn.prepareStatement("SELECT network_id, gateway, ip4_address FROM `cloud`.`nics` WHERE reserver_name IN ('DirectNetworkGuru','DirectPodBasedNetworkGuru') and vm_type='DomainRouter' AND removed IS null");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ Long networkId = rs.getLong(1);
+ String gateway = rs.getString(2);
+ String ip = rs.getString(3);
+ String uuid = UUID.randomUUID().toString();
+ //Insert placeholder nic for each Domain router nic in Shared network
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`nics` (uuid, ip4_address, gateway, network_id, state, strategy, vm_type, default_nic, created) VALUES (?, ?, ?, ?, 'Reserved', 'PlaceHolder', 'DomainRouter', 0, now())");
+ pstmt.setString(1, uuid);
+ pstmt.setString(2, ip);
+ pstmt.setString(3, gateway);
+ pstmt.setLong(4, networkId);
+ pstmt.executeUpdate();
+ s_logger.debug("Created placeholder nic for the ipAddress " + ip + " and network " + networkId);
+
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to create placeholder nics", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+
+ private void updateRemoteAccessVpn(Connection conn) {
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ pstmt = conn.prepareStatement("SELECT vpn_server_addr_id FROM `cloud`.`remote_access_vpn`");
+ rs = pstmt.executeQuery();
+ long id=1;
+ while (rs.next()) {
+ String uuid = UUID.randomUUID().toString();
+ Long ipId = rs.getLong(1);
+ pstmt = conn.prepareStatement("UPDATE `cloud`.`remote_access_vpn` set uuid=?, id=? where vpn_server_addr_id=?");
+ pstmt.setString(1, uuid);
+ pstmt.setLong(2, id);
+ pstmt.setLong(3, ipId);
+ pstmt.executeUpdate();
+ id++;
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to update id/uuid of remote_access_vpn table", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ private void addEgressFwRulesForSRXGuestNw(Connection conn) {
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ ResultSet rsId = null;
+ ResultSet rsNw = null;
+ try {
+ pstmt = conn.prepareStatement("select network_id FROM `cloud`.`ntwk_service_map` where service='Firewall' and provider='JuniperSRX' ");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long netId = rs.getLong(1);
+ //checking for Isolated OR Virtual
+ pstmt = conn.prepareStatement("select account_id, domain_id FROM `cloud`.`networks` where (guest_type='Isolated' OR guest_type='Virtual') and traffic_type='Guest' and vpc_id is NULL and (state='implemented' OR state='Shutdown') and id=? ");
+ pstmt.setLong(1, netId);
+ s_logger.debug("Getting account_id, domain_id from networks table: " + pstmt);
+ rsNw = pstmt.executeQuery();
+
+ if(rsNw.next()) {
+ long accountId = rsNw.getLong(1);
+ long domainId = rsNw.getLong(2);
+
+ //Add new rule for the existing networks
+ s_logger.debug("Adding default egress firewall rule for network " + netId);
+ pstmt = conn.prepareStatement("INSERT INTO firewall_rules (uuid, state, protocol, purpose, account_id, domain_id, network_id, xid, created, traffic_type) VALUES (?, 'Active', 'all', 'Firewall', ?, ?, ?, ?, now(), 'Egress')");
+ pstmt.setString(1, UUID.randomUUID().toString());
+ pstmt.setLong(2, accountId);
+ pstmt.setLong(3, domainId);
+ pstmt.setLong(4, netId);
+ pstmt.setString(5, UUID.randomUUID().toString());
+ s_logger.debug("Inserting default egress firewall rule " + pstmt);
+ pstmt.executeUpdate();
+
+ pstmt = conn.prepareStatement("select id from firewall_rules where protocol='all' and network_id=?");
+ pstmt.setLong(1, netId);
+ rsId = pstmt.executeQuery();
+
+ long firewallRuleId;
+ if(rsId.next()) {
+ firewallRuleId = rsId.getLong(1);
+ pstmt = conn.prepareStatement("insert into firewall_rules_cidrs (firewall_rule_id,source_cidr) values (?, '0.0.0.0/0')");
+ pstmt.setLong(1, firewallRuleId);
+ s_logger.debug("Inserting rule for cidr 0.0.0.0/0 for the new Firewall rule id=" + firewallRuleId + " with statement " + pstmt);
+ pstmt.executeUpdate();
+ }
+ }
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to set egress firewall rules ", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ private void upgradeEIPNetworkOfferings(Connection conn) {
+
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ pstmt = conn.prepareStatement("select id, elastic_ip_service from `cloud`.`network_offerings` where traffic_type='Guest'");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long id = rs.getLong(1);
+ // check if elastic IP service is enabled for network offering
+ if (rs.getLong(2) != 0) {
+ //update network offering with eip_associate_public_ip set to true
+ pstmt = conn.prepareStatement("UPDATE `cloud`.`network_offerings` set eip_associate_public_ip=? where id=?");
+ pstmt.setBoolean(1, true);
+ pstmt.setLong(2, id);
+ pstmt.executeUpdate();
+ }
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to set elastic_ip_service for network offerings with EIP service enabled.", e);
+ }
+ }
+
+ private void updateNetworkACLs(Connection conn) {
+ //Fetch all VPC Tiers
+ //For each tier create a network ACL and move all the acl_items to network_acl_item table
+ // If there are no acl_items for a tier, associate it with default ACL
+
+ s_logger.debug("Updating network ACLs");
+
+ PreparedStatement pstmt = null;
+ PreparedStatement pstmtDelete = null;
+ ResultSet rs = null;
+ ResultSet rsAcls = null;
+ ResultSet rsCidr = null;
+
+ //1,2 are default acl Ids, start acl Ids from 3
+ long nextAclId = 3;
+
+ try {
+ //Get all VPC tiers
+ pstmt = conn.prepareStatement("SELECT id, vpc_id, uuid FROM `cloud`.`networks` where vpc_id is not null and removed is null");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ Long networkId = rs.getLong(1);
+ s_logger.debug("Updating network ACLs for network: "+networkId);
+ Long vpcId = rs.getLong(2);
+ String tierUuid = rs.getString(3);
+ pstmt = conn.prepareStatement("SELECT id, uuid, start_port, end_port, state, protocol, icmp_code, icmp_type, created, traffic_type FROM `cloud`.`firewall_rules` where network_id = ? and purpose = 'NetworkACL'");
+ pstmt.setLong(1, networkId);
+ rsAcls = pstmt.executeQuery();
+ boolean hasAcls = false;
+ Long aclId = null;
+ int number = 1;
+ while(rsAcls.next()){
+ if(!hasAcls){
+ hasAcls = true;
+ aclId = nextAclId++;
+ //create ACL for the tier
+ s_logger.debug("Creating network ACL for tier: "+tierUuid);
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`network_acl` (id, uuid, vpc_id, description, name) values (?, UUID(), ? , ?, ?)");
+ pstmt.setLong(1, aclId);
+ pstmt.setLong(2, vpcId);
+ pstmt.setString(3, "ACL for tier " + tierUuid);
+ pstmt.setString(4, "tier_" + tierUuid);
+ pstmt.executeUpdate();
+ }
+
+ Long fwRuleId = rsAcls.getLong(1);
+ String cidr = null;
+ //get cidr from firewall_rules_cidrs
+ pstmt = conn.prepareStatement("SELECT id, source_cidr FROM `cloud`.`firewall_rules_cidrs` where firewall_rule_id = ?");
+ pstmt.setLong(1, fwRuleId);
+ rsCidr = pstmt.executeQuery();
+ while(rsCidr.next()){
+ Long cidrId = rsCidr.getLong(1);
+ String sourceCidr = rsCidr.getString(2);
+ if(cidr == null){
+ cidr = sourceCidr;
+ } else {
+ cidr += ","+sourceCidr;
+ }
+ //Delete cidr entry
+ pstmtDelete = conn.prepareStatement("DELETE FROM `cloud`.`firewall_rules_cidrs` where id = ?");
+ pstmtDelete.setLong(1, cidrId);
+ pstmtDelete.executeUpdate();
+ }
+
+
+ String aclItemUuid = rsAcls.getString(2);
+ //Move acl to network_acl_item table
+ s_logger.debug("Moving firewall rule: "+aclItemUuid);
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`network_acl_item` (uuid, acl_id, start_port, end_port, state, protocol, icmp_code, icmp_type, created, traffic_type, cidr, number, action) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
+ //uuid
+ pstmt.setString(1, aclItemUuid);
+ //aclId
+ pstmt.setLong(2, aclId);
+ //Start port
+ Integer startPort = rsAcls.getInt(3);
+ if(rsAcls.wasNull()){
+ pstmt.setNull(3, Types.INTEGER);
+ } else {
+ pstmt.setLong(3, startPort);
+ }
+ //End port
+ Integer endPort = rsAcls.getInt(4);
+ if(rsAcls.wasNull()){
+ pstmt.setNull(4, Types.INTEGER);
+ } else {
+ pstmt.setLong(4, endPort);
+ }
+ //State
+ String state = rsAcls.getString(5);
+ pstmt.setString(5, state);
+ //protocol
+ String protocol = rsAcls.getString(6);
+ pstmt.setString(6, protocol);
+ //icmp_code
+ Integer icmpCode = rsAcls.getInt(7);
+ if(rsAcls.wasNull()){
+ pstmt.setNull(7, Types.INTEGER);
+ } else {
+ pstmt.setLong(7, icmpCode);
+ }
+
+ //icmp_type
+ Integer icmpType = rsAcls.getInt(8);
+ if(rsAcls.wasNull()){
+ pstmt.setNull(8, Types.INTEGER);
+ } else {
+ pstmt.setLong(8, icmpType);
+ }
+
+ //created
+ Date created = rsAcls.getDate(9);
+ pstmt.setDate(9, created);
+ //traffic type
+ String trafficType = rsAcls.getString(10);
+ pstmt.setString(10, trafficType);
+
+ //cidr
+ pstmt.setString(11, cidr);
+ //number
+ pstmt.setInt(12, number++);
+ //action
+ pstmt.setString(13, "Allow");
+ pstmt.executeUpdate();
+
+ //Delete firewall rule
+ pstmtDelete = conn.prepareStatement("DELETE FROM `cloud`.`firewall_rules` where id = ?");
+ pstmtDelete.setLong(1, fwRuleId);
+ pstmtDelete.executeUpdate();
+ }
+ if(!hasAcls){
+ //no network ACls for this network.
+ // Assign default Deny ACL
+ aclId = NetworkACL.DEFAULT_DENY;
+ }
+ //Assign acl to network
+ pstmt = conn.prepareStatement("UPDATE `cloud`.`networks` set network_acl_id=? where id=?");
+ pstmt.setLong(1, aclId);
+ pstmt.setLong(2, networkId);
+ pstmt.executeUpdate();
+ }
+ s_logger.debug("Done updating network ACLs ");
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to move network acls from firewall rules table to network_acl_item table", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (rsAcls != null) {
+ rsAcls.close();
+ }
+ if (rsCidr != null) {
+ rsCidr.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ private void updateGlobalDeploymentPlanner(Connection conn) {
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ pstmt = conn
+ .prepareStatement("select value from `cloud`.`configuration` where name = 'vm.allocation.algorithm'");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ String globalValue = rs.getString(1);
+ String plannerName = "FirstFitPlanner";
+
+ if (globalValue != null) {
+ if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.random.toString())) {
+ plannerName = "FirstFitPlanner";
+ } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.firstfit.toString())) {
+ plannerName = "FirstFitPlanner";
+ } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userconcentratedpod_firstfit
+ .toString())) {
+ plannerName = "UserConcentratedPodPlanner";
+ } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userconcentratedpod_random
+ .toString())) {
+ plannerName = "UserConcentratedPodPlanner";
+ } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userdispersing.toString())) {
+ plannerName = "UserDispersingPlanner";
+ }
+ }
+ // update vm.deployment.planner global config
+ pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` set value=? where name = 'vm.deployment.planner'");
+ pstmt.setString(1, plannerName);
+ pstmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to set vm.deployment.planner global config", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+
+ private void upgradeDefaultVpcOffering(Connection conn) {
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ pstmt = conn.prepareStatement("select distinct map.vpc_offering_id from `cloud`.`vpc_offering_service_map` map, `cloud`.`vpc_offerings` off where off.id=map.vpc_offering_id AND service='Lb'");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long id = rs.getLong(1);
+ //Add internal LB vm as a supported provider for the load balancer service
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vpc_offering_service_map` (vpc_offering_id, service, provider) VALUES (?,?,?)");
+ pstmt.setLong(1, id);
+ pstmt.setString(2, "Lb");
+ pstmt.setString(3, "InternalLbVm");
+ pstmt.executeUpdate();
+ }
+
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable update the default VPC offering with the internal lb service", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ private void upgradePhysicalNtwksWithInternalLbProvider(Connection conn) {
+
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network` where removed is null");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long pNtwkId = rs.getLong(1);
+ String uuid = UUID.randomUUID().toString();
+ //Add internal LB VM to the list of physical network service providers
+ pstmt = conn.prepareStatement("INSERT INTO `cloud`.`physical_network_service_providers` " +
+ "(uuid, physical_network_id, provider_name, state, load_balance_service_provided, destination_physical_network_id)" +
+ " VALUES (?, ?, 'InternalLbVm', 'Enabled', 1, 0)");
+ pstmt.setString(1, uuid);
+ pstmt.setLong(2, pNtwkId);
+ pstmt.executeUpdate();
+
+ //Add internal lb vm to the list of physical network elements
+ PreparedStatement pstmt1 = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network_service_providers`" +
+ " WHERE physical_network_id=? AND provider_name='InternalLbVm'");
+ pstmt1.setLong(1, pNtwkId);
+ ResultSet rs1 = pstmt1.executeQuery();
+ while (rs1.next()) {
+ long providerId = rs1.getLong(1);
+ uuid = UUID.randomUUID().toString();
+ pstmt1 = conn.prepareStatement("INSERT INTO `cloud`.`virtual_router_providers` (nsp_id, uuid, type, enabled) VALUES (?, ?, 'InternalLbVm', 1)");
+ pstmt1.setLong(1, providerId);
+ pstmt1.setString(2, uuid);
+ pstmt1.executeUpdate();
+ }
+ }
+
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to update existing physical networks with internal lb provider", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ private void addHostDetailsIndex(Connection conn) {
+ s_logger.debug("Checking if host_details index exists, if not we will add it");
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ try {
+ pstmt = conn.prepareStatement("SHOW INDEX FROM `cloud`.`host_details` where KEY_NAME = 'fk_host_details__host_id'");
+ rs = pstmt.executeQuery();
+ if (rs.next()) {
+ s_logger.debug("Index already exists on host_details - not adding new one");
+ } else {
+ // add the index
+ PreparedStatement pstmtUpdate = conn.prepareStatement("ALTER IGNORE TABLE `cloud`.`host_details` ADD INDEX `fk_host_details__host_id` (`host_id`)");
+ pstmtUpdate.executeUpdate();
+ s_logger.debug("Index did not exist on host_details - added new one");
+ pstmtUpdate.close();
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Failed to check/update the host_details index ", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+
+ private void updateNetworksForPrivateGateways(Connection conn) {
+
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ //1) get all non removed gateways
+ pstmt = conn.prepareStatement("SELECT network_id, vpc_id FROM `cloud`.`vpc_gateways` WHERE type='Private' AND removed IS null");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ Long networkId = rs.getLong(1);
+ Long vpcId = rs.getLong(2);
+ //2) Update networks with vpc_id if its set to NULL
+ pstmt = conn.prepareStatement("UPDATE `cloud`.`networks` set vpc_id=? where id=? and vpc_id is NULL and removed is NULL");
+ pstmt.setLong(1, vpcId);
+ pstmt.setLong(2, networkId);
+ pstmt.executeUpdate();
+
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Failed to update private networks with VPC id.", e);
+ }
+ }
+
+ private void removeFirewallServiceFromSharedNetworkOfferingWithSGService(Connection conn) {
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+
+ try {
+ pstmt = conn.prepareStatement("select id from `cloud`.`network_offerings` where unique_name='DefaultSharedNetworkOfferingWithSGService'");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long id = rs.getLong(1);
+ // remove Firewall service for SG shared network offering
+ pstmt = conn.prepareStatement("DELETE from `cloud`.`ntwk_offering_service_map` where network_offering_id=? and service='Firewall'");
+ pstmt.setLong(1, id);
+ pstmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to remove Firewall service for SG shared network offering.", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ private void fix22xKVMSnapshots(Connection conn) {
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ s_logger.debug("Updating KVM snapshots");
+ try {
+ pstmt = conn.prepareStatement("select id, backup_snap_id from `cloud`.`snapshots` where hypervisor_type='KVM' and removed is null and backup_snap_id is not null");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long id = rs.getLong(1);
+ String backUpPath = rs.getString(2);
+ // Update Backup Path. Remove anything before /snapshots/
+ // e.g 22x Path /mnt/0f14da63-7033-3ca5-bdbe-fa62f4e2f38a/snapshots/1/2/6/i-2-6-VM_ROOT-6_20121219072022
+ // Above path should change to /snapshots/1/2/6/i-2-6-VM_ROOT-6_20121219072022
+ int index = backUpPath.indexOf("snapshots"+File.separator);
+ if (index > 1){
+ String correctedPath = backUpPath.substring(index);
+ s_logger.debug("Updating Snapshot with id: "+id+" original backup path: "+backUpPath+ " updated backup path: "+correctedPath);
+ pstmt = conn.prepareStatement("UPDATE `cloud`.`snapshots` set backup_snap_id=? where id = ?");
+ pstmt.setString(1, correctedPath);
+ pstmt.setLong(2, id);
+ pstmt.executeUpdate();
+ }
+ }
+ s_logger.debug("Done updating KVM snapshots");
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to update backup id for KVM snapshots", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ // Corrects upgrade for deployment with F5 and SRX devices (pre 3.0) to network offering &
+ // network service provider paradigm
+ private void correctExternalNetworkDevicesSetup(Connection conn) {
+ PreparedStatement zoneSearchStmt = null, pNetworkStmt = null, f5DevicesStmt = null, srxDevicesStmt = null;
+ ResultSet zoneResults = null, pNetworksResults = null, f5DevicesResult = null, srxDevicesResult = null;
+
+ try {
+ zoneSearchStmt = conn.prepareStatement("SELECT id, networktype FROM `cloud`.`data_center`");
+ zoneResults = zoneSearchStmt.executeQuery();
+ while (zoneResults.next()) {
+ long zoneId = zoneResults.getLong(1);
+ String networkType = zoneResults.getString(2);
+
+ if (!com.cloud.dc.DataCenter.NetworkType.Advanced.toString().equalsIgnoreCase(networkType)) {
+ continue;
+ }
+
+ pNetworkStmt = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network` where data_center_id=?");
+ pNetworkStmt.setLong(1, zoneId);
+ pNetworksResults = pNetworkStmt.executeQuery();
+ while (pNetworksResults.next()) {
+ long physicalNetworkId = pNetworksResults.getLong(1);
+ PreparedStatement fetchF5NspStmt = conn.prepareStatement("SELECT id from `cloud`.`physical_network_service_providers` where physical_network_id=" + physicalNetworkId
+ + " and provider_name = 'F5BigIp'");
+ ResultSet rsF5NSP = fetchF5NspStmt.executeQuery();
+ boolean hasF5Nsp = rsF5NSP.next();
+ fetchF5NspStmt.close();
+
+ // if there is no 'F5BigIP' physical network service provider added into physical network then
+ // add 'F5BigIP' as network service provider and add the entry in 'external_load_balancer_devices'
+ if (!hasF5Nsp) {
+ f5DevicesStmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalLoadBalancer' AND removed IS NULL");
+ f5DevicesStmt.setLong(1, zoneId);
+ f5DevicesResult = f5DevicesStmt.executeQuery();
+ // add F5BigIP provider and provider instance to physical network if there are any external load
+ // balancers added in the zone
+ while (f5DevicesResult.next()) {
+ long f5HostId = f5DevicesResult.getLong(1);;
+ addF5ServiceProvider(conn, physicalNetworkId, zoneId);
+ addF5LoadBalancer(conn, f5HostId, physicalNetworkId);
+ }
+ }
+
+ PreparedStatement fetchSRXNspStmt = conn.prepareStatement("SELECT id from `cloud`.`physical_network_service_providers` where physical_network_id=" + physicalNetworkId
+ + " and provider_name = 'JuniperSRX'");
+ ResultSet rsSRXNSP = fetchSRXNspStmt.executeQuery();
+ boolean hasSrxNsp = rsSRXNSP.next();
+ fetchSRXNspStmt.close();
+
+ // if there is no 'JuniperSRX' physical network service provider added into physical network then
+ // add 'JuniperSRX' as network service provider and add the entry in 'external_firewall_devices'
+ if (!hasSrxNsp) {
+ srxDevicesStmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalFirewall' AND removed IS NULL");
+ srxDevicesStmt.setLong(1, zoneId);
+ srxDevicesResult = srxDevicesStmt.executeQuery();
+ // add JuniperSRX provider and provider instance to physical network if there are any external
+ // firewall instances added in to the zone
+ while (srxDevicesResult.next()) {
+ long srxHostId = srxDevicesResult.getLong(1);
+ // add SRX provider and provider instance to physical network
+ addSrxServiceProvider(conn, physicalNetworkId, zoneId);
+ addSrxFirewall(conn, srxHostId, physicalNetworkId);
+ }
+ }
+ }
+ }
+
+ // not the network service provider has been provisioned in to physical network, mark all guest network
+ // to be using network offering 'Isolated with external providers'
+ fixZoneUsingExternalDevices(conn);
+
+ if (zoneResults != null) {
+ try {
+ zoneResults.close();
+ } catch (SQLException e) {
+ }
+ }
+
+ if (zoneSearchStmt != null) {
+ try {
+ zoneSearchStmt.close();
+ } catch (SQLException e) {
+ }
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Exception while adding PhysicalNetworks", e);
+ } finally {
+
+ }
+ }
+
+ private void addF5LoadBalancer(Connection conn, long hostId, long physicalNetworkId){
+ PreparedStatement pstmtUpdate = null;
+ try{
+ s_logger.debug("Adding F5 Big IP load balancer with host id " + hostId + " in to physical network" + physicalNetworkId);
+ String insertF5 = "INSERT INTO `cloud`.`external_load_balancer_devices` (physical_network_id, host_id, provider_name, " +
+ "device_name, capacity, is_dedicated, device_state, allocation_state, is_managed, uuid) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ pstmtUpdate = conn.prepareStatement(insertF5);
+ pstmtUpdate.setLong(1, physicalNetworkId);
+ pstmtUpdate.setLong(2, hostId);
+ pstmtUpdate.setString(3, "F5BigIp");
+ pstmtUpdate.setString(4, "F5BigIpLoadBalancer");
+ pstmtUpdate.setLong(5, 0);
+ pstmtUpdate.setBoolean(6, false);
+ pstmtUpdate.setString(7, "Enabled");
+ pstmtUpdate.setString(8, "Shared");
+ pstmtUpdate.setBoolean(9, false);
+ pstmtUpdate.setString(10, UUID.randomUUID().toString());
+ pstmtUpdate.executeUpdate();
+ }catch (SQLException e) {
+ throw new CloudRuntimeException("Exception while adding F5 load balancer device" , e);
+ } finally {
+ if (pstmtUpdate != null) {
+ try {
+ pstmtUpdate.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+ }
+
+ private void addSrxFirewall(Connection conn, long hostId, long physicalNetworkId){
+ PreparedStatement pstmtUpdate = null;
+ try{
+ s_logger.debug("Adding SRX firewall device with host id " + hostId + " in to physical network" + physicalNetworkId);
+ String insertSrx = "INSERT INTO `cloud`.`external_firewall_devices` (physical_network_id, host_id, provider_name, " +
+ "device_name, capacity, is_dedicated, device_state, allocation_state, uuid) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ pstmtUpdate = conn.prepareStatement(insertSrx);
+ pstmtUpdate.setLong(1, physicalNetworkId);
+ pstmtUpdate.setLong(2, hostId);
+ pstmtUpdate.setString(3, "JuniperSRX");
+ pstmtUpdate.setString(4, "JuniperSRXFirewall");
+ pstmtUpdate.setLong(5, 0);
+ pstmtUpdate.setBoolean(6, false);
+ pstmtUpdate.setString(7, "Enabled");
+ pstmtUpdate.setString(8, "Shared");
+ pstmtUpdate.setString(9, UUID.randomUUID().toString());
+ pstmtUpdate.executeUpdate();
+ }catch (SQLException e) {
+ throw new CloudRuntimeException("Exception while adding SRX firewall device ", e);
+ } finally {
+ if (pstmtUpdate != null) {
+ try {
+ pstmtUpdate.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+ }
+
+ private void addF5ServiceProvider(Connection conn, long physicalNetworkId, long zoneId){
+ PreparedStatement pstmtUpdate = null;
+ try{
+ // add physical network service provider - F5BigIp
+ s_logger.debug("Adding PhysicalNetworkServiceProvider F5BigIp" + " in to physical network" + physicalNetworkId);
+ String insertPNSP = "INSERT INTO `cloud`.`physical_network_service_providers` (`uuid`, `physical_network_id` , `provider_name`, `state` ," +
+ "`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," +
+ "`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," +
+ "`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,0,0,0,0,0,0,0,1,0,0,0,0)";
+
+ pstmtUpdate = conn.prepareStatement(insertPNSP);
+ pstmtUpdate.setString(1, UUID.randomUUID().toString());
+ pstmtUpdate.setLong(2, physicalNetworkId);
+ pstmtUpdate.setString(3, "F5BigIp");
+ pstmtUpdate.setString(4, "Enabled");
+ pstmtUpdate.executeUpdate();
+ }catch (SQLException e) {
+ throw new CloudRuntimeException("Exception while adding PhysicalNetworkServiceProvider F5BigIp", e);
+ } finally {
+ if (pstmtUpdate != null) {
+ try {
+ pstmtUpdate.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+ }
+
+ private void addSrxServiceProvider(Connection conn, long physicalNetworkId, long zoneId){
+ PreparedStatement pstmtUpdate = null;
+ try{
+ // add physical network service provider - JuniperSRX
+ s_logger.debug("Adding PhysicalNetworkServiceProvider JuniperSRX");
+ String insertPNSP = "INSERT INTO `cloud`.`physical_network_service_providers` (`uuid`, `physical_network_id` , `provider_name`, `state` ," +
+ "`destination_physical_network_id`, `vpn_service_provided`, `dhcp_service_provided`, `dns_service_provided`, `gateway_service_provided`," +
+ "`firewall_service_provided`, `source_nat_service_provided`, `load_balance_service_provided`, `static_nat_service_provided`," +
+ "`port_forwarding_service_provided`, `user_data_service_provided`, `security_group_service_provided`) VALUES (?,?,?,?,0,0,0,0,1,1,1,0,1,1,0,0)";
+
+ pstmtUpdate = conn.prepareStatement(insertPNSP);
+ pstmtUpdate.setString(1, UUID.randomUUID().toString());
+ pstmtUpdate.setLong(2, physicalNetworkId);
+ pstmtUpdate.setString(3, "JuniperSRX");
+ pstmtUpdate.setString(4, "Enabled");
+ pstmtUpdate.executeUpdate();
+ }catch (SQLException e) {
+ throw new CloudRuntimeException("Exception while adding PhysicalNetworkServiceProvider JuniperSRX" , e);
+ } finally {
+ if (pstmtUpdate != null) {
+ try {
+ pstmtUpdate.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+ }
+
+ // This method does two things
+ //
+ // 1) ensure that networks using external load balancer/firewall in deployments prior to release 3.0
+ // has entry in network_external_lb_device_map and network_external_firewall_device_map
+ //
+ // 2) Some keys of host details for F5 and SRX devices were stored in Camel Case in 2.x releases. From 3.0
+ // they are made in lowercase. On upgrade change the host details name to lower case
+ private void fixZoneUsingExternalDevices(Connection conn) {
+ //Get zones to upgrade
+ List<Long> zoneIds = new ArrayList<Long>();
+ PreparedStatement pstmt = null;
+ PreparedStatement pstmtUpdate = null;
+ ResultSet rs = null;
+ long networkOfferingId, networkId;
+ long f5DeviceId, f5HostId;
+ long srxDevivceId, srxHostId;
+
+ try {
+ pstmt = conn.prepareStatement("select id from `cloud`.`data_center` where lb_provider='F5BigIp' or firewall_provider='JuniperSRX' or gateway_provider='JuniperSRX'");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ zoneIds.add(rs.getLong(1));
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to create network to LB & firewall device mapping for networks that use them", e);
+ }
+
+ if (zoneIds.size() == 0) {
+ return; // no zones using F5 and SRX devices so return
+ }
+
+ // find the default network offering created for external devices during upgrade from 2.2.14
+ try {
+ pstmt = conn.prepareStatement("select id from `cloud`.`network_offerings` where unique_name='Isolated with external providers' ");
+ rs = pstmt.executeQuery();
+ if (rs.first()) {
+ networkOfferingId = rs.getLong(1);
+ } else {
+ throw new CloudRuntimeException("Cannot upgrade as there is no 'Isolated with external providers' network offering crearted .");
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to create network to LB & firewalla device mapping for networks that use them", e);
+ }
+
+ for (Long zoneId : zoneIds) {
+ try {
+ // find the F5 device id in the zone
+ pstmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalLoadBalancer' AND removed IS NULL");
+ pstmt.setLong(1, zoneId);
+ rs = pstmt.executeQuery();
+ if (rs.first()) {
+ f5HostId = rs.getLong(1);
+ } else {
+ throw new CloudRuntimeException("Cannot upgrade as there is no F5 load balancer device found in data center " + zoneId);
+ }
+ pstmt = conn.prepareStatement("SELECT id FROM external_load_balancer_devices WHERE host_id=?");
+ pstmt.setLong(1, f5HostId);
+ rs = pstmt.executeQuery();
+ if (rs.first()) {
+ f5DeviceId = rs.getLong(1);
+ } else {
+ throw new CloudRuntimeException("Cannot upgrade as there is no F5 load balancer device with host ID " + f5HostId + " found in external_load_balancer_device");
+ }
+
+ // find the SRX device id in the zone
+ pstmt = conn.prepareStatement("SELECT id FROM host WHERE data_center_id=? AND type = 'ExternalFirewall' AND removed IS NULL");
+ pstmt.setLong(1, zoneId);
+ rs = pstmt.executeQuery();
+ if (rs.first()) {
+ srxHostId = rs.getLong(1);
+ } else {
+ throw new CloudRuntimeException("Cannot upgrade as there is no SRX firewall device found in data center " + zoneId);
+ }
+ pstmt = conn.prepareStatement("SELECT id FROM external_firewall_devices WHERE host_id=?");
+ pstmt.setLong(1, srxHostId);
+ rs = pstmt.executeQuery();
+ if (rs.first()) {
+ srxDevivceId = rs.getLong(1);
+ } else {
+ throw new CloudRuntimeException("Cannot upgrade as there is no SRX firewall device found with host ID " + srxHostId + " found in external_firewall_devices");
+ }
+
+ // check if network any uses F5 or SRX devices in the zone
+ pstmt = conn.prepareStatement("select id from `cloud`.`networks` where guest_type='Virtual' and data_center_id=? and network_offering_id=? and removed IS NULL");
+ pstmt.setLong(1, zoneId);
+ pstmt.setLong(2, networkOfferingId);
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ // get the network Id
+ networkId = rs.getLong(1);
+
+ // add mapping for the network in network_external_lb_device_map
+ String insertLbMapping = "INSERT INTO `cloud`.`network_external_lb_device_map` (uuid, network_id, external_load_balancer_device_id, created) VALUES ( ?, ?, ?, now())";
+ pstmtUpdate = conn.prepareStatement(insertLbMapping);
+ pstmtUpdate.setString(1, UUID.randomUUID().toString());
+ pstmtUpdate.setLong(2, networkId);
+ pstmtUpdate.setLong(3, f5DeviceId);
+ pstmtUpdate.executeUpdate();
+ s_logger.debug("Successfully added entry in network_external_lb_device_map for network " + networkId + " and F5 device ID " + f5DeviceId);
+
+ // add mapping for the network in network_external_firewall_device_map
+ String insertFwMapping = "INSERT INTO `cloud`.`network_external_firewall_device_map` (uuid, network_id, external_firewall_device_id, created) VALUES ( ?, ?, ?, now())";
+ pstmtUpdate = conn.prepareStatement(insertFwMapping);
+ pstmtUpdate.setString(1, UUID.randomUUID().toString());
+ pstmtUpdate.setLong(2, networkId);
+ pstmtUpdate.setLong(3, srxDevivceId);
+ pstmtUpdate.executeUpdate();
+ s_logger.debug("Successfully added entry in network_external_firewall_device_map for network " + networkId + " and SRX device ID " + srxDevivceId);
+ }
+
+ // update host details for F5 and SRX devices
+ s_logger.debug("Updating the host details for F5 and SRX devices");
+ pstmt = conn.prepareStatement("SELECT host_id, name FROM `cloud`.`host_details` WHERE host_id=? OR host_id=?");
+ pstmt.setLong(1, f5HostId);
+ pstmt.setLong(2, srxHostId);
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long hostId = rs.getLong(1);
+ String camlCaseName = rs.getString(2);
+ if (!(camlCaseName.equalsIgnoreCase("numRetries") ||
+ camlCaseName.equalsIgnoreCase("publicZone") ||
+ camlCaseName.equalsIgnoreCase("privateZone") ||
+ camlCaseName.equalsIgnoreCase("publicInterface") ||
+ camlCaseName.equalsIgnoreCase("privateInterface") ||
+ camlCaseName.equalsIgnoreCase("usageInterface") )) {
+ continue;
+ }
+ String lowerCaseName = camlCaseName.toLowerCase();
+ pstmt = conn.prepareStatement("update `cloud`.`host_details` set name=? where host_id=? AND name=?");
+ pstmt.setString(1, lowerCaseName);
+ pstmt.setLong(2, hostId);
+ pstmt.setString(3, camlCaseName);
+ pstmt.executeUpdate();
+ }
+ s_logger.debug("Successfully updated host details for F5 and SRX devices");
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable create a mapping for the networks in network_external_lb_device_map and network_external_firewall_device_map", e);
+ } finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ s_logger.info("Successfully upgraded network using F5 and SRX devices to have a entry in the network_external_lb_device_map and network_external_firewall_device_map");
+ }
+ }
+
+ // migrate secondary storages (NFS, S3, Swift) from host, s3, swift tables to image_store table
+ private void migrateSecondaryStorageToImageStore(Connection conn) {
+ PreparedStatement storeInsert = null;
+ PreparedStatement storeDetailInsert = null;
+ PreparedStatement storeQuery = null;
+ PreparedStatement s3Query = null;
+ PreparedStatement swiftQuery = null;
+ PreparedStatement nfsQuery = null;
+ ResultSet rs = null;
+ ResultSet storeInfo = null;
+ Long storeId = null;
+
+ s_logger.debug("Migrating secondary storage to image store");
+ try {
+ storeQuery = conn.prepareStatement("select id from `cloud`.`image_store` where uuid = ?");
+ storeDetailInsert = conn
+ .prepareStatement("INSERT INTO `cloud`.`image_store_details` (store_id, name, value) values(?, ?, ?)");
+
+ /*
+ // migrate S3 secondary storage
+ storeInsert = conn
+ .prepareStatement("INSERT INTO `cloud`.`image_store` (uuid, name, image_provider_name, protocol, scope, role, created) values(?, ?, 'S3', ?, 'REGION', 'Image', ?)");
+ s3Query = conn
+ .prepareStatement("select id, uuid, access_key, secret_key, end_point, bucket, https, connection_timeout, max_error_retry, socket_timeout, created from `cloud`.`s3`");
+ rs = s3Query.executeQuery();
+
+ while (rs.next()) {
+ Long s3_id = rs.getLong("id");
+ String s3_uuid = rs.getString("uuid");
+ String s3_accesskey = rs.getString("access_key");
+ String s3_secretkey = rs.getString("secret_key");
+ String s3_endpoint = rs.getString("end_point");
+ String s3_bucket = rs.getString("bucket");
+ boolean s3_https = rs.getObject("https") != null ? (rs.getInt("https") == 0 ? false : true) : false;
+ Integer s3_connectiontimeout = rs.getObject("connection_timeout") != null ? rs
+ .getInt("connection_timeout") : null;
+ Integer s3_retry = rs.getObject("max_error_retry") != null ? rs.getInt("max_error_retry") : null;
+ Integer s3_sockettimeout = rs.getObject("socket_timeout") != null ? rs.getInt("socket_timeout") : null;
+ Date s3_created = rs.getDate("created");
+
+ // insert entry in image_store table and image_store_details
+ // table and store s3_id and store_id mapping
+
+ storeInsert.setString(1, s3_uuid);
+ storeInsert.setString(2, s3_uuid);
+ storeInsert.setString(3, s3_https ? "https" : "http");
+ storeInsert.setDate(4, s3_created);
+ storeInsert.executeUpdate();
+
+ storeQuery.setString(1, s3_uuid);
+ storeInfo = storeQuery.executeQuery();
+ if (storeInfo.next()) {
+ storeId = storeInfo.getLong("id");
+ }
+
+ Map<String, String> detailMap = new HashMap<String, String>();
+ detailMap.put(ApiConstants.S3_ACCESS_KEY, s3_accesskey);
+ detailMap.put(ApiConstants.S3_SECRET_KEY, s3_secretkey);
+ detailMap.put(ApiConstants.S3_BUCKET_NAME, s3_bucket);
+ detailMap.put(ApiConstants.S3_END_POINT, s3_endpoint);
+ detailMap.put(ApiConstants.S3_HTTPS_FLAG, String.valueOf(s3_https));
+ if (s3_connectiontimeout != null) {
+ detailMap.put(ApiConstants.S3_CONNECTION_TIMEOUT, String.valueOf(s3_connectiontimeout));
+ }
+ if (s3_retry != null) {
+ detailMap.put(ApiConstants.S3_MAX_ERROR_RETRY, String.valueOf(s3_retry));
+ }
+ if (s3_sockettimeout != null) {
+ detailMap.put(ApiConstants.S3_SOCKET_TIMEOUT, String.valueOf(s3_sockettimeout));
+ }
+
+ Iterator<String> keyIt = detailMap.keySet().iterator();
+ while (keyIt.hasNext()) {
+ String key = keyIt.next();
+ String val = detailMap.get(key);
+ storeDetailInsert.setLong(1, storeId);
+ storeDetailInsert.setString(2, key);
+ storeDetailInsert.setString(3, val);
+ storeDetailInsert.executeUpdate();
+ }
+ s3_store_id_map.put(s3_id, storeId);
+ }
+
+ // migrate SWIFT secondary storage
+ storeInsert = conn
+ .prepareStatement("INSERT INTO `cloud`.`image_store` (uuid, name, image_provider_name, protocol, url, scope, role, created) values(?, ?, 'Swift', 'http', ?, 'REGION', 'Image', ?)");
+ swiftQuery = conn
+ .prepareStatement("select id, uuid, url, account, username, key, created from `cloud`.`swift`");
+ rs = swiftQuery.executeQuery();
+
+ while (rs.next()) {
+ Long swift_id = rs.getLong("id");
+ String swift_uuid = rs.getString("uuid");
+ String swift_url = rs.getString("url");
+ String swift_account = rs.getString("account");
+ String swift_username = rs.getString("username");
+ String swift_key = rs.getString("key");
+ Date swift_created = rs.getDate("created");
+
+ // insert entry in image_store table and image_store_details
+ // table and store swift_id and store_id mapping
+ storeInsert.setString(1, swift_uuid);
+ storeInsert.setString(2, swift_uuid);
+ storeInsert.setString(3, swift_url);
+ storeInsert.setDate(4, swift_created);
+ storeInsert.executeUpdate();
+
+ storeQuery.setString(1, swift_uuid);
+ storeInfo = storeQuery.executeQuery();
+ if (storeInfo.next()) {
+ storeId = storeInfo.getLong("id");
+ }
+
+ Map<String, String> detailMap = new HashMap<String, String>();
+ detailMap.put(ApiConstants.ACCOUNT, swift_account);
+ detailMap.put(ApiConstants.USERNAME, swift_username);
+ detailMap.put(ApiConstants.KEY, swift_key);
+
+ Iterator<String> keyIt = detailMap.keySet().iterator();
+ while (keyIt.hasNext()) {
+ String key = keyIt.next();
+ String val = detailMap.get(key);
+ storeDetailInsert.setLong(1, storeId);
+ storeDetailInsert.setString(2, key);
+ storeDetailInsert.setString(3, val);
+ storeDetailInsert.executeUpdate();
+ }
+ swift_store_id_map.put(swift_id, storeId);
+ }
+ */
+
+ // migrate NFS secondary storage, for nfs, keep previous host_id as the store_id
+ storeInsert = conn
+ .prepareStatement("INSERT INTO `cloud`.`image_store` (id, uuid, name, image_provider_name, protocol, url, data_center_id, scope, role, parent, total_size, created) values(?, ?, ?, 'NFS', 'nfs', ?, ?, 'ZONE', 'Image', ?, ?, ?)");
+ nfsQuery = conn
+ .prepareStatement("select id, uuid, url, data_center_id, parent, total_size, created from `cloud`.`host` where type = 'SecondaryStorage' and removed is null");
+ rs = nfsQuery.executeQuery();
+
+ while (rs.next()) {
+ Long nfs_id = rs.getLong("id");
+ String nfs_uuid = rs.getString("uuid");
+ String nfs_url = rs.getStr
<TRUNCATED>
[6/9] CLOUDSTACK-4167: Put in upgrade paths in master for 4.1.2 and
4.2
Posted by vi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d47b4a99/engine/schema/src/com/cloud/upgrade/dao/Upgrade411to412.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade411to412.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade411to412.java
new file mode 100644
index 0000000..1bb9ff6
--- /dev/null
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade411to412.java
@@ -0,0 +1,77 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.upgrade.dao;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+import org.apache.log4j.Logger;
+
+import com.cloud.deploy.DeploymentPlanner;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.network.vpc.NetworkACL;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+
+public class Upgrade411to412 implements DbUpgrade {
+ final static Logger s_logger = Logger.getLogger(Upgrade411to412.class);
+
+ @Override
+ public String[] getUpgradableVersionRange() {
+ return new String[] { "4.1.1", "4.1.2" };
+ }
+
+ @Override
+ public String getUpgradedVersion() {
+ return "4.1.2";
+ }
+
+ @Override
+ public boolean supportsRollingUpgrade() {
+ return false;
+ }
+
+ @Override
+ public File[] getPrepareScripts() {
+ // Do nothing.
+ return null;
+ }
+
+ @Override
+ public void performDataMigration(Connection conn) {
+ // Nothing to be done
+ }
+
+ @Override
+ public File[] getCleanupScripts() {
+ return null;
+ }
+}
[4/9] CLOUDSTACK-4167: Put in upgrade paths in master for 4.1.2 and
4.2
Posted by vi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d47b4a99/setup/db/db/schema-410to420-cleanup.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420-cleanup.sql b/setup/db/db/schema-410to420-cleanup.sql
deleted file mode 100644
index b65717f..0000000
--- a/setup/db/db/schema-410to420-cleanup.sql
+++ /dev/null
@@ -1,28 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements. See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership. The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License. You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied. See the License for the
--- specific language governing permissions and limitations
--- under the License.
-
---;
--- Schema cleanup from 4.1.0 to 4.2.0;
---;
-
-#have to drop the foreign key in order to delete primary key; will re-insert the foreign key later
-ALTER TABLE `cloud`.`remote_access_vpn` DROP foreign key `fk_remote_access_vpn__vpn_server_addr_id`;
-ALTER TABLE `cloud`.`remote_access_vpn` DROP primary key;
-ALTER TABLE `cloud`.`remote_access_vpn` ADD primary key (`id`);
-ALTER TABLE `cloud`.`remote_access_vpn` ADD CONSTRAINT `fk_remote_access_vpn__vpn_server_addr_id` FOREIGN KEY (`vpn_server_addr_id`) REFERENCES `user_ip_address` (`id`);
-
-
[2/9] CLOUDSTACK-4167: Put in upgrade paths in master for 4.1.2 and
4.2
Posted by vi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d47b4a99/setup/db/db/schema-412to420-cleanup.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-412to420-cleanup.sql b/setup/db/db/schema-412to420-cleanup.sql
new file mode 100644
index 0000000..2a7ab6a
--- /dev/null
+++ b/setup/db/db/schema-412to420-cleanup.sql
@@ -0,0 +1,26 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied. See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+--;
+-- Schema cleanup from 4.1.0 to 4.2.0;
+--;
+
+#have to drop the foreign key in order to delete primary key; will re-insert the foreign key later
+ALTER TABLE `cloud`.`remote_access_vpn` DROP foreign key `fk_remote_access_vpn__vpn_server_addr_id`;
+ALTER TABLE `cloud`.`remote_access_vpn` DROP primary key;
+ALTER TABLE `cloud`.`remote_access_vpn` ADD primary key (`id`);
+ALTER TABLE `cloud`.`remote_access_vpn` ADD CONSTRAINT `fk_remote_access_vpn__vpn_server_addr_id` FOREIGN KEY (`vpn_server_addr_id`) REFERENCES `user_ip_address` (`id`);
[9/9] git commit: updated refs/heads/4.2 to 0185c2f
Posted by vi...@apache.org.
CLOUDSTACK-3609: ASF 4.1 to 4.2 Upgrade: Invalid Global Configuration parameters are present on the Upgraded Setup
Description:
Remove unused global config parameters from database after
upgrade from 4.1.0/4.1.1/4.1.2 to 4.2.0.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0185c2f4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0185c2f4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0185c2f4
Branch: refs/heads/4.2
Commit: 0185c2f47b5a0f9194f6fa2754d8a6aa2dd27ef0
Parents: d47b4a9
Author: Vijayendra Bhamidipati <vi...@citrix.com>
Authored: Wed Aug 7 10:45:34 2013 -0700
Committer: Vijayendra <vi...@citrix.com>
Committed: Fri Aug 9 18:24:10 2013 -0700
----------------------------------------------------------------------
setup/db/db/schema-412to420.sql | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0185c2f4/setup/db/db/schema-412to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-412to420.sql b/setup/db/db/schema-412to420.sql
index cbd4fac..f00ee22 100644
--- a/setup/db/db/schema-412to420.sql
+++ b/setup/db/db/schema-412to420.sql
@@ -2289,3 +2289,7 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'manag
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Snapshots', 'DEFAULT', 'SnapshotManager', 'kvm.snapshot.enabled', 'false', 'whether snapshot is enabled for KVM hosts');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'eip.use.multiple.netscalers', 'false', 'Should be set to true, if there will be multiple NetScaler devices providing EIP service in a zone');
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Snapshots', 'DEFAULT', 'SnapshotManager', 'snapshot.backup.rightafter', 'true', 'backup snapshot right after snapshot is taken');
+
+DELETE FROM `cloud`.`configuration` where name='vmware.guest.vswitch';
+DELETE FROM `cloud`.`configuration` where name='vmware.private.vswitch';
+DELETE FROM `cloud`.`configuration` where name='vmware.public.vswitch';