Search in sources :

Example 16 with Zone

use of com.cloud.db.model.Zone in project cosmic by MissionCriticalCloud.

the class TemplateServiceImpl method associateTemplateToZone.

// persist entry in template_zone_ref table. zoneId can be empty for
// region-wide image store, in that case,
// we will associate the template to all the zones.
@Override
public void associateTemplateToZone(final long templateId, final Long zoneId) {
    final List<Long> dcs = new ArrayList<>();
    if (zoneId != null) {
        dcs.add(zoneId);
    } else {
        final List<Zone> zones = zoneRepository.findByRemovedIsNull();
        for (final Zone zone : zones) {
            dcs.add(zone.getId());
        }
    }
    for (final Long id : dcs) {
        VMTemplateZoneVO tmpltZoneVO = _vmTemplateZoneDao.findByZoneTemplate(id, templateId);
        if (tmpltZoneVO == null) {
            tmpltZoneVO = new VMTemplateZoneVO(id, templateId, new Date());
            _vmTemplateZoneDao.persist(tmpltZoneVO);
        } else {
            tmpltZoneVO.setLastUpdated(new Date());
            _vmTemplateZoneDao.update(tmpltZoneVO.getId(), tmpltZoneVO);
        }
    }
}
Also used : VMTemplateZoneVO(com.cloud.storage.VMTemplateZoneVO) Zone(com.cloud.db.model.Zone) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 17 with Zone

use of com.cloud.db.model.Zone in project cosmic by MissionCriticalCloud.

the class ExplicitDedicationProcessor method process.

/**
 * This method will process the affinity group of type 'Explicit Dedication' for a deployment of a VM that demands dedicated resources.
 * For ExplicitDedicationProcessor we need to add dedicated resources into the IncludeList based on the level we have dedicated resources available.
 * For eg. if admin dedicates a pod to a domain, then all the user in that domain can use the resources of that pod.
 * We need to take care of the situation when dedicated resources further have resources dedicated to sub-domain/account.
 * This IncludeList is then used to update the avoid list for a given data center.
 */
