bug 9638: fixed bunch of DB upgrade bugs

status 9638: resolved fixed

Conflicts:

	server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java
	utils/src/com/cloud/utils/net/NetUtils.java
This commit is contained in:
alena 2011-04-28 18:26:43 -07:00
parent c6d5682579
commit 11ef6bbbe2
12 changed files with 118 additions and 85 deletions

View File

@ -25,8 +25,11 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TreeMap;
import org.apache.log4j.Logger;
@ -62,7 +65,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
_upgradeMap.put("2.1.7", new DbUpgrade[] { new Upgrade217to218(), new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to223(), new Upgrade222to224() });
_upgradeMap.put("2.1.8", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to223(), new Upgrade222to224(), new Upgrade218to224DomainVlans() });
_upgradeMap.put("2.1.9", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to223(), new Upgrade222to224(), new Upgrade218to224DomainVlans() });
_upgradeMap.put("2.2.1", new DbUpgrade[] { new Upgrade221to222(), new Upgrade222to224()});
_upgradeMap.put("2.2.1", new DbUpgrade[] { new Upgrade221to222(), new Upgrade222to224() });
_upgradeMap.put("2.2.2", new DbUpgrade[] { new Upgrade222to224() });
_upgradeMap.put("2.2.3", new DbUpgrade[] { new Upgrade222to224() });
}
@ -168,31 +171,55 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
if (!ClusterManagerImpl.arePeersRunning(trimmedCurrentVersion)) {
s_logger.info("Cleaning upgrades because all management server are now at the same version");
for (DbUpgrade upgrade : upgrades) {
s_logger.info("Cleanup upgrade " + upgrade.getClass().getSimpleName() + " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-" + upgrade.getUpgradableVersionRange()[1]
+ " to " + upgrade.getUpgradedVersion());
VersionVO version = _dao.findByVersion(upgrade.getUpgradedVersion(), Step.Upgrade);
TreeMap<String, List<DbUpgrade>> upgradedVersions = new TreeMap<String, List<DbUpgrade>>();
if (version != null) {
Transaction txn = Transaction.open("Cleanup");
txn.start();
try {
File[] scripts = upgrade.getCleanupScripts();
if (scripts != null) {
for (File script : scripts) {
runScript(script);
for (DbUpgrade upgrade : upgrades) {
String upgradedVerson = upgrade.getUpgradedVersion();
List<DbUpgrade> upgradeList = upgradedVersions.get(upgradedVerson);
if (upgradeList == null) {
upgradeList = new ArrayList<DbUpgrade>();
}
upgradeList.add(upgrade);
upgradedVersions.put(upgradedVerson, upgradeList);
}
for (String upgradedVersion : upgradedVersions.keySet()) {
List<DbUpgrade> versionUpgrades = upgradedVersions.get(upgradedVersion);
VersionVO version = _dao.findByVersion(upgradedVersion, Step.Upgrade);
s_logger.debug("Upgrading to version " + upgradedVersion + "...");
Transaction txn = Transaction.open("Cleanup");
try {
if (version != null) {
for (DbUpgrade upgrade : versionUpgrades) {
s_logger.info("Cleanup upgrade " + upgrade.getClass().getSimpleName() + " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-"
+ upgrade.getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion());
txn.start();
File[] scripts = upgrade.getCleanupScripts();
if (scripts != null) {
for (File script : scripts) {
runScript(script);
s_logger.debug("Cleanup script " + script.getAbsolutePath() + " is executed successfully");
}
}
txn.commit();
}
txn.start();
version.setStep(Step.Complete);
s_logger.debug("Upgrade completed for version " + upgradedVersion);
version.setUpdated(new Date());
_dao.update(version.getId(), version);
txn.commit();
} finally {
txn.close();
}
} finally {
txn.close();
}
}
}
}
@Override

View File

@ -49,7 +49,7 @@ public class Sanity220To224UpgradeTest extends TestCase {
public void test217to22Upgrade() throws SQLException {
s_logger.debug("Finding sample data from 2.2.1");
DbTestUtils.executeScript("/home/alena/Downloads/before/cloud_report_dump_220_April_26th_1521hrs.sql", false, true);
DbTestUtils.executeScript("PreviousDatabaseSchema/2.2.0/2.2.0.sample.sql", false, true);
Connection conn;
PreparedStatement pstmt;

View File

@ -1,30 +0,0 @@
update firewall_rules set purpose='StaticNat' where is_static_nat=1;
alter table firewall_rules drop column is_static_nat;
alter table user_ip_address add CONSTRAINT `fk_user_ip_address__vm_id` FOREIGN KEY (`vm_id`) REFERENCES `vm_instance`(`id`);
update network_offerings set system_only=1 where name='System-Guest-Network';
update network_offerings set dns_service=1,userdata_service=1,dhcp_service=1 where system_only=0;
update network_offerings set firewall_service=1, lb_service=1,vpn_service=1,gateway_service=1 where traffic_type='guest' and system_only=0;
alter table domain add column `state` char(32) NOT NULL default 'Active' COMMENT 'state of the domain';
alter table nics add column `vm_type` char(32);
update nics set vm_type=(select type from vm_instance where vm_instance.id=nics.instance_id);
INSERT INTO configuration (`category`, `instance`, `component`, `name`, `value`, `description`) VALUES ('Network','DEFAULT','none','network.guest.cidr.limit','22','size limit for guest cidr; cant be less than this value');
alter table user_statistics add column `network_id` bigint unsigned;
update op_networks set nics_count=(nics_count-1) where id in (select d.network_id from domain_router d, vm_instance i where i.state='Running' and i.id=d.id);
update network_offerings set traffic_type='Guest' where system_only=0;
alter table network_offerings add column `guest_type` char(32);
update network_offerings set guest_type='Direct' where id=5;
update network_offerings set guest_type='Virtual' where id=6;
update network_offerings set guest_type='Direct' where id=7;
alter table op_it_work add column `vm_type` char(32) NOT NULL;
update op_it_work set vm_type=(select type from vm_instance where vm_instance.id=op_it_work.instance_id);
alter table networks add column `is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not';
update networks set is_security_group_enabled=0;
alter table data_center add column `is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not';
update data_center set is_security_group_enabled=0;
update data_center set dns_provider='DhcpServer', dhcp_provider='DhcpServer', userdata_provider='DhcpServer', lb_provider=null, firewall_provider=null, vpn_provider=null, gateway_provider=null where networktype='Basic';
update network_offerings set specify_vlan=1 where system_only=0 and guest_type='Direct';
update networks set traffic_type='Guest' where network_offering_id in (select id from network_offerings where system_only=0);
update network_offerings set availability='Optional' where id=7;
delete from configuration where name='router.cleanup.interval';
INSERT INTO configuration (category, instance, component, name, value, description)
VALUES ('Advanced', 'DEFAULT', 'management-server', 'management.network.cidr', NULL, 'The cidr of management server network');

View File

@ -1,3 +0,0 @@
alter table cloud_usage add column `network_id` bigint unsigned;
alter table usage_network add column `network_id` bigint unsigned;
alter table user_statistics add column `network_id` bigint unsigned;

View File

@ -94,7 +94,6 @@ DROP TABLE IF EXISTS `cloud`.`account_vlan_map`;
DROP TABLE IF EXISTS `cloud`.`cluster_details`;
DROP TABLE IF EXISTS `cloud`.`guest_os_category`;
DROP TABLE IF EXISTS `cloud`.`guest_os_hypervisor`;
DROP TABLE IF EXISTS `cloud`.`host_master`;
DROP TABLE IF EXISTS `cloud`.`op_dc_link_local_ip_address_alloc`;
DROP TABLE IF EXISTS `cloud`.`op_host`;
DROP TABLE IF EXISTS `cloud`.`op_nwgrp_work`;

View File

@ -19,7 +19,6 @@ ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `iso_id`;
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `display_name`;
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `group`;
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `storage_ip`;
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `mirrored_vols`;
DROP TABLE `cloud`.`pricing`;
@ -50,10 +49,8 @@ ALTER TABLE `cloud`.`domain_router` DROP INDEX `i_domain_router__account_id`;
ALTER TABLE `cloud`.`domain_router` DROP INDEX `i_domain_router__public_ip_address`;
ALTER TABLE `cloud`.`domain_router` DROP INDEX `i_domain_router__vlan_id`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `gateway`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `ram_size`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `dns1`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `dns2`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `guest_mac_address`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `guest_dc_mac_address`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `vnet`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `dc_vlan`;
@ -62,7 +59,6 @@ ALTER TABLE `cloud`.`domain_router` DROP COLUMN `vlan_id`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `domain_id`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `account_id`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `dhcp_ip_address`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `domain`;
ALTER TABLE `cloud`.`console_proxy` DROP FOREIGN KEY `fk_console_proxy__vlan_id`;
ALTER TABLE `cloud`.`console_proxy` DROP INDEX `i_console_proxy__vlan_id`;
@ -75,7 +71,6 @@ ALTER TABLE `cloud`.`console_proxy` DROP COLUMN `guest_ip_address`;
ALTER TABLE `cloud`.`console_proxy` DROP COLUMN `guest_netmask`;
ALTER TABLE `cloud`.`console_proxy` DROP COLUMN `vlan_db_id`;
ALTER TABLE `cloud`.`console_proxy` DROP COLUMN `vlan_id`;
ALTER TABLE `cloud`.`console_proxy` DROP COLUMN `ram_size`;
ALTER TABLE `cloud`.`secondary_storage_vm` DROP COLUMN `gateway`;
ALTER TABLE `cloud`.`secondary_storage_vm` DROP COLUMN `dns1`;
@ -86,7 +81,6 @@ ALTER TABLE `cloud`.`secondary_storage_vm` DROP COLUMN `guest_ip_address`;
ALTER TABLE `cloud`.`secondary_storage_vm` DROP COLUMN `guest_netmask`;
ALTER TABLE `cloud`.`secondary_storage_vm` DROP COLUMN `vlan_db_id`;
ALTER TABLE `cloud`.`secondary_storage_vm` DROP COLUMN `vlan_id`;
ALTER TABLE `cloud`.`secondary_storage_vm` DROP COLUMN `ram_size`;
#ALTER TABLE `cloud`.`secondary_storage_vm` DROP COLUMN `guid`;
#ALTER TABLE `cloud`.`vlan` ADD CONSTRAINT `fk_vlan__network_id` FOREIGN KEY `fk_vlan__network_id`(`network_id`) REFERENCES `networks`(`id`);
@ -95,8 +89,6 @@ DROP TABLE `cloud`.`vm_disk`;
ALTER TABLE `cloud`.`disk_offering` DROP COLUMN `mirrored`;
ALTER TABLE `cloud`.`service_offering` DROP COLUMN `guest_ip_type`;
ALTER TABLE `cloud`.`load_balancer_vm_map` DROP COLUMN `pending`;
ALTER TABLE `cloud`.`account_vlan_map` MODIFY COLUMN `account_id` bigint unsigned NOT NULL;
@ -121,5 +113,5 @@ ALTER TABLE `cloud`.`template_spool_ref` ADD CONSTRAINT `fk_template_spool_ref__
ALTER TABLE `cloud`.`volumes` MODIFY COLUMN `state` VARCHAR(32) NOT NULL;
ALTER TABLE op_dc_ip_address_alloc ADD CONSTRAINT `fk_op_dc_ip_address_alloc__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`snapshot_policy` ADD KEY `volume_id` (`volume_id`);

View File

@ -75,8 +75,7 @@ CREATE TABLE `cloud`.`network_offerings` (
`userdata_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides user data service',
`vpn_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides vpn service',
`dhcp_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if network offering provides dhcp service',
PRIMARY KEY (`id`),
INDEX `i_network_offerings__removed`(`removed`)
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`networks` (
@ -107,13 +106,7 @@ CREATE TABLE `cloud`.`networks` (
`is_default` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if network is default',
`created` datetime NOT NULL COMMENT 'date created',
`removed` datetime COMMENT 'date removed if not null',
PRIMARY KEY (`id`),
CONSTRAINT `fk_networks__network_offering_id` FOREIGN KEY (`network_offering_id`) REFERENCES `network_offerings`(`id`),
CONSTRAINT `fk_networks__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`),
CONSTRAINT `fk_networks__related` FOREIGN KEY(`related`) REFERENCES `networks`(`id`),
CONSTRAINT `fk_networks__account_id` FOREIGN KEY(`account_id`) REFERENCES `account`(`id`),
CONSTRAINT `fk_networks__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`),
INDEX `i_networks__removed`(`removed`)
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`op_networks`(
@ -170,8 +163,7 @@ CREATE TABLE `cloud`.`nics` (
`removed` datetime COMMENT 'date removed if not null',
PRIMARY KEY (`id`),
CONSTRAINT `fk_nics__instance_id` FOREIGN KEY `fk_nics__instance_id`(`instance_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_nics__networks_id` FOREIGN KEY `fk_nics__networks_id`(`network_id`) REFERENCES `networks`(`id`),
INDEX `i_nics__removed`(`removed`)
CONSTRAINT `fk_nics__networks_id` FOREIGN KEY `fk_nics__networks_id`(`network_id`) REFERENCES `networks`(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `network_offerings` VALUES (1,'System-Public-Network','System Offering for System-Public-Network',NULL,NULL,NULL,'Public',NULL,1,0,NULL,now(),NULL,0,'Required',0,0,0,0,0,0,0),(2,'System-Management-Network','System Offering for System-Management-Network',NULL,NULL,NULL,'Management',NULL,1,0,NULL,now(),NULL,0,'Required',0,0,0,0,0,0,0),(3,'System-Control-Network','System Offering for System-Control-Network',NULL,NULL,NULL,'Control',NULL,1,0,NULL,now(),NULL,0,'Required',0,0,0,0,0,0,0),(4,'System-Storage-Network','System Offering for System-Storage-Network',NULL,NULL,NULL,'Storage',NULL,1,0,NULL,now(),NULL,0,'Required',0,0,0,0,0,0,0),(5,'System-Guest-Network','System-Guest-Network',NULL,NULL,NULL,'Guest',NULL,1,0,NULL,now(),NULL,1,'Required',1,0,0,0,1,0,1),(6,'DefaultVirtualizedNetworkOffering','Virtual Vlan',NULL,NULL,NULL,'Guest',NULL,0,0,NULL,now(),NULL,1,'Required',1,1,1,1,1,1,1),(7,'DefaultDirectNetworkOffering','Direct',NULL,NULL,NULL,'Public',NULL,0,0,NULL,now(),NULL,1,'Required',1,0,0,0,1,0,1);
@ -273,7 +265,6 @@ UPDATE `cloud`.`volumes` SET state='Destroy' WHERE removed IS NOT NULL OR destro
UPDATE `cloud`.`volumes` SET state='Ready' WHERE removed IS NULL AND (destroyed=0 OR destroyed is NULL) AND status='Created';
ALTER TABLE `cloud`.`vlan` ADD COLUMN `network_id` bigint unsigned NOT NULL;
ALTER TABLE `cloud`.`vlan` ADD CONSTRAINT `fk_vlan__data_center_id` FOREIGN KEY `fk_vlan__data_center_id`(`data_center_id`) REFERENCES `data_center`(`id`);
ALTER TABLE `cloud`.`data_center` ADD COLUMN `domain` varchar(100);
ALTER TABLE `cloud`.`data_center` ADD COLUMN `domain_id` bigint unsigned;
@ -287,8 +278,6 @@ ALTER TABLE `cloud`.`data_center` ADD COLUMN `vpn_provider` char(64) DEFAULT 'Vi
ALTER TABLE `cloud`.`data_center` ADD COLUMN `userdata_provider` char(64) DEFAULT 'VirtualRouter';
ALTER TABLE `cloud`.`data_center` ADD COLUMN `enable` tinyint NOT NULL DEFAULT 1;
ALTER TABLE `cloud`.`data_center` ADD CONSTRAINT `fk_data_center__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`);
ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD COLUMN `reservation_id` char(40) NULL;
ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD COLUMN `mac_address` bigint unsigned NOT NULL;
UPDATE `cloud`.`op_dc_ip_address_alloc` SET reservation_id=concat(cast(instance_id as CHAR), ip_address) WHERE taken is NOT NULL;
@ -968,7 +957,6 @@ ALTER TABLE `cloud`.`instance_group` ADD CONSTRAINT `fk_instance_group__account_
ALTER TABLE `cloud`.`instance_group_vm_map` ADD CONSTRAINT `fk_instance_group_vm_map___group_id` FOREIGN KEY `fk_instance_group_vm_map___group_id` (`group_id`) REFERENCES `instance_group` (`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`instance_group_vm_map` ADD CONSTRAINT `fk_instance_group_vm_map___instance_id` FOREIGN KEY `fk_instance_group_vm_map___instance_id` (`instance_id`) REFERENCES `user_vm` (`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`secondary_storage_vm` MODIFY COLUMN `guid` varchar(255);
ALTER TABLE `cloud`.`domain` MODIFY COLUMN `path` varchar(255) NOT NULL;
ALTER TABLE `cloud`.`ssh_keypairs` ADD CONSTRAINT `fk_ssh_keypairs__account_id` FOREIGN KEY `fk_ssh_keypair__account_id` (`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`ssh_keypairs` ADD CONSTRAINT `fk_ssh_keypairs__domain_id` FOREIGN KEY `fk_ssh_keypair__domain_id` (`domain_id`) REFERENCES `domain` (`id`) ON DELETE CASCADE;
@ -979,3 +967,5 @@ UPDATE vm_template SET hypervisor_type='None' WHERE hypervisor_type IS NULL AND
ALTER TABLE `cloud`.`volumes` ADD COLUMN `source_id` bigint unsigned COMMENT 'id for the source';
ALTER TABLE `cloud`.`volumes` ADD COLUMN `source_type` varchar(32) COMMENT 'source from which the volume is created -- snapshot, diskoffering, template, blank';
ALTER TABLE `cloud`.`user_statistics` ADD UNIQUE KEY `account_id` (`account_id`,`data_center_id`);

View File

@ -1,2 +1,14 @@
alter table firewall_rules drop column is_static_nat;
delete from configuration where name='router.cleanup';
ALTER TABLE `cloud`.`console_proxy` DROP COLUMN `ram_size`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `ram_size`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `domain`;
ALTER TABLE `cloud`.`domain_router` DROP COLUMN `guest_mac_address`;
ALTER TABLE `cloud`.`secondary_storage_vm` DROP COLUMN `ram_size`;
ALTER TABLE `cloud`.`service_offering` DROP COLUMN `guest_ip_type`;
ALTER TABLE `cloud`.`vm_instance` DROP COLUMN `mirrored_vols`;

View File

@ -34,4 +34,23 @@ CREATE TABLE IF NOT EXISTS `cloud`.`version` (
`step` char(32) NOT NULL COMMENT 'Step in the upgrade to this version',
PRIMARY KEY (`id`),
INDEX `i_version__version`(`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud`.`data_center` ADD CONSTRAINT `fk_data_center__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`);
ALTER TABLE `cloud`.`data_center` ADD INDEX `i_data_center__domain_id`(`domain_id`);
ALTER TABLE `cloud`.`networks` ADD CONSTRAINT `fk_networks__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center` (`id`);
ALTER TABLE `cloud`.`networks` ADD CONSTRAINT `fk_networks__related` FOREIGN KEY (`related`) REFERENCES `networks` (`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`networks` ADD CONSTRAINT `fk_networks__account_id` FOREIGN KEY (`account_id`) REFERENCES `account` (`id`);
ALTER TABLE `cloud`.`networks` ADD CONSTRAINT `fk_networks__domain_id` FOREIGN KEY (`domain_id`) REFERENCES `domain` (`id`);
ALTER TABLE `cloud`.`networks` ADD INDEX `fk_networks__network_offering_id` (`network_offering_id`);
ALTER TABLE `cloud`.`networks` ADD INDEX `fk_networks__data_center_id` (`data_center_id`);
ALTER TABLE `cloud`.`networks` ADD INDEX `fk_networks__account_id` (`account_id`);
ALTER TABLE `cloud`.`networks` ADD INDEX `fk_networks__domain_id` (`domain_id`);
ALTER TABLE `cloud`.`networks` ADD INDEX `i_networks__removed` (`removed`);
ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD CONSTRAINT `fk_op_dc_ip_address_alloc__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`vlan` ADD CONSTRAINT `fk_vlan__data_center_id` FOREIGN KEY `fk_vlan__data_center_id`(`data_center_id`) REFERENCES `data_center`(`id`);

View File

@ -1,3 +1,6 @@
DROP TABLE IF EXISTS `cloud`.`host_master`;
DROP TABLE IF EXISTS `cloud`.`hypervsior_properties`;
ALTER TABLE `cloud`.`data_center` DROP COLUMN `enable`;
ALTER TABLE `cloud`.`host_pod_ref` DROP COLUMN `enabled`;
DELETE FROM `cloud`.`configuration` WHERE name in ('direct.attach.security.groups.enabled', 'direct.attach.untagged.vlan.enabled', 'hypervisor.type', 'management-server', 'max.volume.size.gb', 'multicast.throttling.rate', 'network.type', 'xen.preallocated.lun.size.range');
@ -10,3 +13,10 @@ ALTER TABLE `cloud`.`volumes` DROP COLUMN `source_type`;
ALTER TABLE `cloud`.`user_vm` DROP COLUMN guest_ip_address;
ALTER TABLE `cloud`.`user_vm` DROP COLUMN guest_mac_address;
ALTER TABLE `cloud`.`user_vm` DROP COLUMN guest_netmask;
ALTER TABLE `cloud`.`secondary_storage_vm` DROP KEY `public_ip_address_2`;
ALTER TABLE `cloud`.`snapshot_policy` DROP KEY `volume_id`;
ALTER TABLE `cloud`.`snapshot_policy` DROP KEY `i_snapshot_policy__volume_id`;

View File

@ -135,5 +135,22 @@ UPDATE `cloud`.`host` SET resource='com.cloud.hypervisor.xen.resource.XenServer5
UPDATE `cloud`.`nics` SET ip_type='Ip4';
UPDATE `cloud`.`nics` SET broadcast_uri='vlan://untagged', isolation_uri='ec2://untagged', strategy='Create' where reserver_name='DirectPodBasedNetworkGuru';
DELETE FROM `cloud`.`configuration` where name='schema.level';
DELETE FROM `cloud`.`configuration` where name='direct.attach.security.groups.enabled';
ALTER TABLE `cloud`.`domain` MODIFY COLUMN `path` varchar(255) NOT NULL;
ALTER TABLE `cloud`.`network_offerings` ADD INDEX `i_network_offerings__removed`(`removed`);
ALTER TABLE `cloud`.`nics` ADD INDEX `i_nics__removed`(`removed`);
ALTER TABLE `cloud`.`snapshot_schedule` DROP KEY `volume_id`;
ALTER TABLE `cloud`.`snapshot_schedule` ADD UNIQUE KEY `volume_id` (`volume_id`,`policy_id`);
ALTER TABLE `cloud`.`storage_pool` MODIFY COLUMN `uuid` varchar(255) UNIQUE;
ALTER TABLE `cloud`.`user_statistics` DROP KEY `account_id`;
ALTER TABLE `cloud`.`user_statistics` ADD UNIQUE KEY `account_id` (`account_id`,`data_center_id`, `public_ip_address`, `device_id`,`device_type`);

View File

@ -116,16 +116,16 @@ public class NetUtils {
List<String> cidrList = new ArrayList<String>();
try {
for (NetworkInterface ifc : IteratorUtil.enumerationAsIterable(NetworkInterface.getNetworkInterfaces())) {
if(ifc.isUp() && !ifc.isVirtual() && !ifc.isLoopback()) {
for (InterfaceAddress address : ifc.getInterfaceAddresses()) {
InetAddress addr = address.getAddress();
int prefixLength = address.getNetworkPrefixLength();
if (prefixLength < 32 && prefixLength > 0) {
String ip = ipFromInetAddress(addr);
cidrList.add(ipAndNetMaskToCidr(ip, getCidrNetmask(prefixLength)));
}
}
}
if (ifc.isUp() && !ifc.isVirtual() && !ifc.isLoopback()) {
for (InterfaceAddress address : ifc.getInterfaceAddresses()) {
InetAddress addr = address.getAddress();
int prefixLength = address.getNetworkPrefixLength();
if (prefixLength < 32 && prefixLength > 0) {
String ip = ipFromInetAddress(addr);
cidrList.add(ipAndNetMaskToCidr(ip, getCidrNetmask(prefixLength)));
}
}
}
}
} catch (SocketException e) {
s_logger.warn("UnknownHostException in getLocalCidrs().", e);