@Override public DataCenter getZone(Long zoneId) { return _dcDao.findById(zoneId); }
public static List<DataCenterVO> listZones() { return s_zoneDao.listAll(); }
@Override public void doInTransactionWithoutResult(TransactionStatus status) { Long resourceId = resourceFinal.getId(); if (!_dedicatedDao.remove(resourceId)) { throw new CloudRuntimeException("Failed to delete Resource " + resourceId); } if (zoneId != null) { // remove the domainId set in zone DataCenterVO dc = _zoneDao.findById(zoneId); if (dc != null) { dc.setDomainId(null); dc.setDomain(null); if (!_zoneDao.update(zoneId, dc)) { throw new CloudRuntimeException("Failed to release dedicated zone, could not clear domainId. Please contact Cloud Support."); } } } } });
private boolean isConsoleProxyVmRequired(long dcId) { DataCenterVO dc = _dcDao.findById(dcId); _dcDao.loadDetails(dc); String cpvmReq = dc.getDetail(ZoneConfig.EnableConsoleProxyVm.key()); if (cpvmReq != null) { return Boolean.parseBoolean(cpvmReq); } return true; }
@Override protected void allocateVnet(Network network, NetworkVO implemented, long dcId, long physicalNetworkId, String reservationId) throws InsufficientVirtualNetworkCapacityException { if (network.getBroadcastUri() == null) { String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId, UseSystemGuestVlans.valueIn(network.getAccountId())); if (vnet == null) { throw new InsufficientVirtualNetworkCapacityException("Unable to allocate vnet as a " + "part of network " + network + " implement ", DataCenter.class, dcId); } implemented.setBroadcastUri(BroadcastDomainType.Vxlan.toUri(vnet)); allocateVnetComplete(network, implemented, dcId, physicalNetworkId, reservationId, vnet); } else { implemented.setBroadcastUri(network.getBroadcastUri()); } }
@Override public Network doInTransaction(TransactionStatus status) throws ResourceAllocationException, InsufficientCapacityException { DataCenterVO dc = _dcDao.lockRow(pNtwk.getDataCenterId(), true); privateIp = new PrivateIpVO(startIp, privateNetwork.getId(), nextMac, vpcId, sourceNat); _privateIpDao.persist(privateIp); _dcDao.update(dc.getId(), dc);
@Override public void doInTransactionWithoutResult(final TransactionStatus status) { final Map<String, String> updatedDetails = new HashMap<String, String>(); _zoneDao.loadDetails(zone); if (zone.getDetails() != null) { updatedDetails.putAll(zone.getDetails()); if (!_zoneDao.update(zoneId, zone)) { throw new CloudRuntimeException("Failed to edit zone. Please contact Cloud Support.");
@Override public List<DedicatedResourceVO> doInTransaction(TransactionStatus status) { // find or create the affinity group by name under this account/domain 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 dc.setDomainId(domainId); if (!_zoneDao.update(zoneId, dc)) { throw new CloudRuntimeException("Failed to dedicate zone, could not set domainId. Please contact Cloud Support."); } } catch (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."); } List<DedicatedResourceVO> result = new ArrayList<DedicatedResourceVO>(); result.add(dedicatedResource); return result; } });
@Override public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { DataCenterVO dc = _dcDao.findById(network.getDataCenterId()); ReservationStrategy rsStrategy = ReservationStrategy.Start; _dcDao.loadDetails(dc); String dhcpStrategy = dc.getDetail(ZoneConfig.DhcpStrategy.key()); if ("external".equalsIgnoreCase(dhcpStrategy)) { rsStrategy = ReservationStrategy.Create; } if (nic == null) { nic = new NicProfile(rsStrategy, null, null, null, null); } else if (nic.getIPv4Address() == null) { nic.setReservationStrategy(ReservationStrategy.Start); } else { nic.setReservationStrategy(ReservationStrategy.Create); } if (rsStrategy == ReservationStrategy.Create) { String mac = _networkModel.getNextAvailableMacAddressInNetwork(network.getId()); nic.setMacAddress(mac); } return nic; }
protected void allocateVnet(final Network network, final NetworkVO implemented, final long dcId, final long physicalNetworkId, final String reservationId) throws InsufficientVirtualNetworkCapacityException { if (network.getBroadcastUri() == null) { final String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId, UseSystemGuestVlans.valueIn(network.getAccountId())); if (vnet == null) { throw new InsufficientVirtualNetworkCapacityException("Unable to allocate vnet as a " + "part of network " + network + " implement ", DataCenter.class, dcId); } implemented.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vnet)); ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), network.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: " + vnet + " Network Id: " + network.getId(), 0); } else { implemented.setBroadcastUri(network.getBroadcastUri()); } }
private boolean validZone(final long zoneId) { return _zoneDao.findById(zoneId) != null; }
@Override public void associateTemplateToZone(long templateId, Long zoneId) { List<Long> dcs = new ArrayList<Long>(); if (zoneId != null) { dcs.add(zoneId); } else { List<DataCenterVO> zones = _dcDao.listAll(); for (DataCenterVO zone : zones) { dcs.add(zone.getId()); } } for (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); } } }
@Override protected void allocateVnet(Network network, NetworkVO implemented, long dcId, long physicalNetworkId, String reservationId) throws InsufficientVirtualNetworkCapacityException { if (network.getBroadcastUri() == null) { String vnet = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), reservationId, UseSystemGuestVlans.valueIn(network.getAccountId())); if (vnet == null) { throw new InsufficientVirtualNetworkCapacityException( "Unable to allocate vnet as a part of network " + network + " implement ", DataCenter.class, dcId); } implemented .setBroadcastUri(BroadcastDomainType.Vswitch.toUri(vnet)); ActionEventUtils.onCompletedActionEvent( CallContext.current().getCallingUserId(), network.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: " + vnet + " Network Id: " + network.getId(), 0); } else { implemented.setBroadcastUri(network.getBroadcastUri()); } }
public static DataCenterVO findZoneById(Long zoneId) { return s_zoneDao.findById(zoneId); }
final List<DataCenterVO> zones = _dcDao.listAll();
vnetId = _dcDao.allocateVnet(dcId, physicalNetworkId, network.getAccountId(), context.getReservationId(), UseSystemGuestVlans.valueIn(network.getAccountId())); if (vnetId == null) { throw new InsufficientVirtualNetworkCapacityException("Unable to allocate vnet as a " +
public static boolean isSecurityGroupEnabledInZone(long zoneId) { DataCenterVO dc = s_zoneDao.findById(zoneId); if (dc == null) { return false; } else { return dc.isSecurityGroupEnabled(); } }
private void associateCrosszoneTemplatesToZone(Long zoneId) { VMTemplateZoneVO tmpltZone; List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll(); List<Long> dcIds = new ArrayList<Long>(); if (zoneId != null) { dcIds.add(zoneId); } else { List<DataCenterVO> dcs = _dcDao.listAll(); if (dcs != null) { for (DataCenterVO dc : dcs) { dcIds.add(dc.getId()); } } } for (VMTemplateVO vt : allTemplates) { if (vt.isCrossZones()) { for (Long dcId : dcIds) { tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId()); if (tmpltZone == null) { VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date()); _vmTemplateZoneDao.persist(vmTemplateZone); } } } } }