Search in sources :

Example 1 with Hypervisor

use of com.cloud.hypervisor.Hypervisor in project cloudstack by apache.

the class ResourceManagerImpl method updateCluster.

@Override
@DB
public Cluster updateCluster(final Cluster clusterToUpdate, final String clusterType, final String hypervisor, final String allocationState, final String managedstate) {
    final ClusterVO cluster = (ClusterVO) clusterToUpdate;
    // Verify cluster information and update the cluster if needed
    boolean doUpdate = false;
    if (hypervisor != null && !hypervisor.isEmpty()) {
        final Hypervisor.HypervisorType hypervisorType = Hypervisor.HypervisorType.getType(hypervisor);
        if (hypervisorType == null) {
            s_logger.error("Unable to resolve " + hypervisor + " to a valid supported hypervisor type");
            throw new InvalidParameterValueException("Unable to resolve " + hypervisor + " to a supported type");
        } else {
            cluster.setHypervisorType(hypervisor);
            doUpdate = true;
        }
    }
    Cluster.ClusterType newClusterType = null;
    if (clusterType != null && !clusterType.isEmpty()) {
        try {
            newClusterType = Cluster.ClusterType.valueOf(clusterType);
        } catch (final IllegalArgumentException ex) {
            throw new InvalidParameterValueException("Unable to resolve " + clusterType + " to a supported type");
        }
        if (newClusterType == null) {
            s_logger.error("Unable to resolve " + clusterType + " to a valid supported cluster type");
            throw new InvalidParameterValueException("Unable to resolve " + clusterType + " to a supported type");
        } else {
            cluster.setClusterType(newClusterType);
            doUpdate = true;
        }
    }
    Grouping.AllocationState newAllocationState = null;
    if (allocationState != null && !allocationState.isEmpty()) {
        try {
            newAllocationState = Grouping.AllocationState.valueOf(allocationState);
        } catch (final IllegalArgumentException ex) {
            throw new InvalidParameterValueException("Unable to resolve Allocation State '" + allocationState + "' to a supported state");
        }
        if (newAllocationState == null) {
            s_logger.error("Unable to resolve " + allocationState + " to a valid supported allocation State");
            throw new InvalidParameterValueException("Unable to resolve " + allocationState + " to a supported state");
        } else {
            cluster.setAllocationState(newAllocationState);
            doUpdate = true;
        }
    }
    Managed.ManagedState newManagedState = null;
    final Managed.ManagedState oldManagedState = cluster.getManagedState();
    if (managedstate != null && !managedstate.isEmpty()) {
        try {
            newManagedState = Managed.ManagedState.valueOf(managedstate);
        } catch (final IllegalArgumentException ex) {
            throw new InvalidParameterValueException("Unable to resolve Managed State '" + managedstate + "' to a supported state");
        }
        if (newManagedState == null) {
            s_logger.error("Unable to resolve Managed State '" + managedstate + "' to a supported state");
            throw new InvalidParameterValueException("Unable to resolve Managed State '" + managedstate + "' to a supported state");
        } else {
            doUpdate = true;
        }
    }
    if (doUpdate) {
        _clusterDao.update(cluster.getId(), cluster);
    }
    if (newManagedState != null && !newManagedState.equals(oldManagedState)) {
        if (newManagedState.equals(Managed.ManagedState.Unmanaged)) {
            boolean success = false;
            try {
                cluster.setManagedState(Managed.ManagedState.PrepareUnmanaged);
                _clusterDao.update(cluster.getId(), cluster);
                List<HostVO> hosts = listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
                for (final HostVO host : hosts) {
                    if (host.getType().equals(Host.Type.Routing) && !host.getStatus().equals(Status.Down) && !host.getStatus().equals(Status.Disconnected) && !host.getStatus().equals(Status.Up) && !host.getStatus().equals(Status.Alert)) {
                        final String msg = "host " + host.getPrivateIpAddress() + " should not be in " + host.getStatus().toString() + " status";
                        throw new CloudRuntimeException("PrepareUnmanaged Failed due to " + msg);
                    }
                }
                for (final HostVO host : hosts) {
                    if (host.getStatus().equals(Status.Up)) {
                        umanageHost(host.getId());
                    }
                }
                final int retry = 40;
                boolean lsuccess = true;
                for (int i = 0; i < retry; i++) {
                    lsuccess = true;
                    try {
                        Thread.sleep(5 * 1000);
                    } catch (final Exception e) {
                    }
                    hosts = listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
                    for (final HostVO host : hosts) {
                        if (!host.getStatus().equals(Status.Down) && !host.getStatus().equals(Status.Disconnected) && !host.getStatus().equals(Status.Alert)) {
                            lsuccess = false;
                            break;
                        }
                    }
                    if (lsuccess == true) {
                        success = true;
                        break;
                    }
                }
                if (success == false) {
                    throw new CloudRuntimeException("PrepareUnmanaged Failed due to some hosts are still in UP status after 5 Minutes, please try later ");
                }
            } finally {
                cluster.setManagedState(success ? Managed.ManagedState.Unmanaged : Managed.ManagedState.PrepareUnmanagedError);
                _clusterDao.update(cluster.getId(), cluster);
            }
        } else if (newManagedState.equals(Managed.ManagedState.Managed)) {
            cluster.setManagedState(Managed.ManagedState.Managed);
            _clusterDao.update(cluster.getId(), cluster);
        }
    }
    return cluster;
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) Hypervisor(com.cloud.hypervisor.Hypervisor) PodCluster(com.cloud.dc.PodCluster) Cluster(com.cloud.org.Cluster) Grouping(com.cloud.org.Grouping) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) HostVO(com.cloud.host.HostVO) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceInUseException(com.cloud.exception.ResourceInUseException) URISyntaxException(java.net.URISyntaxException) DiscoveryException(com.cloud.exception.DiscoveryException) SshException(com.cloud.utils.ssh.SshException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ConfigurationException(javax.naming.ConfigurationException) PermissionDeniedException(com.cloud.exception.PermissionDeniedException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) Managed(com.cloud.org.Managed) DB(com.cloud.utils.db.DB)

Example 2 with Hypervisor

use of com.cloud.hypervisor.Hypervisor in project cloudstack by apache.

the class Upgrade4930to41000 method updateSystemVmTemplates.

@SuppressWarnings("serial")
private void updateSystemVmTemplates(final Connection conn) {
    LOG.debug("Updating System Vm template IDs");
    // Get all hypervisors in use
    final Set<Hypervisor.HypervisorType> hypervisorsListInUse = new HashSet<Hypervisor.HypervisorType>();
    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:
                    // Parralels, Simulator and VirtualBox:
                    break;
            }
        }
    } catch (final SQLException e) {
        LOG.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<Hypervisor.HypervisorType, String> NewTemplateNameList = new HashMap<Hypervisor.HypervisorType, String>() {

        {
            put(Hypervisor.HypervisorType.XenServer, "systemvm-xenserver-4.10");
            put(Hypervisor.HypervisorType.VMware, "systemvm-vmware-4.10");
            put(Hypervisor.HypervisorType.KVM, "systemvm-kvm-4.10");
            put(Hypervisor.HypervisorType.Hyperv, "systemvm-hyperv-4.10");
            put(Hypervisor.HypervisorType.LXC, "systemvm-lxc-4.10");
            put(Hypervisor.HypervisorType.Ovm3, "systemvm-ovm3-4.10");
        }
    };
    final Map<Hypervisor.HypervisorType, String> routerTemplateConfigurationNames = new HashMap<Hypervisor.HypervisorType, String>() {

        {
            put(Hypervisor.HypervisorType.XenServer, "router.template.xenserver");
            put(Hypervisor.HypervisorType.VMware, "router.template.vmware");
            put(Hypervisor.HypervisorType.KVM, "router.template.kvm");
            put(Hypervisor.HypervisorType.Hyperv, "router.template.hyperv");
            put(Hypervisor.HypervisorType.LXC, "router.template.lxc");
            put(Hypervisor.HypervisorType.Ovm3, "router.template.ovm3");
        }
    };
    final Map<Hypervisor.HypervisorType, String> newTemplateUrl = new HashMap<Hypervisor.HypervisorType, String>() {

        {
            put(Hypervisor.HypervisorType.XenServer, "https://download.cloudstack.org/systemvm/4.10/systemvm64template-master-4.10.0-xen.vhd.bz2");
            put(Hypervisor.HypervisorType.VMware, "https://download.cloudstack.org/systemvm/4.10/systemvm64template-master-4.10.0-vmware.ova");
            put(Hypervisor.HypervisorType.KVM, "https://download.cloudstack.org/systemvm/4.10/systemvm64template-master-4.10.0-kvm.qcow2.bz2");
            put(Hypervisor.HypervisorType.Hyperv, "https://download.cloudstack.org/systemvm/4.10/systemvm64template-master-4.10.0-hyperv.vhd.zip");
            put(Hypervisor.HypervisorType.LXC, "https://download.cloudstack.org/systemvm/4.10/systemvm64template-master-4.10.0-kvm.qcow2.bz2");
            put(Hypervisor.HypervisorType.Ovm3, "https://download.cloudstack.org/systemvm/4.10/systemvm64template-master-4.10.0-ovm.raw.bz2");
        }
    };
    final Map<Hypervisor.HypervisorType, String> newTemplateChecksum = new HashMap<Hypervisor.HypervisorType, String>() {

        {
            put(Hypervisor.HypervisorType.XenServer, "908c28a8d4c232f960e0f84af7f86c80");
            put(Hypervisor.HypervisorType.VMware, "970bfb070a80bd74820881d8149643c1");
            put(Hypervisor.HypervisorType.KVM, "bc2eac46f16a2ece6c19d4b89db41de3");
            put(Hypervisor.HypervisorType.Hyperv, "0adb35bd9f92e80d3fc63fcdd9bb55e5");
            put(Hypervisor.HypervisorType.LXC, "bc2eac46f16a2ece6c19d4b89db41de3");
            put(Hypervisor.HypervisorType.Ovm3, "94a41f0a5361933813bb34a51df56f56");
        }
    };
    for (final Map.Entry<Hypervisor.HypervisorType, String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()) {
        LOG.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.10.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) {
                LOG.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 = ?")) {
                    templ_type_pstmt.setLong(1, templateId);
                    templ_type_pstmt.executeUpdate();
                } catch (final SQLException e) {
                    LOG.error("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system': " + e.getMessage());
                    throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system'", e);
                }
                // update template ID of system Vms
                try (PreparedStatement update_templ_id_pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = ?")) {
                    update_templ_id_pstmt.setLong(1, templateId);
                    update_templ_id_pstmt.setString(2, hypervisorAndTemplateName.getKey().toString());
                    update_templ_id_pstmt.executeUpdate();
                } catch (final Exception e) {
                    LOG.error("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to " + templateId + ": " + e.getMessage());
                    throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to " + templateId, e);
                }
                // router.template.* for the corresponding hypervisor
                try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?")) {
                    update_pstmt.setString(1, hypervisorAndTemplateName.getValue());
                    update_pstmt.setString(2, routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()));
                    update_pstmt.executeUpdate();
                } catch (final SQLException e) {
                    LOG.error("updateSystemVmTemplates:Exception while setting " + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to " + hypervisorAndTemplateName.getValue() + ": " + e.getMessage());
                    throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting " + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to " + hypervisorAndTemplateName.getValue(), e);
                }
                // minreq.sysvmtemplate.version for the ACS version
                try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?")) {
                    update_pstmt.setString(1, "4.10.0");
                    update_pstmt.setString(2, "minreq.sysvmtemplate.version");
                    update_pstmt.executeUpdate();
                } catch (final SQLException e) {
                    LOG.error("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.10.0: " + e.getMessage());
                    throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.10.0", e);
                }
            } else {
                if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())) {
                    throw new CloudRuntimeException(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. Cannot upgrade system Vms");
                } else {
                    LOG.warn(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. " + hypervisorAndTemplateName.getKey() + " hypervisor is not used, so not failing upgrade");
                    // hypervisor
                    try (PreparedStatement update_templ_url_pstmt = conn.prepareStatement("UPDATE `cloud`.`vm_template` SET url = ? , checksum = ? WHERE hypervisor_type = ? AND type = 'SYSTEM' AND removed is null order by id desc limit 1")) {
                        update_templ_url_pstmt.setString(1, newTemplateUrl.get(hypervisorAndTemplateName.getKey()));
                        update_templ_url_pstmt.setString(2, newTemplateChecksum.get(hypervisorAndTemplateName.getKey()));
                        update_templ_url_pstmt.setString(3, hypervisorAndTemplateName.getKey().toString());
                        update_templ_url_pstmt.executeUpdate();
                    } catch (final SQLException e) {
                        LOG.error("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type " + hypervisorAndTemplateName.getKey().toString() + ": " + e.getMessage());
                        throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type " + hypervisorAndTemplateName.getKey().toString(), e);
                    }
                }
            }
        } catch (final SQLException e) {
            LOG.error("updateSystemVmTemplates:Exception while getting ids of templates: " + e.getMessage());
            throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting ids of templates", e);
        }
    }
    LOG.debug("Updating System Vm Template IDs Complete");
}
Also used : Hypervisor(com.cloud.hypervisor.Hypervisor) SQLException(java.sql.SQLException) HashMap(java.util.HashMap) PreparedStatement(java.sql.PreparedStatement) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) SQLException(java.sql.SQLException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResultSet(java.sql.ResultSet) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 3 with Hypervisor

use of com.cloud.hypervisor.Hypervisor in project cloudstack by apache.

the class SystemVmTemplateRegistration method parseMetadataFile.

/**
 * This method parses the metadata file consisting of the systemVM templates information
 * @return the version of the systemvm template that is to be used. This is done to in order
 * to fallback on the latest available version of the systemVM template when there does not
 * exist a template corresponding to the current code version.
 */
public static String parseMetadataFile() {
    try {
        Ini ini = new Ini();
        ini.load(new FileReader(METADATA_FILE));
        for (Hypervisor.HypervisorType hypervisorType : hypervisorList) {
            String hypervisor = hypervisorType.name().toLowerCase(Locale.ROOT);
            Ini.Section section = ini.get(hypervisor);
            NewTemplateNameList.put(hypervisorType, section.get("templatename"));
            FileNames.put(hypervisorType, section.get("filename"));
            NewTemplateChecksum.put(hypervisorType, section.get("checksum"));
            NewTemplateUrl.put(hypervisorType, section.get("downloadurl"));
        }
        Ini.Section section = ini.get("default");
        return section.get("version");
    } catch (Exception e) {
        String errMsg = String.format("Failed to parse systemVM template metadata file: %s", METADATA_FILE);
        LOGGER.error(errMsg, e);
        throw new CloudRuntimeException(errMsg, e);
    }
}
Also used : Ini(org.ini4j.Ini) Hypervisor(com.cloud.hypervisor.Hypervisor) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) FileReader(java.io.FileReader) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException)

