public boolean shouldAvoid(DataCenter dc) { if (_dcIds != null && _dcIds.contains(dc.getId())) { return true; } return false; }
@Override public DataCenterJoinVO newDataCenterView(DataCenter dataCenter) { SearchCriteria<DataCenterJoinVO> sc = dofIdSearch.create(); sc.setParameters("id", dataCenter.getId()); List<DataCenterJoinVO> dcs = searchIncludingRemoved(sc, null, null, false); assert dcs != null && dcs.size() == 1 : "No data center found for data center id " + dataCenter.getId(); return dcs.get(0); }
@Override public void checkZoneAccess(final Account caller, final DataCenter zone) { for (final SecurityChecker checker : _secChecker) { if (checker.checkAccess(caller, zone)) { if (s_logger.isDebugEnabled()) { s_logger.debug("Access granted to " + caller + " to zone:" + zone.getId() + " by " + checker.getName()); } return; } else { throw new PermissionDeniedException("Access denied to " + caller + " by " + checker.getName() + " for zone " + zone.getId()); } } assert false : "How can all of the security checkers pass on checking this caller?"; throw new PermissionDeniedException("There's no way to confirm " + caller + " has access to zone:" + zone.getId()); }
@Override @ActionEvent(eventType = EventTypes.EVENT_HA_RESOURCE_ENABLE, eventDescription = "enabling HA for a zone") public boolean enableHA(final DataCenter zone) { dataCenterDetailsDao.persist(zone.getId(), HA_ENABLED_DETAIL, String.valueOf(true)); return true; }
@Override @ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE, eventDescription = "disabling out-of-band management on a zone") public OutOfBandManagementResponse disableOutOfBandManagement(final DataCenter zone) { dataCenterDetailsDao.persist(zone.getId(), OOBM_ENABLED_DETAIL, String.valueOf(false)); transitionPowerStateToDisabled(hostDao.findByDataCenterId(zone.getId())); return buildEnableDisableResponse(false); }
@Override @ActionEvent(eventType = EventTypes.EVENT_HA_RESOURCE_DISABLE, eventDescription = "disabling HA for a zone") public boolean disableHA(final DataCenter zone) { dataCenterDetailsDao.persist(zone.getId(), HA_ENABLED_DETAIL, String.valueOf(false)); return transitionResourceStateToDisabled(zone); }
@Override @ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE, eventDescription = "enabling out-of-band management on a zone") public OutOfBandManagementResponse enableOutOfBandManagement(final DataCenter zone) { dataCenterDetailsDao.persist(zone.getId(), OOBM_ENABLED_DETAIL, String.valueOf(true)); return buildEnableDisableResponse(true); }
protected void sendPortForwardingRules(List<PortForwardingRuleTO> portForwardingRules, DataCenter zone, long externalFirewallId) throws ResourceUnavailableException { if (!portForwardingRules.isEmpty()) { SetPortForwardingRulesCommand cmd = new SetPortForwardingRulesCommand(portForwardingRules); Answer answer = _agentMgr.easySend(externalFirewallId, cmd); if (answer == null || !answer.getResult()) { String details = (answer != null) ? answer.getDetails() : "details unavailable"; String msg = "External firewall was unable to apply port forwarding rules to the SRX appliance in zone " + zone.getName() + " due to: " + details + "."; s_logger.error(msg); throw new ResourceUnavailableException(msg, DataCenter.class, zone.getId()); } } }
protected void sendFirewallRules(List<FirewallRuleTO> firewallRules, DataCenter zone, long externalFirewallId) throws ResourceUnavailableException { if (!firewallRules.isEmpty()) { SetFirewallRulesCommand cmd = new SetFirewallRulesCommand(firewallRules); Answer answer = _agentMgr.easySend(externalFirewallId, cmd); if (answer == null || !answer.getResult()) { String details = (answer != null) ? answer.getDetails() : "details unavailable"; String msg = "External firewall was unable to apply static nat rules to the SRX appliance in zone " + zone.getName() + " due to: " + details + "."; s_logger.error(msg); throw new ResourceUnavailableException(msg, DataCenter.class, zone.getId()); } } }
protected void sendStaticNatRules(List<StaticNatRuleTO> staticNatRules, DataCenter zone, long externalFirewallId) throws ResourceUnavailableException { if (!staticNatRules.isEmpty()) { SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(staticNatRules, null); Answer answer = _agentMgr.easySend(externalFirewallId, cmd); if (answer == null || !answer.getResult()) { String details = (answer != null) ? answer.getDetails() : "details unavailable"; String msg = "External firewall was unable to apply static nat rules to the SRX appliance in zone " + zone.getName() + " due to: " + details + "."; s_logger.error(msg); throw new ResourceUnavailableException(msg, DataCenter.class, zone.getId()); } } }
protected Pair<DeploymentPlan, List<DomainRouterVO>> getDeploymentPlanAndInternalLbVms(final DeployDestination dest, final long guestNetworkId, final Ip requestedGuestIp) { final long dcId = dest.getDataCenter().getId(); final DeploymentPlan plan = new DataCenterDeployment(dcId); final List<DomainRouterVO> internalLbVms = findInternalLbVms(guestNetworkId, requestedGuestIp); return new Pair<DeploymentPlan, List<DomainRouterVO>>(plan, internalLbVms); }
@Override public Network implement(Network network, NetworkOffering offering, DeployDestination destination, ReservationContext context) throws InsufficientVirtualNetworkCapacityException { assert network.getTrafficType() == TrafficType.Storage : "Why are you sending this configuration to me " + network; if (!_sNwMgr.isStorageIpRangeAvailable(destination.getDataCenter().getId())) { return super.implement(network, offering, destination, context); } return network; }
protected void findDefaultServiceOfferingId() { ServiceOfferingVO serviceOffering = serviceOfferingDao.findDefaultSystemOffering(ServiceOffering.routerDefaultOffUniqueName, ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId())); serviceOfferingId = serviceOffering.getId(); }
@Override public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { if (vm.getType() != VirtualMachine.Type.DomainRouter && _nuageVspEntityBuilder.usesVirtualRouter(network.getNetworkOfferingId())) { VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network); if (nic != null && nic.getRequestedIPv4() != null && nic.getRequestedIPv4().equals(vspNetwork.getVirtualRouterIp())) { DataCenter dc = _dcDao.findById(network.getDataCenterId()); s_logger.error("Unable to acquire requested Guest IP address " + nic.getRequestedIPv4() + " because it is reserved for the VR in network " + network); throw new InsufficientVirtualNetworkCapacityException("Unable to acquire requested Guest IP address " + nic.getRequestedIPv4() + " because it is reserved " + "for the VR in network " + network, DataCenter.class,dc.getId()); } } return super.allocate(network, nic, vm); }
protected void generateDeploymentPlan() { final long dcId = dest.getDataCenter().getId(); Long podId = null; if (isBasic()) { if (dest.getPod() == null) { throw new CloudRuntimeException("Pod id is expected in deployment destination"); } podId = dest.getPod().getId(); } plan = new DataCenterDeployment(dcId, podId, null, null, null, null); }
@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { final DataCenter dataCenter = _resourceService.getZone(getZoneId()); if (dataCenter == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId()); } final boolean result = haConfigManager.enableHA(dataCenter); CallContext.current().setEventDetails("Zone Id:" + dataCenter.getId() + " HA enabled: true"); CallContext.current().putContextParameter(DataCenter.class, dataCenter.getUuid()); setupResponse(result); }
@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { final DataCenter dataCenter = _resourceService.getZone(getZoneId()); if (dataCenter == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId()); } final boolean result = haConfigManager.disableHA(dataCenter); CallContext.current().setEventDetails("Zone Id:" + dataCenter.getId() + " HA enabled: false"); CallContext.current().putContextParameter(DataCenter.class, dataCenter.getUuid()); setupResponse(result); }
@Override final public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { final DataCenter zone = _resourceService.getZone(getZoneId()); if (zone == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId()); } OutOfBandManagementResponse response = outOfBandManagementService.disableOutOfBandManagement(zone); CallContext.current().setEventDetails("Zone Id:" + zone.getId() + " out-of-band management enabled: false"); CallContext.current().putContextParameter(DataCenter.class, zone.getUuid()); response.setResponseName(getCommandName()); setResponseObject(response); }
@Override final public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { final DataCenter zone = _resourceService.getZone(getZoneId()); if (zone == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId()); } OutOfBandManagementResponse response = outOfBandManagementService.enableOutOfBandManagement(zone); CallContext.current().setEventDetails("Zone Id:" + zone.getId() + " out-of-band management enabled: true"); CallContext.current().putContextParameter(DataCenter.class, zone.getUuid()); response.setResponseName(getCommandName()); setResponseObject(response); }
protected DiskProfile createDiskCharacteristics(VolumeInfo volume, VirtualMachineTemplate template, DataCenter dc, DiskOffering diskOffering) { if (volume.getVolumeType() == Type.ROOT && Storage.ImageFormat.ISO != template.getFormat()) { TemplateDataStoreVO ss = _vmTemplateStoreDao.findByTemplateZoneDownloadStatus(template.getId(), dc.getId(), VMTemplateStorageResourceAssoc.Status.DOWNLOADED); if (ss == null) { throw new CloudRuntimeException("Template " + template.getName() + " has not been completely downloaded to zone " + dc.getId()); } return new DiskProfile(volume.getId(), volume.getVolumeType(), volume.getName(), diskOffering.getId(), ss.getSize(), diskOffering.getTagsArray(), diskOffering.isUseLocalStorage(), diskOffering.isRecreatable(), Storage.ImageFormat.ISO != template.getFormat() ? template.getId() : null); } else { return new DiskProfile(volume.getId(), volume.getVolumeType(), volume.getName(), diskOffering.getId(), diskOffering.getDiskSize(), diskOffering.getTagsArray(), diskOffering.isUseLocalStorage(), diskOffering.isRecreatable(), null); } }