@Override public HostVO findHostByGuid(final String guid) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getGuid(), Op.EQ, guid); return sc.find(); }
@Override public HostVO findHostByName(final String name) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getName(), Op.EQ, name); return sc.find(); }
private boolean canHandle(DeployDestination dest, TrafficType trafficType, GuestType networkType) { Pod pod = dest.getPod(); if (pod != null && trafficType == TrafficType.Guest) { QueryBuilder<BaremetalPxeVO> sc = QueryBuilder.create(BaremetalPxeVO.class); sc.and(sc.entity().getPodId(), Op.EQ, pod.getId()); return sc.find() != null; } return false; }
@Override public AccountDetailVO findDetail(long accountId, String name) { QueryBuilder<AccountDetailVO> sc = QueryBuilder.create(AccountDetailVO.class); sc.and(sc.entity().getAccountId(), Op.EQ, accountId); sc.and(sc.entity().getName(), Op.EQ, name); return sc.find(); }
private void enableProvider(String providerName) { QueryBuilder<PhysicalNetworkServiceProviderVO> q = QueryBuilder.create(PhysicalNetworkServiceProviderVO.class); q.and(q.entity().getProviderName(), SearchCriteria.Op.EQ, providerName); PhysicalNetworkServiceProviderVO provider = q.find(); provider.setState(PhysicalNetworkServiceProvider.State.Enabled); _pNSPDao.update(provider.getId(), provider); }
protected HostVO findConsoleProxyHostByName(String name) { QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getType(), Op.EQ, Host.Type.ConsoleProxy); sc.and(sc.entity().getName(), Op.EQ, name); return sc.find(); }
@Override public ImageStoreDetailVO findDetail(long storeId, String name) { QueryBuilder<ImageStoreDetailVO> sc = QueryBuilder.create(ImageStoreDetailVO.class); sc.and(sc.entity().getResourceId(), Op.EQ, storeId); sc.and(sc.entity().getName(), Op.EQ, name); return sc.find(); }
QueryBuilder<BaremetalRctVO> sc = QueryBuilder.create(BaremetalRctVO.class); sc.and(sc.entity().getUrl(), SearchCriteria.Op.EQ, cmd.getRctUrl()); BaremetalRctVO vo = sc.find(); if (vo == null) { vo = new BaremetalRctVO();
@Override public DomainDetailVO findDetail(long domainId, String name) { QueryBuilder<DomainDetailVO> sc = QueryBuilder.create(DomainDetailVO.class); sc.and(sc.entity().getDomainId(), Op.EQ, domainId); sc.and(sc.entity().getName(), Op.EQ, name); return sc.find(); }
private boolean canHandle(DeployDestination dest, TrafficType trafficType, GuestType networkType) { Pod pod = dest.getPod(); if (pod != null && dest.getDataCenter().getNetworkType() == NetworkType.Basic && trafficType == TrafficType.Guest) { QueryBuilder<BaremetalDhcpVO> sc = QueryBuilder.create(BaremetalDhcpVO.class); sc.and(sc.entity().getPodId(), Op.EQ, pod.getId()); return sc.find() != null; } return false; }
QueryBuilder<VMInstanceVO> q = QueryBuilder.create(VMInstanceVO.class); q.and(q.entity().getInstanceName(), SearchCriteria.Op.EQ, vm.getName()); VMInstanceVO vmvo = q.find(); vmvo = q.find(); if (vmvo == null) { return new StartAnswer(cmd, String.format("cannot find vm[name:%s] while waiting for baremtal provision done notification", vm.getName()));
QueryBuilder<HostVO> hq = QueryBuilder.create(HostVO.class); hq.and(hq.entity().getPrivateMacAddress(), SearchCriteria.Op.EQ, cmd.getMac()); HostVO host = hq.find(); if (host == null) { throw new CloudRuntimeException(String.format("cannot find host[mac:%s]", cmd.getMac())); VMInstanceVO vm = vmq.find();
QueryBuilder<AccountVO> acntq = QueryBuilder.create(AccountVO.class); acntq.and(acntq.entity().getAccountName(), SearchCriteria.Op.EQ, BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME); AccountVO acnt = acntq.find(); if (acnt != null) { return true;
QueryBuilder<UcsManagerVO> q = QueryBuilder.create(UcsManagerVO.class); q.and(q.entity().getUrl(), Op.EQ, cmd.getUrl()); UcsManagerVO mgrvo = q.find(); if (mgrvo != null) { throw new IllegalArgumentException(String.format("duplicate UCS manager. url[%s] is used by another UCS manager already", cmd.getUrl()));
final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getId(), Op.EQ, agentId); final HostVO h = sc.find(); if (h != null) { final ResourceState resourceState = h.getResourceState();
q.and(q.entity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId()); q.and(q.entity().getId(), Op.EQ, cmd.getBladeId()); UcsBladeVO bvo = q.find(); if (bvo == null) { throw new IllegalArgumentException(String.format("cannot find UCS blade[id:%s, ucs manager id:%s]", cmd.getBladeId(), cmd.getUcsManagerId()));
private boolean preparePxeInBasicZone(VirtualMachineProfile profile, NicProfile nic, DeployDestination dest, ReservationContext context) throws AgentUnavailableException, OperationTimedoutException { NetworkVO nwVO = _nwDao.findById(nic.getNetworkId()); QueryBuilder<BaremetalPxeVO> sc = QueryBuilder.create(BaremetalPxeVO.class); sc.and(sc.entity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.toString()); sc.and(sc.entity().getPhysicalNetworkId(), Op.EQ, nwVO.getPhysicalNetworkId()); BaremetalPxeVO pxeVo = sc.find(); if (pxeVo == null) { throw new CloudRuntimeException("No kickstart PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM"); } VMTemplateVO template = _tmpDao.findById(profile.getTemplateId()); List<String> tuple = parseKickstartUrl(profile); String ks = tuple.get(0); String kernel = tuple.get(1); String initrd = tuple.get(2); PrepareKickstartPxeServerCommand cmd = new PrepareKickstartPxeServerCommand(); cmd.setKsFile(ks); cmd.setInitrd(initrd); cmd.setKernel(kernel); cmd.setMac(nic.getMacAddress()); cmd.setTemplateUuid(template.getUuid()); Answer aws = _agentMgr.send(pxeVo.getHostId(), cmd); if (!aws.getResult()) { s_logger.warn("Unable to set host: " + dest.getHost().getId() + " to PXE boot because " + aws.getDetails()); return false; } return true; }
sc.and(sc.entity().getDataStoreRole(), SearchCriteria.Op.EQ, store.getRole()); sc.and(sc.entity().getRefCnt(), SearchCriteria.Op.EQ, 0); TemplateDataStoreVO template = sc.find(); if (template != null) { return templateFactory.getTemplate(template.getTemplateId(), store); volSc.and(volSc.entity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId()); volSc.and(volSc.entity().getRefCnt(), SearchCriteria.Op.EQ, 0); VolumeDataStoreVO volume = volSc.find(); if (volume != null) { return volumeFactory.getVolume(volume.getVolumeId(), store); snapshotSc.and(snapshotSc.entity().getRole(), SearchCriteria.Op.EQ, store.getRole()); snapshotSc.and(snapshotSc.entity().getRefCnt(), SearchCriteria.Op.EQ, 0); SnapshotDataStoreVO snapshot = snapshotSc.find(); if (snapshot != null) { return snapshotFactory.getSnapshot(snapshot.getSnapshotId(), store);
@Override public SnapshotInfo getChild() { QueryBuilder<SnapshotDataStoreVO> sc = QueryBuilder.create(SnapshotDataStoreVO.class); sc.and(sc.entity().getDataStoreId(), Op.EQ, store.getId()); sc.and(sc.entity().getRole(), Op.EQ, store.getRole()); sc.and(sc.entity().getState(), Op.NIN, State.Destroying, State.Destroyed, State.Error); sc.and(sc.entity().getParentSnapshotId(), Op.EQ, getId()); SnapshotDataStoreVO vo = sc.find(); if (vo == null) { return null; } return snapshotFactory.getSnapshot(vo.getId(), store); }
sc.and(sc.entity().getDeviceType(), Op.EQ, BaremetalPxeType.PING.toString()); sc.and(sc.entity().getPodId(), Op.EQ, dest.getPod().getId()); BaremetalPxeVO pxeVo = sc.find(); if (pxeVo == null) { throw new CloudRuntimeException("No PING PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM");