本文整理汇总了Java中com.cloud.utils.exception.CloudRuntimeException类的典型用法代码示例。如果您正苦于以下问题:Java CloudRuntimeException类的具体用法?Java CloudRuntimeException怎么用?Java CloudRuntimeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CloudRuntimeException类属于com.cloud.utils.exception包,在下文中一共展示了CloudRuntimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
private static void initialize() {
final Properties dbProps = DbProperties.getDbProperties();
if (EncryptionSecretKeyChecker.useEncryption()) {
final String dbSecretKey = dbProps.getProperty("db.cloud.encrypt.secret");
if (dbSecretKey == null || dbSecretKey.isEmpty()) {
throw new CloudRuntimeException("Empty DB secret key in db.properties");
}
s_encryptor = new StandardPBEStringEncryptor();
s_encryptor.setAlgorithm("PBEWithMD5AndDES");
s_encryptor.setPassword(dbSecretKey);
} else {
throw new CloudRuntimeException("Trying to encrypt db values when encrytion is not enabled");
}
}
示例2: doPingTest
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
public boolean doPingTest(final Connection conn, final String computingHostIp) {
final com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_host.getIp(), 22);
try {
sshConnection.connect(null, 60000, 60000);
if (!sshConnection.authenticateWithPassword(_username, _password.peek())) {
throw new CloudRuntimeException("Unable to authenticate");
}
final String cmd = "ping -c 2 " + computingHostIp;
if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) {
throw new CloudRuntimeException("Cannot ping host " + computingHostIp + " from host " + _host.getIp());
}
return true;
} catch (final Exception e) {
s_logger.warn("Catch exception " + e.toString(), e);
return false;
} finally {
sshConnection.close();
}
}
示例3: deletePhysicalNetworkTrafficType
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
public boolean deletePhysicalNetworkTrafficType(final Long id) {
final PhysicalNetworkTrafficTypeVO trafficType = _pNTrafficTypeDao.findById(id);
if (trafficType == null) {
throw new InvalidParameterValueException("Traffic Type with id=" + id + "doesn't exist in the system");
}
// check if there are any networks associated to this physical network with this traffic type
if (TrafficType.Guest.equals(trafficType.getTrafficType())) {
if (!_networksDao.listByPhysicalNetworkTrafficType(trafficType.getPhysicalNetworkId(), trafficType.getTrafficType()).isEmpty()) {
throw new CloudRuntimeException("The Traffic Type is not deletable because there are existing networks with this traffic type:" + trafficType.getTrafficType());
}
} else if (TrafficType.Storage.equals(trafficType.getTrafficType())) {
final PhysicalNetworkVO pn = _physicalNetworkDao.findById(trafficType.getPhysicalNetworkId());
if (_stnwMgr.isAnyStorageIpInUseInZone(pn.getDataCenterId())) {
throw new CloudRuntimeException("The Traffic Type is not deletable because there are still some storage network ip addresses in use:"
+ trafficType.getTrafficType());
}
}
return _pNTrafficTypeDao.remove(id);
}
示例4: execute
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
@Override
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
CallContext.current().setEventDetails("Vm Id: " + getId());
try {
final UserVm result = _userVmService.expungeVm(this.getId());
if (result != null) {
final SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to expunge vm");
}
} catch (final InvalidParameterValueException ipve) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
} catch (final CloudRuntimeException cre) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
}
}
示例5: findById
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
protected T findById(final ID id, final boolean removed, final Boolean lock) {
final StringBuilder sql = new StringBuilder(_selectByIdSql);
if (!removed && _removed != null) {
sql.append(" AND ").append(_removed.first());
}
if (lock != null) {
sql.append(lock ? FOR_UPDATE_CLAUSE : SHARE_MODE_CLAUSE);
}
final TransactionLegacy txn = TransactionLegacy.currentTxn();
PreparedStatement pstmt = null;
try {
pstmt = txn.prepareAutoCloseStatement(sql.toString());
if (_idField.getAnnotation(EmbeddedId.class) == null) {
prepareAttribute(1, pstmt, _idAttributes.get(_table)[0], id);
}
final ResultSet rs = pstmt.executeQuery();
return rs.next() ? toEntityBean(rs, true) : null;
} catch (final SQLException e) {
throw new CloudRuntimeException("DB Exception on: " + pstmt, e);
}
}
示例6: execute
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException {
try {
final NiciraNvpDeviceVO niciraNvpDeviceVO = niciraNvpElementService.addNiciraNvpDevice(this);
if (niciraNvpDeviceVO != null) {
final NiciraNvpDeviceResponse response = niciraNvpElementService.createNiciraNvpDeviceResponse(niciraNvpDeviceVO);
response.setObjectName("niciranvpdevice");
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Nicira NVP device due to internal error.");
}
} catch (final InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
} catch (final CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
}
}
示例7: stopSystemVM
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
@Override
@ActionEvent(eventType = "", eventDescription = "", async = true)
public VMInstanceVO stopSystemVM(final StopSystemVmCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException {
final Long id = cmd.getId();
// verify parameters
final VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(id, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
if (systemVm == null) {
final InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId");
ex.addProxyObject(id.toString(), "vmId");
throw ex;
}
try {
if (systemVm.getType() == VirtualMachine.Type.ConsoleProxy) {
ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_PROXY_STOP, "stopping console proxy Vm");
return stopConsoleProxy(systemVm, cmd.isForced());
} else if (systemVm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
ActionEventUtils.startNestedActionEvent(EventTypes.EVENT_SSVM_STOP, "stopping secondary storage Vm");
return stopSecondaryStorageVm(systemVm, cmd.isForced());
}
return null;
} catch (final OperationTimedoutException e) {
throw new CloudRuntimeException("Unable to stop " + systemVm, e);
}
}
示例8: mount
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
@Override
protected void mount(final String localRootPath, final String remoteDevice, final URI uri) {
ensureLocalRootPathExists(localRootPath, uri);
if (mountExists(localRootPath, uri)) {
return;
}
attemptMount(localRootPath, remoteDevice, uri);
// Change permissions for the mountpoint - seems to bypass authentication
final Script script = new Script(true, "chmod", _timeout, s_logger);
script.add("777", localRootPath);
final String result = script.execute();
if (result != null) {
final String errMsg = "Unable to set permissions for " + localRootPath + " due to " + result;
s_logger.error(errMsg);
throw new CloudRuntimeException(errMsg);
}
s_logger.debug("Successfully set 777 permission for " + localRootPath);
// XXX: Adding the check for creation of snapshots dir here. Might have
// to move it somewhere more logical later.
checkForSnapshotsDir(localRootPath);
checkForVolumesDir(localRootPath);
}
示例9: checkIfZoneIsDeletableFailureOnVolumeTest
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
@Test(expected = CloudRuntimeException.class)
public void checkIfZoneIsDeletableFailureOnVolumeTest() {
final VolumeVO volumeVO = Mockito.mock(VolumeVO.class);
final ArrayList<VolumeVO> arrayList = new ArrayList<>();
arrayList.add(volumeVO);
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_vmInstanceDao.listByZoneId(anyLong())).thenReturn(new ArrayList<>());
Mockito.when(_volumeDao.findByDc(anyLong())).thenReturn(arrayList);
Mockito.when(_physicalNetworkDao.listByZone(anyLong())).thenReturn(new ArrayList<>());
configurationMgr.checkIfZoneIsDeletable(new Random().nextLong());
}
示例10: testScaleVM3
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
@Test(expected = CloudRuntimeException.class)
public void testScaleVM3() throws Exception {
/*VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
Long srcHostId = vm.getHostId();
Long oldSvcOfferingId = vm.getServiceOfferingId();
if (srcHostId == null) {
throw new CloudRuntimeException("Unable to scale the vm because it doesn't have a host id");
}*/
when(_vmInstance.getHostId()).thenReturn(null);
when(_vmInstanceDao.findById(anyLong())).thenReturn(_vmInstance);
when(_vmInstanceDao.findByUuid(any(String.class))).thenReturn(_vmInstance);
final DeploymentPlanner.ExcludeList excludeHostList = new DeploymentPlanner.ExcludeList();
_vmMgr.findHostAndMigrate(_vmInstance.getUuid(), 2l, excludeHostList);
}
示例11: revertToSnapshot
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
public String revertToSnapshot(final Connection conn, final VM vmSnapshot, final String vmName,
final String oldVmUuid, final Boolean snapshotMemory, final String hostUUID)
throws XenAPIException, XmlRpcException {
final String results = callHostPluginAsync(conn, "vmopsSnapshot", "revert_memory_snapshot", 10 * 60 * 1000,
"snapshotUUID", vmSnapshot.getUuid(conn), "vmName", vmName,
"oldVmUuid", oldVmUuid, "snapshotMemory", snapshotMemory.toString(), "hostUUID", hostUUID);
String errMsg = null;
if (results == null || results.isEmpty()) {
errMsg = "revert_memory_snapshot return null";
} else {
if (results.equals("0")) {
return results;
} else {
errMsg = "revert_memory_snapshot exception";
}
}
s_logger.warn(errMsg);
throw new CloudRuntimeException(errMsg);
}
示例12: copyAsync
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
@Override
public void copyAsync(final DataObject srcData, final DataObject destData, final Host destHost, final AsyncCompletionCallback<CopyCommandResult> callback) {
if (srcData.getDataStore() == null || destData.getDataStore() == null) {
throw new CloudRuntimeException("can't find data store");
}
if (srcData.getDataStore().getDriver().canCopy(srcData, destData)) {
srcData.getDataStore().getDriver().copyAsync(srcData, destData, callback);
return;
} else if (destData.getDataStore().getDriver().canCopy(srcData, destData)) {
destData.getDataStore().getDriver().copyAsync(srcData, destData, callback);
return;
}
final DataMotionStrategy strategy = storageStrategyFactory.getDataMotionStrategy(srcData, destData);
if (strategy == null) {
throw new CloudRuntimeException("Can't find strategy to move data. " + "Source: " + srcData.getType().name() + " '" + srcData.getUuid() + ", Destination: " +
destData.getType().name() + " '" + destData.getUuid() + "'");
}
strategy.copyAsync(srcData, destData, destHost, callback);
}
示例13: injectSshKeysIntoSystemVmIsoPatch
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
protected void injectSshKeysIntoSystemVmIsoPatch(final String publicKeyPath, final String privKeyPath) {
s_logger.info("Trying to inject public and private keys into systemvm iso");
final String injectScript = getInjectScript();
final String scriptPath = Script.findScript("", injectScript);
final String systemVmIsoPath = Script.findScript("", "vms/systemvm.iso");
if (scriptPath == null) {
throw new CloudRuntimeException("Unable to find key inject script " + injectScript);
}
if (systemVmIsoPath == null) {
throw new CloudRuntimeException("Unable to find systemvm iso vms/systemvm.iso");
}
final Script command = new Script("/bin/bash", s_logger);
command.add(scriptPath);
command.add(publicKeyPath);
command.add(privKeyPath);
command.add(systemVmIsoPath);
final String result = command.execute();
s_logger.info("Injected public and private keys into systemvm iso with result : " + result);
if (result != null) {
s_logger.warn("Failed to inject generated public key into systemvm iso " + result);
throw new CloudRuntimeException("Failed to inject generated public key into systemvm iso " + result);
}
}
示例14: executeUserRequest
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
@Override
public boolean executeUserRequest(final long hostId, final ResourceState.Event event) throws AgentUnavailableException {
if (event == ResourceState.Event.AdminAskMaintenace) {
return doMaintain(hostId);
} else if (event == ResourceState.Event.AdminCancelMaintenance) {
return doCancelMaintenance(hostId);
} else if (event == ResourceState.Event.DeleteHost) {
/* TODO: Ask alex why we assume the last two parameters are false */
return doDeleteHost(hostId, false, false);
} else if (event == ResourceState.Event.Unmanaged) {
return doUmanageHost(hostId);
} else if (event == ResourceState.Event.UpdatePassword) {
return doUpdateHostPassword(hostId);
} else {
throw new CloudRuntimeException("Received an resource event we are not handling now, " + event);
}
}
示例15: evaluateObject
import com.cloud.utils.exception.CloudRuntimeException; //导入依赖的package包/类
public <T> T evaluateObject(final T obj) {
Class<?> clazz = obj.getClass();
try {
do {
final Field[] fs = clazz.getDeclaredFields();
for (final Field f : fs) {
f.setAccessible(true);
final Object value = get(f.getName());
f.set(obj, value);
}
clazz = clazz.getSuperclass();
} while (clazz != null && clazz != Object.class);
return obj;
} catch (final Exception e) {
throw new CloudRuntimeException(e);
}
}