@Override
public void process(final VirtualMachineProfile vmProfile, final DeploymentPlan plan, ExcludeList avoid) throws AffinityConflictException {
    final VirtualMachine vm = vmProfile.getVirtualMachine();
    final List<AffinityGroupVMMapVO> vmGroupMappings = _affinityGroupVMMapDao.findByVmIdType(vm.getId(), getType());
    final Zone zone = zoneRepository.findOne(vm.getDataCenterId());
    final List<DedicatedResourceVO> resourceList = new ArrayList<>();
    if (vmGroupMappings != null && !vmGroupMappings.isEmpty()) {
        for (final AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {
            if (vmGroupMapping != null) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Processing affinity group " + vmGroupMapping.getAffinityGroupId() + "of type 'ExplicitDedication' for VM Id: " + vm.getId());
                }
                final long affinityGroupId = vmGroupMapping.getAffinityGroupId();
                final List<DedicatedResourceVO> dr = _dedicatedDao.listByAffinityGroupId(affinityGroupId);
                resourceList.addAll(dr);
            }
        }
        boolean canUse = false;
        if (plan.getHostId() != null) {
            final HostVO host = _hostDao.findById(plan.getHostId());
            final ClusterVO clusterofHost = _clusterDao.findById(host.getClusterId());
            final HostPodVO podOfHost = _podDao.findById(host.getPodId());
            final Zone zoneOfHost = zoneRepository.findOne(host.getDataCenterId());
            if (resourceList != null && resourceList.size() != 0) {
                for (final DedicatedResourceVO resource : resourceList) {
                    if ((resource.getHostId() != null && resource.getHostId().longValue() == plan.getHostId().longValue()) || (resource.getClusterId() != null && resource.getClusterId().longValue() == clusterofHost.getId()) || (resource.getPodId() != null && resource.getPodId().longValue() == podOfHost.getId()) || (resource.getDataCenterId() != null && resource.getDataCenterId().longValue() == zoneOfHost.getId())) {
                        canUse = true;
                    }
                }
            }
            if (!canUse) {
                throw new CloudRuntimeException("Cannot use this host " + host.getName() + " for explicit dedication");
            }
        } else if (plan.getClusterId() != null) {
            final ClusterVO cluster = _clusterDao.findById(plan.getClusterId());
            final HostPodVO podOfCluster = _podDao.findById(cluster.getPodId());
            final Zone zoneOfCluster = zoneRepository.findOne(cluster.getDataCenterId());
            final List<HostVO> hostToUse = new ArrayList<>();
            // check whether this cluster or its pod is dedicated
            if (resourceList != null && resourceList.size() != 0) {
                for (final DedicatedResourceVO resource : resourceList) {
                    if ((resource.getClusterId() != null && resource.getClusterId() == cluster.getId()) || (resource.getPodId() != null && resource.getPodId() == podOfCluster.getId()) || (resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfCluster.getId())) {
                        canUse = true;
                    }
                    // cluster
                    if (!canUse) {
                        if (resource.getHostId() != null) {
                            final HostVO dHost = _hostDao.findById(resource.getHostId());
                            if (dHost.getClusterId() == cluster.getId()) {
                                hostToUse.add(dHost);
                            }
                        }
                    }
                }
            }
            if (hostToUse.isEmpty() && !canUse) {
                throw new CloudRuntimeException("Cannot use this cluster " + cluster.getName() + " for explicit dedication");
            }
            if (hostToUse != null && hostToUse.size() != 0) {
                // add other non-dedicated hosts to avoid list
                final List<HostVO> hostList = _hostDao.findByClusterId(cluster.getId());
                for (final HostVO host : hostList) {
                    if (!hostToUse.contains(host)) {
                        avoid.addHost(host.getId());
                    }
                }
            }
        } else if (plan.getPodId() != null) {
            final HostPodVO pod = _podDao.findById(plan.getPodId());
            final Zone zoneOfPod = zoneRepository.findOne(pod.getDataCenterId());
            final List<ClusterVO> clustersToUse = new ArrayList<>();
            final List<HostVO> hostsToUse = new ArrayList<>();
            // check whether this cluster or its pod is dedicated
            if (resourceList != null && resourceList.size() != 0) {
                for (final DedicatedResourceVO resource : resourceList) {
                    if ((resource.getPodId() != null && resource.getPodId() == pod.getId()) || (resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfPod.getId())) {
                        canUse = true;
                    }
                    // this pod
                    if (!canUse) {
                        if (resource.getClusterId() != null) {
                            final ClusterVO dCluster = _clusterDao.findById(resource.getClusterId());
                            if (dCluster.getPodId() == pod.getId()) {
                                clustersToUse.add(dCluster);
                            }
                        }
                        if (resource.getHostId() != null) {
                            final HostVO dHost = _hostDao.findById(resource.getHostId());
                            if (dHost.getPodId() == pod.getId()) {
                                hostsToUse.add(dHost);
                            }
                        }
                    }
                }
            }
            if (hostsToUse.isEmpty() && clustersToUse.isEmpty() && !canUse) {
                throw new CloudRuntimeException("Cannot use this pod " + pod.getName() + " for explicit dedication");
            }
            if (clustersToUse != null && clustersToUse.size() != 0) {
                // add other non-dedicated clusters to avoid list
                final List<ClusterVO> clusterList = _clusterDao.listByPodId(pod.getId());
                for (final ClusterVO cluster : clusterList) {
                    if (!clustersToUse.contains(cluster)) {
                        avoid.addCluster(cluster.getId());
                    }
                }
            }
            if (hostsToUse != null && hostsToUse.size() != 0) {
                // add other non-dedicated hosts to avoid list
                final List<HostVO> hostList = _hostDao.findByPodId(pod.getId());
                for (final HostVO host : hostList) {
                    if (!hostsToUse.contains(host)) {
                        avoid.addHost(host.getId());
                    }
                }
            }
        } else {
            // check all resources under this zone
            if (resourceList != null && resourceList.size() != 0) {
                avoid = updateAvoidList(resourceList, avoid, zone);
            } else {
                avoid.addZone(zone.getId());
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("No dedicated resources available for this domain or account under this group");
                }
            }
            s_logger.debug("ExplicitDedicationProcessor returns Avoid List as: {}", avoid.toString());
        }
    }
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) Zone(com.cloud.db.model.Zone) ArrayList(java.util.ArrayList) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList) List(java.util.List) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 18 with Zone

use of com.cloud.db.model.Zone in project cosmic by MissionCriticalCloud.

the class DedicatedResourceManagerImpl method dedicateZone.

