diff --git a/server/src/com/cloud/upgrade/dao/Upgrade218to22.java b/server/src/com/cloud/upgrade/dao/Upgrade218to22.java
index b20641330bc..e26a134a101 100644
--- a/server/src/com/cloud/upgrade/dao/Upgrade218to22.java
+++ b/server/src/com/cloud/upgrade/dao/Upgrade218to22.java
@@ -1,2046 +1,2090 @@
-/**
- * Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
- *
- * This software is licensed under the GNU General Public License v3 or later.
- *
- * It is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-package com.cloud.upgrade.dao;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TimeZone;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.consoleproxy.ConsoleProxyManager;
-import com.cloud.event.EventTypes;
-import com.cloud.event.EventVO;
-import com.cloud.event.UsageEventVO;
-import com.cloud.network.router.VirtualNetworkApplianceManager;
-import com.cloud.storage.secondary.SecondaryStorageVmManager;
-import com.cloud.utils.DateUtil;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.net.NetUtils;
-import com.cloud.utils.script.Script;
-
-public class Upgrade218to22 implements DbUpgrade {
- final static Logger s_logger = Logger.getLogger(Upgrade218to22.class);
- boolean _basicZone;
-
- @Override
- public File[] getPrepareScripts() {
- String file = Script.findScript("", "db/schema-21to22.sql");
- if (file == null) {
- throw new CloudRuntimeException("Unable to find the upgrade script, schema-21to22.sql");
- }
-
- return new File[] { new File(file) };
- }
-
- protected void upgradeStoragePools(Connection conn) {
- PreparedStatement pstmt;
- try {
- pstmt = conn.prepareStatement("UPDATE storage_pool SET status='Up'");
- pstmt.executeUpdate();
- pstmt.close();
- } catch (SQLException e) {
- throw new CloudRuntimeException("Can't upgrade storage pool ", e);
- }
- }
-
- protected long insertNetworkOffering(Connection conn, String name, String displayText, String trafficType, boolean systemOnly, boolean defaultNetworkOffering, String availability,
- boolean dns_service, boolean gateway_service, boolean firewall_service, boolean lb_service, boolean userdata_service, boolean vpn_service, boolean dhcp_service) {
- String insertSql = "INSERT INTO network_offerings (name, display_text, nw_rate, mc_rate, concurrent_connections, traffic_type, tags, system_only, specify_vlan, service_offering_id, created, removed, `default`, availability, dns_service, gateway_service, firewall_service, lb_service, userdata_service, vpn_service, dhcp_service) "
- + "VALUES (?, ?, NULL, NULL, NULL, ?, NULL, ?, 0, NULL, now(), NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
- try {
- PreparedStatement pstmt = conn.prepareStatement(insertSql, Statement.RETURN_GENERATED_KEYS);
- int i = 1;
- pstmt.setString(i++, name);
- pstmt.setString(i++, displayText);
- pstmt.setString(i++, trafficType);
- pstmt.setBoolean(i++, systemOnly);
- pstmt.setBoolean(i++, defaultNetworkOffering);
- pstmt.setString(i++, availability);
- pstmt.setBoolean(i++, dns_service);
- pstmt.setBoolean(i++, gateway_service);
- pstmt.setBoolean(i++, firewall_service);
- pstmt.setBoolean(i++, lb_service);
- pstmt.setBoolean(i++, userdata_service);
- pstmt.setBoolean(i++, vpn_service);
- pstmt.setBoolean(i++, dhcp_service);
- pstmt.executeUpdate();
- ResultSet rs = pstmt.getGeneratedKeys();
- rs.next();
- long id = rs.getLong(1);
- rs.close();
- pstmt.close();
- return id;
- } catch (SQLException e) {
- throw new CloudRuntimeException("Unable to insert network offering ", e);
- }
- }
-
- protected void upgradeInstanceGroups(Connection conn) {
- try {
-
- // Create instance groups - duplicated names are allowed across accounts
- PreparedStatement pstmt = conn.prepareStatement("SELECT DISTINCT v.group, v.account_id from vm_instance v where v.group is not null");
- ResultSet rs = pstmt.executeQuery();
- ArrayList