From e7a18628673baf26b256897755c56c56b714fdff Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Fri, 3 Aug 2012 11:47:04 -0700 Subject: [PATCH] VPC: CS-15827 - register only VpcVirtualNetworkApplianceMgr Conflicts: api/src/com/cloud/api/BaseCmd.java api/src/com/cloud/network/VpcVirtualNetworkApplianceService.java plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java server/src/com/cloud/configuration/DefaultComponentLibrary.java server/src/com/cloud/ha/UserVmDomRInvestigator.java --- api/src/com/cloud/api/BaseCmd.java | 931 +++++++++--------- .../VpcVirtualNetworkApplianceService.java | 2 +- .../vmware/manager/VmwareManagerImpl.java | 3 - .../lb/ElasticLoadBalancerManagerImpl.java | 4 +- .../src/com/cloud/configuration/Config.java | 4 +- .../DefaultComponentLibrary.java | 2 - .../com/cloud/ha/UserVmDomRInvestigator.java | 8 +- .../cloud/network/SshKeysDistriMonitor.java | 5 - .../element/CloudZonesNetworkElement.java | 3 - .../network/element/VirtualRouterElement.java | 4 +- ...VpcVirtualNetworkApplianceManagerImpl.java | 2 + .../vpn/RemoteAccessVpnManagerImpl.java | 2 - .../com/cloud/storage/StorageManagerImpl.java | 3 - .../com/cloud/upgrade/dao/Upgrade218to22.java | 6 +- 14 files changed, 483 insertions(+), 496 deletions(-) diff --git a/api/src/com/cloud/api/BaseCmd.java b/api/src/com/cloud/api/BaseCmd.java index 720218b104c..fc6b2a537b4 100755 --- a/api/src/com/cloud/api/BaseCmd.java +++ b/api/src/com/cloud/api/BaseCmd.java @@ -14,10 +14,12 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api; - + +package com.cloud.api; + import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -39,7 +41,7 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.NetworkService; import com.cloud.network.StorageNetworkService; -import com.cloud.network.VirtualNetworkApplianceService; +import com.cloud.network.VpcVirtualNetworkApplianceService; import com.cloud.network.firewall.FirewallService; import com.cloud.network.firewall.NetworkACLService; import com.cloud.network.lb.LoadBalancingRulesService; @@ -60,468 +62,469 @@ import com.cloud.user.Account; import com.cloud.user.AccountService; import com.cloud.user.DomainService; import com.cloud.user.ResourceLimitService; +import com.cloud.utils.IdentityProxy; import com.cloud.utils.Pair; import com.cloud.utils.component.ComponentLocator; import com.cloud.vm.BareMetalVmService; import com.cloud.vm.UserVmService; - -public abstract class BaseCmd { - private static final Logger s_logger = Logger.getLogger(BaseCmd.class.getName()); - - public static final String USER_ERROR_MESSAGE = "Internal error executing command, please contact your system administrator"; - public static final int PROGRESS_INSTANCE_CREATED = 1; - - public static final String RESPONSE_TYPE_XML = "xml"; - public static final String RESPONSE_TYPE_JSON = "json"; - - public enum CommandType { - BOOLEAN, DATE, FLOAT, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE - } - - // FIXME: Extract these out into a separate file - // Client error codes - public static final int MALFORMED_PARAMETER_ERROR = 430; - public static final int PARAM_ERROR = 431; - public static final int UNSUPPORTED_ACTION_ERROR = 432; - public static final int PAGE_LIMIT_EXCEED = 433; - - // Server error codes - public static final int INTERNAL_ERROR = 530; - public static final int ACCOUNT_ERROR = 531; - public static final int ACCOUNT_RESOURCE_LIMIT_ERROR = 532; - public static final int INSUFFICIENT_CAPACITY_ERROR = 533; - public static final int RESOURCE_UNAVAILABLE_ERROR = 534; - public static final int RESOURCE_ALLOCATION_ERROR = 534; - public static final int RESOURCE_IN_USE_ERROR = 536; - public static final int NETWORK_RULE_CONFLICT_ERROR = 537; - - public static final DateFormat INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); - public static final DateFormat NEW_INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - public static Pattern newInputDateFormat = Pattern.compile("[\\d]+-[\\d]+-[\\d]+ [\\d]+:[\\d]+:[\\d]+"); - private static final DateFormat _outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); - - private Object _responseObject = null; - private Map fullUrlParams; - - @Parameter(name = "response", type = CommandType.STRING) - private String responseType; - - public static ComponentLocator s_locator; - public static ConfigurationService _configService; - public static AccountService _accountService; - public static UserVmService _userVmService; - public static ManagementService _mgr; - public static StorageService _storageService; - public static ResourceService _resourceService; - public static NetworkService _networkService; - public static TemplateService _templateService; - public static SecurityGroupService _securityGroupService; - public static SnapshotService _snapshotService; - public static ConsoleProxyService _consoleProxyService; - public static VirtualNetworkApplianceService _routerService; - public static ResponseGenerator _responseGenerator; - public static EntityManager _entityMgr; - public static RulesService _rulesService; - public static LoadBalancingRulesService _lbService; - public static RemoteAccessVpnService _ravService; - public static BareMetalVmService _bareMetalVmService; - public static ProjectService _projectService; - public static FirewallService _firewallService; - public static DomainService _domainService; - public static ResourceLimitService _resourceLimitService; - public static IdentityService _identityService; - public static StorageNetworkService _storageNetworkService; - public static VpcService _vpcService; - public static NetworkACLService _networkACLService; - public static TaggedResourceService _taggedResourceService; - public static Site2SiteVpnService _s2sVpnService; - - static void setComponents(ResponseGenerator generator) { - ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name); - _mgr = (ManagementService) ComponentLocator.getComponent(ManagementService.Name); - _accountService = locator.getManager(AccountService.class); - _configService = locator.getManager(ConfigurationService.class); - _userVmService = locator.getManager(UserVmService.class); - _storageService = locator.getManager(StorageService.class); - _resourceService = locator.getManager(ResourceService.class); - _networkService = locator.getManager(NetworkService.class); - _templateService = locator.getManager(TemplateService.class); - _securityGroupService = locator.getManager(SecurityGroupService.class); - _snapshotService = locator.getManager(SnapshotService.class); - _consoleProxyService = locator.getManager(ConsoleProxyService.class); - _routerService = locator.getManager(VirtualNetworkApplianceService.class); - _entityMgr = locator.getManager(EntityManager.class); - _rulesService = locator.getManager(RulesService.class); - _lbService = locator.getManager(LoadBalancingRulesService.class); - _ravService = locator.getManager(RemoteAccessVpnService.class); - _responseGenerator = generator; - _bareMetalVmService = locator.getManager(BareMetalVmService.class); - _projectService = locator.getManager(ProjectService.class); - _firewallService = locator.getManager(FirewallService.class); - _domainService = locator.getManager(DomainService.class); - _resourceLimitService = locator.getManager(ResourceLimitService.class); - _identityService = locator.getManager(IdentityService.class); - _storageNetworkService = locator.getManager(StorageNetworkService.class); - _vpcService = locator.getManager(VpcService.class); - _networkACLService = locator.getManager(NetworkACLService.class); - _taggedResourceService = locator.getManager(TaggedResourceService.class); - _s2sVpnService = locator.getManager(Site2SiteVpnService.class); - } - - public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException; - - public String getResponseType() { - if (responseType == null) { - return RESPONSE_TYPE_XML; - } - return responseType; - } - - public void setResponseType(String responseType) { - this.responseType = responseType; - } - - public abstract String getCommandName(); - - /** - * For commands the API framework needs to know the owner of the object being acted upon. This method is - * used to determine that information. - * - * @return the id of the account that owns the object being acted upon - */ - public abstract long getEntityOwnerId(); - - public Object getResponseObject() { - return _responseObject; - } - - public void setResponseObject(Object responseObject) { - _responseObject = responseObject; - } - - public ManagementService getMgmtServiceRef() { - return _mgr; - } - - public static String getDateString(Date date) { - if (date == null) { - return ""; - } - String formattedString = null; - synchronized (_outputFormat) { - formattedString = _outputFormat.format(date); - } - return formattedString; - } - - // FIXME: move this to a utils method so that maps can be unpacked and integer/long values can be appropriately cast - @SuppressWarnings({ "unchecked", "rawtypes" }) - public Map unpackParams(Map params) { - Map lowercaseParams = new HashMap(); - for (String key : params.keySet()) { - int arrayStartIndex = key.indexOf('['); - int arrayStartLastIndex = key.lastIndexOf('['); - if (arrayStartIndex != arrayStartLastIndex) { - throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key - + "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); - } - - if (arrayStartIndex > 0) { - int arrayEndIndex = key.indexOf(']'); - int arrayEndLastIndex = key.lastIndexOf(']'); - if ((arrayEndIndex < arrayStartIndex) || (arrayEndIndex != arrayEndLastIndex)) { - // malformed parameter - throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key - + "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); - } - - // Now that we have an array object, check for a field name in the case of a complex object - int fieldIndex = key.indexOf('.'); - String fieldName = null; - if (fieldIndex < arrayEndIndex) { - throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key - + "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); - } else { - fieldName = key.substring(fieldIndex + 1); - } - - // parse the parameter name as the text before the first '[' character - String paramName = key.substring(0, arrayStartIndex); - paramName = paramName.toLowerCase(); - - Map mapArray = null; - Map mapValue = null; - String indexStr = key.substring(arrayStartIndex + 1, arrayEndIndex); - int index = 0; - boolean parsedIndex = false; - try { - if (indexStr != null) { - index = Integer.parseInt(indexStr); - parsedIndex = true; - } - } catch (NumberFormatException nfe) { - s_logger.warn("Invalid parameter " + key + " received, unable to parse object array, returning an error."); - } - - if (!parsedIndex) { - throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key - + "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); - } - - Object value = lowercaseParams.get(paramName); - if (value == null) { - // for now, assume object array with sub fields - mapArray = new HashMap(); - mapValue = new HashMap(); - mapArray.put(Integer.valueOf(index), mapValue); - } else if (value instanceof Map) { - mapArray = (HashMap) value; - mapValue = mapArray.get(Integer.valueOf(index)); - if (mapValue == null) { - mapValue = new HashMap(); - mapArray.put(Integer.valueOf(index), mapValue); - } - } - - // we are ready to store the value for a particular field into the map for this object - mapValue.put(fieldName, params.get(key)); - - lowercaseParams.put(paramName, mapArray); - } else { - lowercaseParams.put(key.toLowerCase(), params.get(key)); - } - } - return lowercaseParams; - } - - public String buildResponse(ServerApiException apiException, String responseType) { - StringBuffer sb = new StringBuffer(); - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - // JSON response - sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},"); - sb.append("\"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }"); - } else { - sb.append(""); - sb.append("<" + getCommandName() + ">"); - sb.append("" + apiException.getErrorCode() + ""); - sb.append("" + escapeXml(apiException.getDescription()) + ""); - sb.append(""); - } - return sb.toString(); - } - - public String buildResponse(List> tagList, String responseType) { - StringBuffer prefixSb = new StringBuffer(); - StringBuffer suffixSb = new StringBuffer(); - - // set up the return value with the name of the response - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - prefixSb.append("{ \"" + getCommandName() + "\" : { \"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},"); - } else { - prefixSb.append(""); - prefixSb.append("<" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">"); - } - - int i = 0; - for (Pair tagData : tagList) { - String tagName = tagData.first(); - Object tagValue = tagData.second(); - if (tagValue instanceof Object[]) { - Object[] subObjects = (Object[]) tagValue; - if (subObjects.length < 1) { - continue; - } - writeObjectArray(responseType, suffixSb, i++, tagName, subObjects); - } else { - writeNameValuePair(suffixSb, tagName, tagValue, responseType, i++); - } - } - - if (suffixSb.length() > 0) { - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { // append comma only if we have some suffix else -// not as per strict Json syntax. - prefixSb.append(","); - } - prefixSb.append(suffixSb); - } - // close the response - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - prefixSb.append("} }"); - } else { - prefixSb.append(""); - } - return prefixSb.toString(); - } - - private void writeNameValuePair(StringBuffer sb, String tagName, Object tagValue, String responseType, int propertyCount) { - if (tagValue == null) { - return; - } - - if (tagValue instanceof Object[]) { - Object[] subObjects = (Object[]) tagValue; - if (subObjects.length < 1) { - return; - } - writeObjectArray(responseType, sb, propertyCount, tagName, subObjects); - } else { - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - String seperator = ((propertyCount > 0) ? ", " : ""); - sb.append(seperator + "\"" + tagName + "\" : \"" + escapeJSON(tagValue.toString()) + "\""); - } else { - sb.append("<" + tagName + ">" + escapeXml(tagValue.toString()) + ""); - } - } - } - - @SuppressWarnings("rawtypes") - private void writeObjectArray(String responseType, StringBuffer sb, int propertyCount, String tagName, Object[] subObjects) { - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - String separator = ((propertyCount > 0) ? ", " : ""); - sb.append(separator); - } - int j = 0; - for (Object subObject : subObjects) { - if (subObject instanceof List) { - List subObjList = (List) subObject; - writeSubObject(sb, tagName, subObjList, responseType, j++); - } - } - - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - sb.append("]"); - } - } - - @SuppressWarnings("rawtypes") - private void writeSubObject(StringBuffer sb, String tagName, List tagList, String responseType, int objectCount) { - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - sb.append(((objectCount == 0) ? "\"" + tagName + "\" : [ { " : ", { ")); - } else { - sb.append("<" + tagName + ">"); - } - - int i = 0; - for (Object tag : tagList) { - if (tag instanceof Pair) { - Pair nameValuePair = (Pair) tag; - writeNameValuePair(sb, (String) nameValuePair.first(), nameValuePair.second(), responseType, i++); - } - } - - if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { - sb.append("}"); - } else { - sb.append(""); - } - } - - /** - * Escape xml response set to false by default. API commands to override this method to allow escaping - */ - public boolean requireXmlEscape() { - return true; - } - - private String escapeXml(String xml) { - if (!requireXmlEscape()) { - return xml; - } - int iLen = xml.length(); - if (iLen == 0) { - return xml; - } - StringBuffer sOUT = new StringBuffer(iLen + 256); - int i = 0; - for (; i < iLen; i++) { - char c = xml.charAt(i); - if (c == '<') { - sOUT.append("<"); - } else if (c == '>') { - sOUT.append(">"); - } else if (c == '&') { - sOUT.append("&"); - } else if (c == '"') { - sOUT.append("""); - } else if (c == '\'') { - sOUT.append("'"); - } else { - sOUT.append(c); - } - } - return sOUT.toString(); - } - - private static String escapeJSON(String str) { - if (str == null) { - return str; - } - - return str.replace("\"", "\\\""); - } - - protected long getInstanceIdFromJobSuccessResult(String result) { - s_logger.debug("getInstanceIdFromJobSuccessResult not overridden in subclass " + this.getClass().getName()); - return 0; - } - - public static boolean isAdmin(short accountType) { - return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || - (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) || - (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)); - } - - public static boolean isRootAdmin(short accountType) { - return ((accountType == Account.ACCOUNT_TYPE_ADMIN)); - } - - public void setFullUrlParams(Map map) { - this.fullUrlParams = map; - } - - public Map getFullUrlParams() { - return this.fullUrlParams; - } - - public Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly) { - if (accountName != null) { - if (domainId == null) { - throw new InvalidParameterValueException("Account must be specified with domainId parameter"); - } - - Domain domain = _domainService.getDomain(domainId); - if (domain == null) { - throw new InvalidParameterValueException("Unable to find domain by id=" + domainId); - } - - Account account = _accountService.getActiveAccountByName(accountName, domainId); - if (account != null && account.getType() != Account.ACCOUNT_TYPE_PROJECT) { - if (!enabledOnly || account.getState() == Account.State.enabled) { - return account.getId(); - } else { - throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + " as it's no longer active"); - } - } else { - throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain id=" + domainId); - } - } - - if (projectId != null) { - Project project = _projectService.getProject(projectId); - if (project != null) { - if (!enabledOnly || project.getState() == Project.State.Active) { - return project.getProjectAccountId(); - } else { - PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() + " as it's no longer active"); - ex.addProxyObject(project, projectId, "projectId"); - throw ex; - } - } else { - InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified projectId"); - ex.addProxyObject(project, projectId, "projectId"); - throw ex; - } - } - return null; - } -} + +public abstract class BaseCmd { + private static final Logger s_logger = Logger.getLogger(BaseCmd.class.getName()); + + public static final String USER_ERROR_MESSAGE = "Internal error executing command, please contact your system administrator"; + public static final int PROGRESS_INSTANCE_CREATED = 1; + + public static final String RESPONSE_TYPE_XML = "xml"; + public static final String RESPONSE_TYPE_JSON = "json"; + + public enum CommandType { + BOOLEAN, DATE, FLOAT, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE + } + + // FIXME: Extract these out into a separate file + // Client error codes + public static final int MALFORMED_PARAMETER_ERROR = 430; + public static final int PARAM_ERROR = 431; + public static final int UNSUPPORTED_ACTION_ERROR = 432; + public static final int PAGE_LIMIT_EXCEED = 433; + + // Server error codes + public static final int INTERNAL_ERROR = 530; + public static final int ACCOUNT_ERROR = 531; + public static final int ACCOUNT_RESOURCE_LIMIT_ERROR = 532; + public static final int INSUFFICIENT_CAPACITY_ERROR = 533; + public static final int RESOURCE_UNAVAILABLE_ERROR = 534; + public static final int RESOURCE_ALLOCATION_ERROR = 534; + public static final int RESOURCE_IN_USE_ERROR = 536; + public static final int NETWORK_RULE_CONFLICT_ERROR = 537; + + public static final DateFormat INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); + public static final DateFormat NEW_INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public static Pattern newInputDateFormat = Pattern.compile("[\\d]+-[\\d]+-[\\d]+ [\\d]+:[\\d]+:[\\d]+"); + private static final DateFormat _outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); + + private Object _responseObject = null; + private Map fullUrlParams; + + @Parameter(name = "response", type = CommandType.STRING) + private String responseType; + + public static ComponentLocator s_locator; + public static ConfigurationService _configService; + public static AccountService _accountService; + public static UserVmService _userVmService; + public static ManagementService _mgr; + public static StorageService _storageService; + public static ResourceService _resourceService; + public static NetworkService _networkService; + public static TemplateService _templateService; + public static SecurityGroupService _securityGroupService; + public static SnapshotService _snapshotService; + public static ConsoleProxyService _consoleProxyService; + public static VpcVirtualNetworkApplianceService _routerService; + public static ResponseGenerator _responseGenerator; + public static EntityManager _entityMgr; + public static RulesService _rulesService; + public static LoadBalancingRulesService _lbService; + public static RemoteAccessVpnService _ravService; + public static BareMetalVmService _bareMetalVmService; + public static ProjectService _projectService; + public static FirewallService _firewallService; + public static DomainService _domainService; + public static ResourceLimitService _resourceLimitService; + public static IdentityService _identityService; + public static StorageNetworkService _storageNetworkService; + public static TaggedResourceService _taggedResourceService; + public static VpcService _vpcService; + public static NetworkACLService _networkACLService; + public static Site2SiteVpnService _s2sVpnService; + + static void setComponents(ResponseGenerator generator) { + ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name); + _mgr = (ManagementService) ComponentLocator.getComponent(ManagementService.Name); + _accountService = locator.getManager(AccountService.class); + _configService = locator.getManager(ConfigurationService.class); + _userVmService = locator.getManager(UserVmService.class); + _storageService = locator.getManager(StorageService.class); + _resourceService = locator.getManager(ResourceService.class); + _networkService = locator.getManager(NetworkService.class); + _templateService = locator.getManager(TemplateService.class); + _securityGroupService = locator.getManager(SecurityGroupService.class); + _snapshotService = locator.getManager(SnapshotService.class); + _consoleProxyService = locator.getManager(ConsoleProxyService.class); + _routerService = locator.getManager(VpcVirtualNetworkApplianceService.class); + _entityMgr = locator.getManager(EntityManager.class); + _rulesService = locator.getManager(RulesService.class); + _lbService = locator.getManager(LoadBalancingRulesService.class); + _ravService = locator.getManager(RemoteAccessVpnService.class); + _responseGenerator = generator; + _bareMetalVmService = locator.getManager(BareMetalVmService.class); + _projectService = locator.getManager(ProjectService.class); + _firewallService = locator.getManager(FirewallService.class); + _domainService = locator.getManager(DomainService.class); + _resourceLimitService = locator.getManager(ResourceLimitService.class); + _identityService = locator.getManager(IdentityService.class); + _storageNetworkService = locator.getManager(StorageNetworkService.class); + _taggedResourceService = locator.getManager(TaggedResourceService.class); + _vpcService = locator.getManager(VpcService.class); + _networkACLService = locator.getManager(NetworkACLService.class); + _s2sVpnService = locator.getManager(Site2SiteVpnService.class); + } + + public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException; + + public String getResponseType() { + if (responseType == null) { + return RESPONSE_TYPE_XML; + } + return responseType; + } + + public void setResponseType(String responseType) { + this.responseType = responseType; + } + + public abstract String getCommandName(); + + /** + * For commands the API framework needs to know the owner of the object being acted upon. This method is + * used to determine that information. + * + * @return the id of the account that owns the object being acted upon + */ + public abstract long getEntityOwnerId(); + + public Object getResponseObject() { + return _responseObject; + } + + public void setResponseObject(Object responseObject) { + _responseObject = responseObject; + } + + public ManagementService getMgmtServiceRef() { + return _mgr; + } + + public static String getDateString(Date date) { + if (date == null) { + return ""; + } + String formattedString = null; + synchronized (_outputFormat) { + formattedString = _outputFormat.format(date); + } + return formattedString; + } + + // FIXME: move this to a utils method so that maps can be unpacked and integer/long values can be appropriately cast + @SuppressWarnings({ "unchecked", "rawtypes" }) + public Map unpackParams(Map params) { + Map lowercaseParams = new HashMap(); + for (String key : params.keySet()) { + int arrayStartIndex = key.indexOf('['); + int arrayStartLastIndex = key.lastIndexOf('['); + if (arrayStartIndex != arrayStartLastIndex) { + throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key + + "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); + } + + if (arrayStartIndex > 0) { + int arrayEndIndex = key.indexOf(']'); + int arrayEndLastIndex = key.lastIndexOf(']'); + if ((arrayEndIndex < arrayStartIndex) || (arrayEndIndex != arrayEndLastIndex)) { + // malformed parameter + throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key + + "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); + } + + // Now that we have an array object, check for a field name in the case of a complex object + int fieldIndex = key.indexOf('.'); + String fieldName = null; + if (fieldIndex < arrayEndIndex) { + throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key + + "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); + } else { + fieldName = key.substring(fieldIndex + 1); + } + + // parse the parameter name as the text before the first '[' character + String paramName = key.substring(0, arrayStartIndex); + paramName = paramName.toLowerCase(); + + Map mapArray = null; + Map mapValue = null; + String indexStr = key.substring(arrayStartIndex + 1, arrayEndIndex); + int index = 0; + boolean parsedIndex = false; + try { + if (indexStr != null) { + index = Integer.parseInt(indexStr); + parsedIndex = true; + } + } catch (NumberFormatException nfe) { + s_logger.warn("Invalid parameter " + key + " received, unable to parse object array, returning an error."); + } + + if (!parsedIndex) { + throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key + + "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); + } + + Object value = lowercaseParams.get(paramName); + if (value == null) { + // for now, assume object array with sub fields + mapArray = new HashMap(); + mapValue = new HashMap(); + mapArray.put(Integer.valueOf(index), mapValue); + } else if (value instanceof Map) { + mapArray = (HashMap) value; + mapValue = mapArray.get(Integer.valueOf(index)); + if (mapValue == null) { + mapValue = new HashMap(); + mapArray.put(Integer.valueOf(index), mapValue); + } + } + + // we are ready to store the value for a particular field into the map for this object + mapValue.put(fieldName, params.get(key)); + + lowercaseParams.put(paramName, mapArray); + } else { + lowercaseParams.put(key.toLowerCase(), params.get(key)); + } + } + return lowercaseParams; + } + + public String buildResponse(ServerApiException apiException, String responseType) { + StringBuffer sb = new StringBuffer(); + if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { + // JSON response + sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},"); + sb.append("\"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }"); + } else { + sb.append(""); + sb.append("<" + getCommandName() + ">"); + sb.append("" + apiException.getErrorCode() + ""); + sb.append("" + escapeXml(apiException.getDescription()) + ""); + sb.append(""); + } + return sb.toString(); + } + + public String buildResponse(List> tagList, String responseType) { + StringBuffer prefixSb = new StringBuffer(); + StringBuffer suffixSb = new StringBuffer(); + + // set up the return value with the name of the response + if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { + prefixSb.append("{ \"" + getCommandName() + "\" : { \"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},"); + } else { + prefixSb.append(""); + prefixSb.append("<" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">"); + } + + int i = 0; + for (Pair tagData : tagList) { + String tagName = tagData.first(); + Object tagValue = tagData.second(); + if (tagValue instanceof Object[]) { + Object[] subObjects = (Object[]) tagValue; + if (subObjects.length < 1) { + continue; + } + writeObjectArray(responseType, suffixSb, i++, tagName, subObjects); + } else { + writeNameValuePair(suffixSb, tagName, tagValue, responseType, i++); + } + } + + if (suffixSb.length() > 0) { + if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { // append comma only if we have some suffix else +// not as per strict Json syntax. + prefixSb.append(","); + } + prefixSb.append(suffixSb); + } + // close the response + if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { + prefixSb.append("} }"); + } else { + prefixSb.append(""); + } + return prefixSb.toString(); + } + + private void writeNameValuePair(StringBuffer sb, String tagName, Object tagValue, String responseType, int propertyCount) { + if (tagValue == null) { + return; + } + + if (tagValue instanceof Object[]) { + Object[] subObjects = (Object[]) tagValue; + if (subObjects.length < 1) { + return; + } + writeObjectArray(responseType, sb, propertyCount, tagName, subObjects); + } else { + if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { + String seperator = ((propertyCount > 0) ? ", " : ""); + sb.append(seperator + "\"" + tagName + "\" : \"" + escapeJSON(tagValue.toString()) + "\""); + } else { + sb.append("<" + tagName + ">" + escapeXml(tagValue.toString()) + ""); + } + } + } + + @SuppressWarnings("rawtypes") + private void writeObjectArray(String responseType, StringBuffer sb, int propertyCount, String tagName, Object[] subObjects) { + if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { + String separator = ((propertyCount > 0) ? ", " : ""); + sb.append(separator); + } + int j = 0; + for (Object subObject : subObjects) { + if (subObject instanceof List) { + List subObjList = (List) subObject; + writeSubObject(sb, tagName, subObjList, responseType, j++); + } + } + + if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { + sb.append("]"); + } + } + + @SuppressWarnings("rawtypes") + private void writeSubObject(StringBuffer sb, String tagName, List tagList, String responseType, int objectCount) { + if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { + sb.append(((objectCount == 0) ? "\"" + tagName + "\" : [ { " : ", { ")); + } else { + sb.append("<" + tagName + ">"); + } + + int i = 0; + for (Object tag : tagList) { + if (tag instanceof Pair) { + Pair nameValuePair = (Pair) tag; + writeNameValuePair(sb, (String) nameValuePair.first(), nameValuePair.second(), responseType, i++); + } + } + + if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { + sb.append("}"); + } else { + sb.append(""); + } + } + + /** + * Escape xml response set to false by default. API commands to override this method to allow escaping + */ + public boolean requireXmlEscape() { + return true; + } + + private String escapeXml(String xml) { + if (!requireXmlEscape()) { + return xml; + } + int iLen = xml.length(); + if (iLen == 0) { + return xml; + } + StringBuffer sOUT = new StringBuffer(iLen + 256); + int i = 0; + for (; i < iLen; i++) { + char c = xml.charAt(i); + if (c == '<') { + sOUT.append("<"); + } else if (c == '>') { + sOUT.append(">"); + } else if (c == '&') { + sOUT.append("&"); + } else if (c == '"') { + sOUT.append("""); + } else if (c == '\'') { + sOUT.append("'"); + } else { + sOUT.append(c); + } + } + return sOUT.toString(); + } + + private static String escapeJSON(String str) { + if (str == null) { + return str; + } + + return str.replace("\"", "\\\""); + } + + protected long getInstanceIdFromJobSuccessResult(String result) { + s_logger.debug("getInstanceIdFromJobSuccessResult not overridden in subclass " + this.getClass().getName()); + return 0; + } + + public static boolean isAdmin(short accountType) { + return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || + (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) || + (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)); + } + + public static boolean isRootAdmin(short accountType) { + return ((accountType == Account.ACCOUNT_TYPE_ADMIN)); + } + + public void setFullUrlParams(Map map) { + this.fullUrlParams = map; + } + + public Map getFullUrlParams() { + return this.fullUrlParams; + } + + public Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly) { + if (accountName != null) { + if (domainId == null) { + throw new InvalidParameterValueException("Account must be specified with domainId parameter"); + } + + Domain domain = _domainService.getDomain(domainId); + if (domain == null) { + throw new InvalidParameterValueException("Unable to find domain by id"); + } + + Account account = _accountService.getActiveAccountByName(accountName, domainId); + if (account != null && account.getType() != Account.ACCOUNT_TYPE_PROJECT) { + if (!enabledOnly || account.getState() == Account.State.enabled) { + return account.getId(); + } else { + throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + " as it's no longer active"); + } + } else { + List idList = new ArrayList(); + idList.add(new IdentityProxy("domain", domainId, "domainId")); + throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain with specified id"); + } + } + + if (projectId != null) { + Project project = _projectService.getProject(projectId); + if (project != null) { + if (!enabledOnly || project.getState() == Project.State.Active) { + return project.getProjectAccountId(); + } else { + PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() + " as it's no longer active"); + ex.addProxyObject(project, projectId, "projectId"); + throw ex; + } + } else { + throw new InvalidParameterValueException("Unable to find project by id"); + } + } + return null; + } +} diff --git a/api/src/com/cloud/network/VpcVirtualNetworkApplianceService.java b/api/src/com/cloud/network/VpcVirtualNetworkApplianceService.java index b597463ba83..03eb576bc8d 100644 --- a/api/src/com/cloud/network/VpcVirtualNetworkApplianceService.java +++ b/api/src/com/cloud/network/VpcVirtualNetworkApplianceService.java @@ -21,7 +21,7 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.router.VirtualRouter; -public interface VpcVirtualNetworkApplianceService { +public interface VpcVirtualNetworkApplianceService extends VirtualNetworkApplianceService{ /** * @param router diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java index debb6fe38b2..91c52e52571 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java @@ -71,7 +71,6 @@ import com.cloud.hypervisor.vmware.util.VmwareContext; import com.cloud.network.CiscoNexusVSMDeviceVO; import com.cloud.network.NetworkManager; import com.cloud.network.dao.CiscoNexusVSMDeviceDao; -import com.cloud.network.router.VirtualNetworkApplianceManager; import com.cloud.org.Cluster.ClusterType; import com.cloud.secstorage.CommandExecLogDao; import com.cloud.serializer.GsonHelper; @@ -93,7 +92,6 @@ import com.cloud.vm.DomainRouterVO; import com.google.gson.Gson; import com.vmware.apputils.vim25.ServiceUtil; import com.vmware.vim25.HostConnectSpec; -import com.vmware.vim25.HostPortGroupSpec; import com.vmware.vim25.ManagedObjectReference; @Local(value = {VmwareManager.class}) @@ -118,7 +116,6 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis @Inject CommandExecLogDao _cmdExecLogDao; @Inject ClusterManager _clusterMgr; @Inject CheckPointManager _checkPointMgr; - @Inject VirtualNetworkApplianceManager _routerMgr; @Inject SecondaryStorageVmManager _ssvmMgr; @Inject CiscoNexusVSMDeviceDao _nexusDao; @Inject ClusterVSMMapDao _vsmMapDao; diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index bfa44c84f7c..1c40516ad16 100644 --- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -93,10 +93,10 @@ import com.cloud.network.dao.VirtualRouterProviderDao; import com.cloud.network.lb.LoadBalancingRule.LbDestination; import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy; import com.cloud.network.lb.dao.ElasticLbVmMapDao; -import com.cloud.network.router.VirtualNetworkApplianceManager; import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter.RedundantState; import com.cloud.network.router.VirtualRouter.Role; +import com.cloud.network.router.VpcVirtualNetworkApplianceManager; import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.FirewallRule.Purpose; import com.cloud.network.rules.LoadBalancer; @@ -153,7 +153,7 @@ public class ElasticLoadBalancerManagerImpl implements @Inject LoadBalancingRulesManager _lbMgr; @Inject - VirtualNetworkApplianceManager _routerMgr; + VpcVirtualNetworkApplianceManager _routerMgr; @Inject DomainRouterDao _routerDao = null; @Inject diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index c068cde6222..4cbc035ee76 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -25,7 +25,7 @@ import com.cloud.consoleproxy.ConsoleProxyManager; import com.cloud.ha.HighAvailabilityManager; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.network.NetworkManager; -import com.cloud.network.router.VirtualNetworkApplianceManager; +import com.cloud.network.router.VpcVirtualNetworkApplianceManager; import com.cloud.server.ManagementServer; import com.cloud.storage.StorageManager; import com.cloud.storage.allocator.StoragePoolAllocator; @@ -159,7 +159,7 @@ public enum Config { PingTimeout("Advanced", AgentManager.class, Float.class, "ping.timeout", "2.5", "Multiplier to ping.interval before announcing an agent has timed out", null), ClusterDeltaSyncInterval("Advanced", AgentManager.class, Integer.class, "sync.interval", "60", "Cluster Delta sync interval in seconds", null), Port("Advanced", AgentManager.class, Integer.class, "port", "8250", "Port to listen on for agent connection.", null), - RouterCpuMHz("Advanced", NetworkManager.class, Integer.class, "router.cpu.mhz", String.valueOf(VirtualNetworkApplianceManager.DEFAULT_ROUTER_CPU_MHZ), "Default CPU speed (MHz) for router VM.", null), + RouterCpuMHz("Advanced", NetworkManager.class, Integer.class, "router.cpu.mhz", String.valueOf(VpcVirtualNetworkApplianceManager.DEFAULT_ROUTER_CPU_MHZ), "Default CPU speed (MHz) for router VM.", null), RestartRetryInterval("Advanced", HighAvailabilityManager.class, Integer.class, "restart.retry.interval", "600", "Time (in seconds) between retries to restart a vm", null), RouterStatsInterval("Advanced", NetworkManager.class, Integer.class, "router.stats.interval", "300", "Interval (in seconds) to report router statistics.", null), ExternalNetworkStatsInterval("Advanced", NetworkManager.class, Integer.class, "external.network.stats.interval", "300", "Interval (in seconds) to report external network statistics.", null), diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java index fe82858c948..ecc7cee6ffe 100755 --- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java +++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java @@ -104,7 +104,6 @@ import com.cloud.network.element.VirtualRouterElement; import com.cloud.network.element.VirtualRouterElementService; import com.cloud.network.firewall.FirewallManagerImpl; import com.cloud.network.lb.LoadBalancingRulesManagerImpl; -import com.cloud.network.router.VirtualNetworkApplianceManagerImpl; import com.cloud.network.router.VpcVirtualNetworkApplianceManagerImpl; import com.cloud.network.rules.RulesManagerImpl; import com.cloud.network.rules.dao.PortForwardingRulesDaoImpl; @@ -373,7 +372,6 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com addManager("Snapshot Manager", SnapshotManagerImpl.class); addManager("SnapshotScheduler", SnapshotSchedulerImpl.class); addManager("SecurityGroupManager", SecurityGroupManagerImpl2.class); - addManager("DomainRouterManager", VirtualNetworkApplianceManagerImpl.class); addManager("EntityManager", EntityManagerImpl.class); addManager("LoadBalancingRulesManager", LoadBalancingRulesManagerImpl.class); addManager("RulesManager", RulesManagerImpl.class); diff --git a/server/src/com/cloud/ha/UserVmDomRInvestigator.java b/server/src/com/cloud/ha/UserVmDomRInvestigator.java index 1c53c075b80..5a3e55025e7 100644 --- a/server/src/com/cloud/ha/UserVmDomRInvestigator.java +++ b/server/src/com/cloud/ha/UserVmDomRInvestigator.java @@ -33,8 +33,8 @@ import com.cloud.host.Status; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.network.NetworkManager; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.router.VirtualNetworkApplianceManager; import com.cloud.network.router.VirtualRouter; +import com.cloud.network.router.VpcVirtualNetworkApplianceManager; import com.cloud.utils.component.Inject; import com.cloud.vm.Nic; import com.cloud.vm.UserVmVO; @@ -50,9 +50,9 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl { @Inject private final UserVmDao _userVmDao = null; @Inject private final AgentManager _agentMgr = null; @Inject private final NetworkManager _networkMgr = null; - @Inject private final VirtualNetworkApplianceManager _vnaMgr = null; - - @Override + @Inject private final VpcVirtualNetworkApplianceManager _vnaMgr = null; + + @Override public Boolean isVmAlive(VMInstanceVO vm, HostVO host) { if (vm.getType() != VirtualMachine.Type.User) { if (s_logger.isDebugEnabled()) { diff --git a/server/src/com/cloud/network/SshKeysDistriMonitor.java b/server/src/com/cloud/network/SshKeysDistriMonitor.java index 2755cd641a6..fc7c882cc6f 100755 --- a/server/src/com/cloud/network/SshKeysDistriMonitor.java +++ b/server/src/com/cloud/network/SshKeysDistriMonitor.java @@ -16,9 +16,6 @@ // under the License. package com.cloud.network; -import java.util.HashMap; -import java.util.Map; - import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; @@ -38,8 +35,6 @@ import com.cloud.host.HostVO; import com.cloud.host.Status; import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.network.router.VirtualNetworkApplianceManager; - public class SshKeysDistriMonitor implements Listener { diff --git a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java index fb12140b235..b3fbeac2ea4 100644 --- a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java +++ b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java @@ -47,7 +47,6 @@ import com.cloud.network.NetworkManager; import com.cloud.network.Networks.TrafficType; import com.cloud.network.PhysicalNetworkServiceProvider; import com.cloud.network.dao.NetworkDao; -import com.cloud.network.router.VirtualNetworkApplianceManager; import com.cloud.offering.NetworkOffering; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.uservm.UserVm; @@ -74,8 +73,6 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem @Inject NetworkManager _networkMgr; @Inject - VirtualNetworkApplianceManager _routerMgr; - @Inject UserVmManager _userVmMgr; @Inject UserVmDao _userVmDao; diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java index d6701aa911f..54543974f76 100755 --- a/server/src/com/cloud/network/element/VirtualRouterElement.java +++ b/server/src/com/cloud/network/element/VirtualRouterElement.java @@ -57,8 +57,8 @@ import com.cloud.network.dao.VirtualRouterProviderDao; import com.cloud.network.lb.LoadBalancingRule; import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy; import com.cloud.network.lb.LoadBalancingRulesManager; -import com.cloud.network.router.VirtualNetworkApplianceManager; import com.cloud.network.router.VirtualRouter.Role; +import com.cloud.network.router.VpcVirtualNetworkApplianceManager; import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.LbStickinessMethod; import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType; @@ -105,7 +105,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl @Inject NetworkOfferingDao _networkOfferingDao; @Inject - VirtualNetworkApplianceManager _routerMgr; + VpcVirtualNetworkApplianceManager _routerMgr; @Inject ConfigurationManager _configMgr; @Inject diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java index e60598dd4ac..c5ad65d2d56 100644 --- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java @@ -123,6 +123,7 @@ import com.cloud.vm.dao.VMInstanceDao; public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplianceManagerImpl implements VpcVirtualNetworkApplianceManager{ private static final Logger s_logger = Logger.getLogger(VpcVirtualNetworkApplianceManagerImpl.class); + String _name; @Inject VpcDao _vpcDao; @Inject @@ -1318,4 +1319,5 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian _s2sVpnMgr.markDisconnectVpnConnByVpc(vpcId); } } + } diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java index 7f861445bfc..1f7fbaace50 100755 --- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java +++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java @@ -53,7 +53,6 @@ import com.cloud.network.dao.IPAddressDao; import com.cloud.network.dao.RemoteAccessVpnDao; import com.cloud.network.dao.VpnUserDao; import com.cloud.network.element.RemoteAccessVPNServiceProvider; -import com.cloud.network.router.VirtualNetworkApplianceManager; import com.cloud.network.rules.FirewallManager; import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.FirewallRule.Purpose; @@ -90,7 +89,6 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag @Inject VpnUserDao _vpnUsersDao; @Inject RemoteAccessVpnDao _remoteAccessVpnDao; @Inject IPAddressDao _ipAddressDao; - @Inject VirtualNetworkApplianceManager _routerMgr; @Inject AccountManager _accountMgr; @Inject DomainManager _domainMgr; @Inject NetworkManager _networkMgr; diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index a77ce328949..77da61f111b 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -126,7 +126,6 @@ import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.HypervisorGuruManager; import com.cloud.network.NetworkManager; -import com.cloud.network.router.VirtualNetworkApplianceManager; import com.cloud.org.Grouping; import com.cloud.org.Grouping.AllocationState; import com.cloud.projects.Project.ListProjectResourcesCriteria; @@ -300,8 +299,6 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag @Inject protected ClusterDao _clusterDao; @Inject - protected VirtualNetworkApplianceManager _routerMgr; - @Inject protected UsageEventDao _usageEventDao; @Inject protected VirtualMachineManager _vmMgr; diff --git a/server/src/com/cloud/upgrade/dao/Upgrade218to22.java b/server/src/com/cloud/upgrade/dao/Upgrade218to22.java index c87018f8f43..01fa2cc9cfa 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade218to22.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade218to22.java @@ -41,7 +41,7 @@ import com.cloud.consoleproxy.ConsoleProxyManager; import com.cloud.event.EventTypes; import com.cloud.event.EventVO; import com.cloud.event.UsageEventVO; -import com.cloud.network.router.VirtualNetworkApplianceManager; +import com.cloud.network.router.VpcVirtualNetworkApplianceManager; import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.utils.DateUtil; import com.cloud.utils.NumbersUtil; @@ -1408,7 +1408,7 @@ public class Upgrade218to22 implements DbUpgrade { pstmt.close(); int proxyRamSize = NumbersUtil.parseInt(getConfigValue(conn, "consoleproxy.ram.size"), ConsoleProxyManager.DEFAULT_PROXY_VM_RAMSIZE); - int domrRamSize = NumbersUtil.parseInt(getConfigValue(conn, "router.ram.size"), VirtualNetworkApplianceManager.DEFAULT_ROUTER_VM_RAMSIZE); + int domrRamSize = NumbersUtil.parseInt(getConfigValue(conn, "router.ram.size"), VpcVirtualNetworkApplianceManager.DEFAULT_ROUTER_VM_RAMSIZE); int ssvmRamSize = NumbersUtil.parseInt(getConfigValue(conn, "secstorage.vm.ram.size"), SecondaryStorageVmManager.DEFAULT_SS_VM_RAMSIZE); pstmt = conn @@ -1567,7 +1567,7 @@ public class Upgrade218to22 implements DbUpgrade { pstmt.close(); int proxyCpuMhz = NumbersUtil.parseInt(getConfigValue(conn, "consoleproxy.cpu.mhz"), ConsoleProxyManager.DEFAULT_PROXY_VM_CPUMHZ); - int domrCpuMhz = NumbersUtil.parseInt(getConfigValue(conn, "router.cpu.mhz"), VirtualNetworkApplianceManager.DEFAULT_ROUTER_CPU_MHZ); + int domrCpuMhz = NumbersUtil.parseInt(getConfigValue(conn, "router.cpu.mhz"), VpcVirtualNetworkApplianceManager.DEFAULT_ROUTER_CPU_MHZ); int ssvmCpuMhz = NumbersUtil.parseInt(getConfigValue(conn, "secstorage.vm.cpu.mhz"), SecondaryStorageVmManager.DEFAULT_SS_VM_CPUMHZ); pstmt = conn