Example 4 with Hypervisor

use of com.cloud.hypervisor.Hypervisor in project cloudstack by apache.

the class SystemVmTemplateRegistration method registerTemplates.

public void registerTemplates(Set<Hypervisor.HypervisorType> hypervisorsInUse) {
    GlobalLock lock = GlobalLock.getInternLock("UpgradeDatabase-Lock");
    try {
        LOGGER.info("Grabbing lock to register templates.");
        if (!lock.lock(LOCK_WAIT_TIMEOUT)) {
            throw new CloudRuntimeException("Unable to acquire lock to register SystemVM template.");
        }
        try {
            validateTemplates(hypervisorsInUse);
            // Perform Registration if templates not already registered
            Transaction.execute(new TransactionCallbackNoReturn() {

                @Override
                public void doInTransactionWithoutResult(final TransactionStatus status) {
                    List<Long> zoneIds = getEligibleZoneIds();
                    for (Long zoneId : zoneIds) {
                        String filePath = null;
                        try {
                            filePath = Files.createTempDirectory(TEMPORARY_SECONDARY_STORE).toString();
                            if (filePath == null) {
                                throw new CloudRuntimeException("Failed to create temporary file path to mount the store");
                            }
                            Pair<String, Long> storeUrlAndId = getNfsStoreInZone(zoneId);
                            mountStore(storeUrlAndId.first(), filePath);
                            List<String> hypervisorList = fetchAllHypervisors(zoneId);
                            for (String hypervisor : hypervisorList) {
                                Hypervisor.HypervisorType name = Hypervisor.HypervisorType.getType(hypervisor);
                                String templateName = NewTemplateNameList.get(name);
                                Pair<Hypervisor.HypervisorType, String> hypervisorAndTemplateName = new Pair<Hypervisor.HypervisorType, String>(name, templateName);
                                Long templateId = getRegisteredTemplateId(hypervisorAndTemplateName);
                                if (templateId != null) {
                                    VMTemplateVO templateVO = vmTemplateDao.findById(templateId);
                                    TemplateDataStoreVO templateDataStoreVO = templateDataStoreDao.findByTemplate(templateId, DataStoreRole.Image);
                                    String installPath = templateDataStoreVO.getInstallPath();
                                    if (validateIfSeeded(storeUrlAndId.first(), installPath)) {
                                        continue;
                                    } else if (templateVO != null) {
                                        registerTemplate(hypervisorAndTemplateName, storeUrlAndId, templateVO, filePath);
                                        continue;
                                    }
                                }
                                registerTemplate(hypervisorAndTemplateName, storeUrlAndId, filePath);
                            }
                            unmountStore(filePath);
                        } catch (Exception e) {
                            unmountStore(filePath);
                            throw new CloudRuntimeException("Failed to register systemVM template. Upgrade Failed");
                        }
                    }
                }
            });
        } catch (Exception e) {
            throw new CloudRuntimeException("Failed to register systemVM template. Upgrade Failed");
        }
    } finally {
        lock.unlock();
        lock.releaseRef();
    }
}
Also used : Hypervisor(com.cloud.hypervisor.Hypervisor) VMTemplateVO(com.cloud.storage.VMTemplateVO) TransactionStatus(com.cloud.utils.db.TransactionStatus) TransactionCallbackNoReturn(com.cloud.utils.db.TransactionCallbackNoReturn) TemplateDataStoreVO(org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) GlobalLock(com.cloud.utils.db.GlobalLock) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) List(java.util.List) ArrayList(java.util.ArrayList) Pair(com.cloud.utils.Pair)

