Return-Path: X-Original-To: apmail-cloudstack-issues-archive@www.apache.org Delivered-To: apmail-cloudstack-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0CB8B186FE for ; Mon, 9 Nov 2015 14:45:12 +0000 (UTC) Received: (qmail 65240 invoked by uid 500); 9 Nov 2015 14:45:11 -0000 Delivered-To: apmail-cloudstack-issues-archive@cloudstack.apache.org Received: (qmail 65012 invoked by uid 500); 9 Nov 2015 14:45:11 -0000 Mailing-List: contact issues-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list issues@cloudstack.apache.org Received: (qmail 64775 invoked by uid 500); 9 Nov 2015 14:45:11 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 64704 invoked by uid 99); 9 Nov 2015 14:45:11 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Nov 2015 14:45:11 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 57A2B2C1F5A for ; Mon, 9 Nov 2015 14:45:11 +0000 (UTC) Date: Mon, 9 Nov 2015 14:45:11 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: cloudstack-issues@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CLOUDSTACK-9046) Fix upgrade path from 4.4 and 4.5 to 4.6 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CLOUDSTACK-9046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14996631#comment-14996631 ] ASF GitHub Bot commented on CLOUDSTACK-9046: -------------------------------------------- Github user wilderrodrigues commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1050#discussion_r44281769 --- Diff: engine/schema/src/com/cloud/upgrade/dao/Upgrade452to460.java --- @@ -165,4 +171,173 @@ private void addIndexForVMInstance(Connection conn) { return new File[] { new File(script) }; } + @SuppressWarnings("serial") + private void updateSystemVmTemplates(final Connection conn) { + s_logger.debug("Updating System Vm template IDs"); + // Get all hypervisors in use + final Set hypervisorsListInUse = new HashSet(); + try (PreparedStatement pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null"); ResultSet rs = pstmt.executeQuery()) { + while (rs.next()) { + switch (Hypervisor.HypervisorType.getType(rs.getString(1))) { + case XenServer: + hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer); + break; + case KVM: + hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM); + break; + case VMware: + hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware); + break; + case Hyperv: + hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv); + break; + case LXC: + hypervisorsListInUse.add(Hypervisor.HypervisorType.LXC); + break; + case Ovm3: + hypervisorsListInUse.add(Hypervisor.HypervisorType.Ovm3); + break; + default: // no action on cases Any, BareMetal, None, Ovm, + // Parralels, Simulator and VirtualBox: + break; + } + } + } catch (final SQLException e) { + s_logger.error("updateSystemVmTemplates:Exception while getting hypervisor types from clusters: " + e.getMessage()); + throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting hypervisor types from clusters", e); + } + + final Map NewTemplateNameList = new HashMap() { + { + put(Hypervisor.HypervisorType.XenServer, "systemvm-xenserver-4.6"); + put(Hypervisor.HypervisorType.VMware, "systemvm-vmware-4.6"); + put(Hypervisor.HypervisorType.KVM, "systemvm-kvm-4.6"); + put(Hypervisor.HypervisorType.LXC, "systemvm-lxc-4.6"); + put(Hypervisor.HypervisorType.Hyperv, "systemvm-hyperv-4.6"); + put(Hypervisor.HypervisorType.Ovm3, "systemvm-ovm3-4.6"); + } + }; + + final Map routerTemplateConfigurationNames = new HashMap() { + { + put(Hypervisor.HypervisorType.XenServer, "router.template.xenserver"); + put(Hypervisor.HypervisorType.VMware, "router.template.vmware"); + put(Hypervisor.HypervisorType.KVM, "router.template.kvm"); + put(Hypervisor.HypervisorType.LXC, "router.template.lxc"); + put(Hypervisor.HypervisorType.Hyperv, "router.template.hyperv"); + put(Hypervisor.HypervisorType.Ovm3, "router.template.ovm3"); + } + }; + + final Map newTemplateUrl = new HashMap() { + { + put(Hypervisor.HypervisorType.XenServer, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-xen.vhd.bz2"); + put(Hypervisor.HypervisorType.VMware, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-vmware.ova"); + put(Hypervisor.HypervisorType.KVM, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-kvm.qcow2.bz2"); + put(Hypervisor.HypervisorType.LXC, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-kvm.qcow2.bz2"); + put(Hypervisor.HypervisorType.Hyperv, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-hyperv.vhd.zip"); + put(Hypervisor.HypervisorType.Ovm3, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-ovm.raw.bz2"); + } + }; + + final Map newTemplateChecksum = new HashMap() { + { + put(Hypervisor.HypervisorType.XenServer, "8886f554a499ec5405b6f203d9d36460"); + put(Hypervisor.HypervisorType.VMware, "4b415224fe00b258f66cad9fce9f73fc"); + put(Hypervisor.HypervisorType.KVM, "c059b0d051e0cd6fbe9d5d4fc40c7e5d"); + put(Hypervisor.HypervisorType.LXC, "c059b0d051e0cd6fbe9d5d4fc40c7e5d"); + put(Hypervisor.HypervisorType.Hyperv, "53e24bddfa56ea3139ed37af4b519013"); + put(Hypervisor.HypervisorType.Ovm3, "c8577d27b2daafb2d9a4ed307ce2f00f"); + } + }; + + for (final Map.Entry hypervisorAndTemplateName : NewTemplateNameList.entrySet()) { + s_logger.debug("Updating " + hypervisorAndTemplateName.getKey() + " System Vms"); + try (PreparedStatement pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = ? and removed is null order by id desc limit 1")) { + // Get 4.6.0 system Vm template Id for corresponding hypervisor + long templateId = -1; + pstmt.setString(1, hypervisorAndTemplateName.getValue()); + try (ResultSet rs = pstmt.executeQuery()) { + if (rs.next()) { + templateId = rs.getLong(1); + } + } catch (final SQLException e) { + s_logger.error("updateSystemVmTemplates:Exception while getting ids of templates: " + e.getMessage()); + throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting ids of templates", e); + } + + // change template type to SYSTEM + if (templateId != -1) { + try (PreparedStatement templ_type_pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");) { --- End diff -- Same as commented above. In addition, if I change the code I will have the execute the whole upgrade procedure again. > Fix upgrade path from 4.4 and 4.5 to 4.6 > ---------------------------------------- > > Key: CLOUDSTACK-9046 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9046 > Project: CloudStack > Issue Type: Bug > Security Level: Public(Anyone can view this level - this is the default.) > Components: Upgrade > Affects Versions: 4.6.0 > Reporter: Wilder Rodrigues > Assignee: Wilder Rodrigues > Priority: Blocker > Fix For: 4.6.0 > > > When upgrading to 4.6 from 4.5 or earlier, the systemvm template that is registered upfront is not marked as SYSTEM and set as the template for the existing systemvms. Therefore, new systemvms work fine but existing ones don't. > RCA is missing code in the upgrade path, as is present when upgrading from 4.4 to 4.5 for example. > The code in the Upgrade442to450.java is not generic, as the name suggests, and simply configures the whole SystemVM and all the existing Domain VMs to use the SystemVM-4.5.0 that was registered. It means that after the upgrade all the routers were marked okay, but they were using the old stuff, from 4.5.0. The attempt to deploy a new VM was also failing with the following error (on the host): > 2015-11-07 18:17:31,135 DEBUG [kvm.resource.LibvirtComputingResource] (agentRequest-Handler-4:null) Exit value is 1 > 2015-11-07 18:17:31,135 DEBUG [kvm.resource.LibvirtComputingResource] (agentRequest-Handler-4:null) Traceback (most recent call last): File "/opt/cloud/bin/update_con > fig.py", line 20, in from merge import QueueFile File "/opt/cloud/bin/merge.py", line 23, in import cs_ip File "/opt/cloud/bin/cs_ip.py", lin > e 19, in from netaddr import *ImportError: No module named netaddr > Why that? Because the KVM host has the new systemvm.iso, which contains all the new python stuff, but the systemvm template, which installs the Guest OS (Debian) is old and does not contain the modules we now need. -- This message was sent by Atlassian JIRA (v6.3.4#6332)