本文整理汇总了Java中com.cloud.vm.UserVmVO类的典型用法代码示例。如果您正苦于以下问题:Java UserVmVO类的具体用法?Java UserVmVO怎么用?Java UserVmVO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserVmVO类属于com.cloud.vm包,在下文中一共展示了UserVmVO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateVM
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
@Override
public void updateVM(final long id, final String displayName, final boolean enable, final Long osTypeId, final String userData, final boolean displayVm,
final boolean isDynamicallyScalable, final String customId, final String hostName, final String instanceName) {
final UserVmVO vo = createForUpdate();
vo.setDisplayName(displayName);
vo.setHaEnabled(enable);
vo.setGuestOSId(osTypeId);
vo.setUserData(userData);
vo.setDisplayVm(displayVm);
vo.setDynamicallyScalable(isDynamicallyScalable);
if (hostName != null) {
vo.setHostName(hostName);
}
if (customId != null) {
vo.setUuid(customId);
}
if (instanceName != null) {
vo.setInstanceName(instanceName);
}
update(id, vo);
}
示例2: countCpusForAccount
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
public long countCpusForAccount(final long accountId) {
final GenericSearchBuilder<ServiceOfferingVO, SumCount> cpuSearch = _serviceOfferingDao.createSearchBuilder(SumCount.class);
cpuSearch.select("sum", Func.SUM, cpuSearch.entity().getCpu());
final SearchBuilder<UserVmVO> join1 = _userVmDao.createSearchBuilder();
join1.and("accountId", join1.entity().getAccountId(), Op.EQ);
join1.and("type", join1.entity().getType(), Op.EQ);
join1.and("state", join1.entity().getState(), SearchCriteria.Op.NIN);
join1.and("displayVm", join1.entity().isDisplayVm(), Op.EQ);
cpuSearch.join("offerings", join1, cpuSearch.entity().getId(), join1.entity().getServiceOfferingId(), JoinBuilder.JoinType.INNER);
cpuSearch.done();
final SearchCriteria<SumCount> sc = cpuSearch.create();
sc.setJoinParameters("offerings", "accountId", accountId);
sc.setJoinParameters("offerings", "type", VirtualMachine.Type.User);
sc.setJoinParameters("offerings", "state", new Object[]{State.Destroyed, State.Error, State.Expunging});
sc.setJoinParameters("offerings", "displayVm", 1);
final List<SumCount> cpus = _serviceOfferingDao.customSearch(sc, null);
if (cpus != null) {
return cpus.get(0).sum;
} else {
return 0;
}
}
示例3: calculateMemoryForAccount
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
public long calculateMemoryForAccount(final long accountId) {
final GenericSearchBuilder<ServiceOfferingVO, SumCount> memorySearch = _serviceOfferingDao.createSearchBuilder(SumCount.class);
memorySearch.select("sum", Func.SUM, memorySearch.entity().getRamSize());
final SearchBuilder<UserVmVO> join1 = _userVmDao.createSearchBuilder();
join1.and("accountId", join1.entity().getAccountId(), Op.EQ);
join1.and("type", join1.entity().getType(), Op.EQ);
join1.and("state", join1.entity().getState(), SearchCriteria.Op.NIN);
join1.and("displayVm", join1.entity().isDisplayVm(), Op.EQ);
memorySearch.join("offerings", join1, memorySearch.entity().getId(), join1.entity().getServiceOfferingId(), JoinBuilder.JoinType.INNER);
memorySearch.done();
final SearchCriteria<SumCount> sc = memorySearch.create();
sc.setJoinParameters("offerings", "accountId", accountId);
sc.setJoinParameters("offerings", "type", VirtualMachine.Type.User);
sc.setJoinParameters("offerings", "state", new Object[]{State.Destroyed, State.Error, State.Expunging});
sc.setJoinParameters("offerings", "displayVm", 1);
final List<SumCount> memory = _serviceOfferingDao.customSearch(sc, null);
if (memory != null) {
return memory.get(0).sum;
} else {
return 0;
}
}
示例4: listNics
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
@Override
public List<? extends Nic> listNics(final ListNicsCmd cmd) {
final Account caller = CallContext.current().getCallingAccount();
final Long nicId = cmd.getNicId();
final long vmId = cmd.getVmId();
final Long networkId = cmd.getNetworkId();
final UserVmVO userVm = _userVmDao.findById(vmId);
if (userVm == null || !userVm.isDisplayVm() && caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
final InvalidParameterValueException ex = new InvalidParameterValueException("Virtual mahine id does not exist");
ex.addProxyObject(Long.valueOf(vmId).toString(), "vmId");
throw ex;
}
_accountMgr.checkAccess(caller, null, true, userVm);
return _networkMgr.listVmNics(vmId, nicId, networkId);
}
示例5: accept
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
@Override
public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
_router = router;
final UserVmDao userVmDao = visitor.getVirtualNetworkApplianceFactory().getUserVmDao();
final UserVmVO vm = userVmDao.findById(_profile.getId());
userVmDao.loadDetails(vm);
final NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
// check if this is not the primary subnet.
final NicVO domrGuestNic = nicDao.findByInstanceIdAndIpAddressAndVmtype(_router.getId(), nicDao.getIpAddress(_nic.getNetworkId(), _router.getId()),
VirtualMachine.Type.DomainRouter);
// check if the router ip address and the vm ip address belong to same
// subnet.
// if they do not belong to same netwoek check for the alias ips. if not
// create one.
// This should happen only in case of Basic and Advanced SG enabled
// networks.
if (!NetUtils.sameSubnet(domrGuestNic.getIPv4Address(), _nic.getIPv4Address(), _nic.getIPv4Netmask())) {
return true;
}
return true;
}
示例6: createVolumeFromSnapshot
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
protected VolumeVO createVolumeFromSnapshot(final VolumeVO volume, final long snapshotId, final Long vmId) throws StorageUnavailableException {
final VolumeInfo createdVolume;
final SnapshotVO snapshot = _snapshotDao.findById(snapshotId);
snapshot.getVolumeId();
UserVmVO vm = null;
if (vmId != null) {
vm = _userVmDao.findById(vmId);
}
// sync old snapshots to region store if necessary
createdVolume = _volumeMgr.createVolumeFromSnapshot(volume, snapshot, vm);
return _volsDao.findById(createdVolume.getId());
}
示例7: getMaxDataVolumesSupported
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
private int getMaxDataVolumesSupported(final UserVmVO vm) {
Long hostId = vm.getHostId();
if (hostId == null) {
hostId = vm.getLastHostId();
}
final HostVO host = _hostDao.findById(hostId);
Integer maxDataVolumesSupported = null;
if (host != null) {
_hostDao.loadDetails(host);
maxDataVolumesSupported = _hypervisorCapabilitiesDao.getMaxDataVolumesLimit(host.getHypervisorType(), host.getDetail("product_version"));
}
if (maxDataVolumesSupported == null) {
maxDataVolumesSupported = 6; // 6 data disks by default if nothing
// is specified in
// 'hypervisor_capabilities' table
}
return maxDataVolumesSupported.intValue();
}
示例8: testResourceLimitCheckForUploadedVolume
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
@Test
public void testResourceLimitCheckForUploadedVolume() throws NoSuchFieldException, IllegalAccessException, ResourceAllocationException {
doThrow(new ResourceAllocationException("primary storage resource limit check failed", Resource.ResourceType.primary_storage)).when(_svc._resourceLimitMgr).checkResourceLimit(any(AccountVO.class), any(Resource.ResourceType.class), any(Long.class));
UserVmVO vm = Mockito.mock(UserVmVO.class);
VolumeInfo volumeToAttach = Mockito.mock(VolumeInfo.class);
when(volumeToAttach.getId()).thenReturn(9L);
when(volumeToAttach.getDataCenterId()).thenReturn(34L);
when(volumeToAttach.getVolumeType()).thenReturn(Volume.Type.DATADISK);
when(volumeToAttach.getInstanceId()).thenReturn(null);
when(_userVmDao.findById(anyLong())).thenReturn(vm);
when(vm.getType()).thenReturn(VirtualMachine.Type.User);
when(vm.getState()).thenReturn(State.Running);
when(vm.getDataCenterId()).thenReturn(34L);
when(_svc._volsDao.findByInstanceAndType(anyLong(), any(Volume.Type.class))).thenReturn(new ArrayList(10));
when(_svc.volFactory.getVolume(9L)).thenReturn(volumeToAttach);
when(volumeToAttach.getState()).thenReturn(Volume.State.Uploaded);
DataCenterVO zoneWithDisabledLocalStorage = Mockito.mock(DataCenterVO.class);
when(_svc._dcDao.findById(anyLong())).thenReturn(zoneWithDisabledLocalStorage);
when(zoneWithDisabledLocalStorage.isLocalStorageEnabled()).thenReturn(true);
try {
_svc.attachVolumeToVM(2L, 9L, null);
} catch (InvalidParameterValueException e) {
Assert.assertEquals(e.getMessage(), ("primary storage resource limit check failed"));
}
}
示例9: updateVM
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
@Override
public void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData, boolean displayVm,
boolean isDynamicallyScalable, String customId, String hostName, String instanceName) {
UserVmVO vo = createForUpdate();
vo.setDisplayName(displayName);
vo.setHaEnabled(enable);
vo.setGuestOSId(osTypeId);
vo.setUserData(userData);
vo.setDisplayVm(displayVm);
vo.setDynamicallyScalable(isDynamicallyScalable);
if (hostName != null) {
vo.setHostName(hostName);
}
if (customId != null) {
vo.setUuid(customId);
}
if(instanceName != null){
vo.setInstanceName(instanceName);
}
update(id, vo);
}
示例10: visit
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
@Override
public boolean visit(final UserdataPwdRules userdata) throws ResourceUnavailableException {
final VirtualRouter router = userdata.getRouter();
final Commands commands = new Commands(Command.OnError.Stop);
final VirtualMachineProfile profile = userdata.getProfile();
final NicVO nicVo = userdata.getNicVo();
final UserVmVO userVM = userdata.getUserVM();
final DeployDestination destination = userdata.getDestination();
if (router.getPodIdToDeployIn().longValue() == destination.getPod().getId()) {
_commandSetupHelper.createPasswordCommand(router, profile, nicVo, commands);
_commandSetupHelper.createVmDataCommand(router, userVM, nicVo, userVM.getDetail("SSH.PublicKey"), commands);
return _networkGeneralHelper.sendCommandsToRouter(router, commands);
}
return true;
}
示例11: createAndPersistVMSnapshot
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
/**
* Create, persist and return vm snapshot for userVmVo with given parameters.
* Persistence and support for custom service offerings are done on the same transaction
* @param userVmVo user vm
* @param vmId vm id
* @param vsDescription vm description
* @param vmSnapshotName vm snapshot name
* @param vsDisplayName vm snapshot display name
* @param vmSnapshotType vm snapshot type
* @return vm snapshot
* @throws CloudRuntimeException if vm snapshot couldn't be persisted
*/
protected VMSnapshot createAndPersistVMSnapshot(UserVmVO userVmVo, String vsDescription, String vmSnapshotName, String vsDisplayName, VMSnapshot.Type vmSnapshotType) {
final Long vmId = userVmVo.getId();
final Long serviceOfferingId = userVmVo.getServiceOfferingId();
final VMSnapshotVO vmSnapshotVo =
new VMSnapshotVO(userVmVo.getAccountId(), userVmVo.getDomainId(), vmId, vsDescription, vmSnapshotName, vsDisplayName, serviceOfferingId,
vmSnapshotType, null);
return Transaction.execute(new TransactionCallbackWithException<VMSnapshot, CloudRuntimeException>() {
@Override
public VMSnapshot doInTransaction(TransactionStatus status) {
VMSnapshot vmSnapshot = _vmSnapshotDao.persist(vmSnapshotVo);
if (vmSnapshot == null) {
throw new CloudRuntimeException("Failed to create snapshot for vm: " + vmId);
}
addSupportForCustomServiceOffering(vmId, serviceOfferingId, vmSnapshot.getId());
return vmSnapshot;
}
});
}
示例12: countCpusForAccount
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
public long countCpusForAccount(long accountId) {
GenericSearchBuilder<ServiceOfferingVO, SumCount> cpuSearch = _serviceOfferingDao.createSearchBuilder(SumCount.class);
cpuSearch.select("sum", Func.SUM, cpuSearch.entity().getCpu());
SearchBuilder<UserVmVO> join1 = _userVmDao.createSearchBuilder();
join1.and("accountId", join1.entity().getAccountId(), Op.EQ);
join1.and("type", join1.entity().getType(), Op.EQ);
join1.and("state", join1.entity().getState(), SearchCriteria.Op.NIN);
join1.and("displayVm", join1.entity().isDisplayVm(), Op.EQ);
cpuSearch.join("offerings", join1, cpuSearch.entity().getId(), join1.entity().getServiceOfferingId(), JoinBuilder.JoinType.INNER);
cpuSearch.done();
SearchCriteria<SumCount> sc = cpuSearch.create();
sc.setJoinParameters("offerings", "accountId", accountId);
sc.setJoinParameters("offerings", "type", VirtualMachine.Type.User);
sc.setJoinParameters("offerings", "state", new Object[] {State.Destroyed, State.Error, State.Expunging});
sc.setJoinParameters("offerings", "displayVm", 1);
List<SumCount> cpus = _serviceOfferingDao.customSearch(sc, null);
if (cpus != null) {
return cpus.get(0).sum;
} else {
return 0;
}
}
示例13: calculateMemoryForAccount
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
public long calculateMemoryForAccount(long accountId) {
GenericSearchBuilder<ServiceOfferingVO, SumCount> memorySearch = _serviceOfferingDao.createSearchBuilder(SumCount.class);
memorySearch.select("sum", Func.SUM, memorySearch.entity().getRamSize());
SearchBuilder<UserVmVO> join1 = _userVmDao.createSearchBuilder();
join1.and("accountId", join1.entity().getAccountId(), Op.EQ);
join1.and("type", join1.entity().getType(), Op.EQ);
join1.and("state", join1.entity().getState(), SearchCriteria.Op.NIN);
join1.and("displayVm", join1.entity().isDisplayVm(), Op.EQ);
memorySearch.join("offerings", join1, memorySearch.entity().getId(), join1.entity().getServiceOfferingId(), JoinBuilder.JoinType.INNER);
memorySearch.done();
SearchCriteria<SumCount> sc = memorySearch.create();
sc.setJoinParameters("offerings", "accountId", accountId);
sc.setJoinParameters("offerings", "type", VirtualMachine.Type.User);
sc.setJoinParameters("offerings", "state", new Object[] {State.Destroyed, State.Error, State.Expunging});
sc.setJoinParameters("offerings", "displayVm", 1);
List<SumCount> memory = _serviceOfferingDao.customSearch(sc, null);
if (memory != null) {
return memory.get(0).sum;
} else {
return 0;
}
}
示例14: updateConfigDrive
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
private boolean updateConfigDrive(VirtualMachineProfile profile, String publicKey) {
UserVmVO vm = _userVmDao.findById(profile.getId());
if (vm.getType() != VirtualMachine.Type.User) {
return false;
}
// add/update userdata and/or password info into vm profile
Nic defaultNic = _networkModel.getDefaultNic(vm.getId());
if (defaultNic != null) {
final String serviceOffering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getId(), vm.getServiceOfferingId()).getDisplayText();
final String zoneName = _dcDao.findById(vm.getDataCenterId()).getName();
boolean isWindows = _guestOSCategoryDao.findById(_guestOSDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
List<String[]> vmData = _networkModel.generateVmData(vm.getUserData(), serviceOffering, zoneName, vm.getInstanceName(), vm.getId(),
publicKey, (String) profile.getParameter(VirtualMachineProfile.Param.VmPassword), isWindows);
profile.setVmData(vmData);
profile.setConfigDriveLabel(VirtualMachineManager.VmConfigDriveLabel.value());
}
return true;
}
示例15: listNics
import com.cloud.vm.UserVmVO; //导入依赖的package包/类
@Override
public List<? extends Nic> listNics(ListNicsCmd cmd) {
Account caller = CallContext.current().getCallingAccount();
Long nicId = cmd.getNicId();
long vmId = cmd.getVmId();
String keyword = cmd.getKeyword();
Long networkId = cmd.getNetworkId();
UserVmVO userVm = _userVmDao.findById(vmId);
if (userVm == null || (!userVm.isDisplayVm() && caller.getType() == Account.ACCOUNT_TYPE_NORMAL)) {
throwInvalidIdException("Virtual machine id does not exist", Long.valueOf(vmId).toString(), "vmId");
}
_accountMgr.checkAccess(caller, null, true, userVm);
return _networkMgr.listVmNics(vmId, nicId, networkId, keyword);
}