Example 5 with Hypervisor

use of com.cloud.hypervisor.Hypervisor in project cloudstack by apache.

the class SystemVmTemplateRegistration method validateTemplates.

private void validateTemplates(Set<Hypervisor.HypervisorType> hypervisorsInUse) {
    Set<String> hypervisors = hypervisorsInUse.stream().map(Enum::name).map(name -> name.toLowerCase(Locale.ROOT)).map(this::getHypervisorName).collect(Collectors.toSet());
    List<String> templates = new ArrayList<>();
    for (Hypervisor.HypervisorType hypervisorType : hypervisorsInUse) {
        templates.add(FileNames.get(hypervisorType));
    }
    boolean templatesFound = true;
    for (String hypervisor : hypervisors) {
        String matchedTemplate = templates.stream().filter(x -> x.contains(hypervisor)).findAny().orElse(null);
        if (matchedTemplate == null) {
            templatesFound = false;
            break;
        }
        File tempFile = new File(TEMPLATES_PATH + matchedTemplate);
        String templateChecksum = DigestHelper.calculateChecksum(tempFile);
        if (!templateChecksum.equals(NewTemplateChecksum.get(getHypervisorType(hypervisor)))) {
            LOGGER.error(String.format("Checksum mismatch: %s != %s ", templateChecksum, NewTemplateChecksum.get(getHypervisorType(hypervisor))));
            templatesFound = false;
            break;
        }
    }
    if (!templatesFound) {
        String errMsg = "SystemVm template not found. Cannot upgrade system Vms";
        LOGGER.error(errMsg);
        throw new CloudRuntimeException(errMsg);
    }
}
Also used : Hypervisor(com.cloud.hypervisor.Hypervisor) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

Hypervisor (com.cloud.hypervisor.Hypervisor)19 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)18 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)7 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 HostVO (com.cloud.host.HostVO)7 DB (com.cloud.utils.db.DB)7 URISyntaxException (java.net.URISyntaxException)7 ArrayList (java.util.ArrayList)7 ClusterVO (com.cloud.dc.ClusterVO)6 DiscoveryException (com.cloud.exception.DiscoveryException)6 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)6 ResourceInUseException (com.cloud.exception.ResourceInUseException)6 Cluster (com.cloud.org.Cluster)6 Grouping (com.cloud.org.Grouping)6 VMTemplateVO (com.cloud.storage.VMTemplateVO)6 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)6 HashSet (java.util.HashSet)6