@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_DEDICATE_RESOURCE, eventDescription = "dedicating a Zone")
public List<DedicatedResourceVO> dedicateZone(final Long zoneId, final Long domainId, final String accountName) {
    Long accountId = null;
    List<HostVO> hosts = null;
    if (accountName != null) {
        final Account caller = CallContext.current().getCallingAccount();
        final Account owner = _accountMgr.finalizeOwner(caller, accountName, domainId, null);
        accountId = owner.getId();
    }
    final List<Long> childDomainIds = getDomainChildIds(domainId);
    childDomainIds.add(domainId);
    checkAccountAndDomain(accountId, domainId);
    final Zone zone = zoneRepository.findOne(zoneId);
    if (zone == null) {
        throw new InvalidParameterValueException("Unable to find zone by id " + zoneId);
    } else {
        final DedicatedResourceVO dedicatedZone = _dedicatedDao.findByZoneId(zoneId);
        // check if zone is dedicated
        if (dedicatedZone != null) {
            s_logger.error("Zone " + zone.getName() + " is already dedicated");
            throw new CloudRuntimeException("Zone  " + zone.getName() + " is already dedicated");
        }
        // check if any resource under this zone is dedicated to different account or sub-domain
        final List<HostPodVO> pods = _podDao.listByDataCenterId(zone.getId());
        final List<DedicatedResourceVO> podsToRelease = new ArrayList<>();
        final List<DedicatedResourceVO> clustersToRelease = new ArrayList<>();
        final List<DedicatedResourceVO> hostsToRelease = new ArrayList<>();
        for (final HostPodVO pod : pods) {
            final DedicatedResourceVO dPod = _dedicatedDao.findByPodId(pod.getId());
            if (dPod != null) {
                if (!(childDomainIds.contains(dPod.getDomainId()))) {
                    throw new CloudRuntimeException("Pod " + pod.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                }
                if (accountId != null) {
                    if (dPod.getAccountId().equals(accountId)) {
                        podsToRelease.add(dPod);
                    } else {
                        s_logger.error("Pod " + pod.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                        throw new CloudRuntimeException("Pod " + pod.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                    }
                } else {
                    if (dPod.getAccountId() == null && dPod.getDomainId().equals(domainId)) {
                        podsToRelease.add(dPod);
                    }
                }
            }
        }
        for (final DedicatedResourceVO dr : podsToRelease) {
            releaseDedicatedResource(null, dr.getPodId(), null, null);
        }
        final List<ClusterVO> clusters = _clusterDao.listClustersByDcId(zone.getId());
        for (final ClusterVO cluster : clusters) {
            final DedicatedResourceVO dCluster = _dedicatedDao.findByClusterId(cluster.getId());
            if (dCluster != null) {
                if (!(childDomainIds.contains(dCluster.getDomainId()))) {
                    throw new CloudRuntimeException("Cluster " + cluster.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                }
                if (accountId != null) {
                    if (dCluster.getAccountId().equals(accountId)) {
                        clustersToRelease.add(dCluster);
                    } else {
                        s_logger.error("Cluster " + cluster.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                        throw new CloudRuntimeException("Cluster " + cluster.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                    }
                } else {
                    if (dCluster.getAccountId() == null && dCluster.getDomainId().equals(domainId)) {
                        clustersToRelease.add(dCluster);
                    }
                }
            }
        }
        for (final DedicatedResourceVO dr : clustersToRelease) {
            releaseDedicatedResource(null, null, dr.getClusterId(), null);
        }
        hosts = _hostDao.listByDataCenterId(zone.getId());
        for (final HostVO host : hosts) {
            final DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId());
            if (dHost != null) {
                if (!(childDomainIds.contains(dHost.getDomainId()))) {
                    throw new CloudRuntimeException("Host " + host.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                }
                if (accountId != null) {
                    if (dHost.getAccountId().equals(accountId)) {
                        hostsToRelease.add(dHost);
                    } else {
                        s_logger.error("Host " + host.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                        throw new CloudRuntimeException("Host " + host.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                    }
                } else {
                    if (dHost.getAccountId() == null && dHost.getDomainId().equals(domainId)) {
                        hostsToRelease.add(dHost);
                    }
                }
            }
        }
        for (final DedicatedResourceVO dr : hostsToRelease) {
            releaseDedicatedResource(null, null, null, dr.getHostId());
        }
    }
    checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hosts);
    final Long accountIdFinal = accountId;
    return Transaction.execute(new TransactionCallback<List<DedicatedResourceVO>>() {

        @Override
        public List<DedicatedResourceVO> doInTransaction(final TransactionStatus status) {
            // find or create the affinity group by name under this account/domain
            final AffinityGroup group = findOrCreateDedicatedAffinityGroup(domainId, accountIdFinal);
            if (group == null) {
                s_logger.error("Unable to dedicate zone due to, failed to create dedication affinity group");
                throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support.");
            }
            DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(zoneId, null, null, null, null, null, group.getId());
            try {
                dedicatedResource.setDomainId(domainId);
                if (accountIdFinal != null) {
                    dedicatedResource.setAccountId(accountIdFinal);
                }
                dedicatedResource = _dedicatedDao.persist(dedicatedResource);
                // save the domainId in the zone
                zone.setDomainId(domainId);
                zoneRepository.save(zone);
            } catch (final Exception e) {
                s_logger.error("Unable to dedicate zone due to " + e.getMessage(), e);
                throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support.");
            }
            final List<DedicatedResourceVO> result = new ArrayList<>();
            result.add(dedicatedResource);
            return result;
        }
    });
}
Also used : Account(com.cloud.user.Account) ClusterVO(com.cloud.dc.ClusterVO) Zone(com.cloud.db.model.Zone) ArrayList(java.util.ArrayList) TransactionStatus(com.cloud.utils.db.TransactionStatus) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) AffinityGroup(com.cloud.affinity.AffinityGroup) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) List(java.util.List) ArrayList(java.util.ArrayList) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO) ActionEvent(com.cloud.event.ActionEvent) DB(com.cloud.utils.db.DB)

Example 19 with Zone

use of com.cloud.db.model.Zone in project cosmic by MissionCriticalCloud.

the class ImplicitPlannerTest method initializeForTest.

private void initializeForTest(final VirtualMachineProfileImpl vmProfile, final DataCenterDeployment plan) {
    final Zone zone = mock(Zone.class);
    final VMInstanceVO vm = mock(VMInstanceVO.class);
    final UserVmVO userVm = mock(UserVmVO.class);
    final ServiceOfferingVO offering = mock(ServiceOfferingVO.class);
    final AccountVO account = mock(AccountVO.class);
    when(account.getId()).thenReturn(accountId);
    when(account.getAccountId()).thenReturn(accountId);
    when(vmProfile.getOwner()).thenReturn(account);
    when(vmProfile.getVirtualMachine()).thenReturn(vm);
    when(vmProfile.getId()).thenReturn(12L);
    when(vmDao.findById(12L)).thenReturn(userVm);
    when(userVm.getAccountId()).thenReturn(accountId);
    when(vm.getDataCenterId()).thenReturn(dataCenterId);
    when(zoneRepository.findOne(1L)).thenReturn(zone);
    when(plan.getDataCenterId()).thenReturn(dataCenterId);
    when(plan.getClusterId()).thenReturn(null);
    when(plan.getPodId()).thenReturn(null);
    when(configDao.getValue(anyString())).thenReturn("false").thenReturn("CPU");
    // Mock offering details.
    when(vmProfile.getServiceOffering()).thenReturn(offering);
    when(offering.getId()).thenReturn(offeringId);
    when(vmProfile.getServiceOfferingId()).thenReturn(offeringId);
    when(offering.getCpu()).thenReturn(noOfCpusInOffering);
    when(offering.getRamSize()).thenReturn(ramInOffering);
    final List<Long> clustersWithEnoughCapacity = new ArrayList<>();
    clustersWithEnoughCapacity.add(1L);
    clustersWithEnoughCapacity.add(2L);
    clustersWithEnoughCapacity.add(3L);
    when(capacityDao.listClustersInZoneOrPodByHostCapacities(dataCenterId, noOfCpusInOffering, ramInOffering * 1024L * 1024L, Capacity.CAPACITY_TYPE_CPU, true)).thenReturn(clustersWithEnoughCapacity);
    final Map<Long, Double> clusterCapacityMap = new HashMap<>();
    clusterCapacityMap.put(1L, 2048D);
    clusterCapacityMap.put(2L, 2048D);
    clusterCapacityMap.put(3L, 2048D);
    final Pair<List<Long>, Map<Long, Double>> clustersOrderedByCapacity = new Pair<>(clustersWithEnoughCapacity, clusterCapacityMap);
    when(capacityDao.orderClustersByAggregateCapacity(dataCenterId, Capacity.CAPACITY_TYPE_CPU, true)).thenReturn(clustersOrderedByCapacity);
    final List<Long> disabledClusters = new ArrayList<>();
    final List<Long> clustersWithDisabledPods = new ArrayList<>();
    when(clusterDao.listDisabledClusters(dataCenterId, null)).thenReturn(disabledClusters);
    when(clusterDao.listClustersWithDisabledPods(dataCenterId)).thenReturn(clustersWithDisabledPods);
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) HashMap(java.util.HashMap) Zone(com.cloud.db.model.Zone) ArrayList(java.util.ArrayList) VMInstanceVO(com.cloud.vm.VMInstanceVO) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) AccountVO(com.cloud.user.AccountVO) List(java.util.List) ArrayList(java.util.ArrayList) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) Map(java.util.Map) HashMap(java.util.HashMap) Pair(com.cloud.utils.Pair)

Example 20 with Zone

use of com.cloud.db.model.Zone in project cosmic by MissionCriticalCloud.

the class SecondaryStorageVmAlertAdapter method onSSVMAlert.

public void onSSVMAlert(final Object sender, final SecStorageVmAlertEventArgs args) {
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("received secondary storage vm alert");
    }
    final Zone zone = zoneRepository.findOne(args.getZoneId());
    SecondaryStorageVmVO secStorageVm = args.getSecStorageVm();
    if (secStorageVm == null && args.getSecStorageVmId() != 0) {
        secStorageVm = _ssvmDao.findById(args.getSecStorageVmId());
    }
    if (secStorageVm == null && args.getType() != SecStorageVmAlertEventArgs.SSVM_CREATE_FAILURE) {
        throw new CloudRuntimeException("Invalid alert arguments, secStorageVm must be set");
    }
    switch(args.getType()) {
        case SecStorageVmAlertEventArgs.SSVM_CREATED:
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("New secondary storage vm created, zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + secStorageVm.getPrivateIpAddress());
            }
            break;
        case SecStorageVmAlertEventArgs.SSVM_UP:
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Secondary Storage Vm is up, zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + secStorageVm.getPrivateIpAddress());
            }
            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(), "Secondary Storage Vm up in zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()), "Secondary Storage Vm up (zone " + zone.getName() + ")");
            break;
        case SecStorageVmAlertEventArgs.SSVM_DOWN:
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Secondary Storage Vm is down, zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
            }
            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(), "Secondary Storage Vm down in zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()), "Secondary Storage Vm down (zone " + zone.getName() + ")");
            break;
        case SecStorageVmAlertEventArgs.SSVM_REBOOTED:
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Secondary Storage Vm is rebooted, zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
            }
            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(), "Secondary Storage Vm rebooted in zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()), "Secondary Storage Vm rebooted (zone " + zone.getName() + ")");
            break;
        case SecStorageVmAlertEventArgs.SSVM_CREATE_FAILURE:
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Secondary Storage Vm creation failure, zone: " + zone.getName());
            }
            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), null, "Secondary Storage Vm creation failure. zone: " + zone.getName() + ", error details: " + args.getMessage(), "Secondary Storage Vm creation failure (zone " + zone.getName() + ")");
            break;
        case SecStorageVmAlertEventArgs.SSVM_START_FAILURE:
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Secondary Storage Vm startup failure, zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
            }
            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(), "Secondary Storage Vm startup failure. zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()) + ", error details: " + args.getMessage(), "Secondary Storage Vm startup failure (zone " + zone.getName() + ")");
            break;
        case SecStorageVmAlertEventArgs.SSVM_FIREWALL_ALERT:
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Secondary Storage Vm firewall alert, zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
            }
            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(), "Failed to open secondary storage vm firewall port. zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()), "Secondary Storage Vm alert (zone " + zone.getName() + ")");
            break;
        case SecStorageVmAlertEventArgs.SSVM_STORAGE_ALERT:
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Secondary Storage Vm storage alert, zone: " + zone.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + secStorageVm.getPrivateIpAddress() + ", message: " + args.getMessage());
            }
            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC, args.getZoneId(), secStorageVm.getPodIdToDeployIn(), "Secondary Storage Vm storage issue. zone: " + zone.getName() + ", message: " + args.getMessage(), "Secondary Storage Vm alert (zone " + zone.getName() + ")");
            break;
    }
}
Also used : SecondaryStorageVmVO(com.cloud.vm.SecondaryStorageVmVO) Zone(com.cloud.db.model.Zone) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

Zone (com.cloud.db.model.Zone)106 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)34 ArrayList (java.util.ArrayList)32 DomainRouterVO (com.cloud.vm.DomainRouterVO)28 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)26 Network (com.cloud.network.Network)23 NetworkTopology (com.cloud.network.topology.NetworkTopology)23 Account (com.cloud.user.Account)23 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)23 NetworkVO (com.cloud.network.dao.NetworkVO)22 DeployDestination (com.cloud.deploy.DeployDestination)18 NicProfile (com.cloud.vm.NicProfile)16 List (java.util.List)16 HostPodVO (com.cloud.dc.HostPodVO)15 HostVO (com.cloud.host.HostVO)15 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)14 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)14 DB (com.cloud.utils.db.DB)14 TransactionStatus (com.cloud.utils.db.TransactionStatus)12 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)11