本文整理汇总了Java中com.cloud.utils.exception.CloudRuntimeException.addProxyObject方法的典型用法代码示例。如果您正苦于以下问题:Java CloudRuntimeException.addProxyObject方法的具体用法?Java CloudRuntimeException.addProxyObject怎么用?Java CloudRuntimeException.addProxyObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cloud.utils.exception.CloudRuntimeException
的用法示例。
在下文中一共展示了CloudRuntimeException.addProxyObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: implementNetworkElements
import com.cloud.utils.exception.CloudRuntimeException; //导入方法依赖的package包/类
private void implementNetworkElements(final DeployDestination dest, final ReservationContext context, final Network network, final NetworkOffering offering, final
List<Provider> providersToImplement) throws ResourceUnavailableException, InsufficientCapacityException {
for (final NetworkElement element : networkElements) {
if (providersToImplement.contains(element.getProvider())) {
if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) {
// The physicalNetworkId will not get translated into a uuid by the reponse serializer,
// because the serializer would look up the NetworkVO class's table and retrieve the
// network id instead of the physical network id.
// So just throw this exception as is. We may need to TBD by changing the serializer.
throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: "
+ network.getPhysicalNetworkId());
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Asking " + element.getName() + " to implemenet " + network);
}
if (!element.implement(network, offering, dest, context)) {
final CloudRuntimeException ex = new CloudRuntimeException("Failed to implement provider " + element.getProvider().getName() + " for network with specified " +
"id");
ex.addProxyObject(network.getUuid(), "networkId");
throw ex;
}
}
}
}
示例2: getOrCreateCluster
import com.cloud.utils.exception.CloudRuntimeException; //导入方法依赖的package包/类
private Long getOrCreateCluster(final DataCenterVO zone, final HostPodVO pod, Long clusterId, final String clusterName, final String hypervisorType) {
final Long dcId = zone.getId();
final Long podId = pod.getId();
if (clusterName != null) {
ClusterVO cluster = new ClusterVO(dcId, podId, clusterName);
cluster.setHypervisorType(hypervisorType);
try {
cluster = _clusterDao.persist(cluster);
} catch (final Exception e) {
cluster = _clusterDao.findBy(clusterName, podId);
if (cluster == null) {
final CloudRuntimeException ex =
new CloudRuntimeException("Unable to create cluster " + clusterName + " in pod with specified podId and data center with specified dcID", e);
ex.addProxyObject(pod.getUuid(), "podId");
ex.addProxyObject(zone.getUuid(), "dcId");
throw ex;
}
}
clusterId = cluster.getId();
if (_clusterDetailsDao.findDetail(clusterId, "cpuOvercommitRatio") == null) {
final ClusterDetailsVO cluster_cpu_detail = new ClusterDetailsVO(clusterId, "cpuOvercommitRatio", "1");
final ClusterDetailsVO cluster_memory_detail = new ClusterDetailsVO(clusterId, "memoryOvercommitRatio", "1");
_clusterDetailsDao.persist(cluster_cpu_detail);
_clusterDetailsDao.persist(cluster_memory_detail);
}
}
return clusterId;
}
示例3: createStaticNatForIp
import com.cloud.utils.exception.CloudRuntimeException; //导入方法依赖的package包/类
protected List<StaticNat> createStaticNatForIp(final IpAddress sourceIp, final Account caller, final boolean forRevoke) {
final List<StaticNat> staticNats = new ArrayList<>();
if (!sourceIp.isOneToOneNat()) {
s_logger.debug("Source ip id=" + sourceIp + " is not one to one nat");
return staticNats;
}
final Long networkId = sourceIp.getAssociatedWithNetworkId();
if (networkId == null) {
throw new CloudRuntimeException("Ip address is not associated with any network");
}
final VMInstanceVO vm = _vmInstanceDao.findByIdIncludingRemoved(sourceIp.getAssociatedWithVmId());
final Network network = _networkModel.getNetwork(networkId);
if (network == null) {
final CloudRuntimeException ex = new CloudRuntimeException("Unable to find an ip address to map to specified vm id");
ex.addProxyObject(vm.getUuid(), "vmId");
throw ex;
}
if (caller != null) {
_accountMgr.checkAccess(caller, null, true, sourceIp);
}
// create new static nat rule
// Get nic IP4 address
final Nic guestNic = _networkModel.getNicInNetworkIncludingRemoved(vm.getId(), networkId);
if (guestNic == null) {
throw new InvalidParameterValueException("Vm doesn't belong to the network with specified id");
}
final String dstIp;
dstIp = sourceIp.getVmIp();
if (dstIp == null) {
throw new InvalidParameterValueException("Vm ip is not set as dnat ip for this public ip");
}
String srcMac = null;
try {
srcMac = _networkModel.getNextAvailableMacAddressInNetwork(networkId);
} catch (final InsufficientAddressCapacityException e) {
throw new CloudRuntimeException("Insufficient MAC address for static NAT instantiation.");
}
final StaticNatImpl staticNat = new StaticNatImpl(sourceIp.getAllocatedToAccountId(), sourceIp.getAllocatedInDomainId(), networkId, sourceIp.getId(), dstIp, srcMac,
forRevoke);
staticNats.add(staticNat);
return staticNats;
}