diff --git a/api/src/com/cloud/exception/CloudAuthenticationException.java b/api/src/com/cloud/exception/CloudAuthenticationException.java index 2bba79bab1e..0bf114c0394 100644 --- a/api/src/com/cloud/exception/CloudAuthenticationException.java +++ b/api/src/com/cloud/exception/CloudAuthenticationException.java @@ -17,9 +17,9 @@ package com.cloud.exception; import com.cloud.utils.SerialVersionUID; -import com.cloud.utils.exception.RuntimeCloudException; +import com.cloud.utils.exception.CloudRuntimeException; -public class CloudAuthenticationException extends RuntimeCloudException { +public class CloudAuthenticationException extends CloudRuntimeException { private static final long serialVersionUID = SerialVersionUID.CloudAuthenticationException; public CloudAuthenticationException(String message) { diff --git a/api/src/com/cloud/exception/CloudExecutionException.java b/api/src/com/cloud/exception/CloudExecutionException.java deleted file mode 100755 index d8d70f8ddb5..00000000000 --- a/api/src/com/cloud/exception/CloudExecutionException.java +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.exception; - -import java.util.HashMap; -import com.cloud.utils.exception.RuntimeCloudException; - -import com.cloud.utils.SerialVersionUID; - -/** - * - */ -public class CloudExecutionException extends RuntimeCloudException { - private final static long serialVersionUID = SerialVersionUID.CloudExecutionException; - - private final ErrorCode code; - private final HashMap details; - - public CloudExecutionException(ErrorCode code, String message, Throwable cause) { - super(message, cause); - this.code = code; - details = new HashMap(); - } - - public ErrorCode getErrorCode() { - return code; - } - - public String getErrorMessage() { - return new StringBuilder("Error Code=").append(code).append("; Error Message=").append(super.toString()).toString(); - } - - @Override - public String toString() { - StringBuilder buff = new StringBuilder(); - buff.append("Error Code=").append(code); - buff.append("; Error Message=").append(super.toString()); - if (details.size() > 0) { - buff.append("; Error Details=").append(details.toString()); - } - return buff.toString(); - } -} diff --git a/api/src/com/cloud/exception/ErrorCode.java b/api/src/com/cloud/exception/ErrorCode.java deleted file mode 100755 index 8f048b84800..00000000000 --- a/api/src/com/cloud/exception/ErrorCode.java +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.exception; - -import java.util.HashSet; - -/** - */ -public class ErrorCode { - String code; - private static HashSet s_codes = new HashSet(); - - public ErrorCode(String code) { - this.code = code; - assert !s_codes.contains(this) : "There is already an error code registered for this code: " + code; - s_codes.add(this); - } - - public String getCode() { - return code; - } - - @Override - public int hashCode() { - return code.hashCode(); - } - - @Override - public boolean equals(Object that) { - if (!(that instanceof ErrorCode)) { - return false; - } - - return this.code.equals(((ErrorCode)that).code); - } - - public final static ErrorCode UnableToReachResource = new ErrorCode("resource.unavailable"); -} diff --git a/api/src/com/cloud/user/UserContext.java b/api/src/com/cloud/user/UserContext.java index b140728e596..539e11812af 100644 --- a/api/src/com/cloud/user/UserContext.java +++ b/api/src/com/cloud/user/UserContext.java @@ -50,6 +50,10 @@ public class UserContext { return userId; } + public User getCallerUser() { + return _accountMgr.getActiveUser(userId); + } + public void setCallerUserId(long userId) { this.userId = userId; } diff --git a/api/src/org/apache/cloudstack/api/ServerApiException.java b/api/src/org/apache/cloudstack/api/ServerApiException.java index 70fd34e5cf7..1f57b74745d 100644 --- a/api/src/org/apache/cloudstack/api/ServerApiException.java +++ b/api/src/org/apache/cloudstack/api/ServerApiException.java @@ -15,10 +15,10 @@ // specific language governing permissions and limitations // under the License. package org.apache.cloudstack.api; -import com.cloud.utils.exception.RuntimeCloudException; +import com.cloud.utils.exception.CloudRuntimeException; @SuppressWarnings("serial") -public class ServerApiException extends RuntimeCloudException { +public class ServerApiException extends CloudRuntimeException { private int _errorCode; private String _description; diff --git a/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java b/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java index 132416bac05..bad7ca7b5f6 100644 --- a/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java +++ b/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java @@ -16,11 +16,8 @@ // under the License. package org.apache.cloudstack.api.command.user.discovery; -import com.cloud.user.AccountService; import com.cloud.user.User; import com.cloud.user.UserContext; -import com.cloud.utils.component.Inject; -import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseCmd; @@ -42,16 +39,13 @@ public class ListApisCmd extends BaseCmd { @PlugService ApiDiscoveryService _apiDiscoveryService; - @Inject - private AccountService _accountService; - @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="API name") private String name; @Override public void execute() throws ServerApiException { if (_apiDiscoveryService != null) { - User user = _accountService.getActiveUser(UserContext.current().getCallerUserId()); + User user = UserContext.current().getCallerUser(); ListResponse response = (ListResponse) _apiDiscoveryService.listApis(user, name); if (response == null) { throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Api Discovery plugin was unable to find an api by that name or process any apis"); diff --git a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java index 7e2ed17ecdc..f06e2005552 100644 --- a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java +++ b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java @@ -17,17 +17,13 @@ package org.apache.cloudstack.discovery; import com.cloud.serializer.Param; -import com.cloud.server.ManagementServer; import com.cloud.user.User; import com.cloud.utils.ReflectUtil; import com.cloud.utils.StringUtils; import com.cloud.utils.component.Adapters; import com.cloud.utils.component.ComponentLocator; -import com.cloud.utils.component.Inject; -import com.cloud.utils.component.PluggableService; import com.google.gson.annotations.SerializedName; import org.apache.cloudstack.acl.APIChecker; -import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.BaseAsyncCmd; @@ -54,16 +50,14 @@ import java.util.Set; public class ApiDiscoveryServiceImpl implements ApiDiscoveryService { private static final Logger s_logger = Logger.getLogger(ApiDiscoveryServiceImpl.class); - @Inject(adapter = APIChecker.class) - protected Adapters _apiAccessCheckers; - - private static Map _apiNameDiscoveryResponseMap = null; + protected static Adapters s_apiAccessCheckers = null; + private static Map s_apiNameDiscoveryResponseMap = null; protected ApiDiscoveryServiceImpl() { super(); - if (_apiNameDiscoveryResponseMap == null) { + if (s_apiNameDiscoveryResponseMap == null) { long startTime = System.nanoTime(); - _apiNameDiscoveryResponseMap = new HashMap(); + s_apiNameDiscoveryResponseMap = new HashMap(); cacheResponseMap(); long endTime = System.nanoTime(); s_logger.info("Api Discovery Service: Annotation, docstrings, api relation graph processed in " + (endTime - startTime) / 1000000.0 + " ms"); @@ -142,11 +136,11 @@ public class ApiDiscoveryServiceImpl implements ApiDiscoveryService { } } response.setObjectName("api"); - _apiNameDiscoveryResponseMap.put(apiName, response); + s_apiNameDiscoveryResponseMap.put(apiName, response); } - for (String apiName : _apiNameDiscoveryResponseMap.keySet()) { - ApiDiscoveryResponse response = _apiNameDiscoveryResponseMap.get(apiName); + for (String apiName : s_apiNameDiscoveryResponseMap.keySet()) { + ApiDiscoveryResponse response = s_apiNameDiscoveryResponseMap.get(apiName); Set processedParams = new HashSet(); for (ApiParameterResponse param : response.getParams()) { if (responseApiNameListMap.containsKey(param.getRelated())) { @@ -166,7 +160,7 @@ public class ApiDiscoveryServiceImpl implements ApiDiscoveryService { } else { response.setRelated(null); } - _apiNameDiscoveryResponseMap.put(apiName, response); + s_apiNameDiscoveryResponseMap.put(apiName, response); } } @@ -175,34 +169,39 @@ public class ApiDiscoveryServiceImpl implements ApiDiscoveryService { ListResponse response = new ListResponse(); List responseList = new ArrayList(); + if (s_apiAccessCheckers == null) { + ComponentLocator locator = ComponentLocator.getCurrentLocator(); + s_apiAccessCheckers = locator.getAdapters(APIChecker.class); + } + if (user == null) return null; if (name != null) { - if (!_apiNameDiscoveryResponseMap.containsKey(name)) + if (!s_apiNameDiscoveryResponseMap.containsKey(name)) return null; - for (APIChecker apiChecker : _apiAccessCheckers) { + for (APIChecker apiChecker : s_apiAccessCheckers) { try { apiChecker.checkAccess(user, name); } catch (Exception ex) { return null; } } - responseList.add(_apiNameDiscoveryResponseMap.get(name)); + responseList.add(s_apiNameDiscoveryResponseMap.get(name)); } else { - for (String apiName : _apiNameDiscoveryResponseMap.keySet()) { + for (String apiName : s_apiNameDiscoveryResponseMap.keySet()) { boolean isAllowed = true; - for (APIChecker apiChecker : _apiAccessCheckers) { + for (APIChecker apiChecker : s_apiAccessCheckers) { try { - apiChecker.checkAccess(user, name); + apiChecker.checkAccess(user, apiName); } catch (Exception ex) { isAllowed = false; } } if (isAllowed) - responseList.add(_apiNameDiscoveryResponseMap.get(apiName)); + responseList.add(s_apiNameDiscoveryResponseMap.get(apiName)); } } response.setResponses(responseList); diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorRuntimeException.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorRuntimeException.java index 9891bc82556..9f24bbd0cfc 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorRuntimeException.java +++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorRuntimeException.java @@ -18,12 +18,12 @@ package com.cloud.simulator; import com.cloud.utils.SerialVersionUID; -import com.cloud.utils.exception.RuntimeCloudException; +import com.cloud.utils.exception.CloudRuntimeException; /** * wrap exceptions that you know there's no point in dealing with. */ -public class SimulatorRuntimeException extends RuntimeCloudException { +public class SimulatorRuntimeException extends CloudRuntimeException { private static final long serialVersionUID = SerialVersionUID.CloudRuntimeException; diff --git a/pom.xml b/pom.xml index f752d266a9d..c440a660322 100644 --- a/pom.xml +++ b/pom.xml @@ -244,10 +244,6 @@ dist/console-proxy/js/jquery.js scripts/vm/systemvm/id_rsa.cloud tools/devcloud/basebuild/puppet-devcloudinitial/files/network.conf - tools/devcloud/devcloud.cfg - tools/devcloud/devcloud-advanced.cfg - tools/devcloud-kvm/devcloud-kvm.cfg - tools/devcloud-kvm/devcloud-kvm-advanced.cfg ui/lib/flot/jquery.colorhelpers.js ui/lib/flot/jquery.flot.crosshair.js ui/lib/flot/jquery.flot.fillbetween.js diff --git a/server/src/com/cloud/async/AsyncCommandQueued.java b/server/src/com/cloud/async/AsyncCommandQueued.java index 200b40e71b5..f01c214564b 100644 --- a/server/src/com/cloud/async/AsyncCommandQueued.java +++ b/server/src/com/cloud/async/AsyncCommandQueued.java @@ -17,9 +17,9 @@ package com.cloud.async; import com.cloud.utils.SerialVersionUID; -import com.cloud.utils.exception.RuntimeCloudException; +import com.cloud.utils.exception.CloudRuntimeException; -public class AsyncCommandQueued extends RuntimeCloudException { +public class AsyncCommandQueued extends CloudRuntimeException { private static final long serialVersionUID = SerialVersionUID.AsyncCommandQueued; private SyncQueueVO _queue = null; diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 492e1dc20b1..717da054ac5 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1469,31 +1469,15 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian offeringId = _offering.getId(); } + PublicIp sourceNatIp = null; + if (publicNetwork) { + sourceNatIp = _networkMgr.assignSourceNatIpAddressToGuestNetwork(owner, guestNetwork); + } + // 3) deploy virtual router(s) int count = routerCount - routers.size(); DeploymentPlan plan = planAndRouters.first(); for (int i = 0; i < count; i++) { - PublicIp sourceNatIp = null; - if (publicNetwork) { - int failCount = 0; - // Generate different MAC for VR - while (sourceNatIp == null) { - sourceNatIp = _networkMgr.assignSourceNatIpAddressToGuestNetwork(owner, guestNetwork); - NicVO nic = _nicDao.findByMacAddress(sourceNatIp.getMacAddress()); - // We got duplicate MAC here, so regenerate the mac - if (nic != null) { - s_logger.debug("Failed to find a different mac for redundant router. Try again. The current mac is " + sourceNatIp.getMacAddress()); - sourceNatIp = null; - failCount ++; - } - //Prevent infinite loop - if (failCount > 3) { - s_logger.error("Failed to find a different mac for redundant router! Abort operation!"); - throw new InsufficientAddressCapacityException("Failed to find a different mac for redundant router", null, offeringId); - } - } - } - List> networks = createRouterNetworks(owner, isRedundant, plan, guestNetwork, new Pair(publicNetwork, sourceNatIp)); //don't start the router as we are holding the network lock that needs to be released at the end of router allocation @@ -1715,6 +1699,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian } NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0); List publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false); + String publicIp = defaultNic.getIp4Address(); + // We want to use the identical MAC address for RvR on public interface if possible + NicVO peerNic = _nicDao.findByIp4AddressAndNetworkId(publicIp, publicNetworks.get(0).getId()); + if (peerNic != null) { + s_logger.info("Use same MAC as previous RvR, the MAC is " + peerNic.getMacAddress()); + defaultNic.setMacAddress(peerNic.getMacAddress()); + } networks.add(new Pair(publicNetworks.get(0), defaultNic)); } diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index b25c63f6d7f..7e5f42445d5 100755 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -549,7 +549,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { String username = System.getProperty("user.name"); Boolean devel = Boolean.valueOf(_configDao.getValue("developer")); - if (!username.equalsIgnoreCase("cloud") || !devel) { + if (!username.equalsIgnoreCase("cloud") && !devel) { s_logger.warn("Systemvm keypairs could not be set. Management server should be run as cloud user, or in development mode."); return; } diff --git a/server/src/com/cloud/vm/dao/NicDao.java b/server/src/com/cloud/vm/dao/NicDao.java index af3c7b379c1..762048b65bf 100644 --- a/server/src/com/cloud/vm/dao/NicDao.java +++ b/server/src/com/cloud/vm/dao/NicDao.java @@ -58,6 +58,4 @@ public interface NicDao extends GenericDao { NicVO findByNetworkIdInstanceIdAndBroadcastUri(long networkId, long instanceId, String broadcastUri); NicVO findByIp4AddressAndNetworkIdAndInstanceId(long networkId, long instanceId, String ip4Address); - - NicVO findByMacAddress(String macAddress); } diff --git a/server/src/com/cloud/vm/dao/NicDaoImpl.java b/server/src/com/cloud/vm/dao/NicDaoImpl.java index 00da2eb96a4..3cd7fa6b488 100644 --- a/server/src/com/cloud/vm/dao/NicDaoImpl.java +++ b/server/src/com/cloud/vm/dao/NicDaoImpl.java @@ -50,7 +50,6 @@ public class NicDaoImpl extends GenericDaoBase implements NicDao { AllFieldsSearch.and("address", AllFieldsSearch.entity().getIp4Address(), Op.EQ); AllFieldsSearch.and("isDefault", AllFieldsSearch.entity().isDefaultNic(), Op.EQ); AllFieldsSearch.and("broadcastUri", AllFieldsSearch.entity().getBroadcastUri(), Op.EQ); - AllFieldsSearch.and("macAddress", AllFieldsSearch.entity().getMacAddress(), Op.EQ); AllFieldsSearch.done(); IpSearch = createSearchBuilder(String.class); @@ -200,11 +199,4 @@ public class NicDaoImpl extends GenericDaoBase implements NicDao { sc.setParameters("address", ip4Address); return findOneBy(sc); } - - @Override - public NicVO findByMacAddress(String macAddress) { - SearchCriteria sc = AllFieldsSearch.create(); - sc.setParameters("macAddress", macAddress); - return findOneBy(sc); - } } diff --git a/tools/devcloud-kvm/devcloud-kvm-advanced.cfg b/tools/devcloud-kvm/devcloud-kvm-advanced.cfg index 1110863d848..10cbce00779 100644 --- a/tools/devcloud-kvm/devcloud-kvm-advanced.cfg +++ b/tools/devcloud-kvm/devcloud-kvm-advanced.cfg @@ -1,3 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + + { "zones": [ { diff --git a/tools/devcloud-kvm/devcloud-kvm.cfg b/tools/devcloud-kvm/devcloud-kvm.cfg index 47a128fea14..b3f048aac97 100644 --- a/tools/devcloud-kvm/devcloud-kvm.cfg +++ b/tools/devcloud-kvm/devcloud-kvm.cfg @@ -1,3 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# This is a stock devcloud config converted from the file +# tools/devcloud/devcloud.cfg. + { "zones": [ { diff --git a/tools/devcloud/devcloud-advanced.cfg b/tools/devcloud/devcloud-advanced.cfg index cfbc815dc69..75c3a4f7147 100644 --- a/tools/devcloud/devcloud-advanced.cfg +++ b/tools/devcloud/devcloud-advanced.cfg @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# # This configuration is meant for running advanced networking, with management server on the laptop. # It requires that the user run a DNS resolver within devcloud via 'apt-get install dnsmasq' diff --git a/tools/devcloud/devcloud-advanced_internal-mgt.cfg b/tools/devcloud/devcloud-advanced_internal-mgt.cfg index e360b6b9e37..a1a8cb54722 100644 --- a/tools/devcloud/devcloud-advanced_internal-mgt.cfg +++ b/tools/devcloud/devcloud-advanced_internal-mgt.cfg @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# # This config is designed to run as an advanced network, with management server in devcloud # It also requires an 'apt-get install dnsmasq' to run a resolver in devcloud for internal dns diff --git a/tools/devcloud/devcloud.cfg b/tools/devcloud/devcloud.cfg index 8d296eb7b98..c41f8bcef58 100644 --- a/tools/devcloud/devcloud.cfg +++ b/tools/devcloud/devcloud.cfg @@ -1,3 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + { "zones": [ { diff --git a/utils/src/com/cloud/utils/exception/CloudRuntimeException.java b/utils/src/com/cloud/utils/exception/CloudRuntimeException.java index 78075947d3f..3862e2223d6 100755 --- a/utils/src/com/cloud/utils/exception/CloudRuntimeException.java +++ b/utils/src/com/cloud/utils/exception/CloudRuntimeException.java @@ -16,24 +16,62 @@ // under the License. package com.cloud.utils.exception; +import java.util.ArrayList; + +import com.cloud.utils.AnnotationHelper; import com.cloud.utils.SerialVersionUID; /** * wrap exceptions that you know there's no point in dealing with. */ -public class CloudRuntimeException extends RuntimeCloudException { +public class CloudRuntimeException extends RuntimeException { private static final long serialVersionUID = SerialVersionUID.CloudRuntimeException; - + + // This holds a list of uuids and their names. Add uuid:fieldname pairs + protected ArrayList idList = new ArrayList(); + + protected int csErrorCode; + + public CloudRuntimeException(String message) { super(message); + setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName())); } - + public CloudRuntimeException(String message, Throwable th) { super(message, th); + setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName())); } - - protected CloudRuntimeException() { + + public CloudRuntimeException() { super(); + setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName())); + } + + public void addProxyObject(String uuid) { + idList.add(uuid); + return; + } + + public void addProxyObject(Object voObj, Long id, String idFieldName) { + // Get the VO object's table name. + String tablename = AnnotationHelper.getTableName(voObj); + if (tablename != null) { + addProxyObject(tablename, id, idFieldName); + } + return; + } + + public ArrayList getIdProxyList() { + return idList; + } + + public void setCSErrorCode(int cserrcode) { + this.csErrorCode = cserrcode; + } + + public int getCSErrorCode() { + return this.csErrorCode; } } diff --git a/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java b/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java index 4f637cb46be..2c0c1ccd68b 100755 --- a/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java +++ b/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java @@ -18,10 +18,10 @@ package com.cloud.utils.exception; import com.cloud.utils.SerialVersionUID; -public class HypervisorVersionChangedException extends RuntimeCloudException { +public class HypervisorVersionChangedException extends CloudRuntimeException { private static final long serialVersionUID = SerialVersionUID.CloudRuntimeException; - + public HypervisorVersionChangedException(String message) { super(message); } diff --git a/utils/src/com/cloud/utils/exception/RuntimeCloudException.java b/utils/src/com/cloud/utils/exception/RuntimeCloudException.java deleted file mode 100644 index 52229800785..00000000000 --- a/utils/src/com/cloud/utils/exception/RuntimeCloudException.java +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.utils.exception; - -import com.cloud.utils.AnnotationHelper; -import java.util.ArrayList; - -/** - * by the API response serializer. Any exceptions that are thrown by - * class, which extends Exception instead of RuntimeException like this - * class does. - */ - -public class RuntimeCloudException extends RuntimeException { - - // This holds a list of uuids and their names. Add uuid:fieldname pairs - protected ArrayList idList = new ArrayList(); - - protected int csErrorCode; - - public void addProxyObject(String uuid) { - idList.add(uuid); - return; - } - - public RuntimeCloudException(String message) { - super(message); - setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName())); - } - - public RuntimeCloudException(String message, Throwable cause) { - super(message, cause); - setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName())); - } - - public void addProxyObject(Object voObj, Long id, String idFieldName) { - // Get the VO object's table name. - String tablename = AnnotationHelper.getTableName(voObj); - if (tablename != null) { - addProxyObject(tablename, id, idFieldName); - } - return; - } - - public RuntimeCloudException() { - super(); - setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName())); - } - - public ArrayList getIdProxyList() { - return idList; - } - - public void setCSErrorCode(int cserrcode) { - this.csErrorCode = cserrcode; - } - - public int getCSErrorCode() { - return this.csErrorCode; - } -}