diff --git a/api/src/com/cloud/acl/ControlledEntity.java b/api/src/com/cloud/acl/ControlledEntity.java
index 79d994fbcd6..705b94ce0b0 100644
--- a/api/src/com/cloud/acl/ControlledEntity.java
+++ b/api/src/com/cloud/acl/ControlledEntity.java
@@ -22,14 +22,14 @@ import com.cloud.user.OwnedBy;
/**
* ControlledEntity defines an object for which the access from an
- * account can be controlled. Any object that must have limited
+ * account can be controlled. Any object that must have limited
* access must inherit this interface.
- *
+ *
*/
public interface ControlledEntity extends OwnedBy, PartOf {
- public enum ACLType {
- Account,
- Domain
- }
-
+ public enum ACLType {
+ Account,
+ Domain
+ }
+
}
diff --git a/api/src/com/cloud/acl/SecurityChecker.java b/api/src/com/cloud/acl/SecurityChecker.java
index 385defa20dd..28f9af024a6 100644
--- a/api/src/com/cloud/acl/SecurityChecker.java
+++ b/api/src/com/cloud/acl/SecurityChecker.java
@@ -32,60 +32,74 @@ import com.cloud.utils.component.Adapter;
/**
* SecurityChecker checks the ownership and access control to objects within
- * the management stack for users and accounts.
+ * the management stack for users and accounts.
*/
public interface SecurityChecker extends Adapter {
-
+
public enum AccessType {
ListEntry,
ModifyEntry,
ModifyProject,
UseNetwork
}
+
/**
* Checks if the account owns the object.
*
- * @param caller account to check against.
- * @param object object that the account is trying to access.
- * @return true if access allowed. false if this adapter cannot authenticate ownership.
- * @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed.
+ * @param caller
+ * account to check against.
+ * @param object
+ * object that the account is trying to access.
+ * @return true if access allowed. false if this adapter cannot authenticate ownership.
+ * @throws PermissionDeniedException
+ * if this adapter is suppose to authenticate ownership and the check failed.
*/
boolean checkAccess(Account caller, Domain domain) throws PermissionDeniedException;
-
+
/**
* Checks if the user belongs to an account that owns the object.
*
- * @param user user to check against.
- * @param object object that the account is trying to access.
- * @return true if access allowed. false if this adapter cannot authenticate ownership.
- * @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed.
+ * @param user
+ * user to check against.
+ * @param object
+ * object that the account is trying to access.
+ * @return true if access allowed. false if this adapter cannot authenticate ownership.
+ * @throws PermissionDeniedException
+ * if this adapter is suppose to authenticate ownership and the check failed.
*/
boolean checkAccess(User user, Domain domain) throws PermissionDeniedException;
-
+
/**
* Checks if the account can access the object.
*
- * @param caller account to check against.
- * @param entity object that the account is trying to access.
- * @param accessType TODO
- * @return true if access allowed. false if this adapter cannot provide permission.
- * @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed.
+ * @param caller
+ * account to check against.
+ * @param entity
+ * object that the account is trying to access.
+ * @param accessType
+ * TODO
+ * @return true if access allowed. false if this adapter cannot provide permission.
+ * @throws PermissionDeniedException
+ * if this adapter is suppose to authenticate ownership and the check failed.
*/
boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType) throws PermissionDeniedException;
/**
* Checks if the user belongs to an account that can access the object.
*
- * @param user user to check against.
- * @param entity object that the account is trying to access.
- * @return true if access allowed. false if this adapter cannot authenticate ownership.
- * @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed.
+ * @param user
+ * user to check against.
+ * @param entity
+ * object that the account is trying to access.
+ * @return true if access allowed. false if this adapter cannot authenticate ownership.
+ * @throws PermissionDeniedException
+ * if this adapter is suppose to authenticate ownership and the check failed.
*/
boolean checkAccess(User user, ControlledEntity entity) throws PermissionDeniedException;
-
+
boolean checkAccess(Account account, DataCenter zone) throws PermissionDeniedException;
public boolean checkAccess(Account account, ServiceOffering so) throws PermissionDeniedException;
- boolean checkAccess(Account account, DiskOffering dof) throws PermissionDeniedException;
+ boolean checkAccess(Account account, DiskOffering dof) throws PermissionDeniedException;
}
diff --git a/api/src/com/cloud/api/BaseAsyncCmd.java b/api/src/com/cloud/api/BaseAsyncCmd.java
index 37a1a342be8..b64460b2ae5 100644
--- a/api/src/com/cloud/api/BaseAsyncCmd.java
+++ b/api/src/com/cloud/api/BaseAsyncCmd.java
@@ -23,33 +23,34 @@ import com.cloud.user.User;
import com.cloud.user.UserContext;
/**
- * A base command for supporting asynchronous API calls. When an API command is received, the command will be
+ * A base command for supporting asynchronous API calls. When an API command is received, the command will be
* serialized to the queue (currently the async_job table) and a response will be immediately returned with the
- * id of the queue object. The id can be used to query the status/progress of the command using the
+ * id of the queue object. The id can be used to query the status/progress of the command using the
* queryAsyncJobResult API command.
*/
public abstract class BaseAsyncCmd extends BaseCmd {
public static final String ipAddressSyncObject = "ipaddress";
public static final String networkSyncObject = "network";
-
-
+
private AsyncJob job;
- @Parameter(name="starteventid", type=CommandType.LONG)
+ @Parameter(name = "starteventid", type = CommandType.LONG)
private Long startEventId;
/**
* For proper tracking of async commands through the system, events must be generated when the command is
- * scheduled, started, and completed. Commands should specify the type of event so that when the scheduled,
+ * scheduled, started, and completed. Commands should specify the type of event so that when the scheduled,
* started, and completed events are saved to the events table, they have the proper type information.
+ *
* @return a string representing the type of event, e.g. VM.START, VOLUME.CREATE.
*/
public abstract String getEventType();
/**
* For proper tracking of async commands through the system, events must be generated when the command is
- * scheduled, started, and completed. Commands should specify a description for these events so that when
+ * scheduled, started, and completed. Commands should specify a description for these events so that when
* the scheduled, started, and completed events are saved to the events table, they have a meaningful description.
+ *
* @return a string representing a description of the event
*/
public abstract String getEventDescription();
@@ -73,7 +74,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
public void setStartEventId(Long startEventId) {
this.startEventId = startEventId;
}
-
+
/**
* Async commands that want to be tracked as part of the listXXX commands need to
* provide implementations of the two following methods, getInstanceId() and getInstanceType()
@@ -82,13 +83,13 @@ public abstract class BaseAsyncCmd extends BaseCmd {
* getObjectType() should return a type from the AsyncJob.Type enumeration
*/
public Long getInstanceId() {
- return null;
+ return null;
}
-
+
public AsyncJob.Type getInstanceType() {
- return AsyncJob.Type.None;
+ return AsyncJob.Type.None;
}
-
+
public String getSyncObjType() {
return null;
}
@@ -101,33 +102,34 @@ public abstract class BaseAsyncCmd extends BaseCmd {
return job;
}
- protected long saveStartedEvent(){
- return saveStartedEvent(getEventType(), "Executing job for "+getEventDescription(), getStartEventId());
+ protected long saveStartedEvent() {
+ return saveStartedEvent(getEventType(), "Executing job for " + getEventDescription(), getStartEventId());
}
-
- protected long saveStartedEvent(String eventType, String description, Long startEventId){
+
+ protected long saveStartedEvent(String eventType, String description, Long startEventId) {
UserContext ctx = UserContext.current();
Long userId = ctx.getCallerUserId();
userId = (userId == null) ? User.UID_SYSTEM : userId;
Long startEvent = startEventId;
- if(startEvent == null){
+ if (startEvent == null) {
startEvent = 0L;
}
return _mgr.saveStartedEvent((userId == null) ? User.UID_SYSTEM : userId, getEntityOwnerId(), eventType, description, startEvent);
}
-
- protected long saveCompletedEvent(String level, String description){
+
+ protected long saveCompletedEvent(String level, String description) {
return saveCompletedEvent(level, getEventType(), description, getStartEventId());
}
-
- protected long saveCompletedEvent(String level, String eventType, String description, Long startEventId){
+
+ protected long saveCompletedEvent(String level, String eventType, String description, Long startEventId) {
UserContext ctx = UserContext.current();
Long userId = ctx.getCallerUserId();
userId = (userId == null) ? User.UID_SYSTEM : userId;
Long startEvent = startEventId;
- if(startEvent == null){
+ if (startEvent == null) {
startEvent = 0L;
}
return _mgr.saveCompletedEvent((userId == null) ? User.UID_SYSTEM : userId, getEntityOwnerId(), level, eventType, description, startEvent);
}
+
}
diff --git a/api/src/com/cloud/api/BaseAsyncCreateCmd.java b/api/src/com/cloud/api/BaseAsyncCreateCmd.java
index 602dc19e0fa..5ba621942b9 100644
--- a/api/src/com/cloud/api/BaseAsyncCreateCmd.java
+++ b/api/src/com/cloud/api/BaseAsyncCreateCmd.java
@@ -22,9 +22,9 @@ import com.cloud.api.response.CreateCmdResponse;
import com.cloud.exception.ResourceAllocationException;
public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
- @Parameter(name="id", type=CommandType.LONG)
+ @Parameter(name = "id", type = CommandType.LONG)
private Long id;
-
+
public abstract void create() throws ResourceAllocationException;
public Long getEntityId() {
@@ -34,7 +34,7 @@ public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
public void setEntityId(Long id) {
this.id = id;
}
-
+
public abstract String getEntityTable();
public String getResponse(long jobId, long objectId, String objectEntityTable) {
@@ -53,4 +53,5 @@ public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
public String getCreateEventDescription() {
return null;
}
+
}
diff --git a/api/src/com/cloud/api/BaseCmd.java b/api/src/com/cloud/api/BaseCmd.java
index 1a1be969a1f..a2481f50ce2 100755
--- a/api/src/com/cloud/api/BaseCmd.java
+++ b/api/src/com/cloud/api/BaseCmd.java
@@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- */
-
-package com.cloud.api;
-
+ */
+
+package com.cloud.api;
+
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -28,7 +28,6 @@ import java.util.regex.Pattern;
import org.apache.log4j.Logger;
-import com.cloud.api.response.TrafficTypeImplementorResponse;
import com.cloud.configuration.ConfigurationService;
import com.cloud.consoleproxy.ConsoleProxyService;
import com.cloud.dao.EntityManager;
@@ -63,66 +62,66 @@ 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 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;
+ 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;
+
+ @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;
@@ -130,26 +129,26 @@ public abstract class BaseCmd {
public static ResourceLimitService _resourceLimitService;
public static IdentityService _identityService;
public static StorageNetworkService _storageNetworkService;
-
- 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;
+
+ 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);
@@ -157,337 +156,342 @@ public abstract class BaseCmd {
_resourceLimitService = locator.getManager(ResourceLimitService.class);
_identityService = locator.getManager(IdentityService.class);
_storageNetworkService = locator.getManager(StorageNetworkService.class);
- }
-
- public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
-
- public String getResponseType() {
- if (responseType == null) {
+ }
+
+ 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 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("" + getCommandName() + " cloud-stack-version=\""+_mgr.getVersion()+ "\">");
- }
- 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
+ }
+ 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 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)) {
- 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("" + getCommandName() + ">");
- }
- 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()) + "" + tagName + ">");
- }
- }
- }
-
- @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("" + tagName + ">");
- }
- }
-
- /**
- * 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));
- }
+ // 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("" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
+ }
+ 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("" + getCommandName() + ">");
+ }
+ 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()) + "" + tagName + ">");
+ }
+ }
+ }
+
+ @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("" + tagName + ">");
+ }
+ }
+
+ /**
+ * 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;
+ this.fullUrlParams = map;
}
-
+
public Map getFullUrlParams() {
- return this.fullUrlParams;
+ 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) {
+ 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 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) {
@@ -501,5 +505,5 @@ public abstract class BaseCmd {
}
}
return null;
- }
-}
+ }
+}
diff --git a/api/src/com/cloud/api/BaseListAccountResourcesCmd.java b/api/src/com/cloud/api/BaseListAccountResourcesCmd.java
index af119109bc2..d88238ff267 100644
--- a/api/src/com/cloud/api/BaseListAccountResourcesCmd.java
+++ b/api/src/com/cloud/api/BaseListAccountResourcesCmd.java
@@ -18,11 +18,10 @@
package com.cloud.api;
-public abstract class BaseListAccountResourcesCmd extends BaseListDomainResourcesCmd{
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="List resources by account. Must be used with the domainId parameter.")
- private String accountName;
+public abstract class BaseListAccountResourcesCmd extends BaseListDomainResourcesCmd {
+ @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "List resources by account. Must be used with the domainId parameter.")
+ private String accountName;
public String getAccountName() {
return accountName;
diff --git a/api/src/com/cloud/api/BaseListCmd.java b/api/src/com/cloud/api/BaseListCmd.java
index cec856707d9..7c314a40dda 100755
--- a/api/src/com/cloud/api/BaseListCmd.java
+++ b/api/src/com/cloud/api/BaseListCmd.java
@@ -39,8 +39,6 @@ public abstract class BaseListCmd extends BaseCmd {
@Parameter(name = ApiConstants.PAGE_SIZE, type = CommandType.INTEGER)
private Integer pageSize;
-
-
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
@@ -58,18 +56,18 @@ public abstract class BaseListCmd extends BaseCmd {
if (pageSize != null && MAX_PAGESIZE != null && pageSize.longValue() > MAX_PAGESIZE.longValue()) {
throw new InvalidParameterValueException("Page size can't exceed max allowed page size value: " + MAX_PAGESIZE.longValue());
}
-
+
if (pageSize != null && pageSize.longValue() == PAGESIZE_UNLIMITED && page != null) {
throw new InvalidParameterValueException("Can't specify page parameter when pagesize is -1 (Unlimited)");
}
-
+
return pageSize;
}
static void configure() {
if (_configService.getDefaultPageSize().longValue() != PAGESIZE_UNLIMITED) {
MAX_PAGESIZE = _configService.getDefaultPageSize();
- }
+ }
}
@Override
@@ -82,11 +80,11 @@ public abstract class BaseListCmd extends BaseCmd {
Long defaultPageSize = MAX_PAGESIZE;
Integer pageSizeInt = getPageSize();
if (pageSizeInt != null) {
- if (pageSizeInt.longValue() == PAGESIZE_UNLIMITED) {
- defaultPageSize = null;
- } else {
+ if (pageSizeInt.longValue() == PAGESIZE_UNLIMITED) {
+ defaultPageSize = null;
+ } else {
defaultPageSize = pageSizeInt.longValue();
- }
+ }
}
return defaultPageSize;
}
diff --git a/api/src/com/cloud/api/BaseListDomainResourcesCmd.java b/api/src/com/cloud/api/BaseListDomainResourcesCmd.java
index 08cb00efadd..d1f7d50337e 100644
--- a/api/src/com/cloud/api/BaseListDomainResourcesCmd.java
+++ b/api/src/com/cloud/api/BaseListDomainResourcesCmd.java
@@ -18,26 +18,26 @@
package com.cloud.api;
-public abstract class BaseListDomainResourcesCmd extends BaseListCmd{
-
- @Parameter(name=ApiConstants.LIST_ALL, type=CommandType.BOOLEAN, description="If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false")
+public abstract class BaseListDomainResourcesCmd extends BaseListCmd {
+
+ @Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false")
private Boolean listAll;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="list only resources belonging to the domain specified")
+
+ @IdentityMapper(entityTableName = "domain")
+ @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.LONG, description = "list only resources belonging to the domain specified")
private Long domainId;
-
- @Parameter(name=ApiConstants.IS_RECURSIVE, type=CommandType.BOOLEAN, description="defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.")
+
+ @Parameter(name = ApiConstants.IS_RECURSIVE, type = CommandType.BOOLEAN, description = "defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves.")
private Boolean recursive;
public boolean listAll() {
return listAll == null ? false : listAll;
}
-
+
public boolean isRecursive() {
return recursive == null ? false : recursive;
}
-
+
public Long getDomainId() {
return domainId;
}
diff --git a/api/src/com/cloud/api/BaseListProjectAndAccountResourcesCmd.java b/api/src/com/cloud/api/BaseListProjectAndAccountResourcesCmd.java
index 7f30bfca218..12af907e2fd 100644
--- a/api/src/com/cloud/api/BaseListProjectAndAccountResourcesCmd.java
+++ b/api/src/com/cloud/api/BaseListProjectAndAccountResourcesCmd.java
@@ -18,10 +18,10 @@
package com.cloud.api;
-public abstract class BaseListProjectAndAccountResourcesCmd extends BaseListAccountResourcesCmd{
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list firewall rules by project")
+public abstract class BaseListProjectAndAccountResourcesCmd extends BaseListAccountResourcesCmd {
+
+ @IdentityMapper(entityTableName = "projects")
+ @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.LONG, description = "list firewall rules by project")
private Long projectId;
public Long getProjectId() {
diff --git a/api/src/com/cloud/api/Identity.java b/api/src/com/cloud/api/Identity.java
index 3545fd6d1a4..857c216b9d6 100644
--- a/api/src/com/cloud/api/Identity.java
+++ b/api/src/com/cloud/api/Identity.java
@@ -18,5 +18,5 @@
package com.cloud.api;
public interface Identity {
- String getUuid();
+ String getUuid();
}
diff --git a/api/src/com/cloud/api/IdentityMapper.java b/api/src/com/cloud/api/IdentityMapper.java
index f2b03215fb1..a66765cd48f 100644
--- a/api/src/com/cloud/api/IdentityMapper.java
+++ b/api/src/com/cloud/api/IdentityMapper.java
@@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
-@Target({FIELD})
+@Target({ FIELD })
public @interface IdentityMapper {
- String entityTableName();
+ String entityTableName();
}
diff --git a/api/src/com/cloud/api/IdentityProxy.java b/api/src/com/cloud/api/IdentityProxy.java
index 5d90baa3804..11f0e79ba4c 100644
--- a/api/src/com/cloud/api/IdentityProxy.java
+++ b/api/src/com/cloud/api/IdentityProxy.java
@@ -18,30 +18,29 @@
package com.cloud.api;
public class IdentityProxy {
- private String _tableName;
- private Long _value;
+ private String _tableName;
+ private Long _value;
- public IdentityProxy() {
- }
-
- public IdentityProxy(String tableName) {
- _tableName = tableName;
- }
-
- public String getTableName() {
- return _tableName;
- }
-
- public void setTableName(String tableName) {
- _tableName = tableName;
- }
-
- public Long getValue() {
- return _value;
- }
-
- public void setValue(Long value) {
- _value = value;
- }
+ public IdentityProxy() {
+ }
+
+ public IdentityProxy(String tableName) {
+ _tableName = tableName;
+ }
+
+ public String getTableName() {
+ return _tableName;
+ }
+
+ public void setTableName(String tableName) {
+ _tableName = tableName;
+ }
+
+ public Long getValue() {
+ return _value;
+ }
+
+ public void setValue(Long value) {
+ _value = value;
+ }
}
-
diff --git a/api/src/com/cloud/api/IdentityService.java b/api/src/com/cloud/api/IdentityService.java
index 7b9401ed423..be043a7b40a 100644
--- a/api/src/com/cloud/api/IdentityService.java
+++ b/api/src/com/cloud/api/IdentityService.java
@@ -18,7 +18,9 @@
package com.cloud.api;
public interface IdentityService {
- Long getIdentityId(IdentityMapper mapper, String identityString);
+ Long getIdentityId(IdentityMapper mapper, String identityString);
+
Long getIdentityId(String tableName, String identityString);
- String getIdentityUuid(String tableName, String identityString);
+
+ String getIdentityUuid(String tableName, String identityString);
}
diff --git a/api/src/com/cloud/api/Implementation.java b/api/src/com/cloud/api/Implementation.java
index 5aa18a15c49..9a03be54757 100644
--- a/api/src/com/cloud/api/Implementation.java
+++ b/api/src/com/cloud/api/Implementation.java
@@ -25,11 +25,15 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
-@Target({TYPE})
+@Target({ TYPE })
public @interface Implementation {
Class> responseObject();
+
String description() default "";
+
String usage() default "";
+
boolean includeInApiDoc() default true;
+
String since() default "";
}
diff --git a/api/src/com/cloud/api/Parameter.java b/api/src/com/cloud/api/Parameter.java
index c2fb8088ccd..9b6920d7855 100644
--- a/api/src/com/cloud/api/Parameter.java
+++ b/api/src/com/cloud/api/Parameter.java
@@ -27,16 +27,23 @@ import java.lang.annotation.Target;
import com.cloud.api.BaseCmd.CommandType;
@Retention(RetentionPolicy.RUNTIME)
-@Target({FIELD})
+@Target({ FIELD })
public @interface Parameter {
String name() default "";
+
String description() default "";
+
boolean required() default false;
+
CommandType type() default CommandType.OBJECT;
+
CommandType collectionType() default CommandType.OBJECT;
+
boolean expose() default true;
+
boolean includeInApiDoc() default true;
+
int length() default 255;
+
String since() default "";
}
-
diff --git a/api/src/com/cloud/api/ResponseGenerator.java b/api/src/com/cloud/api/ResponseGenerator.java
index 2ab717dde13..e3cfdab8de6 100755
--- a/api/src/com/cloud/api/ResponseGenerator.java
+++ b/api/src/com/cloud/api/ResponseGenerator.java
@@ -43,11 +43,9 @@ import com.cloud.api.response.IPAddressResponse;
import com.cloud.api.response.InstanceGroupResponse;
import com.cloud.api.response.IpForwardingRuleResponse;
import com.cloud.api.response.LBStickinessResponse;
+import com.cloud.api.response.LDAPConfigResponse;
import com.cloud.api.response.ListResponse;
import com.cloud.api.response.LoadBalancerResponse;
-import com.cloud.api.response.LBStickinessPolicyResponse;
-import com.cloud.network.rules.StickinessPolicy;
-import com.cloud.api.response.LDAPConfigResponse;
import com.cloud.api.response.NetworkOfferingResponse;
import com.cloud.api.response.NetworkResponse;
import com.cloud.api.response.PhysicalNetworkResponse;
@@ -106,9 +104,10 @@ import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.LoadBalancer;
import com.cloud.network.rules.PortForwardingRule;
import com.cloud.network.rules.StaticNatRule;
-import com.cloud.network.security.SecurityRule;
+import com.cloud.network.rules.StickinessPolicy;
import com.cloud.network.security.SecurityGroup;
import com.cloud.network.security.SecurityGroupRules;
+import com.cloud.network.security.SecurityRule;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
@@ -149,7 +148,7 @@ public interface ResponseGenerator {
SnapshotResponse createSnapshotResponse(Snapshot snapshot);
SnapshotPolicyResponse createSnapshotPolicyResponse(SnapshotPolicy policy);
-
+
List createUserVmResponse(String objectName, UserVm... userVms);
List createUserVmResponse(String objectName, EnumSet details, UserVm... userVms);
@@ -159,7 +158,7 @@ public interface ResponseGenerator {
DomainRouterResponse createDomainRouterResponse(VirtualRouter router);
HostResponse createHostResponse(Host host, EnumSet details);
-
+
HostResponse createHostResponse(Host host);
VlanIpRangeResponse createVlanIpRangeResponse(Vlan vlan);
@@ -167,10 +166,10 @@ public interface ResponseGenerator {
IPAddressResponse createIPAddressResponse(IpAddress ipAddress);
LoadBalancerResponse createLoadBalancerResponse(LoadBalancer loadBalancer);
-
+
LBStickinessResponse createLBStickinessPolicyResponse(List extends StickinessPolicy> stickinessPolicies, LoadBalancer lb);
-
- LBStickinessResponse createLBStickinessPolicyResponse( StickinessPolicy stickinessPolicy, LoadBalancer lb);
+
+ LBStickinessResponse createLBStickinessPolicyResponse(StickinessPolicy stickinessPolicy, LoadBalancer lb);
PodResponse createPodResponse(Pod pod, Boolean showCapacities);
@@ -205,6 +204,7 @@ public interface ResponseGenerator {
VpnUsersResponse createVpnUserResponse(VpnUser user);
RemoteAccessVpnResponse createRemoteAccessVpnResponse(RemoteAccessVpn vpn);
+
List createTemplateResponses(long templateId, Long zoneId, boolean readyOnly);
List createTemplateResponses(long templateId, Long snapshotId, Long volumeId, boolean readyOnly);
@@ -252,7 +252,7 @@ public interface ResponseGenerator {
FirewallResponse createFirewallResponse(FirewallRule fwRule);
HypervisorCapabilitiesResponse createHypervisorCapabilitiesResponse(HypervisorCapabilities hpvCapabilities);
-
+
ProjectAccountResponse createProjectAccountResponse(ProjectAccount projectAccount);
ProjectInvitationResponse createProjectInvitationResponse(ProjectInvitation invite);
@@ -268,7 +268,7 @@ public interface ResponseGenerator {
ProviderResponse createNetworkServiceProviderResponse(PhysicalNetworkServiceProvider result);
TrafficTypeResponse createTrafficTypeResponse(PhysicalNetworkTrafficType result);
-
+
VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result);
LDAPConfigResponse createLDAPConfigResponse(String hostname, Integer port, Boolean useSSL, String queryFilter, String baseSearch, String dn);
diff --git a/api/src/com/cloud/api/ResponseObject.java b/api/src/com/cloud/api/ResponseObject.java
index 3b0c2faa946..bd3570f4e31 100644
--- a/api/src/com/cloud/api/ResponseObject.java
+++ b/api/src/com/cloud/api/ResponseObject.java
@@ -21,51 +21,58 @@ package com.cloud.api;
public interface ResponseObject {
/**
* Get the name of the API response
+ *
* @return the name of the API response
*/
String getResponseName();
/**
* Set the name of the API response
+ *
* @param name
*/
void setResponseName(String name);
-
+
/**
* Get the name of the API object
+ *
* @return the name of the API object
*/
String getObjectName();
/**
* Set the name of the APIobject
+ *
* @param name
*/
void setObjectName(String name);
-
+
/**
* Returns the object Id
*/
Long getObjectId();
-
+
/**
* Returns the job id
- * @return
+ *
+ * @return
*/
Long getJobId();
-
+
/**
* Sets the job id
+ *
* @param jobId
*/
void setJobId(Long jobId);
-
+
/**
* Returns the job status
+ *
* @return
*/
Integer getJobStatus();
-
+
/**
*
* @param jobStatus
diff --git a/api/src/com/cloud/api/ServerApiException.java b/api/src/com/cloud/api/ServerApiException.java
index f65b6a846bc..6369f66d9dd 100644
--- a/api/src/com/cloud/api/ServerApiException.java
+++ b/api/src/com/cloud/api/ServerApiException.java
@@ -16,34 +16,36 @@
*
*/
-package com.cloud.api;
-
-@SuppressWarnings("serial")
-public class ServerApiException extends RuntimeException {
- private int _errorCode;
- private String _description;
-
- public ServerApiException() {
- _errorCode = 0;
- _description = null;
- }
-
- public ServerApiException(int errorCode, String description) {
- _errorCode = errorCode;
- _description = description;
- }
-
- public int getErrorCode() {
- return _errorCode;
- }
- public void setErrorCode(int errorCode) {
- _errorCode = errorCode;
- }
-
- public String getDescription() {
- return _description;
- }
- public void setDescription(String description) {
- _description = description;
- }
-}
+package com.cloud.api;
+
+@SuppressWarnings("serial")
+public class ServerApiException extends RuntimeException {
+ private int _errorCode;
+ private String _description;
+
+ public ServerApiException() {
+ _errorCode = 0;
+ _description = null;
+ }
+
+ public ServerApiException(int errorCode, String description) {
+ _errorCode = errorCode;
+ _description = description;
+ }
+
+ public int getErrorCode() {
+ return _errorCode;
+ }
+
+ public void setErrorCode(int errorCode) {
+ _errorCode = errorCode;
+ }
+
+ public String getDescription() {
+ return _description;
+ }
+
+ public void setDescription(String description) {
+ _description = description;
+ }
+}
diff --git a/api/src/com/cloud/api/commands/CreateSecurityGroupCmd.java b/api/src/com/cloud/api/commands/CreateSecurityGroupCmd.java
index 063b3559434..a558b077690 100644
--- a/api/src/com/cloud/api/commands/CreateSecurityGroupCmd.java
+++ b/api/src/com/cloud/api/commands/CreateSecurityGroupCmd.java
@@ -1,4 +1,5 @@
/**
+
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
@@ -14,113 +15,111 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- */
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
+ */
+package com.cloud.api.commands;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.api.ApiConstants;
+import com.cloud.api.BaseCmd;
import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.BaseCmd.CommandType;
-import com.cloud.api.response.SecurityGroupResponse;
-import com.cloud.network.security.SecurityGroup;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(responseObject=SecurityGroupResponse.class, description="Creates a security group")
-public class CreateSecurityGroupCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(CreateSecurityGroupCmd.class.getName());
-
- private static final String s_name = "createsecuritygroupresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the security group. Must be used with domainId.")
- private String accountName;
-
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the security group. If the account parameter is used, domainId must also be used.")
- private Long domainId;
-
- @Parameter(name=ApiConstants.DESCRIPTION, type=CommandType.STRING, description="the description of the security group")
- private String description;
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="name of the security group")
+import com.cloud.api.Implementation;
+import com.cloud.api.Parameter;
+import com.cloud.api.ServerApiException;
+import com.cloud.api.response.SecurityGroupResponse;
+import com.cloud.network.security.SecurityGroup;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(responseObject = SecurityGroupResponse.class, description = "Creates a security group")
+public class CreateSecurityGroupCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(CreateSecurityGroupCmd.class.getName());
+
+ private static final String s_name = "createsecuritygroupresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an optional account for the security group. Must be used with domainId.")
+ private String accountName;
+
+ @IdentityMapper(entityTableName = "domain")
+ @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.LONG, description = "an optional domainId for the security group. If the account parameter is used, domainId must also be used.")
+ private Long domainId;
+
+ @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the security group")
+ private String description;
+
+ @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the security group")
private String securityGroupName;
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Deploy vm for the project")
- private Long projectId;
-
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public String getAccountName() {
- return accountName;
- }
-
- public String getDescription() {
- return description;
- }
-
- public Long getDomainId() {
- return domainId;
- }
-
- public String getSecurityGroupName() {
- return securityGroupName;
+
+ @IdentityMapper(entityTableName = "projects")
+ @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.LONG, description = "Deploy vm for the project")
+ private Long projectId;
+
+ // ///////////////////////////////////////////////////
+ // ///////////////// Accessors ///////////////////////
+ // ///////////////////////////////////////////////////
+
+ public String getAccountName() {
+ return accountName;
}
-
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public String getSecurityGroupName() {
+ return securityGroupName;
+ }
+
public Long getProjectId() {
return projectId;
- }
-
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- Account account = UserContext.current().getCaller();
- if ((account == null) || isAdmin(account.getType())) {
- if ((domainId != null) && (accountName != null)) {
- Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
- if (userAccount != null) {
- return userAccount.getId();
- }
- }
- }
-
- if (account != null) {
- return account.getId();
- }
-
- return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
- }
-
- @Override
- public void execute(){
- SecurityGroup group = _securityGroupService.createSecurityGroup(this);
- if (group != null) {
- SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponse(group);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create security group");
- }
- }
-}
+ }
+
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account account = UserContext.current().getCaller();
+ if ((account == null) || isAdmin(account.getType())) {
+ if ((domainId != null) && (accountName != null)) {
+ Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
+ if (userAccount != null) {
+ return userAccount.getId();
+ }
+ }
+ }
+
+ if (account != null) {
+ return account.getId();
+ }
+
+ return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are
+// tracked
+ }
+
+ @Override
+ public void execute() {
+ SecurityGroup group = _securityGroupService.createSecurityGroup(this);
+ if (group != null) {
+ SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponse(group);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create security group");
+ }
+ }
+}
diff --git a/api/src/com/cloud/api/commands/CreateVMGroupCmd.java b/api/src/com/cloud/api/commands/CreateVMGroupCmd.java
index a760612f7cc..6a07f73b88a 100644
--- a/api/src/com/cloud/api/commands/CreateVMGroupCmd.java
+++ b/api/src/com/cloud/api/commands/CreateVMGroupCmd.java
@@ -29,33 +29,33 @@ import com.cloud.api.response.InstanceGroupResponse;
import com.cloud.user.UserContext;
import com.cloud.vm.InstanceGroup;
-@Implementation(description="Creates a vm group", responseObject=InstanceGroupResponse.class)
-public class CreateVMGroupCmd extends BaseCmd{
+@Implementation(description = "Creates a vm group", responseObject = InstanceGroupResponse.class)
+public class CreateVMGroupCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateVMGroupCmd.class.getName());
private static final String s_name = "createinstancegroupresponse";
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the instance group")
+ @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the instance group")
private String groupName;
- @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account of the instance group. The account parameter must be used with the domainId parameter.")
+ @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the account of the instance group. The account parameter must be used with the domainId parameter.")
private String accountName;
- @IdentityMapper(entityTableName="domain")
- @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID of account owning the instance group")
+ @IdentityMapper(entityTableName = "domain")
+ @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.LONG, description = "the domain ID of account owning the instance group")
private Long domainId;
-
- @IdentityMapper(entityTableName="projects")
- @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="The project of the instance group")
+
+ @IdentityMapper(entityTableName = "projects")
+ @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.LONG, description = "The project of the instance group")
private Long projectId;
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
+ // ///////////////////////////////////////////////////
+ // ///////////////// Accessors ///////////////////////
+ // ///////////////////////////////////////////////////
public String getGroupName() {
return groupName;
@@ -68,32 +68,32 @@ public class CreateVMGroupCmd extends BaseCmd{
public Long getDomainId() {
return domainId;
}
-
+
public Long getProjectId() {
return projectId;
}
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
@Override
public String getCommandName() {
return s_name;
}
-
+
@Override
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
-
+
return accountId;
}
-
+
@Override
- public void execute(){
+ public void execute() {
InstanceGroup result = _userVmService.createVmGroup(this);
if (result != null) {
InstanceGroupResponse response = _responseGenerator.createInstanceGroupResponse(result);
diff --git a/api/src/com/cloud/async/AsyncJob.java b/api/src/com/cloud/async/AsyncJob.java
index 4fdfee60681..8004c84b042 100644
--- a/api/src/com/cloud/async/AsyncJob.java
+++ b/api/src/com/cloud/async/AsyncJob.java
@@ -21,10 +21,10 @@ import java.util.Date;
import com.cloud.api.Identity;
-public interface AsyncJob extends Identity{
- public enum Type {
+public interface AsyncJob extends Identity {
+ public enum Type {
None,
- VirtualMachine,
+ VirtualMachine,
DomainRouter,
Volume,
ConsoleProxy,
@@ -38,29 +38,52 @@ public interface AsyncJob extends Identity{
SecurityGroup,
PhysicalNetwork
}
-
+
Long getId();
+
long getUserId();
+
long getAccountId();
+
String getCmd();
+
int getCmdVersion();
+
String getCmdInfo();
+
int getCallbackType();
+
String getCallbackAddress();
+
int getStatus();
+
int getProcessStatus();
+
int getResultCode();
+
String getResult();
+
Long getInitMsid();
+
Long getCompleteMsid();
+
Date getCreated();
+
Date getLastUpdated();
+
Date getLastPolled();
+
Date getRemoved();
+
Type getInstanceType();
+
Long getInstanceId();
+
String getSessionKey();
+
String getCmdOriginator();
+
boolean isFromPreviousSession();
+
SyncQueueItem getSyncSource();
}
diff --git a/api/src/com/cloud/async/SyncQueueItem.java b/api/src/com/cloud/async/SyncQueueItem.java
index ea2a28f21bd..f8964039e13 100644
--- a/api/src/com/cloud/async/SyncQueueItem.java
+++ b/api/src/com/cloud/async/SyncQueueItem.java
@@ -19,8 +19,8 @@
package com.cloud.async;
public interface SyncQueueItem {
-
- String getContentType();
- Long getContentId();
+ String getContentType();
+
+ Long getContentId();
}
diff --git a/api/src/com/cloud/capacity/Capacity.java b/api/src/com/cloud/capacity/Capacity.java
index e31ae19543c..61fc7c39b1f 100755
--- a/api/src/com/cloud/capacity/Capacity.java
+++ b/api/src/com/cloud/capacity/Capacity.java
@@ -19,7 +19,7 @@ package com.cloud.capacity;
/**
* @author ahuang
- *
+ *
*/
public interface Capacity {
public static final short CAPACITY_TYPE_MEMORY = 0;
@@ -32,18 +32,23 @@ public interface Capacity {
public static final short CAPACITY_TYPE_VLAN = 7;
public static final short CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8;
public static final short CAPACITY_TYPE_LOCAL_STORAGE = 9;
-
+
public long getId();
-
+
public Long getHostOrPoolId();
+
public long getDataCenterId();
+
public Long getPodId();
+
public Long getClusterId();
+
public long getUsedCapacity();
+
public long getTotalCapacity();
+
public short getCapacityType();
- long getReservedCapacity();
-
+ long getReservedCapacity();
}
diff --git a/api/src/com/cloud/cluster/ManagementServerHost.java b/api/src/com/cloud/cluster/ManagementServerHost.java
index 82f6a755bcf..6f45910c33d 100644
--- a/api/src/com/cloud/cluster/ManagementServerHost.java
+++ b/api/src/com/cloud/cluster/ManagementServerHost.java
@@ -16,18 +16,17 @@
*
*/
-
package com.cloud.cluster;
-
public interface ManagementServerHost {
-
- public static enum State { Up, Starting, Down };
+
+ public static enum State {
+ Up, Starting, Down
+ };
long getMsid();
State getState();
String getVersion();
-
}
diff --git a/api/src/com/cloud/configuration/Configuration.java b/api/src/com/cloud/configuration/Configuration.java
index c1d7f4e59d7..cae29eaa2e6 100644
--- a/api/src/com/cloud/configuration/Configuration.java
+++ b/api/src/com/cloud/configuration/Configuration.java
@@ -18,13 +18,12 @@
package com.cloud.configuration;
+public interface Configuration {
+
+ public String getCategory();
-public interface Configuration{
-
- public String getCategory();
-
public String getInstance();
-
+
public String getComponent();
public String getName();
@@ -33,5 +32,4 @@ public interface Configuration{
public String getDescription();
-
}
diff --git a/api/src/com/cloud/configuration/ConfigurationService.java b/api/src/com/cloud/configuration/ConfigurationService.java
index f80e13e4e2c..452923f7f48 100644
--- a/api/src/com/cloud/configuration/ConfigurationService.java
+++ b/api/src/com/cloud/configuration/ConfigurationService.java
@@ -68,7 +68,8 @@ public interface ConfigurationService {
* Create a service offering through the API
*
* @param cmd
- * the command object that specifies the name, number of cpu cores, amount of RAM, etc. for the service offering
+ * the command object that specifies the name, number of cpu cores, amount of RAM, etc. for the service
+ * offering
* @return the newly created service offering if successful, null otherwise
*/
ServiceOffering createServiceOffering(CreateServiceOfferingCmd cmd);
@@ -130,13 +131,21 @@ public interface ConfigurationService {
/**
* Creates a new pod based on the parameters specified in the command object
- * @param zoneId TODO
- * @param name TODO
- * @param startIp TODO
- * @param endIp TODO
- * @param gateway TODO
- * @param netmask TODO
- * @param allocationState TODO
+ *
+ * @param zoneId
+ * TODO
+ * @param name
+ * TODO
+ * @param startIp
+ * TODO
+ * @param endIp
+ * TODO
+ * @param gateway
+ * TODO
+ * @param netmask
+ * TODO
+ * @param allocationState
+ * TODO
* @return the new pod if successful, null otherwise
* @throws
* @throws
@@ -188,12 +197,14 @@ public interface ConfigurationService {
boolean deleteZone(DeleteZoneCmd cmd);
/**
- * Adds a VLAN to the database, along with an IP address range. Can add three types of VLANs: (1) zone-wide VLANs on the
+ * Adds a VLAN to the database, along with an IP address range. Can add three types of VLANs: (1) zone-wide VLANs on
+ * the
* virtual public network (2) pod-wide direct attached VLANs (3) account-specific direct attached VLANs
*
* @param userId
* @param vlanType
- * - either "DomR" (VLAN for a virtual public network) or "DirectAttached" (VLAN for IPs that will be directly
+ * - either "DomR" (VLAN for a virtual public network) or "DirectAttached" (VLAN for IPs that will be
+ * directly
* attached to UserVMs)
* @param zoneId
* @param accountId
diff --git a/api/src/com/cloud/configuration/Resource.java b/api/src/com/cloud/configuration/Resource.java
index 1dcdc762f2d..e867d859bce 100644
--- a/api/src/com/cloud/configuration/Resource.java
+++ b/api/src/com/cloud/configuration/Resource.java
@@ -18,16 +18,16 @@
package com.cloud.configuration;
public interface Resource {
-
- public static final short RESOURCE_UNLIMITED = -1;
-
- public enum ResourceType{
- user_vm ("user_vm", 0, ResourceOwnerType.Account, ResourceOwnerType.Domain),
- public_ip ("public_ip", 1, ResourceOwnerType.Account, ResourceOwnerType.Domain),
- volume ("volume", 2, ResourceOwnerType.Account, ResourceOwnerType.Domain),
- snapshot ("snapshot", 3, ResourceOwnerType.Account, ResourceOwnerType.Domain),
- template ("template", 4, ResourceOwnerType.Account, ResourceOwnerType.Domain),
- project ("project", 5, ResourceOwnerType.Account, ResourceOwnerType.Domain);
+
+ public static final short RESOURCE_UNLIMITED = -1;
+
+ public enum ResourceType {
+ user_vm("user_vm", 0, ResourceOwnerType.Account, ResourceOwnerType.Domain),
+ public_ip("public_ip", 1, ResourceOwnerType.Account, ResourceOwnerType.Domain),
+ volume("volume", 2, ResourceOwnerType.Account, ResourceOwnerType.Domain),
+ snapshot("snapshot", 3, ResourceOwnerType.Account, ResourceOwnerType.Domain),
+ template("template", 4, ResourceOwnerType.Account, ResourceOwnerType.Domain),
+ project("project", 5, ResourceOwnerType.Account, ResourceOwnerType.Domain);
private String name;
private ResourceOwnerType[] supportedOwners;
@@ -37,7 +37,7 @@ public interface Resource {
this.name = name;
this.supportedOwners = supportedOwners;
this.ordinal = ordinal;
- }
+ }
public String getName() {
return name;
@@ -51,22 +51,22 @@ public interface Resource {
boolean success = false;
if (supportedOwners != null) {
int length = supportedOwners.length;
- for (int i = 0; i< length; i++) {
+ for (int i = 0; i < length; i++) {
if (supportedOwners[i].getName().equalsIgnoreCase(ownerType.getName())) {
success = true;
break;
}
}
- }
+ }
return success;
}
-
+
public int getOrdinal() {
return ordinal;
}
}
-
+
public static class ResourceOwnerType {
public static final ResourceOwnerType Account = new ResourceOwnerType("Account");
@@ -82,11 +82,11 @@ public interface Resource {
return name;
}
}
-
+
ResourceType getType();
-
+
long getOwnerId();
-
+
ResourceOwnerType getResourceOwnerType();
}
diff --git a/api/src/com/cloud/configuration/ResourceCount.java b/api/src/com/cloud/configuration/ResourceCount.java
index e5cc19967bb..a9ebcea5c6f 100644
--- a/api/src/com/cloud/configuration/ResourceCount.java
+++ b/api/src/com/cloud/configuration/ResourceCount.java
@@ -18,12 +18,12 @@
package com.cloud.configuration;
-public interface ResourceCount extends Resource{
-
- public Long getId();
-
- public long getCount();
-
- public void setCount(long count);
+public interface ResourceCount extends Resource {
+
+ public Long getId();
+
+ public long getCount();
+
+ public void setCount(long count);
}
diff --git a/api/src/com/cloud/configuration/ResourceLimit.java b/api/src/com/cloud/configuration/ResourceLimit.java
index 8c8b59d91cc..6b36eab4e1f 100644
--- a/api/src/com/cloud/configuration/ResourceLimit.java
+++ b/api/src/com/cloud/configuration/ResourceLimit.java
@@ -18,12 +18,12 @@
package com.cloud.configuration;
-public interface ResourceLimit extends Resource{
-
- public Long getId();
-
- public Long getMax();
-
- public void setMax(Long max);
-
+public interface ResourceLimit extends Resource {
+
+ public Long getId();
+
+ public Long getMax();
+
+ public void setMax(Long max);
+
}
diff --git a/api/src/com/cloud/dao/EntityManager.java b/api/src/com/cloud/dao/EntityManager.java
index 0c07af63692..e2015761547 100644
--- a/api/src/com/cloud/dao/EntityManager.java
+++ b/api/src/com/cloud/dao/EntityManager.java
@@ -72,3 +72,4 @@ public interface EntityManager {
public void remove(Class entityType, K id);
}
+
diff --git a/api/src/com/cloud/dc/DataCenter.java b/api/src/com/cloud/dc/DataCenter.java
index 0db1f516ff9..7ccaefb4ef3 100644
--- a/api/src/com/cloud/dc/DataCenter.java
+++ b/api/src/com/cloud/dc/DataCenter.java
@@ -34,28 +34,49 @@ public interface DataCenter extends Grouping {
Basic,
Advanced,
}
+
long getId();
+
String getDns1();
+
String getDns2();
+
String getName();
+
Long getDomainId();
+
String getDescription();
+
String getDomain();
-
+
NetworkType getNetworkType();
+
String getInternalDns1();
+
String getInternalDns2();
+
String getDnsProvider();
+
String getGatewayProvider();
+
String getFirewallProvider();
+
String getDhcpProvider();
+
String getLoadBalancerProvider();
+
String getUserDataProvider();
+
String getVpnProvider();
+
boolean isSecurityGroupEnabled();
+
Map getDetails();
+
void setDetails(Map details);
+
AllocationState getAllocationState();
- String getZoneToken();
+
+ String getZoneToken();
}
diff --git a/api/src/com/cloud/dc/Pod.java b/api/src/com/cloud/dc/Pod.java
index 42c71d14ecb..b8f4434f880 100644
--- a/api/src/com/cloud/dc/Pod.java
+++ b/api/src/com/cloud/dc/Pod.java
@@ -22,32 +22,31 @@
package com.cloud.dc;
import com.cloud.org.Grouping;
-import com.cloud.org.Grouping.AllocationState;
/**
* Represents one pod in the cloud stack.
- *
+ *
*/
public interface Pod extends Grouping {
/**
* @return unique id mapped to the pod.
*/
long getId();
-
+
String getCidrAddress();
-
+
int getCidrSize();
String getGateway();
-
+
long getDataCenterId();
-
- //String getUniqueName();
-
+
+ // String getUniqueName();
+
String getDescription();
-
+
String getName();
-
+
AllocationState getAllocationState();
boolean getExternalDhcp();
diff --git a/api/src/com/cloud/dc/StorageNetworkIpRange.java b/api/src/com/cloud/dc/StorageNetworkIpRange.java
index b5042dbd52d..c24329b1731 100755
--- a/api/src/com/cloud/dc/StorageNetworkIpRange.java
+++ b/api/src/com/cloud/dc/StorageNetworkIpRange.java
@@ -1,17 +1,17 @@
package com.cloud.dc;
public interface StorageNetworkIpRange {
- String getUuid();
-
- Integer getVlan();
+ String getUuid();
- String getPodUuid();
+ Integer getVlan();
- String getStartIp();
+ String getPodUuid();
- String getEndIp();
+ String getStartIp();
- String getNetworkUuid();
+ String getEndIp();
- String getZoneUuid();
+ String getNetworkUuid();
+
+ String getZoneUuid();
}
diff --git a/api/src/com/cloud/dc/Vlan.java b/api/src/com/cloud/dc/Vlan.java
index 4fe58ddfd74..ec2d223b5a0 100644
--- a/api/src/com/cloud/dc/Vlan.java
+++ b/api/src/com/cloud/dc/Vlan.java
@@ -19,29 +19,29 @@
package com.cloud.dc;
public interface Vlan {
- public enum VlanType {
- DirectAttached,
- VirtualNetwork
- }
-
- public final static String UNTAGGED = "untagged";
+ public enum VlanType {
+ DirectAttached,
+ VirtualNetwork
+ }
- public long getId();
+ public final static String UNTAGGED = "untagged";
- public String getVlanTag();
+ public long getId();
- public String getVlanGateway();
+ public String getVlanTag();
- public String getVlanNetmask();
+ public String getVlanGateway();
- public long getDataCenterId();
+ public String getVlanNetmask();
- public String getIpRange();
+ public long getDataCenterId();
- public VlanType getVlanType();
-
- public Long getNetworkId();
-
- public Long getPhysicalNetworkId();
+ public String getIpRange();
-}
\ No newline at end of file
+ public VlanType getVlanType();
+
+ public Long getNetworkId();
+
+ public Long getPhysicalNetworkId();
+
+}
diff --git a/api/src/com/cloud/deploy/DataCenterDeployment.java b/api/src/com/cloud/deploy/DataCenterDeployment.java
index 2d65994fa4e..222ab9a23cc 100644
--- a/api/src/com/cloud/deploy/DataCenterDeployment.java
+++ b/api/src/com/cloud/deploy/DataCenterDeployment.java
@@ -28,11 +28,11 @@ public class DataCenterDeployment implements DeploymentPlan {
Long _physicalNetworkId;
ExcludeList _avoids = null;
boolean _recreateDisks;
-
+
public DataCenterDeployment(long dataCenterId) {
this(dataCenterId, null, null, null, null, null);
}
-
+
public DataCenterDeployment(long dataCenterId, Long podId, Long clusterId, Long hostId, Long poolId, Long physicalNetworkId) {
_dcId = dataCenterId;
_podId = podId;
@@ -41,7 +41,7 @@ public class DataCenterDeployment implements DeploymentPlan {
_poolId = poolId;
_physicalNetworkId = physicalNetworkId;
}
-
+
@Override
public long getDataCenterId() {
return _dcId;
@@ -58,10 +58,10 @@ public class DataCenterDeployment implements DeploymentPlan {
}
@Override
- public Long getHostId(){
- return _hostId;
+ public Long getHostId() {
+ return _hostId;
}
-
+
@Override
public Long getPoolId() {
return _poolId;
@@ -76,7 +76,7 @@ public class DataCenterDeployment implements DeploymentPlan {
public void setAvoids(ExcludeList avoids) {
_avoids = avoids;
}
-
+
@Override
public Long getPhysicalNetworkId() {
return _physicalNetworkId;
diff --git a/api/src/com/cloud/deploy/DeployDestination.java b/api/src/com/cloud/deploy/DeployDestination.java
index a482a9e3851..4acf3d80421 100644
--- a/api/src/com/cloud/deploy/DeployDestination.java
+++ b/api/src/com/cloud/deploy/DeployDestination.java
@@ -41,19 +41,19 @@ public class DeployDestination {
public DataCenter getDataCenter() {
return _dc;
}
-
+
public Pod getPod() {
return _pod;
}
-
+
public Cluster getCluster() {
return _cluster;
}
-
+
public Host getHost() {
return _host;
}
-
+
public Map getStorageForDisks() {
return _storage;
}
@@ -64,23 +64,23 @@ public class DeployDestination {
_cluster = cluster;
_host = host;
}
-
+
public DeployDestination(DataCenter dc, Pod pod, Cluster cluster, Host host, Map storage) {
- this(dc,pod,cluster,host);
+ this(dc, pod, cluster, host);
_storage = storage;
}
public DeployDestination() {
}
-
+
@Override
public int hashCode() {
return NumbersUtil.hash(_host.getId());
}
-
+
@Override
public boolean equals(Object obj) {
- DeployDestination that = (DeployDestination)obj;
+ DeployDestination that = (DeployDestination) obj;
if (this._dc == null || that._dc == null) {
return false;
}
@@ -104,47 +104,47 @@ public class DeployDestination {
}
return this._host.getId() == that._host.getId();
}
-
+
@Override
public String toString() {
-
+
Long dcId = null;
Long podId = null;
Long clusterId = null;
Long hostId = null;
-
+
if (_dc != null) {
dcId = _dc.getId();
- }
-
+ }
+
if (_pod != null) {
podId = _pod.getId();
}
-
+
if (_cluster != null) {
clusterId = _cluster.getId();
}
-
+
if (_host != null) {
hostId = _host.getId();
}
-
- StringBuilder destination = new StringBuilder("Dest[Zone(Id)-Pod(Id)-Cluster(Id)-Host(Id)-Storage(Volume(Id|Type-->Pool(Id))] : Dest[");
- destination.append("Zone(").append(dcId).append(")").append("-");
- destination.append("Pod(").append(podId).append(")").append("-");
- destination.append("Cluster(").append(clusterId).append(")").append("-");
- destination.append("Host(").append(hostId).append(")").append("-");
- destination.append("Storage(");
- if(_storage != null){
- String storageStr = "";
- for(Volume vol : _storage.keySet()){
- if(!storageStr.equals("")){
- storageStr = storageStr + ", ";
- }
- storageStr = storageStr + "Volume(" + vol.getId() + "|"+ vol.getVolumeType().name() + "-->Pool("+_storage.get(vol).getId()+")";
- }
- destination.append(storageStr);
- }
+
+ StringBuilder destination = new StringBuilder("Dest[Zone(Id)-Pod(Id)-Cluster(Id)-Host(Id)-Storage(Volume(Id|Type-->Pool(Id))] : Dest[");
+ destination.append("Zone(").append(dcId).append(")").append("-");
+ destination.append("Pod(").append(podId).append(")").append("-");
+ destination.append("Cluster(").append(clusterId).append(")").append("-");
+ destination.append("Host(").append(hostId).append(")").append("-");
+ destination.append("Storage(");
+ if (_storage != null) {
+ String storageStr = "";
+ for (Volume vol : _storage.keySet()) {
+ if (!storageStr.equals("")) {
+ storageStr = storageStr + ", ";
+ }
+ storageStr = storageStr + "Volume(" + vol.getId() + "|" + vol.getVolumeType().name() + "-->Pool(" + _storage.get(vol).getId() + ")";
+ }
+ destination.append(storageStr);
+ }
return destination.append(")]").toString();
}
}
diff --git a/api/src/com/cloud/deploy/DeploymentPlan.java b/api/src/com/cloud/deploy/DeploymentPlan.java
index 5f7144d49c3..91ad5825ba5 100644
--- a/api/src/com/cloud/deploy/DeploymentPlan.java
+++ b/api/src/com/cloud/deploy/DeploymentPlan.java
@@ -20,47 +20,47 @@ package com.cloud.deploy;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
/**
- * Describes how a VM should be deployed.
+ * Describes how a VM should be deployed.
*/
public interface DeploymentPlan {
- // TODO: This interface is not fully developed. It really
- // should be more complicated than this and allow a
- // number of parameters to be specified.
-
+ // TODO: This interface is not fully developed. It really
+ // should be more complicated than this and allow a
+ // number of parameters to be specified.
+
/**
* @return data center the VM should deploy in.
*/
public long getDataCenterId();
-
+
/**
* @return pod the Vm should deploy in; null if no preference.
*/
public Long getPodId();
-
+
/**
* @return cluster the VM should deploy in; null if no preference.
*/
public Long getClusterId();
-
+
/**
* @return host the VM should deploy in; null if no preference.
*/
public Long getHostId();
-
+
/**
* @return pool the VM should be created in; null if no preference.
*/
public Long getPoolId();
-
+
/**
* @param avoids
- * Set the ExcludeList to avoid for deployment
+ * Set the ExcludeList to avoid for deployment
*/
public void setAvoids(ExcludeList avoids);
/**
* @return
- * the ExcludeList to avoid for deployment
+ * the ExcludeList to avoid for deployment
*/
public ExcludeList getAvoids();
diff --git a/api/src/com/cloud/deploy/DeploymentPlanner.java b/api/src/com/cloud/deploy/DeploymentPlanner.java
index 669024c63e7..2644215ee3c 100644
--- a/api/src/com/cloud/deploy/DeploymentPlanner.java
+++ b/api/src/com/cloud/deploy/DeploymentPlanner.java
@@ -43,67 +43,79 @@ public interface DeploymentPlanner extends Adapter {
/**
* plan is called to determine where a virtual machine should be running.
*
- * @param vm virtual machine.
- * @param plan deployment plan that tells you where it's being deployed to.
- * @param avoid avoid these data centers, pods, clusters, or hosts.
+ * @param vm
+ * virtual machine.
+ * @param plan
+ * deployment plan that tells you where it's being deployed to.
+ * @param avoid
+ * avoid these data centers, pods, clusters, or hosts.
* @return DeployDestination for that virtual machine.
*/
DeployDestination plan(VirtualMachineProfile extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException;
-
+
/**
* check() is called right before the virtual machine starts to make sure
* the host has enough capacity.
*
- * @param vm virtual machine in question.
- * @param plan deployment plan used to determined the deploy destination.
- * @param dest destination returned by plan.
- * @param avoid what to avoid.
- * @return true if it's okay to start; false if not. If false, the exclude list will include what should be excluded.
+ * @param vm
+ * virtual machine in question.
+ * @param plan
+ * deployment plan used to determined the deploy destination.
+ * @param dest
+ * destination returned by plan.
+ * @param avoid
+ * what to avoid.
+ * @return true if it's okay to start; false if not. If false, the exclude list will include what should be
+ * excluded.
*/
boolean check(VirtualMachineProfile extends VirtualMachine> vm, DeploymentPlan plan, DeployDestination dest, ExcludeList exclude);
-
+
/**
- * canHandle is called before plan to determine if the plan can do the allocation. Planers should be exclusive so planner writer must
+ * canHandle is called before plan to determine if the plan can do the allocation. Planers should be exclusive so
+ * planner writer must
* make sure only one planer->canHandle return true in the planner list
*
- * @param vm virtual machine.
- * @param plan deployment plan that tells you where it's being deployed to.
- * @param avoid avoid these data centers, pods, clusters, or hosts.
+ * @param vm
+ * virtual machine.
+ * @param plan
+ * deployment plan that tells you where it's being deployed to.
+ * @param avoid
+ * avoid these data centers, pods, clusters, or hosts.
* @return true if it's okay to allocate; false or not
*/
boolean canHandle(VirtualMachineProfile extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid);
-
+
public enum AllocationAlgorithm {
random,
firstfit,
userdispersing,
userconcentratedpod;
}
-
+
public static class ExcludeList {
private Set _dcIds;
private Set _podIds;
private Set _clusterIds;
private Set _hostIds;
private Set _poolIds;
-
- public ExcludeList(){
+
+ public ExcludeList() {
}
-
- public ExcludeList(Set _dcIds, Set _podIds, Set _clusterIds, Set _hostIds, Set _poolIds){
- this._dcIds = _dcIds;
- this._podIds = _podIds;
- this._clusterIds = _clusterIds;
- this._poolIds = _poolIds;
+
+ public ExcludeList(Set _dcIds, Set _podIds, Set _clusterIds, Set _hostIds, Set _poolIds) {
+ this._dcIds = _dcIds;
+ this._podIds = _podIds;
+ this._clusterIds = _clusterIds;
+ this._poolIds = _poolIds;
}
-
+
public boolean add(InsufficientCapacityException e) {
Class> scope = e.getScope();
-
+
if (scope == null) {
return false;
}
-
+
if (Host.class.isAssignableFrom(scope)) {
addHost(e.getId());
} else if (Pod.class.isAssignableFrom(scope)) {
@@ -117,17 +129,17 @@ public interface DeploymentPlanner extends Adapter {
} else {
return false;
}
-
+
return true;
}
-
+
public boolean add(ResourceUnavailableException e) {
Class> scope = e.getScope();
-
+
if (scope == null) {
return false;
}
-
+
if (Host.class.isAssignableFrom(scope)) {
addHost(e.getResourceId());
} else if (Pod.class.isAssignableFrom(scope)) {
@@ -141,109 +153,109 @@ public interface DeploymentPlanner extends Adapter {
} else {
return false;
}
-
+
return true;
}
-
+
public void addPool(long poolId) {
- if (_poolIds == null) {
- _poolIds = new HashSet();
- }
+ if (_poolIds == null) {
+ _poolIds = new HashSet();
+ }
_poolIds.add(poolId);
}
-
+
public void addDataCenter(long dataCenterId) {
if (_dcIds == null) {
_dcIds = new HashSet();
}
_dcIds.add(dataCenterId);
}
-
+
public void addPod(long podId) {
if (_podIds == null) {
_podIds = new HashSet();
}
_podIds.add(podId);
}
-
+
public void addCluster(long clusterId) {
if (_clusterIds == null) {
_clusterIds = new HashSet();
}
_clusterIds.add(clusterId);
}
-
+
public void addHost(long hostId) {
if (_hostIds == null) {
_hostIds = new HashSet();
}
_hostIds.add(hostId);
}
-
+
public boolean shouldAvoid(Host host) {
if (_dcIds != null && _dcIds.contains(host.getDataCenterId())) {
return true;
}
-
+
if (_podIds != null && _podIds.contains(host.getPodId())) {
return true;
}
-
+
if (_clusterIds != null && _clusterIds.contains(host.getClusterId())) {
return true;
}
-
+
if (_hostIds != null && _hostIds.contains(host.getId())) {
return true;
}
-
+
return false;
}
-
+
public boolean shouldAvoid(Cluster cluster) {
if (_dcIds != null && _dcIds.contains(cluster.getDataCenterId())) {
return true;
}
-
+
if (_podIds != null && _podIds.contains(cluster.getPodId())) {
return true;
}
-
+
if (_clusterIds != null && _clusterIds.contains(cluster.getId())) {
return true;
- }
+ }
return false;
}
-
+
public boolean shouldAvoid(Pod pod) {
if (_dcIds != null && _dcIds.contains(pod.getDataCenterId())) {
return true;
}
-
+
if (_podIds != null && _podIds.contains(pod.getId())) {
return true;
}
-
+
return false;
}
-
+
public boolean shouldAvoid(StoragePool pool) {
if (_dcIds != null && _dcIds.contains(pool.getDataCenterId())) {
return true;
}
-
+
if (_podIds != null && _podIds.contains(pool.getPodId())) {
return true;
}
-
+
if (_clusterIds != null && _clusterIds.contains(pool.getClusterId())) {
return true;
}
-
+
if (_poolIds != null && _poolIds.contains(pool.getId())) {
return true;
}
-
+
return false;
}
@@ -252,26 +264,26 @@ public interface DeploymentPlanner extends Adapter {
return true;
}
return false;
- }
+ }
- public Set getDataCentersToAvoid(){
- return _dcIds;
+ public Set getDataCentersToAvoid() {
+ return _dcIds;
}
-
- public Set getPodsToAvoid(){
- return _podIds;
+
+ public Set getPodsToAvoid() {
+ return _podIds;
}
-
- public Set getClustersToAvoid(){
- return _clusterIds;
+
+ public Set getClustersToAvoid() {
+ return _clusterIds;
}
-
- public Set getHostsToAvoid(){
- return _hostIds;
+
+ public Set getHostsToAvoid() {
+ return _hostIds;
}
-
- public Set getPoolsToAvoid(){
- return _poolIds;
+
+ public Set getPoolsToAvoid() {
+ return _poolIds;
}
}
}
diff --git a/api/src/com/cloud/domain/Domain.java b/api/src/com/cloud/domain/Domain.java
index fc27974f374..e8d8cea5d70 100644
--- a/api/src/com/cloud/domain/Domain.java
+++ b/api/src/com/cloud/domain/Domain.java
@@ -30,29 +30,31 @@ import com.cloud.user.OwnedBy;
*/
public interface Domain extends OwnedBy {
public static final long ROOT_DOMAIN = 1L;
-
- enum State {Active, Inactive};
-
+
+ enum State {
+ Active, Inactive
+ };
+
long getId();
Long getParent();
-
+
void setParent(Long parent);
String getName();
-
+
void setName(String name);
-
+
Date getRemoved();
-
+
String getPath();
-
+
void setPath(String path);
-
+
int getLevel();
-
+
int getChildCount();
-
+
long getNextChildSeq();
State getState();
diff --git a/api/src/com/cloud/domain/PartOf.java b/api/src/com/cloud/domain/PartOf.java
index 70f7a3c7857..ccee2bbe569 100644
--- a/api/src/com/cloud/domain/PartOf.java
+++ b/api/src/com/cloud/domain/PartOf.java
@@ -22,7 +22,7 @@
package com.cloud.domain;
/**
- * PartOf must be implemented by all objects that belongs
+ * PartOf must be implemented by all objects that belongs
* in a domain.
*/
public interface PartOf {
diff --git a/api/src/com/cloud/event/ActionEvent.java b/api/src/com/cloud/event/ActionEvent.java
index 61ff14ba968..1175a5201d8 100644
--- a/api/src/com/cloud/event/ActionEvent.java
+++ b/api/src/com/cloud/event/ActionEvent.java
@@ -24,11 +24,14 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-@Target({TYPE, METHOD})
+@Target({ TYPE, METHOD })
@Retention(RUNTIME)
public @interface ActionEvent {
boolean create() default false;
+
boolean async() default false;
+
String eventType();
+
String eventDescription();
}
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index dea9234e9ee..d4d40dbb1e8 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -16,171 +16,171 @@
*
*/
-package com.cloud.event;
-
-public class EventTypes {
- // VM Events
- public static final String EVENT_VM_CREATE = "VM.CREATE";
- public static final String EVENT_VM_DESTROY = "VM.DESTROY";
- public static final String EVENT_VM_START = "VM.START";
- public static final String EVENT_VM_STOP = "VM.STOP";
- public static final String EVENT_VM_REBOOT = "VM.REBOOT";
- public static final String EVENT_VM_UPDATE = "VM.UPDATE";
- public static final String EVENT_VM_UPGRADE = "VM.UPGRADE";
- public static final String EVENT_VM_RESETPASSWORD = "VM.RESETPASSWORD";
- public static final String EVENT_VM_MIGRATE = "VM.MIGRATE";
+package com.cloud.event;
+
+public class EventTypes {
+ // VM Events
+ public static final String EVENT_VM_CREATE = "VM.CREATE";
+ public static final String EVENT_VM_DESTROY = "VM.DESTROY";
+ public static final String EVENT_VM_START = "VM.START";
+ public static final String EVENT_VM_STOP = "VM.STOP";
+ public static final String EVENT_VM_REBOOT = "VM.REBOOT";
+ public static final String EVENT_VM_UPDATE = "VM.UPDATE";
+ public static final String EVENT_VM_UPGRADE = "VM.UPGRADE";
+ public static final String EVENT_VM_RESETPASSWORD = "VM.RESETPASSWORD";
+ public static final String EVENT_VM_MIGRATE = "VM.MIGRATE";
public static final String EVENT_VM_MOVE = "VM.MOVE";
public static final String EVENT_VM_RESTORE = "VM.RESTORE";
-
- // Domain Router
- public static final String EVENT_ROUTER_CREATE = "ROUTER.CREATE";
- public static final String EVENT_ROUTER_DESTROY = "ROUTER.DESTROY";
- public static final String EVENT_ROUTER_START = "ROUTER.START";
- public static final String EVENT_ROUTER_STOP = "ROUTER.STOP";
- public static final String EVENT_ROUTER_REBOOT = "ROUTER.REBOOT";
- public static final String EVENT_ROUTER_HA = "ROUTER.HA";
- public static final String EVENT_ROUTER_UPGRADE = "ROUTER.UPGRADE";
- // Console proxy
- public static final String EVENT_PROXY_CREATE = "PROXY.CREATE";
- public static final String EVENT_PROXY_DESTROY = "PROXY.DESTROY";
- public static final String EVENT_PROXY_START = "PROXY.START";
- public static final String EVENT_PROXY_STOP = "PROXY.STOP";
- public static final String EVENT_PROXY_REBOOT = "PROXY.REBOOT";
- public static final String EVENT_PROXY_HA = "PROXY.HA";
+ // Domain Router
+ public static final String EVENT_ROUTER_CREATE = "ROUTER.CREATE";
+ public static final String EVENT_ROUTER_DESTROY = "ROUTER.DESTROY";
+ public static final String EVENT_ROUTER_START = "ROUTER.START";
+ public static final String EVENT_ROUTER_STOP = "ROUTER.STOP";
+ public static final String EVENT_ROUTER_REBOOT = "ROUTER.REBOOT";
+ public static final String EVENT_ROUTER_HA = "ROUTER.HA";
+ public static final String EVENT_ROUTER_UPGRADE = "ROUTER.UPGRADE";
- // VNC Console Events
- public static final String EVENT_VNC_CONNECT = "VNC.CONNECT";
- public static final String EVENT_VNC_DISCONNECT = "VNC.DISCONNECT";
+ // Console proxy
+ public static final String EVENT_PROXY_CREATE = "PROXY.CREATE";
+ public static final String EVENT_PROXY_DESTROY = "PROXY.DESTROY";
+ public static final String EVENT_PROXY_START = "PROXY.START";
+ public static final String EVENT_PROXY_STOP = "PROXY.STOP";
+ public static final String EVENT_PROXY_REBOOT = "PROXY.REBOOT";
+ public static final String EVENT_PROXY_HA = "PROXY.HA";
- // Network Events
- public static final String EVENT_NET_IP_ASSIGN = "NET.IPASSIGN";
- public static final String EVENT_NET_IP_RELEASE = "NET.IPRELEASE";
- public static final String EVENT_NET_RULE_ADD = "NET.RULEADD";
- public static final String EVENT_NET_RULE_DELETE = "NET.RULEDELETE";
+ // VNC Console Events
+ public static final String EVENT_VNC_CONNECT = "VNC.CONNECT";
+ public static final String EVENT_VNC_DISCONNECT = "VNC.DISCONNECT";
+
+ // Network Events
+ public static final String EVENT_NET_IP_ASSIGN = "NET.IPASSIGN";
+ public static final String EVENT_NET_IP_RELEASE = "NET.IPRELEASE";
+ public static final String EVENT_NET_RULE_ADD = "NET.RULEADD";
+ public static final String EVENT_NET_RULE_DELETE = "NET.RULEDELETE";
public static final String EVENT_NET_RULE_MODIFY = "NET.RULEMODIFY";
public static final String EVENT_NETWORK_CREATE = "NETWORK.CREATE";
public static final String EVENT_NETWORK_DELETE = "NETWORK.DELETE";
public static final String EVENT_NETWORK_UPDATE = "NETWORK.UPDATE";
public static final String EVENT_FIREWALL_OPEN = "FIREWALL.OPEN";
public static final String EVENT_FIREWALL_CLOSE = "FIREWALL.CLOSE";
-
+
// Load Balancers
- public static final String EVENT_ASSIGN_TO_LOAD_BALANCER_RULE = "LB.ASSIGN.TO.RULE";
+ public static final String EVENT_ASSIGN_TO_LOAD_BALANCER_RULE = "LB.ASSIGN.TO.RULE";
public static final String EVENT_REMOVE_FROM_LOAD_BALANCER_RULE = "LB.REMOVE.FROM.RULE";
public static final String EVENT_LOAD_BALANCER_CREATE = "LB.CREATE";
public static final String EVENT_LOAD_BALANCER_DELETE = "LB.DELETE";
public static final String EVENT_LB_STICKINESSPOLICY_CREATE = "LB.STICKINESSPOLICY.CREATE";
- public static final String EVENT_LB_STICKINESSPOLICY_DELETE = "LB.STICKINESSPOLICY.DELETE";
+ public static final String EVENT_LB_STICKINESSPOLICY_DELETE = "LB.STICKINESSPOLICY.DELETE";
public static final String EVENT_LOAD_BALANCER_UPDATE = "LB.UPDATE";
// Account events
public static final String EVENT_ACCOUNT_DISABLE = "ACCOUNT.DISABLE";
public static final String EVENT_ACCOUNT_CREATE = "ACCOUNT.CREATE";
public static final String EVENT_ACCOUNT_DELETE = "ACCOUNT.DELETE";
-
- // UserVO Events
- public static final String EVENT_USER_LOGIN = "USER.LOGIN";
- public static final String EVENT_USER_LOGOUT = "USER.LOGOUT";
- public static final String EVENT_USER_CREATE = "USER.CREATE";
- public static final String EVENT_USER_DELETE = "USER.DELETE";
- public static final String EVENT_USER_DISABLE = "USER.DISABLE";
- public static final String EVENT_USER_UPDATE = "USER.UPDATE";
- public static final String EVENT_USER_ENABLE = "USER.ENABLE";
- public static final String EVENT_USER_LOCK = "USER.LOCK";
- //Template Events
- public static final String EVENT_TEMPLATE_CREATE = "TEMPLATE.CREATE";
- public static final String EVENT_TEMPLATE_DELETE = "TEMPLATE.DELETE";
- public static final String EVENT_TEMPLATE_UPDATE = "TEMPLATE.UPDATE";
+ // UserVO Events
+ public static final String EVENT_USER_LOGIN = "USER.LOGIN";
+ public static final String EVENT_USER_LOGOUT = "USER.LOGOUT";
+ public static final String EVENT_USER_CREATE = "USER.CREATE";
+ public static final String EVENT_USER_DELETE = "USER.DELETE";
+ public static final String EVENT_USER_DISABLE = "USER.DISABLE";
+ public static final String EVENT_USER_UPDATE = "USER.UPDATE";
+ public static final String EVENT_USER_ENABLE = "USER.ENABLE";
+ public static final String EVENT_USER_LOCK = "USER.LOCK";
+
+ // Template Events
+ public static final String EVENT_TEMPLATE_CREATE = "TEMPLATE.CREATE";
+ public static final String EVENT_TEMPLATE_DELETE = "TEMPLATE.DELETE";
+ public static final String EVENT_TEMPLATE_UPDATE = "TEMPLATE.UPDATE";
public static final String EVENT_TEMPLATE_DOWNLOAD_START = "TEMPLATE.DOWNLOAD.START";
public static final String EVENT_TEMPLATE_DOWNLOAD_SUCCESS = "TEMPLATE.DOWNLOAD.SUCCESS";
- public static final String EVENT_TEMPLATE_DOWNLOAD_FAILED = "TEMPLATE.DOWNLOAD.FAILED";
- public static final String EVENT_TEMPLATE_COPY = "TEMPLATE.COPY";
+ public static final String EVENT_TEMPLATE_DOWNLOAD_FAILED = "TEMPLATE.DOWNLOAD.FAILED";
+ public static final String EVENT_TEMPLATE_COPY = "TEMPLATE.COPY";
public static final String EVENT_TEMPLATE_EXTRACT = "TEMPLATE.EXTRACT";
public static final String EVENT_TEMPLATE_UPLOAD = "TEMPLATE.UPLOAD";
- public static final String EVENT_TEMPLATE_CLEANUP = "TEMPLATE.CLEANUP";
+ public static final String EVENT_TEMPLATE_CLEANUP = "TEMPLATE.CLEANUP";
- // Volume Events
- public static final String EVENT_VOLUME_CREATE = "VOLUME.CREATE";
- public static final String EVENT_VOLUME_DELETE = "VOLUME.DELETE";
- public static final String EVENT_VOLUME_ATTACH = "VOLUME.ATTACH";
- public static final String EVENT_VOLUME_DETACH = "VOLUME.DETACH";
- public static final String EVENT_VOLUME_EXTRACT = "VOLUME.EXTRACT";
- public static final String EVENT_VOLUME_UPLOAD = "VOLUME.UPLOAD";
- public static final String EVENT_VOLUME_MIGRATE = "VOLUME.MIGRATE";
+ // Volume Events
+ public static final String EVENT_VOLUME_CREATE = "VOLUME.CREATE";
+ public static final String EVENT_VOLUME_DELETE = "VOLUME.DELETE";
+ public static final String EVENT_VOLUME_ATTACH = "VOLUME.ATTACH";
+ public static final String EVENT_VOLUME_DETACH = "VOLUME.DETACH";
+ public static final String EVENT_VOLUME_EXTRACT = "VOLUME.EXTRACT";
+ public static final String EVENT_VOLUME_UPLOAD = "VOLUME.UPLOAD";
+ public static final String EVENT_VOLUME_MIGRATE = "VOLUME.MIGRATE";
- // Domains
- public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE";
- public static final String EVENT_DOMAIN_DELETE = "DOMAIN.DELETE";
- public static final String EVENT_DOMAIN_UPDATE = "DOMAIN.UPDATE";
+ // Domains
+ public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE";
+ public static final String EVENT_DOMAIN_DELETE = "DOMAIN.DELETE";
+ public static final String EVENT_DOMAIN_UPDATE = "DOMAIN.UPDATE";
- // Snapshots
- public static final String EVENT_SNAPSHOT_CREATE = "SNAPSHOT.CREATE";
- public static final String EVENT_SNAPSHOT_DELETE = "SNAPSHOT.DELETE";
+ // Snapshots
+ public static final String EVENT_SNAPSHOT_CREATE = "SNAPSHOT.CREATE";
+ public static final String EVENT_SNAPSHOT_DELETE = "SNAPSHOT.DELETE";
public static final String EVENT_SNAPSHOT_POLICY_CREATE = "SNAPSHOTPOLICY.CREATE";
public static final String EVENT_SNAPSHOT_POLICY_UPDATE = "SNAPSHOTPOLICY.UPDATE";
- public static final String EVENT_SNAPSHOT_POLICY_DELETE = "SNAPSHOTPOLICY.DELETE";
+ public static final String EVENT_SNAPSHOT_POLICY_DELETE = "SNAPSHOTPOLICY.DELETE";
- // ISO
- public static final String EVENT_ISO_CREATE = "ISO.CREATE";
- public static final String EVENT_ISO_DELETE = "ISO.DELETE";
- public static final String EVENT_ISO_COPY = "ISO.COPY";
- public static final String EVENT_ISO_ATTACH = "ISO.ATTACH";
+ // ISO
+ public static final String EVENT_ISO_CREATE = "ISO.CREATE";
+ public static final String EVENT_ISO_DELETE = "ISO.DELETE";
+ public static final String EVENT_ISO_COPY = "ISO.COPY";
+ public static final String EVENT_ISO_ATTACH = "ISO.ATTACH";
public static final String EVENT_ISO_DETACH = "ISO.DETACH";
public static final String EVENT_ISO_EXTRACT = "ISO.EXTRACT";
- public static final String EVENT_ISO_UPLOAD = "ISO.UPLOAD";
+ public static final String EVENT_ISO_UPLOAD = "ISO.UPLOAD";
- //SSVM
+ // SSVM
public static final String EVENT_SSVM_CREATE = "SSVM.CREATE";
- public static final String EVENT_SSVM_DESTROY = "SSVM.DESTROY";
- public static final String EVENT_SSVM_START = "SSVM.START";
- public static final String EVENT_SSVM_STOP = "SSVM.STOP";
- public static final String EVENT_SSVM_REBOOT = "SSVM.REBOOT";
- public static final String EVENT_SSVM_HA = "SSVM.HA";
+ public static final String EVENT_SSVM_DESTROY = "SSVM.DESTROY";
+ public static final String EVENT_SSVM_START = "SSVM.START";
+ public static final String EVENT_SSVM_STOP = "SSVM.STOP";
+ public static final String EVENT_SSVM_REBOOT = "SSVM.REBOOT";
+ public static final String EVENT_SSVM_HA = "SSVM.HA";
- // Service Offerings
- public static final String EVENT_SERVICE_OFFERING_CREATE = "SERVICE.OFFERING.CREATE";
- public static final String EVENT_SERVICE_OFFERING_EDIT = "SERVICE.OFFERING.EDIT";
- public static final String EVENT_SERVICE_OFFERING_DELETE = "SERVICE.OFFERING.DELETE";
+ // Service Offerings
+ public static final String EVENT_SERVICE_OFFERING_CREATE = "SERVICE.OFFERING.CREATE";
+ public static final String EVENT_SERVICE_OFFERING_EDIT = "SERVICE.OFFERING.EDIT";
+ public static final String EVENT_SERVICE_OFFERING_DELETE = "SERVICE.OFFERING.DELETE";
- // Disk Offerings
+ // Disk Offerings
public static final String EVENT_DISK_OFFERING_CREATE = "DISK.OFFERING.CREATE";
public static final String EVENT_DISK_OFFERING_EDIT = "DISK.OFFERING.EDIT";
public static final String EVENT_DISK_OFFERING_DELETE = "DISK.OFFERING.DELETE";
-
- //Network offerings
+
+ // Network offerings
public static final String EVENT_NETWORK_OFFERING_CREATE = "NETWORK.OFFERING.CREATE";
public static final String EVENT_NETWORK_OFFERING_ASSIGN = "NETWORK.OFFERING.ASSIGN";
public static final String EVENT_NETWORK_OFFERING_EDIT = "NETWORK.OFFERING.EDIT";
public static final String EVENT_NETWORK_OFFERING_REMOVE = "NETWORK.OFFERING.REMOVE";
public static final String EVENT_NETWORK_OFFERING_DELETE = "NETWORK.OFFERING.DELETE";
- // Pods
- public static final String EVENT_POD_CREATE = "POD.CREATE";
- public static final String EVENT_POD_EDIT = "POD.EDIT";
- public static final String EVENT_POD_DELETE = "POD.DELETE";
+ // Pods
+ public static final String EVENT_POD_CREATE = "POD.CREATE";
+ public static final String EVENT_POD_EDIT = "POD.EDIT";
+ public static final String EVENT_POD_DELETE = "POD.DELETE";
- // Zones
- public static final String EVENT_ZONE_CREATE = "ZONE.CREATE";
- public static final String EVENT_ZONE_EDIT = "ZONE.EDIT";
- public static final String EVENT_ZONE_DELETE = "ZONE.DELETE";
+ // Zones
+ public static final String EVENT_ZONE_CREATE = "ZONE.CREATE";
+ public static final String EVENT_ZONE_EDIT = "ZONE.EDIT";
+ public static final String EVENT_ZONE_DELETE = "ZONE.DELETE";
- // VLANs/IP ranges
- public static final String EVENT_VLAN_IP_RANGE_CREATE = "VLAN.IP.RANGE.CREATE";
- public static final String EVENT_VLAN_IP_RANGE_DELETE = "VLAN.IP.RANGE.DELETE";
-
- public static final String EVENT_STORAGE_IP_RANGE_CREATE = "STORAGE.IP.RANGE.CREATE";
- public static final String EVENT_STORAGE_IP_RANGE_DELETE = "STORAGE.IP.RANGE.DELETE";
- public static final String EVENT_STORAGE_IP_RANGE_UPDATE = "STORAGE.IP.RANGE.UPDATE";
+ // VLANs/IP ranges
+ public static final String EVENT_VLAN_IP_RANGE_CREATE = "VLAN.IP.RANGE.CREATE";
+ public static final String EVENT_VLAN_IP_RANGE_DELETE = "VLAN.IP.RANGE.DELETE";
- // Configuration Table
- public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT";
+ public static final String EVENT_STORAGE_IP_RANGE_CREATE = "STORAGE.IP.RANGE.CREATE";
+ public static final String EVENT_STORAGE_IP_RANGE_DELETE = "STORAGE.IP.RANGE.DELETE";
+ public static final String EVENT_STORAGE_IP_RANGE_UPDATE = "STORAGE.IP.RANGE.UPDATE";
- // Security Groups
- public static final String EVENT_SECURITY_GROUP_AUTHORIZE_INGRESS = "SG.AUTH.INGRESS";
+ // Configuration Table
+ public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT";
+
+ // Security Groups
+ public static final String EVENT_SECURITY_GROUP_AUTHORIZE_INGRESS = "SG.AUTH.INGRESS";
public static final String EVENT_SECURITY_GROUP_REVOKE_INGRESS = "SG.REVOKE.INGRESS";
- public static final String EVENT_SECURITY_GROUP_AUTHORIZE_EGRESS = "SG.AUTH.EGRESS";
+ public static final String EVENT_SECURITY_GROUP_AUTHORIZE_EGRESS = "SG.AUTH.EGRESS";
public static final String EVENT_SECURITY_GROUP_REVOKE_EGRESS = "SG.REVOKE.EGRESS";
public static final String EVENT_SECURITY_GROUP_CREATE = "SG.CREATE";
public static final String EVENT_SECURITY_GROUP_DELETE = "SG.DELETE";
@@ -193,61 +193,61 @@ public class EventTypes {
public static final String EVENT_MAINTENANCE_CANCEL_PRIMARY_STORAGE = "MAINT.CANCEL.PS";
public static final String EVENT_MAINTENANCE_PREPARE = "MAINT.PREPARE";
public static final String EVENT_MAINTENANCE_PREPARE_PRIMARY_STORAGE = "MAINT.PREPARE.PS";
-
- //VPN
+
+ // VPN
public static final String EVENT_REMOTE_ACCESS_VPN_CREATE = "VPN.REMOTE.ACCESS.CREATE";
public static final String EVENT_REMOTE_ACCESS_VPN_DESTROY = "VPN.REMOTE.ACCESS.DESTROY";
public static final String EVENT_VPN_USER_ADD = "VPN.USER.ADD";
public static final String EVENT_VPN_USER_REMOVE = "VPN.USER.REMOVE";
-
- //Network
- public static final String EVENT_NETWORK_RESTART = "NETWORK.RESTART";
-
- //Custom certificates
- public static final String EVENT_UPLOAD_CUSTOM_CERTIFICATE = "UPLOAD.CUSTOM.CERTIFICATE";
-
- //OneToOnenat
- public static final String EVENT_ENABLE_STATIC_NAT = "STATICNAT.ENABLE";
- public static final String EVENT_DISABLE_STATIC_NAT = "STATICNAT.DISABLE";
-
- public static final String EVENT_ZONE_VLAN_ASSIGN = "ZONE.VLAN.ASSIGN";
- public static final String EVENT_ZONE_VLAN_RELEASE = "ZONE.VLAN.RELEASE";
-
- //Projects
- public static final String EVENT_PROJECT_CREATE = "PROJECT.CREATE";
- public static final String EVENT_PROJECT_UPDATE = "PROJECT.UPDATE";
- public static final String EVENT_PROJECT_DELETE = "PROJECT.DELETE";
- public static final String EVENT_PROJECT_ACTIVATE = "PROJECT.ACTIVATE";
- public static final String EVENT_PROJECT_SUSPEND = "PROJECT.SUSPEND";
- public static final String EVENT_PROJECT_ACCOUNT_ADD = "PROJECT.ACCOUNT.ADD";
- public static final String EVENT_PROJECT_INVITATION_UPDATE = "PROJECT.INVITATION.UPDATE";
- public static final String EVENT_PROJECT_INVITATION_REMOVE = "PROJECT.INVITATION.REMOVE";
- public static final String EVENT_PROJECT_ACCOUNT_REMOVE = "PROJECT.ACCOUNT.REMOVE";
-
- //Network as a Service
- public static final String EVENT_NETWORK_ELEMENT_CONFIGURE = "NETWORK.ELEMENT.CONFIGURE";
- //Physical Network Events
+ // Network
+ public static final String EVENT_NETWORK_RESTART = "NETWORK.RESTART";
+
+ // Custom certificates
+ public static final String EVENT_UPLOAD_CUSTOM_CERTIFICATE = "UPLOAD.CUSTOM.CERTIFICATE";
+
+ // OneToOnenat
+ public static final String EVENT_ENABLE_STATIC_NAT = "STATICNAT.ENABLE";
+ public static final String EVENT_DISABLE_STATIC_NAT = "STATICNAT.DISABLE";
+
+ public static final String EVENT_ZONE_VLAN_ASSIGN = "ZONE.VLAN.ASSIGN";
+ public static final String EVENT_ZONE_VLAN_RELEASE = "ZONE.VLAN.RELEASE";
+
+ // Projects
+ public static final String EVENT_PROJECT_CREATE = "PROJECT.CREATE";
+ public static final String EVENT_PROJECT_UPDATE = "PROJECT.UPDATE";
+ public static final String EVENT_PROJECT_DELETE = "PROJECT.DELETE";
+ public static final String EVENT_PROJECT_ACTIVATE = "PROJECT.ACTIVATE";
+ public static final String EVENT_PROJECT_SUSPEND = "PROJECT.SUSPEND";
+ public static final String EVENT_PROJECT_ACCOUNT_ADD = "PROJECT.ACCOUNT.ADD";
+ public static final String EVENT_PROJECT_INVITATION_UPDATE = "PROJECT.INVITATION.UPDATE";
+ public static final String EVENT_PROJECT_INVITATION_REMOVE = "PROJECT.INVITATION.REMOVE";
+ public static final String EVENT_PROJECT_ACCOUNT_REMOVE = "PROJECT.ACCOUNT.REMOVE";
+
+ // Network as a Service
+ public static final String EVENT_NETWORK_ELEMENT_CONFIGURE = "NETWORK.ELEMENT.CONFIGURE";
+
+ // Physical Network Events
public static final String EVENT_PHYSICAL_NETWORK_CREATE = "PHYSICAL.NETWORK.CREATE";
public static final String EVENT_PHYSICAL_NETWORK_DELETE = "PHYSICAL.NETWORK.DELETE";
public static final String EVENT_PHYSICAL_NETWORK_UPDATE = "PHYSICAL.NETWORK.UPDATE";
-
- //Physical Network Service Provider Events
+
+ // Physical Network Service Provider Events
public static final String EVENT_SERVICE_PROVIDER_CREATE = "SERVICE.PROVIDER.CREATE";
public static final String EVENT_SERVICE_PROVIDER_DELETE = "SERVICE.PROVIDER.DELETE";
public static final String EVENT_SERVICE_PROVIDER_UPDATE = "SERVICE.PROVIDER.UPDATE";
- //Physical Network TrafficType Events
+ // Physical Network TrafficType Events
public static final String EVENT_TRAFFIC_TYPE_CREATE = "TRAFFIC.TYPE.CREATE";
public static final String EVENT_TRAFFIC_TYPE_DELETE = "TRAFFIC.TYPE.DELETE";
public static final String EVENT_TRAFFIC_TYPE_UPDATE = "TRAFFIC.TYPE.UPDATE";
// external network device events
- public static final String EVENT_EXTERAL_LB_DEVICE_ADD = "PHYSICAL.LOADBALANCER.ADD" ;
+ public static final String EVENT_EXTERAL_LB_DEVICE_ADD = "PHYSICAL.LOADBALANCER.ADD";
public static final String EVENT_EXTERAL_LB_DEVICE_DELETE = "PHYSICAL.LOADBALANCER.DELETE";
public static final String EVENT_EXTERAL_LB_DEVICE_CONFIGURE = "PHYSICAL.LOADBALANCER.CONFIGURE";
- public static final String EVENT_EXTERAL_FIREWALL_DEVICE_ADD = "PHYSICAL.FIREWALL.ADD" ;
+ public static final String EVENT_EXTERAL_FIREWALL_DEVICE_ADD = "PHYSICAL.FIREWALL.ADD";
public static final String EVENT_EXTERAL_FIREWALL_DEVICE_DELETE = "PHYSICAL.FIREWALL.DELETE";
public static final String EVENT_EXTERAL_FIREWALL_DEVICE_CONFIGURE = "PHYSICAL.FIREWALL.CONFIGURE";
-}
+}
diff --git a/api/src/com/cloud/exception/AccountLimitException.java b/api/src/com/cloud/exception/AccountLimitException.java
index 85be5023558..e9d8a2659d1 100644
--- a/api/src/com/cloud/exception/AccountLimitException.java
+++ b/api/src/com/cloud/exception/AccountLimitException.java
@@ -21,21 +21,20 @@ import com.cloud.utils.SerialVersionUID;
import com.cloud.utils.exception.CloudRuntimeException;
public class AccountLimitException extends CloudRuntimeException {
-
+
private static final long serialVersionUID = SerialVersionUID.AccountLimitException;
-
+
protected AccountLimitException() {
super();
}
-
+
public AccountLimitException(String msg) {
super(msg);
}
-
+
public AccountLimitException(String msg, Throwable cause) {
super(msg, cause);
}
-
- // TODO: Add the actual thing that causes the exception. Is it ip address, vm, etc?
+ // TODO: Add the actual thing that causes the exception. Is it ip address, vm, etc?
}
diff --git a/api/src/com/cloud/exception/InsufficientAddressCapacityException.java b/api/src/com/cloud/exception/InsufficientAddressCapacityException.java
index de2beecd832..e5084fb579f 100644
--- a/api/src/com/cloud/exception/InsufficientAddressCapacityException.java
+++ b/api/src/com/cloud/exception/InsufficientAddressCapacityException.java
@@ -25,14 +25,14 @@ import com.cloud.utils.SerialVersionUID;
*/
public class InsufficientAddressCapacityException extends InsufficientNetworkCapacityException {
- private static final long serialVersionUID = SerialVersionUID.InsufficientAddressCapacityException;
-
- public InsufficientAddressCapacityException(String msg, Class> scope, Long id) {
- super(msg, scope, id);
- }
-
- protected InsufficientAddressCapacityException() {
- super();
- }
+ private static final long serialVersionUID = SerialVersionUID.InsufficientAddressCapacityException;
+
+ public InsufficientAddressCapacityException(String msg, Class> scope, Long id) {
+ super(msg, scope, id);
+ }
+
+ protected InsufficientAddressCapacityException() {
+ super();
+ }
}
diff --git a/api/src/com/cloud/exception/InternalErrorException.java b/api/src/com/cloud/exception/InternalErrorException.java
index 9acc31ded00..fb2a2ba8e9f 100644
--- a/api/src/com/cloud/exception/InternalErrorException.java
+++ b/api/src/com/cloud/exception/InternalErrorException.java
@@ -20,13 +20,10 @@ package com.cloud.exception;
public class InternalErrorException extends ManagementServerException {
+ private static final long serialVersionUID = -3070582946175427902L;
- private static final long serialVersionUID = -3070582946175427902L;
-
- public InternalErrorException(String message) {
- super(message);
- }
-
-
+ public InternalErrorException(String message) {
+ super(message);
+ }
}
diff --git a/api/src/com/cloud/exception/InvalidParameterValueException.java b/api/src/com/cloud/exception/InvalidParameterValueException.java
index 1449fc1fc9a..1e98dbf30a9 100644
--- a/api/src/com/cloud/exception/InvalidParameterValueException.java
+++ b/api/src/com/cloud/exception/InvalidParameterValueException.java
@@ -22,14 +22,14 @@ import com.cloud.utils.exception.CloudRuntimeException;
/**
* @author chiradeep
- *
+ *
*/
public class InvalidParameterValueException extends CloudRuntimeException {
- private static final long serialVersionUID = -2232066904895010203L;
+ private static final long serialVersionUID = -2232066904895010203L;
- public InvalidParameterValueException(String message) {
- super(message);
- }
+ public InvalidParameterValueException(String message) {
+ super(message);
+ }
}
diff --git a/api/src/com/cloud/exception/ManagementServerException.java b/api/src/com/cloud/exception/ManagementServerException.java
index 41ba73d138a..bf30277e216 100644
--- a/api/src/com/cloud/exception/ManagementServerException.java
+++ b/api/src/com/cloud/exception/ManagementServerException.java
@@ -21,24 +21,18 @@ import com.cloud.utils.SerialVersionUID;
/**
* @author chiradeep
- *
+ *
*/
public class ManagementServerException extends Exception {
+ private static final long serialVersionUID = SerialVersionUID.ManagementServerException;
- private static final long serialVersionUID = SerialVersionUID.ManagementServerException;
+ public ManagementServerException() {
+ }
- public ManagementServerException() {
-
- }
-
-
- public ManagementServerException(String message) {
- super(message);
- }
-
-
-
+ public ManagementServerException(String message) {
+ super(message);
+ }
}
diff --git a/api/src/com/cloud/exception/NetworkRuleConflictException.java b/api/src/com/cloud/exception/NetworkRuleConflictException.java
index fe8781b4487..957f7d9f2d3 100644
--- a/api/src/com/cloud/exception/NetworkRuleConflictException.java
+++ b/api/src/com/cloud/exception/NetworkRuleConflictException.java
@@ -19,12 +19,12 @@
package com.cloud.exception;
public class NetworkRuleConflictException extends
- ManagementServerException {
+ ManagementServerException {
- private static final long serialVersionUID = -294905017911859479L;
+ private static final long serialVersionUID = -294905017911859479L;
- public NetworkRuleConflictException(String message) {
- super(message);
- }
+ public NetworkRuleConflictException(String message) {
+ super(message);
+ }
}
diff --git a/api/src/com/cloud/exception/PermissionDeniedException.java b/api/src/com/cloud/exception/PermissionDeniedException.java
index 70d3971885d..0d45cf4181c 100644
--- a/api/src/com/cloud/exception/PermissionDeniedException.java
+++ b/api/src/com/cloud/exception/PermissionDeniedException.java
@@ -26,43 +26,43 @@ import com.cloud.utils.exception.CloudRuntimeException;
/**
* @author chiradeep
- *
+ *
*/
public class PermissionDeniedException extends CloudRuntimeException {
- private static final long serialVersionUID = SerialVersionUID.PermissionDeniedException;
+ private static final long serialVersionUID = SerialVersionUID.PermissionDeniedException;
- public PermissionDeniedException(String message) {
- super(message);
- }
-
- protected PermissionDeniedException() {
- super();
- }
-
- List extends ControlledEntity> violations;
- Account account;
-
- public PermissionDeniedException(String message, Account account, List extends ControlledEntity> violations) {
- super(message);
- this.violations = violations;
- this.account = account;
- }
-
- public Account getAccount() {
- return account;
- }
-
- public List extends ControlledEntity> getEntitiesInViolation() {
- return violations;
- }
-
- public void addDetails(Account account, List extends ControlledEntity> violations) {
- this.account = account;
- this.violations = violations;
- }
-
- public void addViolations(List extends ControlledEntity> violations) {
- this.violations = violations;
- }
+ public PermissionDeniedException(String message) {
+ super(message);
+ }
+
+ protected PermissionDeniedException() {
+ super();
+ }
+
+ List extends ControlledEntity> violations;
+ Account account;
+
+ public PermissionDeniedException(String message, Account account, List extends ControlledEntity> violations) {
+ super(message);
+ this.violations = violations;
+ this.account = account;
+ }
+
+ public Account getAccount() {
+ return account;
+ }
+
+ public List extends ControlledEntity> getEntitiesInViolation() {
+ return violations;
+ }
+
+ public void addDetails(Account account, List extends ControlledEntity> violations) {
+ this.account = account;
+ this.violations = violations;
+ }
+
+ public void addViolations(List extends ControlledEntity> violations) {
+ this.violations = violations;
+ }
}
diff --git a/api/src/com/cloud/exception/ResourceAllocationException.java b/api/src/com/cloud/exception/ResourceAllocationException.java
index 8e1b8c19d20..ced64ec76c3 100644
--- a/api/src/com/cloud/exception/ResourceAllocationException.java
+++ b/api/src/com/cloud/exception/ResourceAllocationException.java
@@ -22,16 +22,16 @@ import com.cloud.configuration.Resource.ResourceType;
public class ResourceAllocationException extends ManagementServerException {
- private static final long serialVersionUID = -2232066904895010203L;
- private ResourceType resourceType;
+ private static final long serialVersionUID = -2232066904895010203L;
+ private ResourceType resourceType;
- public ResourceAllocationException(String message, ResourceType resourceType) {
- super(message);
- this.resourceType = resourceType;
- }
-
- public ResourceType getResourceType() {
- return this.resourceType;
- }
+ public ResourceAllocationException(String message, ResourceType resourceType) {
+ super(message);
+ this.resourceType = resourceType;
+ }
+
+ public ResourceType getResourceType() {
+ return this.resourceType;
+ }
}
diff --git a/api/src/com/cloud/exception/ResourceInUseException.java b/api/src/com/cloud/exception/ResourceInUseException.java
index d622b4cc924..a134595d1bd 100644
--- a/api/src/com/cloud/exception/ResourceInUseException.java
+++ b/api/src/com/cloud/exception/ResourceInUseException.java
@@ -19,38 +19,38 @@ package com.cloud.exception;
/**
* @author chiradeep
- *
+ *
*/
public class ResourceInUseException extends ManagementServerException {
-
- private static final long serialVersionUID = 1383416910411639324L;
- private String resourceType;
- private String resourceName;
- public ResourceInUseException(String message) {
- super(message);
- }
-
- public ResourceInUseException(String message, String resourceType,
- String resourceName) {
- super(message);
- this.resourceType = resourceType;
- this.resourceName = resourceName;
- }
+ private static final long serialVersionUID = 1383416910411639324L;
+ private String resourceType;
+ private String resourceName;
- public void setResourceType(String resourceType) {
- this.resourceType = resourceType;
- }
-
- public String getResourceType() {
- return this.resourceType;
- }
+ public ResourceInUseException(String message) {
+ super(message);
+ }
- public void setResourceName(String resourceName) {
- this.resourceName = resourceName;
- }
+ public ResourceInUseException(String message, String resourceType,
+ String resourceName) {
+ super(message);
+ this.resourceType = resourceType;
+ this.resourceName = resourceName;
+ }
- public String getResourceName() {
- return resourceName;
- }
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public String getResourceType() {
+ return this.resourceType;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
}
diff --git a/api/src/com/cloud/exception/UnsupportedServiceException.java b/api/src/com/cloud/exception/UnsupportedServiceException.java
index d6da7a11fae..7fddb4e9733 100644
--- a/api/src/com/cloud/exception/UnsupportedServiceException.java
+++ b/api/src/com/cloud/exception/UnsupportedServiceException.java
@@ -20,8 +20,8 @@ package com.cloud.exception;
import com.cloud.utils.exception.CloudRuntimeException;
-public class UnsupportedServiceException extends CloudRuntimeException{
-
+public class UnsupportedServiceException extends CloudRuntimeException {
+
public UnsupportedServiceException(String message) {
super(message);
}
diff --git a/api/src/com/cloud/exception/VirtualMachineMigrationException.java b/api/src/com/cloud/exception/VirtualMachineMigrationException.java
index 3d136750f4d..f7dce48b97e 100644
--- a/api/src/com/cloud/exception/VirtualMachineMigrationException.java
+++ b/api/src/com/cloud/exception/VirtualMachineMigrationException.java
@@ -22,7 +22,7 @@ import com.cloud.utils.SerialVersionUID;
public class VirtualMachineMigrationException extends Exception {
private static final long serialVersionUID = SerialVersionUID.VirtualMachineMigrationException;
- public VirtualMachineMigrationException(String message) {
- super(message);
- }
+ public VirtualMachineMigrationException(String message) {
+ super(message);
+ }
}
diff --git a/api/src/com/cloud/network/IpAddress.java b/api/src/com/cloud/network/IpAddress.java
index 66837e5bca0..7b1d06fd709 100644
--- a/api/src/com/cloud/network/IpAddress.java
+++ b/api/src/com/cloud/network/IpAddress.java
@@ -26,58 +26,58 @@ import com.cloud.utils.net.Ip;
* IpAddress represents the public ip address to be allocated in the CloudStack.
*
* When it is not allocated, it should have
- * - State = Free
- * - Allocated = null
- * - AccountId = null
- * - DomainId = null
- *
+ * - State = Free
+ * - Allocated = null
+ * - AccountId = null
+ * - DomainId = null
+ *
* When it is allocated, it should have
- * - State = Allocated
- * - AccountId = account owner.
- * - DomainId = domain of the account owner.
- * - Allocated = time it was allocated.
+ * - State = Allocated
+ * - AccountId = account owner.
+ * - DomainId = domain of the account owner.
+ * - Allocated = time it was allocated.
*/
-public interface IpAddress extends ControlledEntity{
+public interface IpAddress extends ControlledEntity {
enum State {
- Allocating, // The IP Address is being propagated to other network elements and is not ready for use yet.
- Allocated, // The IP address is in used.
- Releasing, // The IP address is being released for other network elements and is not ready for allocation.
- Free // The IP address is ready to be allocated.
+ Allocating, // The IP Address is being propagated to other network elements and is not ready for use yet.
+ Allocated, // The IP address is in used.
+ Releasing, // The IP address is being released for other network elements and is not ready for allocation.
+ Free // The IP address is ready to be allocated.
}
-
+
long getDataCenterId();
Ip getAddress();
-
+
Date getAllocatedTime();
-
+
boolean isSourceNat();
long getVlanId();
boolean isOneToOneNat();
-
+
State getState();
-
+
boolean readyToUse();
-
+
Long getAssociatedWithNetworkId();
-
+
Long getAssociatedWithVmId();
-
+
public Long getPhysicalNetworkId();
-
+
/**
* @return database id.
*/
long getId();
-
+
void setState(IpAddress.State state);
- Long getAllocatedToAccountId();
+ Long getAllocatedToAccountId();
- Long getAllocatedInDomainId();
+ Long getAllocatedInDomainId();
- boolean getElastic();
+ boolean getElastic();
}
diff --git a/api/src/com/cloud/network/NetworkProfile.java b/api/src/com/cloud/network/NetworkProfile.java
index c02a084bdd2..c8a4fe014b2 100644
--- a/api/src/com/cloud/network/NetworkProfile.java
+++ b/api/src/com/cloud/network/NetworkProfile.java
@@ -24,7 +24,6 @@ import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
-
public class NetworkProfile implements Network {
private long id;
private long dataCenterId;
@@ -167,7 +166,7 @@ public class NetworkProfile implements Network {
public String getDisplayText() {
return displayText;
}
-
+
@Override
public String getReservationId() {
return reservationId;
@@ -182,9 +181,9 @@ public class NetworkProfile implements Network {
public long getDomainId() {
return domainId;
}
-
+
@Override
- public Network.GuestType getGuestType(){
+ public Network.GuestType getGuestType() {
return guestType;
}
@@ -199,11 +198,11 @@ public class NetworkProfile implements Network {
}
@Override
- public ACLType getAclType() {
- return aclType;
- }
-
- @Override
+ public ACLType getAclType() {
+ return aclType;
+ }
+
+ @Override
public boolean isSpecifiedCidr() {
return specifiedCidr;
}
@@ -212,16 +211,16 @@ public class NetworkProfile implements Network {
this.specifiedCidr = specifiedCidr;
}
- @Override
- public boolean isRestartRequired() {
- // TODO Auto-generated method stub
- return false;
- }
+ @Override
+ public boolean isRestartRequired() {
+ // TODO Auto-generated method stub
+ return false;
+ }
- @Override
- public boolean getSpecifyIpRanges() {
- // TODO Auto-generated method stub
- return false;
- }
+ @Override
+ public boolean getSpecifyIpRanges() {
+ // TODO Auto-generated method stub
+ return false;
+ }
}
diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java
index 89833212cb6..d66c4eae61d 100755
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@ -84,7 +84,7 @@ public interface NetworkService {
Integer getNetworkRate(long networkId, Long vmId);
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
-
+
Map> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, List isolationMethods, String broadcastDomainRange, Long domainId, List tags, String name);
@@ -114,7 +114,7 @@ public interface NetworkService {
PhysicalNetworkServiceProvider getPhysicalNetworkServiceProvider(Long providerId);
PhysicalNetworkServiceProvider getCreatedPhysicalNetworkServiceProvider(Long providerId);
-
+
long findPhysicalNetworkId(long zoneId, String tag);
PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType, String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan);
@@ -128,8 +128,9 @@ public interface NetworkService {
List extends PhysicalNetworkTrafficType> listTrafficTypes(Long physicalNetworkId);
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
-
+
Network getExclusiveGuestNetwork(long zoneId);
-
+
List> listTrafficTypeImplementor(ListTrafficTypeImplementorsCmd cmd);
+
}
diff --git a/api/src/com/cloud/network/Networks.java b/api/src/com/cloud/network/Networks.java
index 32d53d29359..39300c3df86 100755
--- a/api/src/com/cloud/network/Networks.java
+++ b/api/src/com/cloud/network/Networks.java
@@ -24,18 +24,18 @@ import com.cloud.utils.exception.CloudRuntimeException;
/**
* Network includes all of the enums used within networking.
- *
+ *
*/
public class Networks {
-
+
public enum RouterPrivateIpStrategy {
None,
- DcGlobal, //global to data center
+ DcGlobal, // global to data center
HostLocal;
-
+
public static String DummyPrivateIp = "169.254.1.1";
}
-
+
/**
* Different ways to assign ip address to this network.
*/
@@ -45,7 +45,7 @@ public class Networks {
Dhcp,
ExternalDhcp;
};
-
+
public enum AddressFormat {
Ip4,
Ip6,
@@ -53,7 +53,7 @@ public class Networks {
}
/**
- * Different types of broadcast domains.
+ * Different types of broadcast domains.
*/
public enum BroadcastDomainType {
Native(null, null),
@@ -63,29 +63,29 @@ public class Networks {
Vnet("vnet", Long.class),
Storage("storage", Integer.class),
UnDecided(null, null);
-
+
private String scheme;
private Class> type;
-
+
private BroadcastDomainType(String scheme, Class> type) {
this.scheme = scheme;
this.type = type;
}
-
+
/**
- * @return scheme to be used in broadcast uri. Null indicates that this type does not have broadcast tags.
+ * @return scheme to be used in broadcast uri. Null indicates that this type does not have broadcast tags.
*/
public String scheme() {
return scheme;
}
-
+
/**
* @return type of the value in the broadcast uri. Null indicates that this type does not have broadcast tags.
*/
public Class> type() {
return type;
}
-
+
public URI toUri(T value) {
try {
return new URI(scheme + "://" + value);
@@ -94,47 +94,47 @@ public class Networks {
}
}
};
-
+
/**
- * Different types of network traffic in the data center.
+ * Different types of network traffic in the data center.
*/
public enum TrafficType {
- None,
+ None,
Public,
Guest,
Storage,
Management,
Control,
Vpn;
-
+
public static boolean isSystemNetwork(TrafficType trafficType) {
- if(Storage.equals(trafficType)
+ if (Storage.equals(trafficType)
|| Management.equals(trafficType)
- || Control.equals(trafficType)){
+ || Control.equals(trafficType)) {
return true;
}
return false;
}
-
+
public static TrafficType getTrafficType(String type) {
- if ("Public".equals(type)) {
- return Public;
- } else if ("Guest".equals(type)) {
- return Guest;
- } else if ("Storage".equals(type)) {
- return Storage;
- } else if ("Management".equals(type)) {
- return Management;
- } else if ("Control".equals(type)) {
- return Control;
- } else if ("Vpn".equals(type)) {
- return Vpn;
- } else {
- return None;
- }
+ if ("Public".equals(type)) {
+ return Public;
+ } else if ("Guest".equals(type)) {
+ return Guest;
+ } else if ("Storage".equals(type)) {
+ return Storage;
+ } else if ("Management".equals(type)) {
+ return Management;
+ } else if ("Control".equals(type)) {
+ return Control;
+ } else if ("Vpn".equals(type)) {
+ return Vpn;
+ } else {
+ return None;
+ }
}
};
-
+
public enum IsolationType {
None(null, null),
Ec2("ec2", String.class),
@@ -142,43 +142,44 @@ public class Networks {
Vswitch("vs", String.class),
Undecided(null, null),
Vnet("vnet", Long.class);
-
+
private final String scheme;
private final Class> type;
-
+
private IsolationType(String scheme, Class> type) {
this.scheme = scheme;
this.type = type;
}
-
+
public String scheme() {
return scheme;
}
-
+
public Class> type() {
return type;
}
-
+
public URI toUri(T value) {
try {
- //assert(this!=Vlan || value.getClass().isAssignableFrom(Integer.class)) : "Why are you putting non integer into vlan url";
+ // assert(this!=Vlan || value.getClass().isAssignableFrom(Integer.class)) :
+ // "Why are you putting non integer into vlan url";
return new URI(scheme + "://" + value.toString());
} catch (URISyntaxException e) {
throw new CloudRuntimeException("Unable to convert to isolation type URI: " + value);
}
}
}
-
+
public enum BroadcastScheme {
Vlan("vlan"),
VSwitch("vswitch");
-
+
private String scheme;
-
+
private BroadcastScheme(String scheme) {
this.scheme = scheme;
}
-
+
@Override
public String toString() {
return scheme;
diff --git a/api/src/com/cloud/network/PhysicalNetwork.java b/api/src/com/cloud/network/PhysicalNetwork.java
index 02f281137e9..fefc2d4fb55 100644
--- a/api/src/com/cloud/network/PhysicalNetwork.java
+++ b/api/src/com/cloud/network/PhysicalNetwork.java
@@ -25,7 +25,7 @@ import java.util.List;
/**
* This defines the specifics of a physical network present in a data center
- *
+ *
*/
public interface PhysicalNetwork {
@@ -33,30 +33,30 @@ public interface PhysicalNetwork {
Disabled,
Enabled;
}
-
+
public enum IsolationMethod {
VLAN,
L3,
GRE;
}
-
+
public enum BroadcastDomainRange {
POD,
ZONE;
}
-
+
long getId();
BroadcastDomainRange getBroadcastDomainRange();
- //TrafficType getTrafficType();
+ // TrafficType getTrafficType();
long getDataCenterId();
State getState();
List getTags();
-
+
List getIsolationMethods();
Long getDomainId();
@@ -67,6 +67,6 @@ public interface PhysicalNetwork {
String getUuid();
- String getName();
+ String getName();
}
diff --git a/api/src/com/cloud/network/PhysicalNetworkServiceProvider.java b/api/src/com/cloud/network/PhysicalNetworkServiceProvider.java
index 523d2a661e7..157c5fc001b 100644
--- a/api/src/com/cloud/network/PhysicalNetworkServiceProvider.java
+++ b/api/src/com/cloud/network/PhysicalNetworkServiceProvider.java
@@ -25,11 +25,9 @@ import java.util.List;
import com.cloud.network.Network.Service;
-
-
/**
* This defines the specifics of a physical network service provider
- *
+ *
*/
public interface PhysicalNetworkServiceProvider {
@@ -38,13 +36,13 @@ public interface PhysicalNetworkServiceProvider {
Enabled,
Shutdown;
}
-
+
long getId();
State getState();
long getPhysicalNetworkId();
-
+
String getProviderName();
long getDestinationPhysicalNetworkId();
diff --git a/api/src/com/cloud/network/PhysicalNetworkSetupInfo.java b/api/src/com/cloud/network/PhysicalNetworkSetupInfo.java
index b51ac5a846e..3d5a5e03c5d 100644
--- a/api/src/com/cloud/network/PhysicalNetworkSetupInfo.java
+++ b/api/src/com/cloud/network/PhysicalNetworkSetupInfo.java
@@ -17,23 +17,22 @@
*/
package com.cloud.network;
-
/**
- * PhysicalNetworkNames provides the labels to identify per traffic type
- * the physical networks available to the host .
+ * PhysicalNetworkNames provides the labels to identify per traffic type
+ * the physical networks available to the host .
*/
public class PhysicalNetworkSetupInfo {
-
- //physical network ID as seen by Mgmt server
- Long physicalNetworkId;
+
+ // physical network ID as seen by Mgmt server
+ Long physicalNetworkId;
String privateNetworkName;
String publicNetworkName;
String guestNetworkName;
String storageNetworkName;
- //this is used by VmWare to identify the vlan to use for management traffic
+ // this is used by VmWare to identify the vlan to use for management traffic
String mgmtVlan;
-
- public PhysicalNetworkSetupInfo(){
+
+ public PhysicalNetworkSetupInfo() {
}
public String getPrivateNetworkName() {
@@ -51,7 +50,7 @@ public class PhysicalNetworkSetupInfo {
public String getStorageNetworkName() {
return storageNetworkName;
}
-
+
public void setPrivateNetworkName(String privateNetworkName) {
this.privateNetworkName = privateNetworkName;
}
@@ -66,8 +65,8 @@ public class PhysicalNetworkSetupInfo {
public void setStorageNetworkName(String storageNetworkName) {
this.storageNetworkName = storageNetworkName;
- }
-
+ }
+
public Long getPhysicalNetworkId() {
return physicalNetworkId;
}
@@ -84,5 +83,4 @@ public class PhysicalNetworkSetupInfo {
this.mgmtVlan = mgmtVlan;
}
-
}
diff --git a/api/src/com/cloud/network/PhysicalNetworkTrafficType.java b/api/src/com/cloud/network/PhysicalNetworkTrafficType.java
index 3c7c387957f..2946496cad5 100644
--- a/api/src/com/cloud/network/PhysicalNetworkTrafficType.java
+++ b/api/src/com/cloud/network/PhysicalNetworkTrafficType.java
@@ -23,26 +23,24 @@ package com.cloud.network;
import com.cloud.network.Networks.TrafficType;
-
-
/**
* This defines the specifics of a physical network traffic type
- *
+ *
*/
public interface PhysicalNetworkTrafficType {
long getId();
long getPhysicalNetworkId();
-
+
TrafficType getTrafficType();
String getXenNetworkLabel();
String getKvmNetworkLabel();
-
+
String getVmwareNetworkLabel();
-
+
String getSimulatorNetworkLabel();
String getUuid();
diff --git a/api/src/com/cloud/network/StorageNetworkService.java b/api/src/com/cloud/network/StorageNetworkService.java
index 43e05cd70cf..d038a0162bb 100755
--- a/api/src/com/cloud/network/StorageNetworkService.java
+++ b/api/src/com/cloud/network/StorageNetworkService.java
@@ -10,11 +10,11 @@ import com.cloud.api.commands.listStorageNetworkIpRangeCmd;
import com.cloud.dc.StorageNetworkIpRange;
public interface StorageNetworkService {
- StorageNetworkIpRange createIpRange(CreateStorageNetworkIpRangeCmd cmd) throws SQLException;
+ StorageNetworkIpRange createIpRange(CreateStorageNetworkIpRangeCmd cmd) throws SQLException;
- void deleteIpRange(DeleteStorageNetworkIpRangeCmd cmd);
+ void deleteIpRange(DeleteStorageNetworkIpRangeCmd cmd);
- List listIpRange(listStorageNetworkIpRangeCmd cmd);
-
- StorageNetworkIpRange updateIpRange(UpdateStorageNetworkIpRangeCmd cmd);
+ List listIpRange(listStorageNetworkIpRangeCmd cmd);
+
+ StorageNetworkIpRange updateIpRange(UpdateStorageNetworkIpRangeCmd cmd);
}
diff --git a/api/src/com/cloud/network/VirtualNetworkApplianceService.java b/api/src/com/cloud/network/VirtualNetworkApplianceService.java
index 4d370a1adea..b551aaecb83 100644
--- a/api/src/com/cloud/network/VirtualNetworkApplianceService.java
+++ b/api/src/com/cloud/network/VirtualNetworkApplianceService.java
@@ -22,32 +22,38 @@ import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.router.VirtualRouter;
-import com.cloud.utils.component.PluggableService;
public interface VirtualNetworkApplianceService {
/**
* Starts domain router
- * @param cmd the command specifying router's id
+ *
+ * @param cmd
+ * the command specifying router's id
* @return DomainRouter object
*/
VirtualRouter startRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
-
+
/**
* Reboots domain router
- * @param cmd the command specifying router's id
+ *
+ * @param cmd
+ * the command specifying router's id
* @return router if successful
*/
VirtualRouter rebootRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
-
+
VirtualRouter upgradeRouter(UpgradeRouterCmd cmd);
-
+
/**
* Stops domain router
- * @param id of the router
- * @param forced just do it. caller knows best.
+ *
+ * @param id
+ * of the router
+ * @param forced
+ * just do it. caller knows best.
* @return router if successful, null otherwise
- * @throws ResourceUnavailableException
- * @throws ConcurrentOperationException
+ * @throws ResourceUnavailableException
+ * @throws ConcurrentOperationException
*/
VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUnavailableException, ConcurrentOperationException;
diff --git a/api/src/com/cloud/network/VirtualRouterProvider.java b/api/src/com/cloud/network/VirtualRouterProvider.java
index b25a898b64c..9fee68b2a65 100644
--- a/api/src/com/cloud/network/VirtualRouterProvider.java
+++ b/api/src/com/cloud/network/VirtualRouterProvider.java
@@ -23,8 +23,12 @@ public interface VirtualRouterProvider {
VirtualRouter,
ElasticLoadBalancerVm
}
+
public VirtualRouterProviderType getType();
+
public long getId();
+
public boolean isEnabled();
+
public long getNspId();
}
diff --git a/api/src/com/cloud/network/VpnUser.java b/api/src/com/cloud/network/VpnUser.java
index c7a68238e88..e817e3a7f5a 100644
--- a/api/src/com/cloud/network/VpnUser.java
+++ b/api/src/com/cloud/network/VpnUser.java
@@ -25,12 +25,12 @@ public interface VpnUser extends ControlledEntity {
Revoke,
Active
}
-
+
long getId();
-
+
String getUsername();
String getPassword();
-
+
State getState();
}
diff --git a/api/src/com/cloud/network/firewall/FirewallService.java b/api/src/com/cloud/network/firewall/FirewallService.java
index 6ce885a1f04..86d1181de4e 100644
--- a/api/src/com/cloud/network/firewall/FirewallService.java
+++ b/api/src/com/cloud/network/firewall/FirewallService.java
@@ -10,18 +10,22 @@ import com.cloud.user.Account;
public interface FirewallService {
FirewallRule createFirewallRule(FirewallRule rule) throws NetworkRuleConflictException;
+
List extends FirewallRule> listFirewallRules(ListFirewallRulesCmd cmd);
-
+
/**
- * Revokes a firewall rule
- * @param ruleId the id of the rule to revoke.
+ * Revokes a firewall rule
+ *
+ * @param ruleId
+ * the id of the rule to revoke.
* @return
*/
boolean revokeFirewallRule(long ruleId, boolean apply);
-
+
boolean applyFirewallRules(long ipId, Account caller) throws ResourceUnavailableException;
-
+
FirewallRule getFirewallRule(long ruleId);
-
+
boolean revokeRelatedFirewallRule(long ruleId, boolean apply);
+
}
diff --git a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
index 65c61f85ad8..c2906fd2089 100644
--- a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
+++ b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
@@ -18,57 +18,66 @@
package com.cloud.network.lb;
import java.util.List;
+
import com.cloud.api.commands.CreateLBStickinessPolicyCmd;
import com.cloud.api.commands.CreateLoadBalancerRuleCmd;
import com.cloud.api.commands.ListLBStickinessPoliciesCmd;
-
import com.cloud.api.commands.ListLoadBalancerRuleInstancesCmd;
import com.cloud.api.commands.ListLoadBalancerRulesCmd;
import com.cloud.api.commands.UpdateLoadBalancerRuleCmd;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.rules.StickinessPolicy;
import com.cloud.network.rules.LoadBalancer;
-
-
+import com.cloud.network.rules.StickinessPolicy;
import com.cloud.uservm.UserVm;
-
public interface LoadBalancingRulesService {
/**
* Create a load balancer rule from the given ipAddress/port to the given private port
- * @param openFirewall TODO
- * @param cmd the command specifying the ip address, public port, protocol, private port, and algorithm
+ *
+ * @param openFirewall
+ * TODO
+ * @param cmd
+ * the command specifying the ip address, public port, protocol, private port, and algorithm
* @return the newly created LoadBalancerVO if successful, null otherwise
- * @throws InsufficientAddressCapacityException
+ * @throws InsufficientAddressCapacityException
*/
LoadBalancer createLoadBalancerRule(CreateLoadBalancerRuleCmd lb, boolean openFirewall) throws NetworkRuleConflictException, InsufficientAddressCapacityException;
LoadBalancer updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd);
-
+
boolean deleteLoadBalancerRule(long lbRuleId, boolean apply);
+
/**
- * Create a stickiness policy to a load balancer from the given stickiness method name and parameters in (name,value) pairs.
- * @param cmd the command specifying the stickiness method name, params (name,value pairs), policy name and description.
+ * Create a stickiness policy to a load balancer from the given stickiness method name and parameters in
+ * (name,value) pairs.
+ *
+ * @param cmd
+ * the command specifying the stickiness method name, params (name,value pairs), policy name and
+ * description.
* @return the newly created stickiness policy if successfull, null otherwise
* @thows NetworkRuleConflictException
*/
public StickinessPolicy createLBStickinessPolicy(CreateLBStickinessPolicyCmd cmd) throws NetworkRuleConflictException;
-
+
public boolean applyLBStickinessPolicy(CreateLBStickinessPolicyCmd cmd) throws ResourceUnavailableException;
-
+
boolean deleteLBStickinessPolicy(long stickinessPolicyId);
+
/**
* Assign a virtual machine, or list of virtual machines, to a load balancer.
*/
boolean assignToLoadBalancer(long lbRuleId, List vmIds);
boolean removeFromLoadBalancer(long lbRuleId, List vmIds);
-
+
boolean applyLoadBalancerConfig(long lbRuleId) throws ResourceUnavailableException;
+
/**
- * List instances that have either been applied to a load balancer or are eligible to be assigned to a load balancer.
+ * List instances that have either been applied to a load balancer or are eligible to be assigned to a load
+ * balancer.
+ *
* @param cmd
* @return list of vm instances that have been or can be applied to a load balancer
*/
@@ -76,21 +85,26 @@ public interface LoadBalancingRulesService {
/**
* List load balancer rules based on the given criteria
- * @param cmd the command that specifies the criteria to use for listing load balancers. Load balancers can be listed
+ *
+ * @param cmd
+ * the command that specifies the criteria to use for listing load balancers. Load balancers can be
+ * listed
* by id, name, public ip, and vm instance id
* @return list of load balancers that match the criteria
*/
List extends LoadBalancer> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd);
+
/**
* List stickiness policies based on the given criteria
- * @param cmd the command specifies the load balancing rule id.
+ *
+ * @param cmd
+ * the command specifies the load balancing rule id.
* @return list of stickiness policies that match the criteria.
*/
List extends StickinessPolicy> searchForLBStickinessPolicies(ListLBStickinessPoliciesCmd cmd);
-
-
+
List listByNetworkId(long networkId);
-
+
LoadBalancer findById(long LoadBalancer);
}
diff --git a/api/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java b/api/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java
index 8f7887878c2..d7c663e509d 100644
--- a/api/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java
+++ b/api/src/com/cloud/network/ovs/OvsCreateGreTunnelAnswer.java
@@ -22,62 +22,62 @@ import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
public class OvsCreateGreTunnelAnswer extends Answer {
- String hostIp;
- String remoteIp;
- String bridge;
- String key;
- long from;
- long to;
- int port;
-
- public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details) {
- super(cmd, success, details);
- }
-
- public OvsCreateGreTunnelAnswer(Command cmd, boolean success,
- String details, String hostIp, String bridge) {
- super(cmd, success, details);
- OvsCreateGreTunnelCommand c = (OvsCreateGreTunnelCommand)cmd;
- this.hostIp = hostIp;
- this.bridge = bridge;
- this.remoteIp = c.getRemoteIp();
- this.key = c.getKey();
- this.port = -1;
- this.from = c.getFrom();
- this.to = c.getTo();
- }
-
- public OvsCreateGreTunnelAnswer(Command cmd, boolean success,
- String details, String hostIp, String bridge, int port) {
- this(cmd, success, details, hostIp, bridge);
- this.port = port;
- }
-
- public String getHostIp() {
- return hostIp;
- }
-
- public String getRemoteIp() {
- return remoteIp;
- }
-
- public String getBridge() {
- return bridge;
- }
-
- public String getKey() {
- return key;
- }
-
- public long getFrom() {
- return from;
- }
-
- public long getTo() {
- return to;
- }
-
- public int getPort() {
- return port;
- }
+ String hostIp;
+ String remoteIp;
+ String bridge;
+ String key;
+ long from;
+ long to;
+ int port;
+
+ public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details) {
+ super(cmd, success, details);
+ }
+
+ public OvsCreateGreTunnelAnswer(Command cmd, boolean success,
+ String details, String hostIp, String bridge) {
+ super(cmd, success, details);
+ OvsCreateGreTunnelCommand c = (OvsCreateGreTunnelCommand) cmd;
+ this.hostIp = hostIp;
+ this.bridge = bridge;
+ this.remoteIp = c.getRemoteIp();
+ this.key = c.getKey();
+ this.port = -1;
+ this.from = c.getFrom();
+ this.to = c.getTo();
+ }
+
+ public OvsCreateGreTunnelAnswer(Command cmd, boolean success,
+ String details, String hostIp, String bridge, int port) {
+ this(cmd, success, details, hostIp, bridge);
+ this.port = port;
+ }
+
+ public String getHostIp() {
+ return hostIp;
+ }
+
+ public String getRemoteIp() {
+ return remoteIp;
+ }
+
+ public String getBridge() {
+ return bridge;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public long getFrom() {
+ return from;
+ }
+
+ public long getTo() {
+ return to;
+ }
+
+ public int getPort() {
+ return port;
+ }
}
diff --git a/api/src/com/cloud/network/ovs/OvsCreateGreTunnelCommand.java b/api/src/com/cloud/network/ovs/OvsCreateGreTunnelCommand.java
index 471f54f4b9b..7ab77d8359f 100644
--- a/api/src/com/cloud/network/ovs/OvsCreateGreTunnelCommand.java
+++ b/api/src/com/cloud/network/ovs/OvsCreateGreTunnelCommand.java
@@ -21,36 +21,36 @@ package com.cloud.network.ovs;
import com.cloud.agent.api.Command;
public class OvsCreateGreTunnelCommand extends Command {
- String remoteIp;
- String key;
- long from;
- long to;
-
- @Override
- public boolean executeInSequence() {
- return true;
- }
+ String remoteIp;
+ String key;
+ long from;
+ long to;
- public OvsCreateGreTunnelCommand(String remoteIp, String key, long from, long to) {
- this.remoteIp = remoteIp;
- this.key = key;
- this.from = from;
- this.to = to;
- }
-
- public String getRemoteIp() {
- return remoteIp;
- }
-
- public String getKey() {
- return key;
- }
-
- public long getFrom() {
- return from;
- }
-
- public long getTo() {
- return to;
- }
+ @Override
+ public boolean executeInSequence() {
+ return true;
+ }
+
+ public OvsCreateGreTunnelCommand(String remoteIp, String key, long from, long to) {
+ this.remoteIp = remoteIp;
+ this.key = key;
+ this.from = from;
+ this.to = to;
+ }
+
+ public String getRemoteIp() {
+ return remoteIp;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public long getFrom() {
+ return from;
+ }
+
+ public long getTo() {
+ return to;
+ }
}
diff --git a/api/src/com/cloud/network/ovs/OvsCreateTunnelCommand.java b/api/src/com/cloud/network/ovs/OvsCreateTunnelCommand.java
index 637987e853e..419d7e95d20 100644
--- a/api/src/com/cloud/network/ovs/OvsCreateTunnelCommand.java
+++ b/api/src/com/cloud/network/ovs/OvsCreateTunnelCommand.java
@@ -16,56 +16,56 @@
*
*/
-package com.cloud.network.ovs;
-
-import com.cloud.agent.api.Command;
-
-public class OvsCreateTunnelCommand extends Command {
- String key;
- String remoteIp;
- Long from;
- Long to;
- long account;
-
- //for debug info
- String fromIp;
-
- @Override
- public boolean executeInSequence() {
- return true;
- }
-
- public OvsCreateTunnelCommand(String remoteIp, String key, Long from, Long to, long account, String fromIp) {
- this.remoteIp = remoteIp;
- this.key = key;
- this.from = from;
- this.to = to;
- this.account = account;
- this.fromIp = fromIp;
- }
-
- public String getKey() {
- return key;
- }
-
- public String getRemoteIp() {
- return remoteIp;
- }
-
- public Long getFrom() {
- return from;
- }
-
- public Long getTo() {
- return to;
- }
-
- public long getAccount() {
- return account;
- }
-
- public String getFromIp() {
- return fromIp;
- }
-
-}
+package com.cloud.network.ovs;
+
+import com.cloud.agent.api.Command;
+
+public class OvsCreateTunnelCommand extends Command {
+ String key;
+ String remoteIp;
+ Long from;
+ Long to;
+ long account;
+
+ // for debug info
+ String fromIp;
+
+ @Override
+ public boolean executeInSequence() {
+ return true;
+ }
+
+ public OvsCreateTunnelCommand(String remoteIp, String key, Long from, Long to, long account, String fromIp) {
+ this.remoteIp = remoteIp;
+ this.key = key;
+ this.from = from;
+ this.to = to;
+ this.account = account;
+ this.fromIp = fromIp;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getRemoteIp() {
+ return remoteIp;
+ }
+
+ public Long getFrom() {
+ return from;
+ }
+
+ public Long getTo() {
+ return to;
+ }
+
+ public long getAccount() {
+ return account;
+ }
+
+ public String getFromIp() {
+ return fromIp;
+ }
+
+}
diff --git a/api/src/com/cloud/network/ovs/OvsDeleteFlowCommand.java b/api/src/com/cloud/network/ovs/OvsDeleteFlowCommand.java
index 77e3d14e13f..fdb0dc52efc 100644
--- a/api/src/com/cloud/network/ovs/OvsDeleteFlowCommand.java
+++ b/api/src/com/cloud/network/ovs/OvsDeleteFlowCommand.java
@@ -21,18 +21,18 @@ package com.cloud.network.ovs;
import com.cloud.agent.api.Command;
public class OvsDeleteFlowCommand extends Command {
- String vmName;
-
- @Override
- public boolean executeInSequence() {
- return true;
- }
+ String vmName;
- public String getVmName() {
- return vmName;
- }
-
- public OvsDeleteFlowCommand(String vmName) {
- this.vmName = vmName;
- }
+ @Override
+ public boolean executeInSequence() {
+ return true;
+ }
+
+ public String getVmName() {
+ return vmName;
+ }
+
+ public OvsDeleteFlowCommand(String vmName) {
+ this.vmName = vmName;
+ }
}
diff --git a/api/src/com/cloud/network/ovs/OvsSetTagAndFlowAnswer.java b/api/src/com/cloud/network/ovs/OvsSetTagAndFlowAnswer.java
index 97effd9103b..5faa43cbfad 100644
--- a/api/src/com/cloud/network/ovs/OvsSetTagAndFlowAnswer.java
+++ b/api/src/com/cloud/network/ovs/OvsSetTagAndFlowAnswer.java
@@ -22,21 +22,21 @@ import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
public class OvsSetTagAndFlowAnswer extends Answer {
- Long vmId;
- Long seqno;
-
- public OvsSetTagAndFlowAnswer(Command cmd, boolean success, String details) {
- super(cmd, success, details);
- OvsSetTagAndFlowCommand c = (OvsSetTagAndFlowCommand)cmd;
- this.vmId = c.getVmId();
- this.seqno = Long.parseLong(c.getSeqNo());
- }
-
- public Long getVmId() {
- return vmId;
- }
-
- public Long getSeqNo() {
- return seqno;
- }
+ Long vmId;
+ Long seqno;
+
+ public OvsSetTagAndFlowAnswer(Command cmd, boolean success, String details) {
+ super(cmd, success, details);
+ OvsSetTagAndFlowCommand c = (OvsSetTagAndFlowCommand) cmd;
+ this.vmId = c.getVmId();
+ this.seqno = Long.parseLong(c.getSeqNo());
+ }
+
+ public Long getVmId() {
+ return vmId;
+ }
+
+ public Long getSeqNo() {
+ return seqno;
+ }
}
diff --git a/api/src/com/cloud/network/ovs/OvsSetTagAndFlowCommand.java b/api/src/com/cloud/network/ovs/OvsSetTagAndFlowCommand.java
index 3f75fb278b1..3061e66a01c 100644
--- a/api/src/com/cloud/network/ovs/OvsSetTagAndFlowCommand.java
+++ b/api/src/com/cloud/network/ovs/OvsSetTagAndFlowCommand.java
@@ -21,42 +21,42 @@ package com.cloud.network.ovs;
import com.cloud.agent.api.Command;
public class OvsSetTagAndFlowCommand extends Command {
- String vlans;
- String vmName;
- String seqno;
- String tag;
- Long vmId;
-
- @Override
- public boolean executeInSequence() {
- return true;
- }
-
- public String getSeqNo() {
- return seqno;
- }
-
- public String getVlans() {
- return vlans;
- }
-
- public String getVmName() {
- return vmName;
- }
-
- public Long getVmId() {
- return vmId;
- }
-
- public String getTag() {
- return tag;
- }
-
- public OvsSetTagAndFlowCommand(String vmName, String tag, String vlans, String seqno, Long vmId) {
- this.vmName = vmName;
- this.tag = tag;
- this.vlans = vlans;
- this.seqno = seqno;
- this.vmId = vmId;
- }
+ String vlans;
+ String vmName;
+ String seqno;
+ String tag;
+ Long vmId;
+
+ @Override
+ public boolean executeInSequence() {
+ return true;
+ }
+
+ public String getSeqNo() {
+ return seqno;
+ }
+
+ public String getVlans() {
+ return vlans;
+ }
+
+ public String getVmName() {
+ return vmName;
+ }
+
+ public Long getVmId() {
+ return vmId;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+
+ public OvsSetTagAndFlowCommand(String vmName, String tag, String vlans, String seqno, Long vmId) {
+ this.vmName = vmName;
+ this.tag = tag;
+ this.vlans = vlans;
+ this.seqno = seqno;
+ this.vmId = vmId;
+ }
}
diff --git a/api/src/com/cloud/network/rules/RulesService.java b/api/src/com/cloud/network/rules/RulesService.java
index 1588d7d633e..55439632be3 100644
--- a/api/src/com/cloud/network/rules/RulesService.java
+++ b/api/src/com/cloud/network/rules/RulesService.java
@@ -26,50 +26,61 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
public interface RulesService {
- List extends FirewallRule> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, Long projectId, boolean isRecursive, boolean listAll);
+ List extends FirewallRule> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, Long projectId, boolean isRecursive, boolean listAll);
/**
* Creates a port forwarding rule between two ip addresses or between
* an ip address and a virtual machine.
- * @param rule rule to be created.
- * @param vmId vm to be linked to. If specified the destination ip address is ignored.
- * @param openFirewall TODO
+ *
+ * @param rule
+ * rule to be created.
+ * @param vmId
+ * vm to be linked to. If specified the destination ip address is ignored.
+ * @param openFirewall
+ * TODO
* @return PortForwardingRule if created.
- * @throws NetworkRuleConflictException if conflicts in the network rules are detected.
+ * @throws NetworkRuleConflictException
+ * if conflicts in the network rules are detected.
*/
PortForwardingRule createPortForwardingRule(PortForwardingRule rule, Long vmId, boolean openFirewall) throws NetworkRuleConflictException;
-
+
/**
- * Revokes a port forwarding rule
- * @param ruleId the id of the rule to revoke.
- * @param caller
+ * Revokes a port forwarding rule
+ *
+ * @param ruleId
+ * the id of the rule to revoke.
+ * @param caller
* @return
*/
boolean revokePortForwardingRule(long ruleId, boolean apply);
+
/**
* List port forwarding rules assigned to an ip address
- * @param cmd the command object holding the criteria for listing port forwarding rules (the ipAddress)
+ *
+ * @param cmd
+ * the command object holding the criteria for listing port forwarding rules (the ipAddress)
* @return list of port forwarding rules on the given address, empty list if no rules exist
*/
public List extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd cmd);
boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
-
+
boolean enableStaticNat(long ipAddressId, long vmId) throws NetworkRuleConflictException, ResourceUnavailableException;
-
+
PortForwardingRule getPortForwardigRule(long ruleId);
+
FirewallRule getFirewallRule(long ruleId);
-
+
StaticNatRule createStaticNatRule(StaticNatRule rule, boolean openFirewall) throws NetworkRuleConflictException;
-
+
boolean revokeStaticNatRule(long ruleId, boolean apply);
-
+
boolean applyStaticNatRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
-
+
StaticNatRule buildStaticNatRule(FirewallRule rule);
-
+
List getSourceCidrs(long ruleId);
- boolean disableStaticNat(long ipId) throws ResourceUnavailableException, NetworkRuleConflictException, InsufficientAddressCapacityException;
-
+ boolean disableStaticNat(long ipId) throws ResourceUnavailableException, NetworkRuleConflictException, InsufficientAddressCapacityException;
+
}
diff --git a/api/src/com/cloud/network/rules/StaticNatRule.java b/api/src/com/cloud/network/rules/StaticNatRule.java
index 682553394a2..bb660c8e715 100644
--- a/api/src/com/cloud/network/rules/StaticNatRule.java
+++ b/api/src/com/cloud/network/rules/StaticNatRule.java
@@ -20,28 +20,28 @@ package com.cloud.network.rules;
import com.cloud.acl.ControlledEntity;
-public interface StaticNatRule extends ControlledEntity, FirewallRule{
-
+public interface StaticNatRule extends ControlledEntity, FirewallRule {
+
long getId();
-
+
String getXid();
-
+
String getProtocol();
Integer getSourcePortStart();
Integer getSourcePortEnd();
-
+
Purpose getPurpose();
State getState();
-
+
long getAccountId();
-
+
long getDomainId();
-
+
long getNetworkId();
-
+
long getSourceIpAddressId();
String getDestIpAddress();
diff --git a/api/src/com/cloud/network/rules/StickinessPolicy.java b/api/src/com/cloud/network/rules/StickinessPolicy.java
index 8e02466f40b..e9e7e16647c 100644
--- a/api/src/com/cloud/network/rules/StickinessPolicy.java
+++ b/api/src/com/cloud/network/rules/StickinessPolicy.java
@@ -21,9 +21,8 @@ import java.util.List;
import com.cloud.utils.Pair;
-
/**
- * Definition for a StickinessPolicy
+ * Definition for a StickinessPolicy
*/
public interface StickinessPolicy {
@@ -38,8 +37,8 @@ public interface StickinessPolicy {
public String getMethodName();
public boolean isRevoke();
-
+
public List> getParams(); /* get params in Map format */
-
+
public String getUuid();
}
diff --git a/api/src/com/cloud/offering/DiskOffering.java b/api/src/com/cloud/offering/DiskOffering.java
index 252d23f8900..cd8717c07e6 100644
--- a/api/src/com/cloud/offering/DiskOffering.java
+++ b/api/src/com/cloud/offering/DiskOffering.java
@@ -19,35 +19,34 @@ package com.cloud.offering;
import java.util.Date;
-
/**
* Represents a disk offering that specifies what the end user needs in
* the disk offering.
- *
+ *
*/
public interface DiskOffering {
long getId();
-
+
String getUniqueName();
-
+
boolean getUseLocalStorage();
-
+
Long getDomainId();
-
+
String getName();
-
+
boolean getSystemUse();
-
+
String getDisplayText();
-
+
public String getTags();
-
+
public String[] getTagsArray();
-
+
Date getCreated();
-
+
long getDiskSize();
-
+
boolean isCustomized();
void setDiskSize(long diskSize);
diff --git a/api/src/com/cloud/offering/NetworkOffering.java b/api/src/com/cloud/offering/NetworkOffering.java
index 7d6fed2e18e..2ee8cfa1c2d 100644
--- a/api/src/com/cloud/offering/NetworkOffering.java
+++ b/api/src/com/cloud/offering/NetworkOffering.java
@@ -22,29 +22,29 @@ import com.cloud.network.Networks.TrafficType;
/**
* Describes network offering
- *
+ *
*/
public interface NetworkOffering {
-
+
public enum Availability {
Required,
Optional
}
-
+
public enum State {
Disabled,
Enabled
}
-
+
public final static String SystemPublicNetwork = "System-Public-Network";
public final static String SystemControlNetwork = "System-Control-Network";
public final static String SystemManagementNetwork = "System-Management-Network";
public final static String SystemStorageNetwork = "System-Storage-Network";
-
+
public final static String DefaultSharedNetworkOfferingWithSGService = "DefaultSharedNetworkOfferingWithSGService";
public final static String DefaultIsolatedNetworkOfferingWithSourceNatService = "DefaultIsolatedNetworkOfferingWithSourceNatService";
public final static String DefaultSharedNetworkOffering = "DefaultSharedNetworkOffering";
- public final static String DefaultIsolatedNetworkOffering= "DefaultIsolatedNetworkOffering";
+ public final static String DefaultIsolatedNetworkOffering = "DefaultIsolatedNetworkOffering";
public final static String DefaultSharedEIPandELBNetworkOffering = "DefaultSharedNetscalerEIPandELBNetworkOffering";
long getId();
@@ -53,32 +53,32 @@ public interface NetworkOffering {
* @return name for the network offering.
*/
String getName();
-
+
/**
* @return text to display to the end user.
*/
String getDisplayText();
-
+
/**
* @return the rate in megabits per sec to which a VM's network interface is throttled to
*/
Integer getRateMbps();
-
+
/**
* @return the rate megabits per sec to which a VM's multicast&broadcast traffic is throttled to
*/
Integer getMulticastRateMbps();
-
+
TrafficType getTrafficType();
-
+
boolean getSpecifyVlan();
-
+
String getTags();
-
+
boolean isDefault();
-
+
boolean isSystemOnly();
-
+
Availability getAvailability();
String getUniqueName();
@@ -86,22 +86,23 @@ public interface NetworkOffering {
void setState(State state);
State getState();
-
+
GuestType getGuestType();
-
+
Long getServiceOfferingId();
boolean getDedicatedLB();
boolean getSharedSourceNat();
-
+
boolean getRedundantRouter();
-
+
boolean isConserveMode();
- boolean getElasticIp();
+ boolean getElasticIp();
- boolean getElasticLb();
+ boolean getElasticLb();
+
+ boolean getSpecifyIpRanges();
- boolean getSpecifyIpRanges();
}
diff --git a/api/src/com/cloud/offering/OfferingManager.java b/api/src/com/cloud/offering/OfferingManager.java
index 671dbea8aad..d34079b9334 100644
--- a/api/src/com/cloud/offering/OfferingManager.java
+++ b/api/src/com/cloud/offering/OfferingManager.java
@@ -18,31 +18,34 @@
package com.cloud.offering;
/**
- * An offering is a package of features offered to the end user. OfferingManager
+ * An offering is a package of features offered to the end user. OfferingManager
* is responsible for the life cycle of the offerings available from CloudStack.
- * An administrator can create, delete, enable, and disable offerings.
+ * An administrator can create, delete, enable, and disable offerings.
*
* There are three types of offerings:
- * - Service Offering - package of computing power and the root disk.
- * - Disk Offering - package of disk performance and size specification.
- * - Network Offering - package of services available on a network.
- *
+ * - Service Offering - package of computing power and the root disk.
+ * - Disk Offering - package of disk performance and size specification.
+ * - Network Offering - package of services available on a network.
+ *
*/
public interface OfferingManager {
/**
* Creates a service offering.
+ *
* @return ServiceOffering
*/
ServiceOffering createServiceOffering();
/**
* Creates a disk offering.
+ *
* @return DiskOffering
*/
DiskOffering createDiskOffering();
/**
* Creates a network offering.
+ *
* @return NetworkOffering
*/
NetworkOffering createNetworkOffering();
diff --git a/api/src/com/cloud/offering/ServiceOffering.java b/api/src/com/cloud/offering/ServiceOffering.java
index 3fc71e0143e..2b85b625fae 100755
--- a/api/src/com/cloud/offering/ServiceOffering.java
+++ b/api/src/com/cloud/offering/ServiceOffering.java
@@ -20,7 +20,7 @@ package com.cloud.offering;
import java.util.Date;
/**
- * ServiceOffering models the different types of service contracts to be
+ * ServiceOffering models the different types of service contracts to be
* offered.
*/
public interface ServiceOffering {
@@ -28,36 +28,35 @@ public interface ServiceOffering {
local,
shared
}
-
+
long getId();
-
+
String getDisplayText();
-
+
Date getCreated();
-
+
String getTags();
-
- /**
+
+ /**
* @return user readable description
*/
String getName();
-
-
+
/**
* @return is this a system service offering
*/
boolean getSystemUse();
-
+
/**
* @return # of cpu.
*/
int getCpu();
-
+
/**
* @return speed in mhz
*/
int getSpeed();
-
+
/**
* @return ram size in megabytes
*/
@@ -72,30 +71,30 @@ public interface ServiceOffering {
* @return Does this service plan offer VM to use CPU resources beyond the service offering limits?
*/
boolean getLimitCpuUse();
-
+
/**
* @return the rate in megabits per sec to which a VM's network interface is throttled to
*/
Integer getRateMbps();
-
+
/**
* @return the rate megabits per sec to which a VM's multicast&broadcast traffic is throttled to
*/
Integer getMulticastRateMbps();
-
+
/**
* @return whether or not the service offering requires local storage
*/
boolean getUseLocalStorage();
-
- Long getDomainId();
-
+
+ Long getDomainId();
+
/**
* @return tag that should be present on the host needed, optional parameter
*/
String getHostTag();
boolean getDefaultUse();
-
+
String getSystemVmType();
}
diff --git a/api/src/com/cloud/org/Cluster.java b/api/src/com/cloud/org/Cluster.java
index 697d6365ab9..547d619953c 100644
--- a/api/src/com/cloud/org/Cluster.java
+++ b/api/src/com/cloud/org/Cluster.java
@@ -26,18 +26,23 @@ import com.cloud.org.Managed.ManagedState;
public interface Cluster extends Grouping {
public static enum ClusterType {
- CloudManaged,
- ExternalManaged;
+ CloudManaged,
+ ExternalManaged;
};
-
+
long getId();
-
+
String getName();
+
long getDataCenterId();
+
long getPodId();
HypervisorType getHypervisorType();
+
ClusterType getClusterType();
+
AllocationState getAllocationState();
+
ManagedState getManagedState();
}
diff --git a/api/src/com/cloud/projects/Project.java b/api/src/com/cloud/projects/Project.java
index 91d926e8503..3ca68eafa56 100644
--- a/api/src/com/cloud/projects/Project.java
+++ b/api/src/com/cloud/projects/Project.java
@@ -23,8 +23,13 @@ import com.cloud.api.Identity;
import com.cloud.domain.PartOf;
public interface Project extends PartOf, Identity {
- public enum State {Active, Disabled, Suspended}
- public enum ListProjectResourcesCriteria {ListProjectResourcesOnly, SkipProjectResources}
+ public enum State {
+ Active, Disabled, Suspended
+ }
+
+ public enum ListProjectResourcesCriteria {
+ ListProjectResourcesOnly, SkipProjectResources
+ }
String getDisplayText();
@@ -37,7 +42,7 @@ public interface Project extends PartOf, Identity {
Date getRemoved();
String getName();
-
+
long getProjectAccountId();
State getState();
diff --git a/api/src/com/cloud/projects/ProjectAccount.java b/api/src/com/cloud/projects/ProjectAccount.java
index cc43734c9be..2ab4303c46f 100644
--- a/api/src/com/cloud/projects/ProjectAccount.java
+++ b/api/src/com/cloud/projects/ProjectAccount.java
@@ -1,14 +1,15 @@
package com.cloud.projects;
-
public interface ProjectAccount {
- public enum Role {Admin, Regular};
-
+ public enum Role {
+ Admin, Regular
+ };
+
long getAccountId();
-
+
long getProjectId();
-
+
Role getAccountRole();
-
+
long getProjectAccountId();
}
diff --git a/api/src/com/cloud/projects/ProjectInvitation.java b/api/src/com/cloud/projects/ProjectInvitation.java
index 0f6bdfa4cc1..b789f27a40a 100644
--- a/api/src/com/cloud/projects/ProjectInvitation.java
+++ b/api/src/com/cloud/projects/ProjectInvitation.java
@@ -4,8 +4,10 @@ import java.util.Date;
import com.cloud.acl.ControlledEntity;
-public interface ProjectInvitation extends ControlledEntity{
- public enum State {Pending, Completed, Expired, Declined}
+public interface ProjectInvitation extends ControlledEntity {
+ public enum State {
+ Pending, Completed, Expired, Declined
+ }
long getId();
diff --git a/api/src/com/cloud/projects/ProjectService.java b/api/src/com/cloud/projects/ProjectService.java
index 37484528fdb..2c2614ea913 100644
--- a/api/src/com/cloud/projects/ProjectService.java
+++ b/api/src/com/cloud/projects/ProjectService.java
@@ -8,65 +8,71 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.projects.ProjectAccount.Role;
import com.cloud.user.Account;
-
public interface ProjectService {
/**
* Creates a new project
*
- * @param name - project name
- * @param displayText - project display text
- * @param accountName - account name of the project owner
- * @param domainId - domainid of the project owner
+ * @param name
+ * - project name
+ * @param displayText
+ * - project display text
+ * @param accountName
+ * - account name of the project owner
+ * @param domainId
+ * - domainid of the project owner
* @return the project if created successfully, null otherwise
- * @throws ResourceAllocationException
+ * @throws ResourceAllocationException
*/
Project createProject(String name, String displayText, String accountName, Long domainId) throws ResourceAllocationException;
-
+
/**
* Deletes a project
*
- * @param id - project id
+ * @param id
+ * - project id
* @return true if the project was deleted successfully, false otherwise
*/
boolean deleteProject(long id);
-
+
/**
* Gets a project by id
*
- * @param id - project id
+ * @param id
+ * - project id
* @return project object
*/
Project getProject(long id);
-
+
List extends Project> listProjects(Long id, String name, String displayText, String state, String accountName, Long domainId, String keyword, Long startIndex, Long pageSize, boolean listAll, boolean isRecursive);
ProjectAccount assignAccountToProject(Project project, long accountId, Role accountRole);
-
+
Account getProjectOwner(long projectId);
boolean unassignAccountFromProject(long projectId, long accountId);
-
+
Project findByProjectAccountId(long projectAccountId);
-
+
Project findByNameAndDomainId(String name, long domainId);
-
+
Project updateProject(long id, String displayText, String newOwnerName) throws ResourceAllocationException;
-
+
boolean addAccountToProject(long projectId, String accountName, String email);
boolean deleteAccountFromProject(long projectId, String accountName);
-
+
List extends ProjectAccount> listProjectAccounts(long projectId, String accountName, String role, Long startIndex, Long pageSizeVal);
-
- List extends ProjectInvitation> listProjectInvitations(Long id, Long projectId, String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive, boolean listAll);
-
+
+ List extends ProjectInvitation> listProjectInvitations(Long id, Long projectId, String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive,
+ boolean listAll);
+
boolean updateInvitation(long projectId, String accountName, String token, boolean accept);
-
+
Project activateProject(long projectId);
-
+
Project suspendProject(long projectId) throws ConcurrentOperationException, ResourceUnavailableException;
Project enableProject(long projectId);
-
+
boolean deleteProjectInvitation(long invitationId);
}
diff --git a/api/src/com/cloud/resource/ResourceState.java b/api/src/com/cloud/resource/ResourceState.java
index 71888da8e2b..2af78c0d644 100755
--- a/api/src/com/cloud/resource/ResourceState.java
+++ b/api/src/com/cloud/resource/ResourceState.java
@@ -3,18 +3,17 @@ package com.cloud.resource;
import java.util.List;
import java.util.Set;
-import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.fsm.StateMachine;
public enum ResourceState {
- Creating,
+ Creating,
Enabled,
Disabled,
PrepareForMaintenance,
ErrorInMaintenance,
Maintenance,
Error;
-
+
public enum Event {
InternalCreated("Resource is created"),
Enable("Admin enables"),
@@ -26,54 +25,55 @@ public enum ResourceState {
UnableToMigrate("Management server migrates VM failed"),
Error("An internal error happened"),
DeleteHost("Admin delete a host"),
-
+
/*
* Below events don't cause resource state to change, they are merely
* for ClusterManager propagating event from one mgmt server to another
*/
Unmanaged("Umanage a cluster");
-
+
private final String comment;
+
private Event(String comment) {
this.comment = comment;
}
-
+
public String getDescription() {
return this.comment;
}
-
+
public static Event toEvent(String e) {
- if (Enable.toString().equals(e)) {
- return Enable;
- } else if (Disable.toString().equals(e)) {
- return Disable;
- }
-
- return null;
+ if (Enable.toString().equals(e)) {
+ return Enable;
+ } else if (Disable.toString().equals(e)) {
+ return Disable;
+ }
+
+ return null;
}
}
-
+
public ResourceState getNextState(Event a) {
return s_fsm.getNextState(this, a);
}
-
+
public ResourceState[] getFromStates(Event a) {
List from = s_fsm.getFromStates(this, a);
return from.toArray(new ResourceState[from.size()]);
}
-
+
public Set getPossibleEvents() {
return s_fsm.getPossibleEvents(this);
}
-
+
public static String[] toString(ResourceState... states) {
String[] strs = new String[states.length];
- for (int i=0; i s_fsm = new StateMachine();
static {
s_fsm.addTransition(null, Event.InternalCreated, ResourceState.Enabled);
diff --git a/api/src/com/cloud/serializer/Param.java b/api/src/com/cloud/serializer/Param.java
index f733c557cd2..21f3d3a79aa 100644
--- a/api/src/com/cloud/serializer/Param.java
+++ b/api/src/com/cloud/serializer/Param.java
@@ -16,18 +16,21 @@
*
*/
-package com.cloud.serializer;
-
+package com.cloud.serializer;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Param {
- String name() default "";
- String propName() default "";
- String description() default "";
-
- // 2 parameters below are used by cloudstack api
- Class> responseObject() default Object.class;
- boolean includeInApiDoc() default true;
-}
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Param {
+ String name() default "";
+
+ String propName() default "";
+
+ String description() default "";
+
+ // 2 parameters below are used by cloudstack api
+ Class> responseObject() default Object.class;
+
+ boolean includeInApiDoc() default true;
+}
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index 02217f4ff42..a6b3534b70d 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -100,7 +100,8 @@ public interface ManagementService {
static final String Name = "management-server";
/**
- * Retrieves the list of data centers with search criteria. Currently the only search criteria is "available" zones for the
+ * Retrieves the list of data centers with search criteria. Currently the only search criteria is "available" zones
+ * for the
* account that invokes the API. By specifying available=true all zones which the account can access. By specifying
* available=false the zones where the account has virtual machine instances will be returned.
*
@@ -140,7 +141,8 @@ public interface ManagementService {
List extends Pod> searchForPods(ListPodsByCmd cmd);
/**
- * Searches for servers by the specified search criteria Can search by: "name", "type", "state", "dataCenterId", "podId"
+ * Searches for servers by the specified search criteria Can search by: "name", "type", "state", "dataCenterId",
+ * "podId"
*
* @param cmd
* @return List of Hosts
@@ -158,7 +160,8 @@ public interface ManagementService {
VirtualMachineTemplate updateTemplate(UpdateTemplateCmd cmd);
/**
- * Obtains a list of events by the specified search criteria. Can search by: "username", "type", "level", "startDate",
+ * Obtains a list of events by the specified search criteria. Can search by: "username", "type", "level",
+ * "startDate",
* "endDate"
*
* @param c
@@ -167,7 +170,8 @@ public interface ManagementService {
List extends Event> searchForEvents(ListEventsCmd c);
/**
- * Obtains a list of routers by the specified search criteria. Can search by: "userId", "name", "state", "dataCenterId",
+ * Obtains a list of routers by the specified search criteria. Can search by: "userId", "name", "state",
+ * "dataCenterId",
* "podId", "hostId"
*
* @param cmd
@@ -175,9 +179,9 @@ public interface ManagementService {
*/
List extends VirtualRouter> searchForRouters(ListRoutersCmd cmd);
-
/**
- * Obtains a list of IP Addresses by the specified search criteria. Can search by: "userId", "dataCenterId", "address"
+ * Obtains a list of IP Addresses by the specified search criteria. Can search by: "userId", "dataCenterId",
+ * "address"
*
* @param cmd
* the command that wraps the search criteria
@@ -236,7 +240,8 @@ public interface ManagementService {
* List ISOs that match the specified criteria.
*
* @param cmd
- * The command that wraps the (optional) templateId, name, keyword, templateFilter, bootable, account, and zoneId
+ * The command that wraps the (optional) templateId, name, keyword, templateFilter, bootable, account,
+ * and zoneId
* parameters.
* @return list of ISOs
*/
@@ -246,7 +251,8 @@ public interface ManagementService {
* List templates that match the specified criteria.
*
* @param cmd
- * The command that wraps the (optional) templateId, name, keyword, templateFilter, bootable, account, and zoneId
+ * The command that wraps the (optional) templateId, name, keyword, templateFilter, bootable, account,
+ * and zoneId
* parameters.
* @return list of ISOs
*/
@@ -300,7 +306,8 @@ public interface ManagementService {
* Extracts the volume to a particular location.
*
* @param cmd
- * the command specifying url (where the volume needs to be extracted to), zoneId (zone where the volume exists),
+ * the command specifying url (where the volume needs to be extracted to), zoneId (zone where the volume
+ * exists),
* id (the id of the volume)
* @throws URISyntaxException
* @throws InternalErrorException
@@ -311,7 +318,9 @@ public interface ManagementService {
/**
* return an array of available hypervisors
- * @param zoneId TODO
+ *
+ * @param zoneId
+ * TODO
*
* @return an array of available hypervisors in the cloud
*/
@@ -381,7 +390,8 @@ public interface ManagementService {
*
* @param cmd
* The api command class.
- * @return A VO containing the key pair name, finger print for the public key and the private key material of the key pair.
+ * @return A VO containing the key pair name, finger print for the public key and the private key material of the
+ * key pair.
*/
SSHKeyPair createSSHKeyPair(CreateSSHKeyPairCmd cmd);
@@ -406,12 +416,15 @@ public interface ManagementService {
Type findSystemVMTypeById(long instanceId);
/**
- * List hosts for migrating the given VM. The API returns list of all hosts in the VM's cluster minus the current host and
+ * List hosts for migrating the given VM. The API returns list of all hosts in the VM's cluster minus the current
+ * host and
* also a list of hosts that seem to have enough CPU and RAM capacity to host this VM.
*
- * @param Long vmId
+ * @param Long
+ * vmId
* Id of The VM to migrate
- * @return Pair, List extends Host>> List of all Hosts in VM's cluster and list of Hosts with enough capacity
+ * @return Pair, List extends Host>> List of all Hosts in VM's cluster and list of Hosts with
+ * enough capacity
*/
Pair, List extends Host>> listHostsForMigrationOfVM(Long vmId, Long startIndex, Long pageSize);
diff --git a/api/src/com/cloud/storage/GuestOS.java b/api/src/com/cloud/storage/GuestOS.java
index 7934280fcef..b8c9f8604f0 100644
--- a/api/src/com/cloud/storage/GuestOS.java
+++ b/api/src/com/cloud/storage/GuestOS.java
@@ -20,8 +20,11 @@ package com.cloud.storage;
public interface GuestOS {
- long getId();
- String getName();
- String getDisplayName();
- long getCategoryId();
+ long getId();
+
+ String getName();
+
+ String getDisplayName();
+
+ long getCategoryId();
}
diff --git a/api/src/com/cloud/storage/GuestOsCategory.java b/api/src/com/cloud/storage/GuestOsCategory.java
index 2a5b691facb..f90cd0c143d 100644
--- a/api/src/com/cloud/storage/GuestOsCategory.java
+++ b/api/src/com/cloud/storage/GuestOsCategory.java
@@ -19,13 +19,13 @@ package com.cloud.storage;
/**
* @author ahuang
- *
+ *
*/
public interface GuestOsCategory {
long getId();
-
+
String getName();
-
+
void setName(String name);
}
diff --git a/api/src/com/cloud/storage/Snapshot.java b/api/src/com/cloud/storage/Snapshot.java
index 0fc5f235fc0..f04162329db 100644
--- a/api/src/com/cloud/storage/Snapshot.java
+++ b/api/src/com/cloud/storage/Snapshot.java
@@ -16,14 +16,14 @@
*
*/
-package com.cloud.storage;
-
+package com.cloud.storage;
+
import java.util.Date;
import com.cloud.acl.ControlledEntity;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
-
-public interface Snapshot extends ControlledEntity{
+
+public interface Snapshot extends ControlledEntity {
public enum Type {
MANUAL,
RECURRING,
@@ -33,52 +33,62 @@ public interface Snapshot extends ControlledEntity{
WEEKLY,
MONTHLY;
private int max = 8;
-
+
public void setMax(int max) {
this.max = max;
}
-
+
public int getMax() {
return max;
}
-
+
public String toString() {
return this.name();
}
-
+
public boolean equals(String snapshotType) {
return this.toString().equalsIgnoreCase(snapshotType);
}
}
-
+
public enum Status {
Creating,
CreatedOnPrimary,
BackingUp,
BackedUp,
Error;
-
+
public String toString() {
return this.name();
}
-
+
public boolean equals(String status) {
return this.toString().equalsIgnoreCase(status);
}
}
-
+
public static final long MANUAL_POLICY_ID = 0L;
-
- Long getId();
- long getAccountId();
- long getVolumeId();
- String getPath();
- String getName();
- Date getCreated();
- Type getType();
+
+ Long getId();
+
+ long getAccountId();
+
+ long getVolumeId();
+
+ String getPath();
+
+ String getName();
+
+ Date getCreated();
+
+ Type getType();
+
Status getStatus();
+
HypervisorType getHypervisorType();
+
boolean isRecursive();
+
short getsnapshotType();
-
-}
+
+}
diff --git a/api/src/com/cloud/storage/Storage.java b/api/src/com/cloud/storage/Storage.java
index a974cb7d5ae..79768768b42 100755
--- a/api/src/com/cloud/storage/Storage.java
+++ b/api/src/com/cloud/storage/Storage.java
@@ -28,46 +28,46 @@ public class Storage {
ISO(false, false, false),
OVA(true, true, true, "ova"),
BAREMETAL(false, false, false);
-
+
private final boolean thinProvisioned;
private final boolean supportSparse;
private final boolean supportSnapshot;
private final String fileExtension;
-
+
private ImageFormat(boolean thinProvisioned, boolean supportSparse, boolean supportSnapshot) {
this.thinProvisioned = thinProvisioned;
this.supportSparse = supportSparse;
this.supportSnapshot = supportSnapshot;
fileExtension = null;
}
-
+
private ImageFormat(boolean thinProvisioned, boolean supportSparse, boolean supportSnapshot, String fileExtension) {
this.thinProvisioned = thinProvisioned;
this.supportSparse = supportSparse;
this.supportSnapshot = supportSnapshot;
this.fileExtension = fileExtension;
}
-
+
public boolean isThinProvisioned() {
return thinProvisioned;
}
-
+
public boolean supportsSparse() {
return supportSparse;
}
-
+
public boolean supportSnapshot() {
return supportSnapshot;
}
-
+
public String getFileExtension() {
- if(fileExtension == null)
- return toString().toLowerCase();
-
- return fileExtension;
+ if (fileExtension == null)
+ return toString().toLowerCase();
+
+ return fileExtension;
}
}
-
+
public static enum FileSystem {
Unknown,
ext3,
@@ -82,48 +82,51 @@ public class Storage {
hfs,
hfsp
}
-
+
public static enum TemplateType {
- SYSTEM, /*routing, system vm template*/
- BUILTIN, /*buildin template*/
- PERHOST, /* every host has this template, don't need to install it in secondary storage */
- USER /* User supplied template/iso */
+ SYSTEM, /* routing, system vm template */
+ BUILTIN, /* buildin template */
+ PERHOST, /* every host has this template, don't need to install it in secondary storage */
+ USER /* User supplied template/iso */
}
-
+
public static enum StoragePoolType {
- Filesystem(false), //local directory
- NetworkFilesystem(true), //NFS or CIFS
- IscsiLUN(true), //shared LUN, with a clusterfs overlay
- Iscsi(true), //for e.g., ZFS Comstar
- ISO(false), // for iso image
- LVM(false), // XenServer local LVM SR
+ Filesystem(false), // local directory
+ NetworkFilesystem(true), // NFS or CIFS
+ IscsiLUN(true), // shared LUN, with a clusterfs overlay
+ Iscsi(true), // for e.g., ZFS Comstar
+ ISO(false), // for iso image
+ LVM(false), // XenServer local LVM SR
CLVM(true),
SharedMountPoint(true),
- VMFS(true), // VMware VMFS storage
- PreSetup(true), // for XenServer, Storage Pool is set up by customers.
- EXT(false), // XenServer local EXT SR
+ VMFS(true), // VMware VMFS storage
+ PreSetup(true), // for XenServer, Storage Pool is set up by customers.
+ EXT(false), // XenServer local EXT SR
OCFS2(true);
-
+
boolean shared;
-
+
StoragePoolType(boolean shared) {
this.shared = shared;
}
-
+
public boolean isShared() {
return shared;
}
}
- public static List getNonSharedStoragePoolTypes(){
- List nonSharedStoragePoolTypes = new ArrayList();
- for(StoragePoolType storagePoolType : StoragePoolType.values()){
- if (!storagePoolType.isShared()){
- nonSharedStoragePoolTypes.add(storagePoolType);
- }
- }
- return nonSharedStoragePoolTypes;
-
+
+ public static List getNonSharedStoragePoolTypes() {
+ List nonSharedStoragePoolTypes = new ArrayList();
+ for (StoragePoolType storagePoolType : StoragePoolType.values()) {
+ if (!storagePoolType.isShared()) {
+ nonSharedStoragePoolTypes.add(storagePoolType);
+ }
+ }
+ return nonSharedStoragePoolTypes;
+
}
- public static enum StorageResourceType {STORAGE_POOL, STORAGE_HOST, SECONDARY_STORAGE, LOCAL_SECONDARY_STORAGE}
+ public static enum StorageResourceType {
+ STORAGE_POOL, STORAGE_HOST, SECONDARY_STORAGE, LOCAL_SECONDARY_STORAGE
+ }
}
diff --git a/api/src/com/cloud/storage/StorageGuru.java b/api/src/com/cloud/storage/StorageGuru.java
index 396013debf5..1a1a54bb661 100644
--- a/api/src/com/cloud/storage/StorageGuru.java
+++ b/api/src/com/cloud/storage/StorageGuru.java
@@ -20,11 +20,13 @@ package com.cloud.storage;
import com.cloud.utils.component.Adapter;
/**
- * StorageGuru understands about how to implement different
+ * StorageGuru understands about how to implement different
* types of storage pools.
*/
public interface StorageGuru extends Adapter {
void createVolume();
+
void prepareVolume();
+
void destroyVolume();
}
diff --git a/api/src/com/cloud/storage/StoragePool.java b/api/src/com/cloud/storage/StoragePool.java
index 28ce7b51699..d8cc10b8a0e 100644
--- a/api/src/com/cloud/storage/StoragePool.java
+++ b/api/src/com/cloud/storage/StoragePool.java
@@ -19,37 +19,36 @@ package com.cloud.storage;
import java.util.Date;
-import com.cloud.host.Status;
import com.cloud.storage.Storage.StoragePoolType;
/**
* @author chiradeep
- *
+ *
*/
-public interface StoragePool {
-
+public interface StoragePool {
+
/**
* @return id of the pool.
*/
- long getId();
-
+ long getId();
+
/**
* @return name of the pool.
*/
String getName();
-
+
/***
*
* @return unique identifier
*/
String getUuid();
-
+
/**
* @return the type of pool.
*/
StoragePoolType getPoolType();
-
+
/**
* @return the date the pool first registered
*/
@@ -59,42 +58,39 @@ public interface StoragePool {
* @return the last time the state of this pool was modified.
*/
Date getUpdateTime();
-
-
+
/**
* @return availability zone.
*/
long getDataCenterId();
-
+
/**
* @return capacity of storage poolin bytes
*/
long getCapacityBytes();
-
/**
* @return available storage in bytes
*/
long getAvailableBytes();
-
-
+
Long getClusterId();
/**
* @return the fqdn or ip address of the storage host
*/
String getHostAddress();
-
+
/**
* @return the filesystem path of the pool on the storage host (server)
*/
String getPath();
-
+
/**
* @return the storage pool represents a shared storage resource
*/
boolean isShared();
-
+
/**
* @return the storage pool represents a local storage resource
*/
@@ -103,9 +99,9 @@ public interface StoragePool {
/**
* @return the storage pool status
*/
- StoragePoolStatus getStatus();
-
- int getPort();
-
- Long getPodId();
+ StoragePoolStatus getStatus();
+
+ int getPort();
+
+ Long getPodId();
}
diff --git a/api/src/com/cloud/storage/StorageService.java b/api/src/com/cloud/storage/StorageService.java
index a375b7c3b62..60cd55c9d45 100644
--- a/api/src/com/cloud/storage/StorageService.java
+++ b/api/src/com/cloud/storage/StorageService.java
@@ -38,7 +38,8 @@ public interface StorageService {
* Create StoragePool based on uri
*
* @param cmd
- * the command object that specifies the zone, cluster/pod, URI, details, etc. to use to create the storage pool.
+ * the command object that specifies the zone, cluster/pod, URI, details, etc. to use to create the
+ * storage pool.
* @return
* @throws ResourceInUseException
* @throws IllegalArgumentException
@@ -52,7 +53,8 @@ public interface StorageService {
* Creates the database object for a volume based on the given criteria
*
* @param cmd
- * the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot, name)
+ * the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
+ * name)
* @return the volume object
* @throws PermissionDeniedException
*/
@@ -62,7 +64,8 @@ public interface StorageService {
* Creates the volume based on the given criteria
*
* @param cmd
- * the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot, name)
+ * the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot,
+ * name)
* @return the volume object
*/
Volume createVolume(CreateVolumeCmd cmd);
@@ -106,8 +109,8 @@ public interface StorageService {
public StoragePool getStoragePool(long id);
- Volume migrateVolume(Long volumeId, Long storagePoolId) throws ConcurrentOperationException;
+ Volume migrateVolume(Long volumeId, Long storagePoolId) throws ConcurrentOperationException;
- List extends Volume> searchForVolumes(ListVolumesCmd cmd);
+ List extends Volume> searchForVolumes(ListVolumesCmd cmd);
}
diff --git a/api/src/com/cloud/storage/Swift.java b/api/src/com/cloud/storage/Swift.java
index 83f8906edac..0c98ef19543 100644
--- a/api/src/com/cloud/storage/Swift.java
+++ b/api/src/com/cloud/storage/Swift.java
@@ -21,9 +21,14 @@ import com.cloud.agent.api.to.SwiftTO;
public interface Swift {
public long getId();
+
public String getUrl();
+
public String getAccount();
+
public String getUserName();
+
public String getKey();
+
public SwiftTO toSwiftTO();
}
diff --git a/api/src/com/cloud/storage/Upload.java b/api/src/com/cloud/storage/Upload.java
index cc5b69e2aaf..a3b68e7f043 100755
--- a/api/src/com/cloud/storage/Upload.java
+++ b/api/src/com/cloud/storage/Upload.java
@@ -22,10 +22,18 @@ import java.util.Date;
public interface Upload {
- public static enum Status {UNKNOWN, ABANDONED, UPLOADED, NOT_UPLOADED, UPLOAD_ERROR, UPLOAD_IN_PROGRESS, NOT_COPIED, COPY_IN_PROGRESS, COPY_ERROR, COPY_COMPLETE, DOWNLOAD_URL_CREATED, DOWNLOAD_URL_NOT_CREATED, ERROR}
- public static enum Type {VOLUME, TEMPLATE, ISO}
- public static enum Mode {FTP_UPLOAD, HTTP_DOWNLOAD}
-
+ public static enum Status {
+ UNKNOWN, ABANDONED, UPLOADED, NOT_UPLOADED, UPLOAD_ERROR, UPLOAD_IN_PROGRESS, NOT_COPIED, COPY_IN_PROGRESS, COPY_ERROR, COPY_COMPLETE, DOWNLOAD_URL_CREATED, DOWNLOAD_URL_NOT_CREATED, ERROR
+ }
+
+ public static enum Type {
+ VOLUME, TEMPLATE, ISO
+ }
+
+ public static enum Mode {
+ FTP_UPLOAD, HTTP_DOWNLOAD
+ }
+
long getHostId();
long getId();
@@ -57,5 +65,5 @@ public interface Upload {
String getInstallPath();
void setInstallPath(String installPath);
-
+
}
diff --git a/api/src/com/cloud/storage/VMTemplateStorageResourceAssoc.java b/api/src/com/cloud/storage/VMTemplateStorageResourceAssoc.java
index a78db8d3ac4..9feb0c6adae 100644
--- a/api/src/com/cloud/storage/VMTemplateStorageResourceAssoc.java
+++ b/api/src/com/cloud/storage/VMTemplateStorageResourceAssoc.java
@@ -21,47 +21,49 @@ import java.util.Date;
/**
* @author chiradeep
- *
+ *
*/
public interface VMTemplateStorageResourceAssoc {
- public static enum Status {UNKNOWN, DOWNLOAD_ERROR, NOT_DOWNLOADED, DOWNLOAD_IN_PROGRESS, DOWNLOADED, ABANDONED, UPLOADED, NOT_UPLOADED, UPLOAD_ERROR, UPLOAD_IN_PROGRESS}
+ public static enum Status {
+ UNKNOWN, DOWNLOAD_ERROR, NOT_DOWNLOADED, DOWNLOAD_IN_PROGRESS, DOWNLOADED, ABANDONED, UPLOADED, NOT_UPLOADED, UPLOAD_ERROR, UPLOAD_IN_PROGRESS
+ }
- String getInstallPath();
+ String getInstallPath();
- long getTemplateId();
+ long getTemplateId();
- void setTemplateId(long templateId);
+ void setTemplateId(long templateId);
- int getDownloadPercent();
+ int getDownloadPercent();
- void setDownloadPercent(int downloadPercent);
+ void setDownloadPercent(int downloadPercent);
- void setDownloadState(Status downloadState);
+ void setDownloadState(Status downloadState);
- long getId();
+ long getId();
- Date getCreated();
+ Date getCreated();
- Date getLastUpdated();
+ Date getLastUpdated();
- void setLastUpdated(Date date);
+ void setLastUpdated(Date date);
- void setInstallPath(String installPath);
+ void setInstallPath(String installPath);
- Status getDownloadState();
+ Status getDownloadState();
- void setLocalDownloadPath(String localPath);
+ void setLocalDownloadPath(String localPath);
- String getLocalDownloadPath();
+ String getLocalDownloadPath();
- void setErrorString(String errorString);
+ void setErrorString(String errorString);
- String getErrorString();
+ String getErrorString();
- void setJobId(String jobId);
+ void setJobId(String jobId);
- String getJobId();;
-
- long getTemplateSize();
+ String getJobId();;
+
+ long getTemplateSize();
}
diff --git a/api/src/com/cloud/storage/Volume.java b/api/src/com/cloud/storage/Volume.java
index 262558cd100..54d43e3746d 100755
--- a/api/src/com/cloud/storage/Volume.java
+++ b/api/src/com/cloud/storage/Volume.java
@@ -74,9 +74,9 @@ public interface Volume extends ControlledEntity, BasedOn, StateObject listSnapshots(ListSnapshotsCmd cmd);
/**
- * Delete specified snapshot from the specified. If no other policies are assigned it calls destroy snapshot. This will be
+ * Delete specified snapshot from the specified. If no other policies are assigned it calls destroy snapshot. This
+ * will be
* used for manual snapshots too.
- * @param snapshotId TODO
+ *
+ * @param snapshotId
+ * TODO
*/
boolean deleteSnapshot(long snapshotId);
/**
- * Creates a policy with specified schedule. maxSnaps specifies the number of most recent snapshots that are to be retained.
+ * Creates a policy with specified schedule. maxSnaps specifies the number of most recent snapshots that are to be
+ * retained.
* If the number of snapshots go beyond maxSnaps the oldest snapshot is deleted
*
* @param cmd
* the command that
- * @param policyOwner TODO
+ * @param policyOwner
+ * TODO
* @return the newly created snapshot policy if success, null otherwise
*/
SnapshotPolicy createPolicy(CreateSnapshotPolicyCmd cmd, Account policyOwner);
@@ -84,7 +89,9 @@ public interface SnapshotService {
/**
* Create a snapshot of a volume
- * @param snapshotOwner TODO
+ *
+ * @param snapshotOwner
+ * TODO
* @param cmd
* the API command wrapping the parameters for creating the snapshot (mainly volumeId)
*
diff --git a/api/src/com/cloud/storage/template/TemplateInfo.java b/api/src/com/cloud/storage/template/TemplateInfo.java
index ec09eb8eb4c..e9f6b9a93e3 100644
--- a/api/src/com/cloud/storage/template/TemplateInfo.java
+++ b/api/src/com/cloud/storage/template/TemplateInfo.java
@@ -17,8 +17,6 @@
*/
package com.cloud.storage.template;
-
-
public class TemplateInfo {
String templateName;
String installPath;
@@ -27,11 +25,11 @@ public class TemplateInfo {
long id;
boolean isPublic;
boolean isCorrupted;
-
+
protected TemplateInfo() {
-
+
}
-
+
public TemplateInfo(String templateName, String installPath, long size, long physicalSize, boolean isPublic, boolean isCorrupted) {
this.templateName = templateName;
this.installPath = installPath;
@@ -44,40 +42,41 @@ public class TemplateInfo {
public TemplateInfo(String templateName, String installPath, boolean isPublic, boolean isCorrupted) {
this(templateName, installPath, 0, 0, isPublic, isCorrupted);
}
-
+
public long getId() {
return id;
}
-
+
public String getTemplateName() {
return templateName;
}
-
+
public String getInstallPath() {
return installPath;
}
-
+
public boolean isPublic() {
return isPublic;
}
-
+
public boolean isCorrupted() {
return isCorrupted;
}
-
+
public void setInstallPath(String installPath) {
this.installPath = installPath;
}
-
+
public long getSize() {
return size;
}
-
+
public long getPhysicalSize() {
return physicalSize;
}
-
+
public void setSize(long size) {
this.size = size;
}
+
}
diff --git a/api/src/com/cloud/template/TemplateService.java b/api/src/com/cloud/template/TemplateService.java
index 5766df96e52..b034959359f 100755
--- a/api/src/com/cloud/template/TemplateService.java
+++ b/api/src/com/cloud/template/TemplateService.java
@@ -40,8 +40,8 @@ public interface TemplateService {
VirtualMachineTemplate registerIso(RegisterIsoCmd cmd) throws IllegalArgumentException, ResourceAllocationException;
VirtualMachineTemplate copyTemplate(CopyTemplateCmd cmd) throws StorageUnavailableException, ResourceAllocationException;
-
- VirtualMachineTemplate prepareTemplate(long templateId, long zoneId) ;
+
+ VirtualMachineTemplate prepareTemplate(long templateId, long zoneId);
boolean detachIso(long vmId);
@@ -84,7 +84,7 @@ public interface TemplateService {
VirtualMachineTemplate getTemplate(long templateId);
- List listTemplatePermissions(ListTemplateOrIsoPermissionsCmd cmd);
+ List listTemplatePermissions(ListTemplateOrIsoPermissionsCmd cmd);
- boolean updateTemplateOrIsoPermissions(UpdateTemplateOrIsoPermissionsCmd cmd);
+ boolean updateTemplateOrIsoPermissions(UpdateTemplateOrIsoPermissionsCmd cmd);
}
diff --git a/api/src/com/cloud/template/VirtualMachineTemplate.java b/api/src/com/cloud/template/VirtualMachineTemplate.java
index c9efabdf83c..30501f49a56 100755
--- a/api/src/com/cloud/template/VirtualMachineTemplate.java
+++ b/api/src/com/cloud/template/VirtualMachineTemplate.java
@@ -27,15 +27,19 @@ import com.cloud.storage.Storage.TemplateType;
public interface VirtualMachineTemplate extends ControlledEntity {
- public static enum BootloaderType { PyGrub, HVM, External, CD };
+ public static enum BootloaderType {
+ PyGrub, HVM, External, CD
+ };
+
public enum TemplateFilter {
- featured, // returns templates that have been marked as featured and public
- self, // returns templates that have been registered or created by the calling user
- selfexecutable, // same as self, but only returns templates that are ready to be deployed with
- sharedexecutable, // ready templates that have been granted to the calling user by another user
- executable, // templates that are owned by the calling user, or public templates, that can be used to deploy a new VM
- community, // returns templates that have been marked as public but not featured
- all // all templates (only usable by admins)
+ featured, // returns templates that have been marked as featured and public
+ self, // returns templates that have been registered or created by the calling user
+ selfexecutable, // same as self, but only returns templates that are ready to be deployed with
+ sharedexecutable, // ready templates that have been granted to the calling user by another user
+ executable, // templates that are owned by the calling user, or public templates, that can be used to deploy a
+// new VM
+ community, // returns templates that have been marked as public but not featured
+ all // all templates (only usable by admins)
}
/**
@@ -64,7 +68,7 @@ public interface VirtualMachineTemplate extends ControlledEntity {
String getDisplayText();
boolean getEnablePassword();
-
+
boolean getEnableSshKey();
boolean isCrossZones();
@@ -90,6 +94,6 @@ public interface VirtualMachineTemplate extends ControlledEntity {
Long getSourceTemplateId();
String getTemplateTag();
-
+
Map getDetails();
}
diff --git a/api/src/com/cloud/user/Account.java b/api/src/com/cloud/user/Account.java
index 60273ed11b8..4bc13c80d28 100755
--- a/api/src/com/cloud/user/Account.java
+++ b/api/src/com/cloud/user/Account.java
@@ -30,13 +30,13 @@ public interface Account extends ControlledEntity {
CustomerCare,
Project
}
-
+
public enum State {
disabled,
enabled,
locked
}
-
+
public static final short ACCOUNT_TYPE_NORMAL = 0;
public static final short ACCOUNT_TYPE_ADMIN = 1;
public static final short ACCOUNT_TYPE_DOMAIN_ADMIN = 2;
@@ -48,12 +48,17 @@ public interface Account extends ControlledEntity {
public static final String ACCOUNT_STATE_ENABLED = "enabled";
public static final String ACCOUNT_STATE_LOCKED = "locked";
- public static final long ACCOUNT_ID_SYSTEM = 1;
+ public static final long ACCOUNT_ID_SYSTEM = 1;
public long getId();
+
public String getAccountName();
+
public short getType();
+
public State getState();
+
public Date getRemoved();
+
public String getNetworkDomain();
}
diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java
index b1a72b89e51..b58511be503 100755
--- a/api/src/com/cloud/user/AccountService.java
+++ b/api/src/com/cloud/user/AccountService.java
@@ -38,24 +38,38 @@ public interface AccountService {
/**
* Creates a new user and account, stores the password as is so encrypted passwords are recommended.
- * @param userName TODO
- * @param password TODO
- * @param firstName TODO
- * @param lastName TODO
- * @param email TODO
- * @param timezone TODO
- * @param accountName TODO
- * @param accountType TODO
- * @param domainId TODO
- * @param networkDomain TODO
+ *
+ * @param userName
+ * TODO
+ * @param password
+ * TODO
+ * @param firstName
+ * TODO
+ * @param lastName
+ * TODO
+ * @param email
+ * TODO
+ * @param timezone
+ * TODO
+ * @param accountName
+ * TODO
+ * @param accountType
+ * TODO
+ * @param domainId
+ * TODO
+ * @param networkDomain
+ * TODO
*
* @return the user if created successfully, null otherwise
*/
- UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain, Map details);
+ UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
+ Map details);
/**
* Deletes a user by userId
- * @param accountId - id of the account do delete
+ *
+ * @param accountId
+ * - id of the account do delete
*
* @return true if delete was successful, false otherwise
*/
@@ -64,7 +78,8 @@ public interface AccountService {
/**
* Disables a user by userId
*
- * @param userId - the userId
+ * @param userId
+ * - the userId
* @return UserAccount object
*/
UserAccount disableUser(long userId);
@@ -72,13 +87,15 @@ public interface AccountService {
/**
* Enables a user
*
- * @param userId - the userId
+ * @param userId
+ * - the userId
* @return UserAccount object
*/
UserAccount enableUser(long userId);
/**
- * Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses allocated/etc.
+ * Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses
+ * allocated/etc.
*
* @param userId
* @return UserAccount object
@@ -95,8 +112,11 @@ public interface AccountService {
/**
* Disables an account by accountName and domainId
- * @param accountName TODO
- * @param domainId TODO
+ *
+ * @param accountName
+ * TODO
+ * @param domainId
+ * TODO
* @param accountId
* @param disabled
* account if success
@@ -109,19 +129,22 @@ public interface AccountService {
*
* @param accountName
* - the enableAccount command defining the accountId to be deleted.
- * @param domainId TODO
+ * @param domainId
+ * TODO
* @param accountId
* @return account object
*/
Account enableAccount(String accountName, Long domainId, Long accountId);
/**
- * Locks an account by accountId. A locked account cannot access the API, but will still have running VMs/IP addresses
+ * Locks an account by accountId. A locked account cannot access the API, but will still have running VMs/IP
+ * addresses
* allocated/etc.
*
* @param accountName
* - the LockAccount command defining the accountId to be locked.
- * @param domainId TODO
+ * @param domainId
+ * TODO
* @param accountId
* @return account object
*/
@@ -142,39 +165,40 @@ public interface AccountService {
User getSystemUser();
User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId);
- boolean deleteUser(DeleteUserCmd deleteUserCmd);
-
- boolean isAdmin(short accountType);
-
- Account finalizeOwner(Account caller, String accountName, Long domainId, Long projectId);
-
- Pair,Long> finalizeAccountDomainForList(Account caller, String accountName, Long domainId, Long projectId);
-
- Account getActiveAccountByName(String accountName, Long domainId);
-
- Account getActiveAccountById(Long accountId);
-
- Account getAccount(Long accountId);
-
- User getActiveUser(long userId);
-
- User getUserIncludingRemoved(long userId);
-
- boolean isRootAdmin(short accountType);
-
- User getActiveUserByRegistrationToken(String registrationToken);
-
- void markUserRegistered(long userId);
-
- public String[] createApiKeyAndSecretKey(RegisterCmd cmd);
- List extends Account> searchForAccounts(ListAccountsCmd cmd);
+ boolean deleteUser(DeleteUserCmd deleteUserCmd);
+
+ boolean isAdmin(short accountType);
+
+ Account finalizeOwner(Account caller, String accountName, Long domainId, Long projectId);
+
+ Pair, Long> finalizeAccountDomainForList(Account caller, String accountName, Long domainId, Long projectId);
+
+ Account getActiveAccountByName(String accountName, Long domainId);
+
+ Account getActiveAccountById(Long accountId);
+
+ Account getAccount(Long accountId);
+
+ User getActiveUser(long userId);
+
+ User getUserIncludingRemoved(long userId);
+
+ boolean isRootAdmin(short accountType);
+
+ User getActiveUserByRegistrationToken(String registrationToken);
+
+ void markUserRegistered(long userId);
+
+ public String[] createApiKeyAndSecretKey(RegisterCmd cmd);
+
+ List extends Account> searchForAccounts(ListAccountsCmd cmd);
+
+ List extends UserAccount> searchForUsers(ListUsersCmd cmd)
+ throws PermissionDeniedException;
- List extends UserAccount> searchForUsers(ListUsersCmd cmd)
- throws PermissionDeniedException;
-
void checkAccess(Account account, Domain domain) throws PermissionDeniedException;
-
+
void checkAccess(Account account, AccessType accessType, boolean sameOwner, ControlledEntity... entities) throws PermissionDeniedException;
}
diff --git a/api/src/com/cloud/user/DomainService.java b/api/src/com/cloud/user/DomainService.java
index 6b4f83f832f..31decd5d6ab 100644
--- a/api/src/com/cloud/user/DomainService.java
+++ b/api/src/com/cloud/user/DomainService.java
@@ -27,9 +27,9 @@ import com.cloud.exception.PermissionDeniedException;
public interface DomainService {
Domain createDomain(String name, Long parentId, String networkDomain);
-
+
Domain getDomain(long id);
-
+
/**
* Return whether a domain is a child domain of a given domain.
*
@@ -41,9 +41,10 @@ public interface DomainService {
boolean deleteDomain(long domainId, Boolean cleanup);
- List extends Domain> searchForDomains(ListDomainsCmd cmd)
- throws PermissionDeniedException;
+ List extends Domain> searchForDomains(ListDomainsCmd cmd)
+ throws PermissionDeniedException;
+
+ List extends Domain> searchForDomainChildren(ListDomainChildrenCmd cmd)
+ throws PermissionDeniedException;
- List extends Domain> searchForDomainChildren(ListDomainChildrenCmd cmd)
- throws PermissionDeniedException;
}
diff --git a/api/src/com/cloud/user/ResourceLimitService.java b/api/src/com/cloud/user/ResourceLimitService.java
index 542e3f0300b..2f9e5340361 100644
--- a/api/src/com/cloud/user/ResourceLimitService.java
+++ b/api/src/com/cloud/user/ResourceLimitService.java
@@ -26,13 +26,18 @@ import com.cloud.domain.Domain;
import com.cloud.exception.ResourceAllocationException;
public interface ResourceLimitService {
-
+
/**
* Updates an existing resource limit with the specified details. If a limit doesn't exist, will create one.
- * @param accountId TODO
- * @param domainId TODO
- * @param resourceType TODO
- * @param max TODO
+ *
+ * @param accountId
+ * TODO
+ * @param domainId
+ * TODO
+ * @param resourceType
+ * TODO
+ * @param max
+ * TODO
*
* @return the updated/created resource limit
*/
@@ -40,26 +45,36 @@ public interface ResourceLimitService {
/**
* Updates an existing resource count details for the account/domain
- * @param accountId TODO
- * @param domainId TODO
- * @param typeId TODO
+ *
+ * @param accountId
+ * TODO
+ * @param domainId
+ * TODO
+ * @param typeId
+ * TODO
* @return the updated/created resource counts
*/
List extends ResourceCount> recalculateResourceCount(Long accountId, Long domainId, Integer typeId);
-
+
/**
* Search for resource limits for the given id and/or account and/or type and/or domain.
- * @param id TODO
- * @param accountId TODO
- * @param domainId TODO
- * @param type TODO
+ *
+ * @param id
+ * TODO
+ * @param accountId
+ * TODO
+ * @param domainId
+ * TODO
+ * @param type
+ * TODO
* @return a list of limits that match the criteria
*/
public List extends ResourceLimit> searchForLimits(Long id, Long accountId, Long domainId, Integer type, Long startIndex, Long pageSizeVal);
-
+
/**
* Finds the resource limit for a specified account and type. If the account has an infinite limit, will check
* the account's parent domain, and if that limit is also infinite, will return the ROOT domain's limit.
+ *
* @param account
* @param type
* @return resource limit
@@ -69,6 +84,7 @@ public interface ResourceLimitService {
/**
* Finds the resource limit for a specified domain and type. If the domain has an infinite limit, will check
* up the domain hierarchy
+ *
* @param account
* @param type
* @return resource limit
@@ -77,31 +93,37 @@ public interface ResourceLimitService {
/**
* Increments the resource count
+ *
* @param accountId
* @param type
* @param delta
*/
- public void incrementResourceCount(long accountId, ResourceType type, Long...delta);
-
+ public void incrementResourceCount(long accountId, ResourceType type, Long... delta);
+
/**
* Decrements the resource count
+ *
* @param accountId
* @param type
* @param delta
*/
- public void decrementResourceCount(long accountId, ResourceType type, Long...delta);
-
+ public void decrementResourceCount(long accountId, ResourceType type, Long... delta);
+
/**
* Checks if a limit has been exceeded for an account
+ *
* @param account
* @param type
- * @param count the number of resources being allocated, count will be added to current allocation and compared against maximum allowed allocation
- * @throws ResourceAllocationException
+ * @param count
+ * the number of resources being allocated, count will be added to current allocation and compared
+ * against maximum allowed allocation
+ * @throws ResourceAllocationException
*/
- public void checkResourceLimit(Account account, ResourceCount.ResourceType type, long...count) throws ResourceAllocationException;
-
+ public void checkResourceLimit(Account account, ResourceCount.ResourceType type, long... count) throws ResourceAllocationException;
+
/**
* Gets the count of resources for a resource type and account
+ *
* @param account
* @param type
* @return count of resources
diff --git a/api/src/com/cloud/user/SSHKeyPair.java b/api/src/com/cloud/user/SSHKeyPair.java
index e518e3ec9ca..0ecaf39c996 100644
--- a/api/src/com/cloud/user/SSHKeyPair.java
+++ b/api/src/com/cloud/user/SSHKeyPair.java
@@ -22,29 +22,29 @@ import com.cloud.acl.ControlledEntity;
public interface SSHKeyPair extends ControlledEntity {
- /**
- * @return The id of the key pair.
- */
- public long getId();
-
- /**
- * @return The given name of the key pair.
- */
- public String getName();
-
- /**
- * @return The finger print of the public key.
- */
- public String getFingerprint();
-
- /**
- * @return The public key of the key pair.
- */
- public String getPublicKey();
-
- /**
- * @return The private key of the key pair.
- */
- public String getPrivateKey();
-
+ /**
+ * @return The id of the key pair.
+ */
+ public long getId();
+
+ /**
+ * @return The given name of the key pair.
+ */
+ public String getName();
+
+ /**
+ * @return The finger print of the public key.
+ */
+ public String getFingerprint();
+
+ /**
+ * @return The public key of the key pair.
+ */
+ public String getPublicKey();
+
+ /**
+ * @return The private key of the key pair.
+ */
+ public String getPrivateKey();
+
}
diff --git a/api/src/com/cloud/user/User.java b/api/src/com/cloud/user/User.java
index 5e2ebea5a17..d4d93d2f637 100644
--- a/api/src/com/cloud/user/User.java
+++ b/api/src/com/cloud/user/User.java
@@ -16,59 +16,59 @@
*
*/
-package com.cloud.user;
-
-import java.util.Date;
-
-public interface User extends OwnedBy {
- public static final long UID_SYSTEM = 1;
-
- public long getId();
-
- public Date getCreated();
-
- public Date getRemoved();
-
- public String getUsername();
-
- public void setUsername(String username);
-
- public String getPassword();
-
- public void setPassword(String password);
-
- public String getFirstname();
-
- public void setFirstname(String firstname);
-
- public String getLastname();
-
- public void setLastname(String lastname);
+package com.cloud.user;
- public void setAccountId(long accountId);
+import java.util.Date;
+
+public interface User extends OwnedBy {
+ public static final long UID_SYSTEM = 1;
+
+ public long getId();
+
+ public Date getCreated();
+
+ public Date getRemoved();
+
+ public String getUsername();
+
+ public void setUsername(String username);
+
+ public String getPassword();
+
+ public void setPassword(String password);
+
+ public String getFirstname();
+
+ public void setFirstname(String firstname);
+
+ public String getLastname();
+
+ public void setLastname(String lastname);
+
+ public void setAccountId(long accountId);
public String getEmail();
-
+
public void setEmail(String email);
public Account.State getState();
public void setState(Account.State state);
- public String getApiKey();
-
- public void setApiKey(String apiKey);
-
+ public String getApiKey();
+
+ public void setApiKey(String apiKey);
+
public String getSecretKey();
-
+
public void setSecretKey(String secretKey);
-
+
public String getTimezone();
-
+
public void setTimezone(String timezone);
- String getRegistrationToken();
+ String getRegistrationToken();
- boolean isRegistered();
-
-}
\ No newline at end of file
+ boolean isRegistered();
+
+}
diff --git a/api/src/com/cloud/user/UserAccount.java b/api/src/com/cloud/user/UserAccount.java
index 636dce221ea..5b446ec6f4a 100644
--- a/api/src/com/cloud/user/UserAccount.java
+++ b/api/src/com/cloud/user/UserAccount.java
@@ -16,46 +16,46 @@
*
*/
-package com.cloud.user;
-
-import java.util.Date;
-
-public interface UserAccount {
- Long getId();
-
- String getUsername();
-
- String getPassword();
-
- String getFirstname();
-
- String getLastname();
-
- long getAccountId();
-
- String getEmail();
-
- String getState();
-
- String getApiKey();
-
- String getSecretKey();
-
- Date getCreated();
-
- Date getRemoved();
-
- String getAccountName();
-
- short getType();
-
- Long getDomainId();
-
- String getAccountState();
+package com.cloud.user;
+
+import java.util.Date;
+
+public interface UserAccount {
+ Long getId();
+
+ String getUsername();
+
+ String getPassword();
+
+ String getFirstname();
+
+ String getLastname();
+
+ long getAccountId();
+
+ String getEmail();
+
+ String getState();
+
+ String getApiKey();
+
+ String getSecretKey();
+
+ Date getCreated();
+
+ Date getRemoved();
+
+ String getAccountName();
+
+ short getType();
+
+ Long getDomainId();
+
+ String getAccountState();
String getTimezone();
- String getRegistrationToken();
+ String getRegistrationToken();
- boolean isRegistered();
-}
+ boolean isRegistered();
+}
diff --git a/api/src/com/cloud/user/UserContext.java b/api/src/com/cloud/user/UserContext.java
index 380c10dae7d..5ea7b48b5e8 100644
--- a/api/src/com/cloud/user/UserContext.java
+++ b/api/src/com/cloud/user/UserContext.java
@@ -16,16 +16,16 @@
*
*/
-package com.cloud.user;
+package com.cloud.user;
import com.cloud.server.ManagementService;
import com.cloud.utils.component.ComponentLocator;
-public class UserContext {
-
+public class UserContext {
+
private static ThreadLocal s_currentContext = new ThreadLocal();
private static final ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
- private static final AccountService _accountMgr = locator.getManager(AccountService.class);
+ private static final AccountService _accountMgr = locator.getManager(AccountService.class);
private long userId;
private String sessionId;
@@ -34,31 +34,31 @@ public class UserContext {
private long accountId;
private String eventDetails;
- private boolean apiServer;
+ private boolean apiServer;
- private static UserContext s_adminContext = new UserContext(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, false);
+ private static UserContext s_adminContext = new UserContext(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(), null, false);
- public UserContext() {
- }
-
- public UserContext(long userId, Account accountObject, String sessionId, boolean apiServer) {
- this.userId = userId;
- this.account = accountObject;
- this.sessionId = sessionId;
- this.apiServer = apiServer;
- }
-
- public long getCallerUserId() {
- return userId;
+ public UserContext() {
}
-
- public void setCallerUserId(long userId) {
- this.userId = userId;
- }
- public String getSessionId() {
- return sessionId;
- }
+ public UserContext(long userId, Account accountObject, String sessionId, boolean apiServer) {
+ this.userId = userId;
+ this.account = accountObject;
+ this.sessionId = sessionId;
+ this.apiServer = apiServer;
+ }
+
+ public long getCallerUserId() {
+ return userId;
+ }
+
+ public void setCallerUserId(long userId) {
+ this.userId = userId;
+ }
+
+ public String getSessionId() {
+ return sessionId;
+ }
public Account getCaller() {
return account;
@@ -68,49 +68,50 @@ public class UserContext {
this.account = accountObject;
}
- public void setSessionKey(String sessionId) {
- this.sessionId = sessionId;
- }
+ public void setSessionKey(String sessionId) {
+ this.sessionId = sessionId;
+ }
- public boolean isApiServer() {
- return apiServer;
- }
+ public boolean isApiServer() {
+ return apiServer;
+ }
- public void setApiServer(boolean apiServer) {
- this.apiServer = apiServer;
- }
+ public void setApiServer(boolean apiServer) {
+ this.apiServer = apiServer;
+ }
- public static UserContext current() {
+ public static UserContext current() {
UserContext context = s_currentContext.get();
- if(context == null) {
+ if (context == null) {
//
// TODO: we should enforce explicit UserContext setup at major entry-points for security concerns,
- // however, there are many places that run background jobs assume the system context.
+ // however, there are many places that run background jobs assume the system context.
//
- // If there is a security concern, all entry points from user (including the front end that takes HTTP request in and
+ // If there is a security concern, all entry points from user (including the front end that takes HTTP
+// request in and
// the core async-job manager that runs commands from user) have explicitly setup the UserContext.
- //
+ //
return s_adminContext;
}
return context;
}
- public static void updateContext(long userId, Account accountObject, String sessionId) {
- UserContext context = current();
- assert(context != null) : "Context should be already setup before you can call this one";
+ public static void updateContext(long userId, Account accountObject, String sessionId) {
+ UserContext context = current();
+ assert (context != null) : "Context should be already setup before you can call this one";
- context.setCallerUserId(userId);
- context.setCaller(accountObject);
- context.setSessionKey(sessionId);
- }
+ context.setCallerUserId(userId);
+ context.setCaller(accountObject);
+ context.setSessionKey(sessionId);
+ }
- public static void registerContext(long userId, Account accountObject, String sessionId, boolean apiServer) {
- s_currentContext.set(new UserContext(userId, accountObject, sessionId, apiServer));
- }
+ public static void registerContext(long userId, Account accountObject, String sessionId, boolean apiServer) {
+ s_currentContext.set(new UserContext(userId, accountObject, sessionId, apiServer));
+ }
- public static void unregisterContext() {
- s_currentContext.set(null);
- }
+ public static void unregisterContext() {
+ s_currentContext.set(null);
+ }
public void setStartEventId(long startEventId) {
this.startEventId = startEventId;
@@ -135,4 +136,4 @@ public class UserContext {
public String getEventDetails() {
return eventDetails;
}
-}
+}
diff --git a/api/src/com/cloud/uservm/UserVm.java b/api/src/com/cloud/uservm/UserVm.java
index c92bb6391e5..20d0ae016f3 100755
--- a/api/src/com/cloud/uservm/UserVm.java
+++ b/api/src/com/cloud/uservm/UserVm.java
@@ -24,19 +24,19 @@ import com.cloud.vm.VirtualMachine;
* This represents one running virtual machine instance.
*/
public interface UserVm extends VirtualMachine, ControlledEntity {
-
+
Long getIsoId();
-
+
String getDisplayName();
-
+
String getUserData();
-
+
String getPassword();
-
+
void setUserData(String userData);
- String getDetail(String name);
-
- void setAccountId(long accountId);
+ String getDetail(String name);
+
+ void setAccountId(long accountId);
}
diff --git a/api/src/com/cloud/vm/BareMetalVmService.java b/api/src/com/cloud/vm/BareMetalVmService.java
index fd9c3a738f4..30df126d704 100755
--- a/api/src/com/cloud/vm/BareMetalVmService.java
+++ b/api/src/com/cloud/vm/BareMetalVmService.java
@@ -18,7 +18,6 @@
package com.cloud.vm;
-import com.cloud.exception.ResourceAllocationException;
public interface BareMetalVmService extends UserVmService {
}
diff --git a/api/src/com/cloud/vm/DiskProfile.java b/api/src/com/cloud/vm/DiskProfile.java
index 9b05470b36f..d24b0836532 100644
--- a/api/src/com/cloud/vm/DiskProfile.java
+++ b/api/src/com/cloud/vm/DiskProfile.java
@@ -24,7 +24,7 @@ import com.cloud.storage.Volume;
/**
* DiskProfile describes a disk and what functionality is required from it.
* This object is generated by the management server and passed to the allocators
- * and resources to allocate and create disks. There object is immutable once
+ * and resources to allocate and create disks. There object is immutable once
* it has been created.
*/
public class DiskProfile {
@@ -37,12 +37,12 @@ public class DiskProfile {
private long diskOfferingId;
private Long templateId;
private long volumeId;
-
+
private HypervisorType hyperType;
-
+
protected DiskProfile() {
}
-
+
public DiskProfile(long volumeId, Volume.Type type, String name, long diskOfferingId, long size, String[] tags, boolean useLocalStorage, boolean recreatable, Long templateId) {
this.type = type;
this.name = name;
@@ -54,26 +54,26 @@ public class DiskProfile {
this.templateId = templateId;
this.volumeId = volumeId;
}
-
+
public DiskProfile(Volume vol, DiskOffering offering, HypervisorType hyperType) {
this(vol.getId(), vol.getVolumeType(), vol.getName(), offering.getId(), vol.getSize(), offering.getTagsArray(), offering.getUseLocalStorage(), offering.isCustomized(), null);
this.hyperType = hyperType;
}
-
+
/**
* @return size of the disk requested in bytes.
*/
public long getSize() {
return size;
}
-
+
/**
* @return id of the volume backing up this disk characteristics
*/
public long getVolumeId() {
return volumeId;
}
-
+
/**
* @return Unique name for the disk.
*/
@@ -82,61 +82,62 @@ public class DiskProfile {
}
/**
- * @return tags for the disk. This can be used to match it to different storage pools.
+ * @return tags for the disk. This can be used to match it to different storage pools.
*/
public String[] getTags() {
return tags;
}
/**
- * @return type of volume.
+ * @return type of volume.
*/
public Volume.Type getType() {
return type;
}
-
+
/**
* @return Does this volume require local storage?
*/
public boolean useLocalStorage() {
return useLocalStorage;
}
-
+
public void setUseLocalStorage(boolean useLocalStorage) {
this.useLocalStorage = useLocalStorage;
}
+
/**
- * @return Is this volume recreatable? A volume is recreatable if the disk's content can be
- * reconstructed from the template.
+ * @return Is this volume recreatable? A volume is recreatable if the disk's content can be
+ * reconstructed from the template.
*/
public boolean isRecreatable() {
return recreatable;
}
-
+
/**
- * @return template id the disk is based on. Can be null if it is not based on any templates.
+ * @return template id the disk is based on. Can be null if it is not based on any templates.
*/
public Long getTemplateId() {
return templateId;
}
-
+
/**
* @return disk offering id that the disk is based on.
*/
public long getDiskOfferingId() {
return diskOfferingId;
}
-
+
@Override
public String toString() {
return new StringBuilder("DskChr[").append(type).append("|").append(size).append("|").append("]").toString();
}
-
+
public void setHyperType(HypervisorType hyperType) {
- this.hyperType = hyperType;
+ this.hyperType = hyperType;
}
-
+
public HypervisorType getHypersorType() {
- return this.hyperType;
+ return this.hyperType;
}
}
diff --git a/api/src/com/cloud/vm/InstanceGroup.java b/api/src/com/cloud/vm/InstanceGroup.java
index 3f0e78a8e73..fe3ec9e2b48 100644
--- a/api/src/com/cloud/vm/InstanceGroup.java
+++ b/api/src/com/cloud/vm/InstanceGroup.java
@@ -23,8 +23,11 @@ import com.cloud.acl.ControlledEntity;
public interface InstanceGroup extends ControlledEntity {
long getId();
+
String getName();
+
Date getCreated();
- Short getAccountType();
+
+ Short getAccountType();
}
diff --git a/api/src/com/cloud/vm/Nic.java b/api/src/com/cloud/vm/Nic.java
index bc7cc6e08b2..75259df5234 100644
--- a/api/src/com/cloud/vm/Nic.java
+++ b/api/src/com/cloud/vm/Nic.java
@@ -92,7 +92,8 @@ public interface Nic {
long getId();
/**
- * @return reservation id returned by the allocation source. This can be the String version of the database id if the
+ * @return reservation id returned by the allocation source. This can be the String version of the database id if
+ * the
* allocation source does not need it's own implementation of the reservation id. This is passed back to the
* allocation source to release the resource.
*/
diff --git a/api/src/com/cloud/vm/ReservationContext.java b/api/src/com/cloud/vm/ReservationContext.java
index 837698262a2..a16522b7570 100644
--- a/api/src/com/cloud/vm/ReservationContext.java
+++ b/api/src/com/cloud/vm/ReservationContext.java
@@ -25,29 +25,29 @@ import com.cloud.user.User;
import com.cloud.utils.Journal;
/**
- * Specifies the entity that is calling the api.
+ * Specifies the entity that is calling the api.
*/
public interface ReservationContext extends PartOf, OwnedBy {
/**
* @return the user making the call.
*/
User getCaller();
-
+
/**
* @return the account
*/
Account getAccount();
-
+
/**
* @return the domain.
*/
Domain getDomain();
-
+
/**
* @return the journal
*/
Journal getJournal();
-
+
/**
* @return the reservation id.
*/
diff --git a/api/src/com/cloud/vm/RunningOn.java b/api/src/com/cloud/vm/RunningOn.java
index 192d8912126..36c41374fde 100644
--- a/api/src/com/cloud/vm/RunningOn.java
+++ b/api/src/com/cloud/vm/RunningOn.java
@@ -23,10 +23,10 @@ package com.cloud.vm;
/**
* RunningOn must be implemented by objects that runs on hosts.
- *
+ *
*/
public interface RunningOn {
-
+
Long getHostId();
}
diff --git a/api/src/com/cloud/vm/UserVmService.java b/api/src/com/cloud/vm/UserVmService.java
index f8f2c7aafe7..d4cc05eb479 100755
--- a/api/src/com/cloud/vm/UserVmService.java
+++ b/api/src/com/cloud/vm/UserVmService.java
@@ -109,7 +109,7 @@ public interface UserVmService {
Volume detachVolumeFromVM(DetachVolumeCmd cmmd);
UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException,
- ResourceAllocationException;
+ ResourceAllocationException;
UserVm rebootVirtualMachine(RebootVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException;
@@ -121,9 +121,11 @@ public interface UserVmService {
* Create a template database record in preparation for creating a private template.
*
* @param cmd
- * the command object that defines the name, display text, snapshot/volume, bits, public/private, etc. for the
+ * the command object that defines the name, display text, snapshot/volume, bits, public/private, etc.
+ * for the
* private template
- * @param templateOwner TODO
+ * @param templateOwner
+ * TODO
* @return the vm template object if successful, null otherwise
* @throws ResourceAllocationException
*/
@@ -154,10 +156,14 @@ public interface UserVmService {
* @param displayName
* - an optional user generated name for the virtual machine
* @param diskOfferingId
- * - the ID of the disk offering for the virtual machine. If the template is of ISO format, the diskOfferingId is
- * for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk volume.
- * If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk Volume
- * created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT Disk
+ * - the ID of the disk offering for the virtual machine. If the template is of ISO format, the
+ * diskOfferingId is
+ * for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk
+ * volume.
+ * If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk
+ * Volume
+ * created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT
+ * Disk
* Volume created
* @param diskSize
* - the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId
@@ -166,17 +172,22 @@ public interface UserVmService {
* @param hypervisor
* - the hypervisor on which to deploy the virtual machine
* @param userData
- * - an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary
- * data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported. Using HTTP
+ * - an optional binary data that can be sent to the virtual machine upon a successful deployment. This
+ * binary
+ * data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported.
+ * Using HTTP
* GET (via querystring), you can send up to 2KB of data after base64 encoding
* @param sshKeyPair
* - name of the ssh key pair used to login to the virtual machine
- * @param requestedIps TODO
- * @param defaultIp TODO
+ * @param requestedIps
+ * TODO
+ * @param defaultIp
+ * TODO
* @param accountName
* - an optional account for the virtual machine. Must be used with domainId
* @param domainId
- * - an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used
+ * - an optional domainId for the virtual machine. If the account parameter is used, domainId must also
+ * be used
* @return UserVm object if successful.
*
* @throws InsufficientCapacityException
@@ -189,10 +200,11 @@ public interface UserVmService {
*/
UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List securityGroupIdList, Account owner, String hostName,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map requestedIps, String defaultIp, String keyboard)
- throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
+ throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/**
- * Creates a User VM in Advanced Zone (Security Group feature is enabled) in the database and returns the VM to the caller.
+ * Creates a User VM in Advanced Zone (Security Group feature is enabled) in the database and returns the VM to the
+ * caller.
*
* @param zone
* - availability zone for the virtual machine
@@ -209,10 +221,14 @@ public interface UserVmService {
* @param displayName
* - an optional user generated name for the virtual machine
* @param diskOfferingId
- * - the ID of the disk offering for the virtual machine. If the template is of ISO format, the diskOfferingId is
- * for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk volume.
- * If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk Volume
- * created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT Disk
+ * - the ID of the disk offering for the virtual machine. If the template is of ISO format, the
+ * diskOfferingId is
+ * for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk
+ * volume.
+ * If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk
+ * Volume
+ * created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT
+ * Disk
* Volume created
* @param diskSize
* - the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId
@@ -221,17 +237,22 @@ public interface UserVmService {
* @param hypervisor
* - the hypervisor on which to deploy the virtual machine
* @param userData
- * - an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary
- * data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported. Using HTTP
+ * - an optional binary data that can be sent to the virtual machine upon a successful deployment. This
+ * binary
+ * data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported.
+ * Using HTTP
* GET (via querystring), you can send up to 2KB of data after base64 encoding
* @param sshKeyPair
* - name of the ssh key pair used to login to the virtual machine
- * @param requestedIps TODO
- * @param defaultIp TODO
+ * @param requestedIps
+ * TODO
+ * @param defaultIp
+ * TODO
* @param accountName
* - an optional account for the virtual machine. Must be used with domainId
* @param domainId
- * - an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used
+ * - an optional domainId for the virtual machine. If the account parameter is used, domainId must also
+ * be used
* @return UserVm object if successful.
*
* @throws InsufficientCapacityException
@@ -243,11 +264,13 @@ public interface UserVmService {
* @throws InsufficientResourcesException
*/
UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List networkIdList, List securityGroupIdList,
- Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map requestedIps, String defaultIp, String keyboard)
- throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
+ Account owner, String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map requestedIps,
+ String defaultIp, String keyboard)
+ throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/**
- * Creates a User VM in Advanced Zone (Security Group feature is disabled) in the database and returns the VM to the caller.
+ * Creates a User VM in Advanced Zone (Security Group feature is disabled) in the database and returns the VM to the
+ * caller.
*
* @param zone
* - availability zone for the virtual machine
@@ -262,10 +285,14 @@ public interface UserVmService {
* @param displayName
* - an optional user generated name for the virtual machine
* @param diskOfferingId
- * - the ID of the disk offering for the virtual machine. If the template is of ISO format, the diskOfferingId is
- * for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk volume.
- * If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk Volume
- * created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT Disk
+ * - the ID of the disk offering for the virtual machine. If the template is of ISO format, the
+ * diskOfferingId is
+ * for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk
+ * volume.
+ * If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk
+ * Volume
+ * created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT
+ * Disk
* Volume created
* @param diskSize
* - the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId
@@ -274,17 +301,22 @@ public interface UserVmService {
* @param hypervisor
* - the hypervisor on which to deploy the virtual machine
* @param userData
- * - an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary
- * data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported. Using HTTP
+ * - an optional binary data that can be sent to the virtual machine upon a successful deployment. This
+ * binary
+ * data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported.
+ * Using HTTP
* GET (via querystring), you can send up to 2KB of data after base64 encoding
* @param sshKeyPair
* - name of the ssh key pair used to login to the virtual machine
- * @param requestedIps TODO
- * @param defaultIp TODO
+ * @param requestedIps
+ * TODO
+ * @param defaultIp
+ * TODO
* @param accountName
* - an optional account for the virtual machine. Must be used with domainId
* @param domainId
- * - an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used
+ * - an optional domainId for the virtual machine. If the account parameter is used, domainId must also
+ * be used
* @return UserVm object if successful.
*
* @throws InsufficientCapacityException
@@ -297,7 +329,7 @@ public interface UserVmService {
*/
UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffering, VirtualMachineTemplate template, List networkIdList, Account owner, String hostName,
String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, String userData, String sshKeyPair, Map requestedIps, String defaultIp, String keyboard)
- throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
+ throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
/**
* Starts the virtual machine created from createVirtualMachine.
@@ -354,15 +386,19 @@ public interface UserVmService {
HypervisorType getHypervisorTypeOfUserVM(long vmid);
UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException,
- ResourceAllocationException;
+ ResourceAllocationException;
UserVm getUserVm(long vmId);
/**
- * Migrate the given VM to the destination host provided. The API returns the migrated VM if migration succeeds. Only Root
+ * Migrate the given VM to the destination host provided. The API returns the migrated VM if migration succeeds.
+ * Only Root
* Admin can migrate a VM.
- * @param destinationStorage TODO
- * @param Long vmId
+ *
+ * @param destinationStorage
+ * TODO
+ * @param Long
+ * vmId
* vmId of The VM to migrate
* @param Host
* destinationHost to migrate the VM
@@ -379,9 +415,9 @@ public interface UserVmService {
*/
VirtualMachine migrateVirtualMachine(Long vmId, Host destinationHost) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
- UserVm moveVMToUser(AssignVMCmd moveUserVMCmd) throws ResourceAllocationException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException ;
+ UserVm moveVMToUser(AssignVMCmd moveUserVMCmd) throws ResourceAllocationException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
- VirtualMachine vmStorageMigration(Long vmId, StoragePool destPool);
-
- UserVm restoreVM(RestoreVMCmd cmd);
+ VirtualMachine vmStorageMigration(Long vmId, StoragePool destPool);
+
+ UserVm restoreVM(RestoreVMCmd cmd);
}
diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java
index c28f3331615..56bf3a75064 100755
--- a/api/src/com/cloud/vm/VirtualMachine.java
+++ b/api/src/com/cloud/vm/VirtualMachine.java
@@ -26,13 +26,12 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.fsm.StateMachine2;
import com.cloud.utils.fsm.StateObject;
-
/**
* VirtualMachine describes the properties held by a virtual machine
- *
+ *
*/
public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, StateObject {
-
+
public enum State {
Starting(true, "VM is being started. At this state, you should find host id filled which means it's being started on that host."),
Running(false, "VM is running. host id has the host that it is running on."),
@@ -45,38 +44,38 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
Unknown(false, "VM state is unknown."),
Shutdowned(false, "VM is shutdowned from inside");
-
private final boolean _transitional;
String _description;
-
+
private State(boolean transitional, String description) {
_transitional = transitional;
_description = description;
}
-
+
public String getDescription() {
return _description;
}
-
+
public boolean isTransitional() {
return _transitional;
}
-
+
public static StateMachine2 getStateMachine() {
return s_fsm;
}
-
+
protected static final StateMachine2 s_fsm = new StateMachine2();
static {
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.StartRequested, State.Starting);
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.DestroyRequested, State.Destroyed);
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.StopRequested, State.Stopped);
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.AgentReportStopped, State.Stopped);
-
- // please pay attention about state transition to Error state, there should be only one case (failed in VM creation process)
+
+ // please pay attention about state transition to Error state, there should be only one case (failed in VM
+ // creation process)
// that can have such transition
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.OperationFailedToError, State.Error);
-
+
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.OperationFailed, State.Stopped);
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.ExpungeOperation, State.Expunging);
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.AgentReportShutdowned, State.Stopped);
@@ -112,28 +111,28 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
s_fsm.addTransition(State.Error, VirtualMachine.Event.DestroyRequested, State.Expunging);
s_fsm.addTransition(State.Error, VirtualMachine.Event.ExpungeOperation, State.Expunging);
}
-
+
public static boolean isVmStarted(State oldState, Event e, State newState) {
if (oldState == State.Starting && newState == State.Running) {
return true;
}
return false;
}
-
+
public static boolean isVmStopped(State oldState, Event e, State newState) {
if (oldState == State.Stopping && newState == State.Stopped) {
return true;
}
return false;
}
-
+
public static boolean isVmMigrated(State oldState, Event e, State newState) {
if (oldState == State.Migrating && newState == State.Running && (e == Event.OperationSucceeded || e == Event.AgentReportRunning)) {
return true;
}
return false;
}
-
+
public static boolean isVmCreated(State oldState, Event e, State newState) {
if (oldState == State.Destroyed && newState == State.Stopped) {
// VM recover
@@ -141,7 +140,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
}
return false;
}
-
+
public static boolean isVmDestroyed(State oldState, Event e, State newState) {
if (oldState == State.Stopped && newState == State.Destroyed) {
return true;
@@ -149,34 +148,34 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
if (oldState == State.Stopped && newState == State.Error) {
return true;
}
-
+
if (oldState == State.Stopped && newState == State.Expunging) {
- return true;
+ return true;
}
-
+
return false;
}
}
-
+
public enum Event {
- CreateRequested,
- StartRequested,
- StopRequested,
- DestroyRequested,
- RecoveryRequested,
- AgentReportStopped,
- AgentReportRunning,
- MigrationRequested,
- StorageMigrationRequested,
- ExpungeOperation,
- OperationSucceeded,
- OperationFailed,
- OperationFailedToError,
- OperationRetry,
- AgentReportShutdowned,
- AgentReportMigrated
+ CreateRequested,
+ StartRequested,
+ StopRequested,
+ DestroyRequested,
+ RecoveryRequested,
+ AgentReportStopped,
+ AgentReportRunning,
+ MigrationRequested,
+ StorageMigrationRequested,
+ ExpungeOperation,
+ OperationSucceeded,
+ OperationFailed,
+ OperationFailedToError,
+ OperationRetry,
+ AgentReportShutdowned,
+ AgentReportMigrated
};
-
+
public enum Type {
User,
DomainRouter,
@@ -184,90 +183,92 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
SecondaryStorageVm,
ElasticIpVm,
ElasticLoadBalancerVm,
-
+
/*
* UserBareMetal is only used for selecting VirtualMachineGuru, there is no
* VM with this type. UserBareMetal should treat exactly as User.
*/
UserBareMetal;
-
+
public static boolean isSystemVM(VirtualMachine.Type vmtype) {
- if(DomainRouter.equals(vmtype)
- || ConsoleProxy.equals(vmtype)
- || SecondaryStorageVm.equals(vmtype)){
- return true;
- }
+ if (DomainRouter.equals(vmtype)
+ || ConsoleProxy.equals(vmtype)
+ || SecondaryStorageVm.equals(vmtype)) {
+ return true;
+ }
return false;
}
}
-
+
/**
* @return The name of the vm instance used by the cloud stack to uniquely
- * reference this VM. You can build names that starts with this name and it
- * guarantees uniqueness for things related to the VM.
+ * reference this VM. You can build names that starts with this name and it
+ * guarantees uniqueness for things related to the VM.
*/
public String getInstanceName();
-
+
/**
- * @return the id of this virtual machine. null means the id has not been set.
+ * @return the id of this virtual machine. null means the id has not been set.
*/
public long getId();
-
+
/**
- * @return the host name of the virtual machine. If the user did not
- * specify the host name when creating the virtual machine then it is
- * defaults to the instance name.
+ * @return the host name of the virtual machine. If the user did not
+ * specify the host name when creating the virtual machine then it is
+ * defaults to the instance name.
*/
public String getHostName();
-
+
/**
* @return the ip address of the virtual machine.
*/
public String getPrivateIpAddress();
-
+
/**
* @return mac address.
*/
public String getPrivateMacAddress();
-
+
/**
* @return password of the host for vnc purposes.
*/
public String getVncPassword();
-
+
/**
* @return the state of the virtual machine
*/
- //public State getState();
-
+ // public State getState();
+
/**
* @return template id.
*/
public long getTemplateId();
-
+
/**
* returns the guest OS ID
+ *
* @return guestOSId
*/
public long getGuestOSId();
-
+
/**
* @return pod id.
*/
public Long getPodIdToDeployIn();
-
+
/**
* @return data center id.
*/
public long getDataCenterIdToDeployIn();
-
+
/**
* @return id of the host it was assigned last time.
*/
public Long getLastHostId();
+
@Override
public Long getHostId();
-
+
/**
* @return should HA be enabled for this machine?
*/
@@ -277,16 +278,17 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, S
* @return should limit CPU usage to the service offering?
*/
public boolean limitCpuUse();
- /**
+
+ /**
* @return date when machine was created
*/
- public Date getCreated();
-
- public long getServiceOfferingId();
-
- Type getType();
-
- HypervisorType getHypervisorType();
-
- public Map getDetails();
+ public Date getCreated();
+
+ public long getServiceOfferingId();
+
+ Type getType();
+
+ HypervisorType getHypervisorType();
+
+ public Map getDetails();
}
diff --git a/api/src/com/cloud/vm/VirtualMachineProfile.java b/api/src/com/cloud/vm/VirtualMachineProfile.java
index 0ff762507e4..8c5295e34b7 100644
--- a/api/src/com/cloud/vm/VirtualMachineProfile.java
+++ b/api/src/com/cloud/vm/VirtualMachineProfile.java
@@ -27,111 +27,111 @@ import com.cloud.template.VirtualMachineTemplate;
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
import com.cloud.user.Account;
-
/**
- * VirtualMachineProfile describes one virtual machine. This object
- * is passed to various adapters to be processed. Anything that is
- * set in this object is transitional. It does not get persisted
- * back to the database. This allows the adapters to process
+ * VirtualMachineProfile describes one virtual machine. This object
+ * is passed to various adapters to be processed. Anything that is
+ * set in this object is transitional. It does not get persisted
+ * back to the database. This allows the adapters to process
* the information in the virtual machine and make determinations
* on what the virtual machine profile should look like before it is
* actually started on the hypervisor.
- *
- * @param a VirtualMachine
+ *
+ * @param
+ * a VirtualMachine
*/
public interface VirtualMachineProfile {
-
-
+
public static class Param {
-
+
public static final Param VmPassword = new Param("VmPassword");
public static final Param ControlNic = new Param("ControlNic");
public static final Param ReProgramNetwork = new Param("RestartNetwork");
public static final Param PxeSeverType = new Param("PxeSeverType");
-
+
private String name;
-
+
public Param(String name) {
- synchronized(Param.class) {
+ synchronized (Param.class) {
this.name = name;
}
}
-
+
public String getName() {
return name;
}
- }
-
+ }
+
String getHostName();
-
+
String getInstanceName();
-
+
Account getOwner();
-
+
/**
* @return the virtual machine that backs up this profile.
*/
T getVirtualMachine();
-
+
/**
* @return service offering for this virtual machine.
*/
ServiceOffering getServiceOffering();
-
+
/**
* @return parameter specific for this type of virtual machine.
*/
Object getParameter(Param name);
-
+
/**
* @return the hypervisor type needed for this virtual machine.
*/
HypervisorType getHypervisorType();
-
+
/**
* @return template the virtual machine is based on.
*/
VirtualMachineTemplate getTemplate();
-
+
/**
* @return the template id
*/
long getTemplateId();
-
+
/**
* @return the service offering id
*/
long getServiceOfferingId();
-
+
/**
* @return virtual machine id.
*/
long getId();
-
+
List getNics();
-
+
List getDisks();
-
+
void addNic(int index, NicProfile nic);
-
+
void addDisk(int index, VolumeTO disk);
-
+
StringBuilder getBootArgsBuilder();
-
+
void addBootArgs(String... args);
-
+
String getBootArgs();
-
+
void addNic(NicProfile nic);
-
+
void addDisk(VolumeTO disk);
-
+
VirtualMachine.Type getType();
-
+
void setParameter(Param name, Object value);
- void setBootLoaderType(BootloaderType bootLoader);
- BootloaderType getBootLoaderType();
-
- Map getParameters();
+ void setBootLoaderType(BootloaderType bootLoader);
+
+ BootloaderType getBootLoaderType();
+
+ Map getParameters();
}
diff --git a/api/src/com/cloud/vm/VmStats.java b/api/src/com/cloud/vm/VmStats.java
index 1056bb18465..034a3a1d44b 100644
--- a/api/src/com/cloud/vm/VmStats.java
+++ b/api/src/com/cloud/vm/VmStats.java
@@ -19,9 +19,11 @@
package com.cloud.vm;
public interface VmStats {
- //vm related stats
- public double getCPUUtilization();
+ // vm related stats
+ public double getCPUUtilization();
+
public double getNetworkReadKBs();
+
public double getNetworkWriteKBs();
}
diff --git a/core/src/com/cloud/configuration/ResourceLimitVO.java b/core/src/com/cloud/configuration/ResourceLimitVO.java
index 0900aa4ef04..33aeb5d6994 100644
--- a/core/src/com/cloud/configuration/ResourceLimitVO.java
+++ b/core/src/com/cloud/configuration/ResourceLimitVO.java
@@ -28,100 +28,101 @@ import javax.persistence.Id;
import javax.persistence.Table;
@Entity
-@Table(name="resource_limit")
+@Table(name = "resource_limit")
public class ResourceLimitVO implements ResourceLimit {
-
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
private Long id = null;
-
- @Column(name="type")
- @Enumerated(EnumType.STRING)
- private ResourceCount.ResourceType type;
-
- @Column(name="domain_id")
+
+ @Column(name = "type")
+ @Enumerated(EnumType.STRING)
+ private ResourceCount.ResourceType type;
+
+ @Column(name = "domain_id")
private Long domainId;
-
- @Column(name="account_id")
+
+ @Column(name = "account_id")
private Long accountId;
-
- @Column(name="max")
- private Long max;
-
- public ResourceLimitVO() {}
-
- public ResourceLimitVO(ResourceCount.ResourceType type, Long max, long ownerId, ResourceOwnerType ownerType) {
- this.type = type;
- this.max = max;
-
- if (ownerType == ResourceOwnerType.Account) {
+
+ @Column(name = "max")
+ private Long max;
+
+ public ResourceLimitVO() {
+ }
+
+ public ResourceLimitVO(ResourceCount.ResourceType type, Long max, long ownerId, ResourceOwnerType ownerType) {
+ this.type = type;
+ this.max = max;
+
+ if (ownerType == ResourceOwnerType.Account) {
this.accountId = ownerId;
} else if (ownerType == ResourceOwnerType.Domain) {
this.domainId = ownerId;
}
- }
-
- @Override
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- @Override
- public ResourceType getType() {
- return type;
- }
-
- public void setType(ResourceCount.ResourceType type) {
- this.type = type;
- }
-
- public Long getDomainId() {
- return domainId;
- }
-
- public Long getAccountId() {
- return accountId;
- }
-
- @Override
- public Long getMax() {
- return max;
- }
-
- @Override
- public void setMax(Long max) {
- this.max = max;
- }
-
- @Override
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public ResourceType getType() {
+ return type;
+ }
+
+ public void setType(ResourceCount.ResourceType type) {
+ this.type = type;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public Long getAccountId() {
+ return accountId;
+ }
+
+ @Override
+ public Long getMax() {
+ return max;
+ }
+
+ @Override
+ public void setMax(Long max) {
+ this.max = max;
+ }
+
+ @Override
public long getOwnerId() {
if (accountId != null) {
return accountId;
- }
-
+ }
+
return domainId;
}
-
- @Override
- public ResourceOwnerType getResourceOwnerType() {
- if (accountId != null) {
- return ResourceOwnerType.Account;
- } else {
- return ResourceOwnerType.Domain;
- }
- }
- public void setDomainId(Long domainId) {
- this.domainId = domainId;
+ @Override
+ public ResourceOwnerType getResourceOwnerType() {
+ if (accountId != null) {
+ return ResourceOwnerType.Account;
+ } else {
+ return ResourceOwnerType.Domain;
+ }
}
- public void setAccountId(Long accountId) {
- this.accountId = accountId;
- }
+ public void setDomainId(Long domainId) {
+ this.domainId = domainId;
+ }
+
+ public void setAccountId(Long accountId) {
+ this.accountId = accountId;
+ }
}
diff --git a/core/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java b/core/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
index 98b9eab694b..d2124fc9f55 100644
--- a/core/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
+++ b/core/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
@@ -531,12 +531,13 @@ public class XenServerConnectionPool {
s_logger.debug(msg);
throw new CloudRuntimeException(msg);
}
+ Host host = null;
synchronized (poolUuid.intern()) {
// Let's see if it is an existing connection.
mConn = getConnect(poolUuid);
if (mConn != null){
try{
- Host.getByUuid(mConn, hostUuid);
+ host = Host.getByUuid(mConn, hostUuid);
} catch (Types.SessionInvalid e) {
s_logger.debug("Session thgrough ip " + mConn.getIp() + " is invalid for pool(" + poolUuid + ") due to " + e.toString());
try {
@@ -635,6 +636,45 @@ public class XenServerConnectionPool {
}
}
}
+
+ if ( mConn != null ) {
+ if (s_managePool) {
+ try {
+ Map args = new HashMap();
+ host.callPlugin(mConn, "echo", "main", args);
+ } catch (Types.SessionInvalid e) {
+ if (s_logger.isDebugEnabled()) {
+ String msg = "Catch Exception: " + e.getClass().getName() + " Can't connect host " + ipAddress + " due to " + e.toString();
+ s_logger.debug(msg);
+ }
+ PoolEmergencyResetMaster(ipAddress, mConn.getIp(), mConn.getUsername(), mConn.getPassword());
+ } catch (Types.CannotContactHost e ) {
+ if (s_logger.isDebugEnabled()) {
+ String msg = "Catch Exception: " + e.getClass().getName() + " Can't connect host " + ipAddress + " due to " + e.toString();
+ s_logger.debug(msg);
+ }
+ PoolEmergencyResetMaster(ipAddress, mConn.getIp(), mConn.getUsername(), mConn.getPassword());
+ } catch (Types.HostOffline e ) {
+ if (s_logger.isDebugEnabled()) {
+ String msg = "Catch Exception: " + e.getClass().getName() + " Host is offline " + ipAddress + " due to " + e.toString();
+ s_logger.debug(msg);
+ }
+ PoolEmergencyResetMaster(ipAddress, mConn.getIp(), mConn.getUsername(), mConn.getPassword());
+ } catch (Types.HostNotLive e ) {
+ String msg = "Catch Exception: " + e.getClass().getName() + " Host Not Live " + ipAddress + " due to " + e.toString();
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug(msg);
+ }
+ PoolEmergencyResetMaster(ipAddress, mConn.getIp(), mConn.getUsername(), mConn.getPassword());
+ } catch (Exception e) {
+ String msg = "Master can not talk to Slave " + hostUuid + " IP " + ipAddress;
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug(msg);
+ }
+ throw new CloudRuntimeException(msg);
+ }
+ }
+ }
return mConn;
}
@@ -879,24 +919,6 @@ public class XenServerConnectionPool {
}
loginWithPassword(this, _username, _password, APIVersion.latest().toString());
method_params[0] = getSessionReference();
- } catch (Types.CannotContactHost e ) {
- if (s_logger.isDebugEnabled()) {
- String msg = "Cannot Contact Host for method: " + method_call + " due to " + e.toString();
- s_logger.debug(msg);
- }
- throw e;
- } catch (Types.HostOffline e ) {
- if (s_logger.isDebugEnabled()) {
- String msg = "Host Offline for method: " + method_call + " due to " + e.toString();
- s_logger.debug(msg);
- }
- throw e;
- } catch (Types.HostNotLive e ) {
- if (s_logger.isDebugEnabled()) {
- String msg = "Host is Not alive for method: " + method_call + " due to " + e.toString();
- s_logger.debug(msg);
- }
- throw e;
} catch (XmlRpcClientException e) {
s_logger.debug("XmlRpcClientException for method: " + method_call + " due to " + e.getMessage());
removeConnect(_poolUuid);
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index d0079df516b..498668ef4a6 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -276,18 +276,19 @@ public class ApiResponseHelper implements ResponseGenerator {
Long ipLimit = ApiDBUtils.findCorrectResourceLimit(ResourceType.public_ip, account.getId());
String ipLimitDisplay = (accountIsAdmin || ipLimit == -1) ? "Unlimited" : String.valueOf(ipLimit);
Long ipTotal = ApiDBUtils.getResourceCount(ResourceType.public_ip, account.getId());
-
+
Long ips = ipLimit - ipTotal;
- //check how many free ips are left, and if it's less than max allowed number of ips from account - use this value
+ // check how many free ips are left, and if it's less than max allowed number of ips from account - use this
+// value
Long ipsLeft = ApiDBUtils.countFreePublicIps();
boolean unlimited = true;
if (ips.longValue() > ipsLeft.longValue()) {
- ips = ipsLeft;
- unlimited = false;
+ ips = ipsLeft;
+ unlimited = false;
}
-
+
String ipAvail = ((accountIsAdmin || ipLimit == -1) && unlimited) ? "Unlimited" : String.valueOf(ips);
-
+
accountResponse.setIpLimit(ipLimitDisplay);
accountResponse.setIpTotal(ipTotal);
accountResponse.setIpAvailable(ipAvail);
@@ -319,7 +320,7 @@ public class ApiResponseHelper implements ResponseGenerator {
// Get stopped and running VMs
int vmStopped = 0;
int vmRunning = 0;
-
+
List permittedAccounts = new ArrayList();
permittedAccounts.add(account.getId());
@@ -353,8 +354,7 @@ public class ApiResponseHelper implements ResponseGenerator {
accountResponse.setDetails(ApiDBUtils.getAccountDetails(account.getId()));
return accountResponse;
}
-
-
+
@Override
public UserResponse createUserResponse(UserAccount user) {
UserResponse userResponse = new UserResponse();
@@ -418,7 +418,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public ResourceLimitResponse createResourceLimitResponse(ResourceLimit limit) {
ResourceLimitResponse resourceLimitResponse = new ResourceLimitResponse();
- if (limit.getResourceOwnerType() == ResourceOwnerType.Domain) {
+ if (limit.getResourceOwnerType() == ResourceOwnerType.Domain) {
populateDomain(resourceLimitResponse, limit.getOwnerId());
} else if (limit.getResourceOwnerType() == ResourceOwnerType.Account) {
Account accountTemp = ApiDBUtils.findAccountById(limit.getOwnerId());
@@ -496,7 +496,7 @@ public class ApiResponseHelper implements ResponseGenerator {
public SnapshotResponse createSnapshotResponse(Snapshot snapshot) {
SnapshotResponse snapshotResponse = new SnapshotResponse();
snapshotResponse.setId(snapshot.getId());
-
+
populateOwner(snapshotResponse, snapshot);
VolumeVO volume = findVolumeById(snapshot.getVolumeId());
@@ -528,7 +528,6 @@ public class ApiResponseHelper implements ResponseGenerator {
return policyResponse;
}
-
@Override
public HostResponse createHostResponse(Host host) {
@@ -556,17 +555,17 @@ public class ApiResponseHelper implements ResponseGenerator {
hostResponse.setIpAddress(host.getPrivateIpAddress());
hostResponse.setVersion(host.getVersion());
hostResponse.setCreated(host.getCreated());
-
- if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)
- || details.contains(HostDetails.stats) || details.contains(HostDetails.events) ){
-
+
+ if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)
+ || details.contains(HostDetails.stats) || details.contains(HostDetails.events)) {
+
GuestOSCategoryVO guestOSCategory = ApiDBUtils.getHostGuestOSCategory(host.getId());
if (guestOSCategory != null) {
hostResponse.setOsCategoryId(guestOSCategory.getId());
hostResponse.setOsCategoryName(guestOSCategory.getName());
}
hostResponse.setZoneName(ApiDBUtils.findZoneById(host.getDataCenterId()).getName());
-
+
if (host.getPodId() != null) {
HostPodVO pod = ApiDBUtils.findPodById(host.getPodId());
if (pod != null) {
@@ -581,26 +580,26 @@ public class ApiResponseHelper implements ResponseGenerator {
}
}
- DecimalFormat decimalFormat = new DecimalFormat("#.##");
- if (host.getType() == Host.Type.Routing) {
+ DecimalFormat decimalFormat = new DecimalFormat("#.##");
+ if (host.getType() == Host.Type.Routing) {
- if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)){
- //set allocated capacities
- Long mem = ApiDBUtils.getMemoryOrCpuCapacitybyHost(host.getId(),Capacity.CAPACITY_TYPE_MEMORY);
- Long cpu = ApiDBUtils.getMemoryOrCpuCapacitybyHost(host.getId(),Capacity.CAPACITY_TYPE_CPU);
-
- hostResponse.setMemoryAllocated(mem);
+ if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)) {
+ // set allocated capacities
+ Long mem = ApiDBUtils.getMemoryOrCpuCapacitybyHost(host.getId(), Capacity.CAPACITY_TYPE_MEMORY);
+ Long cpu = ApiDBUtils.getMemoryOrCpuCapacitybyHost(host.getId(), Capacity.CAPACITY_TYPE_CPU);
+
+ hostResponse.setMemoryAllocated(mem);
hostResponse.setMemoryTotal(host.getTotalMemory());
hostResponse.setHostTags(ApiDBUtils.getHostTags(host.getId()));
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
-
+
String cpuAlloc = decimalFormat.format(((float) cpu / (float) (host.getCpus() * host.getSpeed())) * 100f) + "%";
hostResponse.setCpuAllocated(cpuAlloc);
String cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor()).toString();
hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning);
}
-
- if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)){
+
+ if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
// set CPU/RAM/Network stats
String cpuUsed = null;
HostStats hostStats = ApiDBUtils.getHostStatistics(host.getId());
@@ -608,24 +607,24 @@ public class ApiResponseHelper implements ResponseGenerator {
float cpuUtil = (float) hostStats.getCpuUtilization();
cpuUsed = decimalFormat.format(cpuUtil) + "%";
hostResponse.setCpuUsed(cpuUsed);
- hostResponse.setMemoryUsed( (new Double(hostStats.getUsedMemory())).longValue());
+ hostResponse.setMemoryUsed((new Double(hostStats.getUsedMemory())).longValue());
hostResponse.setNetworkKbsRead((new Double(hostStats.getNetworkReadKBs())).longValue());
hostResponse.setNetworkKbsWrite((new Double(hostStats.getNetworkWriteKBs())).longValue());
-
+
}
}
-
- }else if (host.getType() == Host.Type.SecondaryStorage){
- StorageStats secStorageStats = ApiDBUtils.getSecondaryStorageStatistics(host.getId());
- if (secStorageStats != null){
- hostResponse.setDiskSizeTotal(secStorageStats.getCapacityBytes());
- hostResponse.setDiskSizeAllocated(secStorageStats.getByteUsed());
- }
+
+ } else if (host.getType() == Host.Type.SecondaryStorage) {
+ StorageStats secStorageStats = ApiDBUtils.getSecondaryStorageStatistics(host.getId());
+ if (secStorageStats != null) {
+ hostResponse.setDiskSizeTotal(secStorageStats.getCapacityBytes());
+ hostResponse.setDiskSizeAllocated(secStorageStats.getByteUsed());
+ }
}
hostResponse.setLocalStorageActive(ApiDBUtils.isLocalStorageActiveOnHost(host));
-
- if (details.contains(HostDetails.all) || details.contains(HostDetails.events)){
+
+ if (details.contains(HostDetails.all) || details.contains(HostDetails.events)) {
Set possibleEvents = host.getStatus().getPossibleEvents();
if ((possibleEvents != null) && !possibleEvents.isEmpty()) {
String events = "";
@@ -692,9 +691,9 @@ public class ApiResponseHelper implements ResponseGenerator {
populateAccount(vlanResponse, owner.getId());
populateDomain(vlanResponse, owner.getDomainId());
}
-
+
vlanResponse.setPhysicalNetworkId(vlan.getPhysicalNetworkId());
-
+
vlanResponse.setObjectName("vlan");
return vlanResponse;
}
@@ -809,34 +808,34 @@ public class ApiResponseHelper implements ResponseGenerator {
podResponse.setEndIp(((ipRange.length > 1) && (ipRange[1] != null)) ? ipRange[1] : "");
podResponse.setGateway(pod.getGateway());
podResponse.setAllocationState(pod.getAllocationState().toString());
- if (showCapacities != null && showCapacities){
- List capacities = ApiDBUtils.getCapacityByClusterPodZone(null,pod.getId(),null);
- Set capacityResponses = new HashSet();
- float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor();
-
- for (SummedCapacity capacity : capacities){
- CapacityResponse capacityResponse = new CapacityResponse();
- capacityResponse.setCapacityType(capacity.getCapacityType());
- capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
- if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU){
- capacityResponse.setCapacityTotal(new Long((long)(capacity.getTotalCapacity()*cpuOverprovisioningFactor)));
- }else if(capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED){
- List c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, pod.getId() ,null);
- capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
- capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity());
- }else{
- capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
- }
- if (capacityResponse.getCapacityTotal() != 0) {
- capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f));
- } else {
- capacityResponse.setPercentUsed(s_percentFormat.format(0L));
- }
- capacityResponses.add(capacityResponse);
- }
- // Do it for stats as well.
- capacityResponses.addAll(getStatsCapacityresponse(null, null, pod.getId(), pod.getDataCenterId()));
- podResponse.setCapacitites(new ArrayList(capacityResponses));
+ if (showCapacities != null && showCapacities) {
+ List capacities = ApiDBUtils.getCapacityByClusterPodZone(null, pod.getId(), null);
+ Set capacityResponses = new HashSet();
+ float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor();
+
+ for (SummedCapacity capacity : capacities) {
+ CapacityResponse capacityResponse = new CapacityResponse();
+ capacityResponse.setCapacityType(capacity.getCapacityType());
+ capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
+ if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
+ capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * cpuOverprovisioningFactor)));
+ } else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
+ List c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, pod.getId(), null);
+ capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
+ capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity());
+ } else {
+ capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
+ }
+ if (capacityResponse.getCapacityTotal() != 0) {
+ capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f));
+ } else {
+ capacityResponse.setPercentUsed(s_percentFormat.format(0L));
+ }
+ capacityResponses.add(capacityResponse);
+ }
+ // Do it for stats as well.
+ capacityResponses.addAll(getStatsCapacityresponse(null, null, pod.getId(), pod.getDataCenterId()));
+ podResponse.setCapacitites(new ArrayList(capacityResponses));
}
podResponse.setObjectName("pod");
return podResponse;
@@ -862,48 +861,48 @@ public class ApiResponseHelper implements ResponseGenerator {
// FIXME zoneResponse.setVlan(dataCenter.get.getVnet());
}
- if (showCapacities != null && showCapacities){
- List capacities = ApiDBUtils.getCapacityByClusterPodZone(dataCenter.getId(),null,null);
- Set capacityResponses = new HashSet();
- float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor();
-
- for (SummedCapacity capacity : capacities){
- CapacityResponse capacityResponse = new CapacityResponse();
- capacityResponse.setCapacityType(capacity.getCapacityType());
- capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
- if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU){
- capacityResponse.setCapacityTotal(new Long((long)(capacity.getTotalCapacity()*cpuOverprovisioningFactor)));
- }else if(capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED){
- List c = ApiDBUtils.findNonSharedStorageForClusterPodZone(dataCenter.getId(), null ,null);
- capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
- capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity());
- }else{
- capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
- }
- if (capacityResponse.getCapacityTotal() != 0) {
- capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f));
- } else {
- capacityResponse.setPercentUsed(s_percentFormat.format(0L));
- }
- capacityResponses.add(capacityResponse);
- }
- // Do it for stats as well.
- capacityResponses.addAll(getStatsCapacityresponse(null, null, null, dataCenter.getId()));
-
- zoneResponse.setCapacitites(new ArrayList(capacityResponses));
+ if (showCapacities != null && showCapacities) {
+ List capacities = ApiDBUtils.getCapacityByClusterPodZone(dataCenter.getId(), null, null);
+ Set capacityResponses = new HashSet();
+ float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor();
+
+ for (SummedCapacity capacity : capacities) {
+ CapacityResponse capacityResponse = new CapacityResponse();
+ capacityResponse.setCapacityType(capacity.getCapacityType());
+ capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
+ if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
+ capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * cpuOverprovisioningFactor)));
+ } else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
+ List c = ApiDBUtils.findNonSharedStorageForClusterPodZone(dataCenter.getId(), null, null);
+ capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
+ capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity());
+ } else {
+ capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
+ }
+ if (capacityResponse.getCapacityTotal() != 0) {
+ capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f));
+ } else {
+ capacityResponse.setPercentUsed(s_percentFormat.format(0L));
+ }
+ capacityResponses.add(capacityResponse);
+ }
+ // Do it for stats as well.
+ capacityResponses.addAll(getStatsCapacityresponse(null, null, null, dataCenter.getId()));
+
+ zoneResponse.setCapacitites(new ArrayList(capacityResponses));
}
-
- //set network domain info
+
+ // set network domain info
zoneResponse.setDomain(dataCenter.getDomain());
-
- //set domain info
+
+ // set domain info
Long domainId = dataCenter.getDomainId();
if (domainId != null) {
- Domain domain = ApiDBUtils.findDomainById(domainId);
- zoneResponse.setDomainId(domain.getId());
- zoneResponse.setDomainName(domain.getName());
+ Domain domain = ApiDBUtils.findDomainById(domainId);
+ zoneResponse.setDomainId(domain.getId());
+ zoneResponse.setDomainName(domain.getName());
}
-
+
zoneResponse.setType(dataCenter.getNetworkType().toString());
zoneResponse.setAllocationState(dataCenter.getAllocationState().toString());
zoneResponse.setZoneToken(dataCenter.getZoneToken());
@@ -912,30 +911,30 @@ public class ApiResponseHelper implements ResponseGenerator {
return zoneResponse;
}
- private List getStatsCapacityresponse(Long poolId, Long clusterId, Long podId, Long zoneId){
- List capacities = new ArrayList();
- capacities.add(ApiDBUtils.getStoragePoolUsedStats(poolId, clusterId, podId, zoneId));
- if(clusterId == null && podId == null){
- capacities.add(ApiDBUtils.getSecondaryStorageUsedStats(poolId, zoneId));
- }
-
- List capacityResponses = new ArrayList();
- for (CapacityVO capacity : capacities){
- CapacityResponse capacityResponse = new CapacityResponse();
- capacityResponse.setCapacityType(capacity.getCapacityType());
- capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
- capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
- if (capacityResponse.getCapacityTotal() != 0) {
+ private List getStatsCapacityresponse(Long poolId, Long clusterId, Long podId, Long zoneId) {
+ List capacities = new ArrayList();
+ capacities.add(ApiDBUtils.getStoragePoolUsedStats(poolId, clusterId, podId, zoneId));
+ if (clusterId == null && podId == null) {
+ capacities.add(ApiDBUtils.getSecondaryStorageUsedStats(poolId, zoneId));
+ }
+
+ List capacityResponses = new ArrayList();
+ for (CapacityVO capacity : capacities) {
+ CapacityResponse capacityResponse = new CapacityResponse();
+ capacityResponse.setCapacityType(capacity.getCapacityType());
+ capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
+ capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
+ if (capacityResponse.getCapacityTotal() != 0) {
capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f));
} else {
capacityResponse.setPercentUsed(s_percentFormat.format(0L));
}
- capacityResponses.add(capacityResponse);
- }
-
- return capacityResponses;
+ capacityResponses.add(capacityResponse);
+ }
+
+ return capacityResponses;
}
-
+
@Override
public VolumeResponse createVolumeResponse(Volume volume) {
VolumeResponse volResponse = new VolumeResponse();
@@ -956,18 +955,18 @@ public class ApiResponseHelper implements ResponseGenerator {
Long instanceId = volume.getInstanceId();
if (instanceId != null && volume.getState() != Volume.State.Destroy) {
VMInstanceVO vm = ApiDBUtils.findVMInstanceById(instanceId);
- if(vm != null){
- volResponse.setVirtualMachineId(vm.getId());
- volResponse.setVirtualMachineName(vm.getHostName());
- UserVm userVm = ApiDBUtils.findUserVmById(vm.getId());
- if (userVm != null) {
- volResponse.setVirtualMachineDisplayName(userVm.getDisplayName());
- volResponse.setVirtualMachineState(vm.getState().toString());
- } else {
- s_logger.error("User Vm with Id: "+instanceId+" does not exist for volume "+volume.getId());
- }
+ if (vm != null) {
+ volResponse.setVirtualMachineId(vm.getId());
+ volResponse.setVirtualMachineName(vm.getHostName());
+ UserVm userVm = ApiDBUtils.findUserVmById(vm.getId());
+ if (userVm != null) {
+ volResponse.setVirtualMachineDisplayName(userVm.getDisplayName());
+ volResponse.setVirtualMachineState(vm.getState().toString());
+ } else {
+ s_logger.error("User Vm with Id: " + instanceId + " does not exist for volume " + volume.getId());
+ }
} else {
- s_logger.error("Vm with Id: "+instanceId+" does not exist for volume "+volume.getId());
+ s_logger.error("Vm with Id: " + instanceId + " does not exist for volume " + volume.getId());
}
}
@@ -1019,13 +1018,13 @@ public class ApiResponseHelper implements ResponseGenerator {
// if (volume.getSourceType() != null) {
// volResponse.setSourceType(volume.getSourceType().toString());
// }
-
- //return hypervisor for ROOT and Resource domain only
+
+ // return hypervisor for ROOT and Resource domain only
Account caller = UserContext.current().getCaller();
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
volResponse.setHypervisor(ApiDBUtils.getVolumeHyperType(volume.getId()).toString());
}
-
+
volResponse.setAttached(volume.getAttached());
volResponse.setDestroyed(volume.getState() == Volume.State.Destroy);
VMTemplateVO template = ApiDBUtils.findTemplateById(volume.getTemplateId());
@@ -1041,7 +1040,7 @@ public class ApiResponseHelper implements ResponseGenerator {
groupResponse.setId(group.getId());
groupResponse.setName(group.getName());
groupResponse.setCreated(group.getCreated());
-
+
populateOwner(groupResponse, group);
groupResponse.setObjectName("instancegroup");
@@ -1073,14 +1072,14 @@ public class ApiResponseHelper implements ResponseGenerator {
}
StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
- long allocatedSize = ApiDBUtils.getStorageCapacitybyPool(pool.getId(),Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
+ long allocatedSize = ApiDBUtils.getStorageCapacitybyPool(pool.getId(), Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
poolResponse.setDiskSizeAllocated(allocatedSize);
-
+
if (stats != null) {
Long used = stats.getByteUsed();
- poolResponse.setDiskSizeUsed(used);
- }
+ poolResponse.setDiskSizeUsed(used);
+ }
if (pool.getClusterId() != null) {
ClusterVO cluster = ApiDBUtils.findClusterById(pool.getClusterId());
@@ -1109,35 +1108,35 @@ public class ApiResponseHelper implements ResponseGenerator {
}
DataCenterVO zone = ApiDBUtils.findZoneById(cluster.getDataCenterId());
clusterResponse.setZoneName(zone.getName());
- if (showCapacities != null && showCapacities){
- List capacities = ApiDBUtils.getCapacityByClusterPodZone(null,null,cluster.getId());
- Set capacityResponses = new HashSet();
- float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor();
-
- for (SummedCapacity capacity : capacities){
- CapacityResponse capacityResponse = new CapacityResponse();
- capacityResponse.setCapacityType(capacity.getCapacityType());
- capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
-
- if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU){
- capacityResponse.setCapacityTotal(new Long((long)(capacity.getTotalCapacity()*cpuOverprovisioningFactor)));
- }else if(capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED){
- List c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, null, cluster.getId());
- capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
- capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity());
- }else{
- capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
- }
- if (capacityResponse.getCapacityTotal() != 0) {
- capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f));
- } else {
- capacityResponse.setPercentUsed(s_percentFormat.format(0L));
- }
- capacityResponses.add(capacityResponse);
- }
- // Do it for stats as well.
- capacityResponses.addAll(getStatsCapacityresponse(null, cluster.getId(), pod.getId(), pod.getDataCenterId()));
- clusterResponse.setCapacitites(new ArrayList(capacityResponses));
+ if (showCapacities != null && showCapacities) {
+ List capacities = ApiDBUtils.getCapacityByClusterPodZone(null, null, cluster.getId());
+ Set capacityResponses = new HashSet();
+ float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor();
+
+ for (SummedCapacity capacity : capacities) {
+ CapacityResponse capacityResponse = new CapacityResponse();
+ capacityResponse.setCapacityType(capacity.getCapacityType());
+ capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
+
+ if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
+ capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * cpuOverprovisioningFactor)));
+ } else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
+ List c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, null, cluster.getId());
+ capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
+ capacityResponse.setCapacityUsed(capacity.getUsedCapacity() - c.get(0).getUsedCapacity());
+ } else {
+ capacityResponse.setCapacityTotal(capacity.getTotalCapacity());
+ }
+ if (capacityResponse.getCapacityTotal() != 0) {
+ capacityResponse.setPercentUsed(s_percentFormat.format((float) capacityResponse.getCapacityUsed() / (float) capacityResponse.getCapacityTotal() * 100f));
+ } else {
+ capacityResponse.setPercentUsed(s_percentFormat.format(0L));
+ }
+ capacityResponses.add(capacityResponse);
+ }
+ // Do it for stats as well.
+ capacityResponses.addAll(getStatsCapacityresponse(null, cluster.getId(), pod.getId(), pod.getDataCenterId()));
+ clusterResponse.setCapacitites(new ArrayList(capacityResponses));
}
clusterResponse.setObjectName("cluster");
return clusterResponse;
@@ -1208,19 +1207,18 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setObjectName("ipforwardingrule");
return response;
}
-
-
+
@Override
- public List createUserVmResponse(String objectName, EnumSet details, UserVm...userVms) {
+ public List createUserVmResponse(String objectName, EnumSet details, UserVm... userVms) {
Account caller = UserContext.current().getCaller();
Map dataCenters = new HashMap();
Map hosts = new HashMap();
Map templates = new HashMap();
Map serviceOfferings = new HashMap();
Map networks = new HashMap();
-
+
List vmResponses = new ArrayList();
-
+
for (UserVm userVm : userVms) {
UserVmResponse userVmResponse = new UserVmResponse();
Account acct = ApiDBUtils.findAccountById(Long.valueOf(userVm.getAccountId()));
@@ -1234,8 +1232,6 @@ public class ApiResponseHelper implements ResponseGenerator {
userVmResponse.setName(userVm.getHostName());
userVmResponse.setCreated(userVm.getCreated());
-
-
userVmResponse.setHaEnable(userVm.isHaEnabled());
if (userVm.getDisplayName() != null) {
@@ -1246,13 +1242,13 @@ public class ApiResponseHelper implements ResponseGenerator {
userVmResponse.setPassword(userVm.getPassword());
}
- if (details.contains(VMDetails.all) || details.contains(VMDetails.group)){
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.group)) {
InstanceGroupVO group = ApiDBUtils.findInstanceGroupForVM(userVm.getId());
if (group != null) {
userVmResponse.setGroup(group.getName());
userVmResponse.setGroupId(group.getId());
}
-
+
}
// Data Center Info
@@ -1261,193 +1257,191 @@ public class ApiResponseHelper implements ResponseGenerator {
zone = ApiDBUtils.findZoneById(userVm.getDataCenterIdToDeployIn());
dataCenters.put(zone.getId(), zone);
}
-
+
userVmResponse.setZoneId(zone.getId());
userVmResponse.setZoneName(zone.getName());
-
// if user is an admin, display host id
if (((caller == null) || (caller.getType() == Account.ACCOUNT_TYPE_ADMIN)) && (userVm.getHostId() != null)) {
Host host = hosts.get(userVm.getHostId());
-
+
if (host == null) {
host = ApiDBUtils.findHostById(userVm.getHostId());
hosts.put(host.getId(), host);
}
-
+
userVmResponse.setHostId(host.getId());
userVmResponse.setHostName(host.getName());
}
-
+
if (userVm.getState() != null) {
- if (userVm.getHostId() != null) {
- Host host = hosts.get(userVm.getHostId());
-
+ if (userVm.getHostId() != null) {
+ Host host = hosts.get(userVm.getHostId());
+
if (host == null) {
host = ApiDBUtils.findHostById(userVm.getHostId());
hosts.put(host.getId(), host);
}
if (host.getStatus() != com.cloud.host.Status.Up) {
- userVmResponse.setState(VirtualMachine.State.Unknown.toString());
+ userVmResponse.setState(VirtualMachine.State.Unknown.toString());
} else {
- userVmResponse.setState(userVm.getState().toString());
+ userVmResponse.setState(userVm.getState().toString());
}
- } else {
- userVmResponse.setState(userVm.getState().toString());
- }
+ } else {
+ userVmResponse.setState(userVm.getState().toString());
+ }
}
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
- if (userVm.getHypervisorType() != null){
+ if (userVm.getHypervisorType() != null) {
userVmResponse.setHypervisor(userVm.getHypervisorType().toString());
}
- }
-
- if (details.contains(VMDetails.all) || details.contains(VMDetails.tmpl)){
- // Template Info
- VMTemplateVO template = templates.get(userVm.getTemplateId());
- if (template == null) {
- template = ApiDBUtils.findTemplateById(userVm.getTemplateId());
- if (template != null) {
- templates.put(template.getId(), template);
- }
- }
-
- if (template != null) {
- userVmResponse.setTemplateId(userVm.getTemplateId());
- userVmResponse.setTemplateName(template.getName());
- userVmResponse.setTemplateDisplayText(template.getDisplayText());
- userVmResponse.setPasswordEnabled(template.getEnablePassword());
- } else {
- userVmResponse.setTemplateId(-1L);
- userVmResponse.setTemplateName("ISO Boot");
- userVmResponse.setTemplateDisplayText("ISO Boot");
- userVmResponse.setPasswordEnabled(false);
- }
}
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.tmpl)) {
+ // Template Info
+ VMTemplateVO template = templates.get(userVm.getTemplateId());
+ if (template == null) {
+ template = ApiDBUtils.findTemplateById(userVm.getTemplateId());
+ if (template != null) {
+ templates.put(template.getId(), template);
+ }
+ }
- if (details.contains(VMDetails.all) || details.contains(VMDetails.iso)){
- // ISO Info
- VMTemplateVO iso = templates.get(userVm.getIsoId());
- if (iso == null) {
- iso = ApiDBUtils.findTemplateById(userVm.getIsoId());
- if (iso != null) {
- templates.put(iso.getId(), iso);
- }
- }
-
- if (iso != null) {
- userVmResponse.setIsoId(iso.getId());
- userVmResponse.setIsoName(iso.getName());
- }
+ if (template != null) {
+ userVmResponse.setTemplateId(userVm.getTemplateId());
+ userVmResponse.setTemplateName(template.getName());
+ userVmResponse.setTemplateDisplayText(template.getDisplayText());
+ userVmResponse.setPasswordEnabled(template.getEnablePassword());
+ } else {
+ userVmResponse.setTemplateId(-1L);
+ userVmResponse.setTemplateName("ISO Boot");
+ userVmResponse.setTemplateDisplayText("ISO Boot");
+ userVmResponse.setPasswordEnabled(false);
+ }
}
- if (details.contains(VMDetails.all) || details.contains(VMDetails.servoff)){
- // Service Offering Info
- ServiceOffering offering = serviceOfferings.get(userVm.getServiceOfferingId());
-
- if (offering == null) {
- offering = ApiDBUtils.findServiceOfferingById(userVm.getServiceOfferingId());
- serviceOfferings.put(offering.getId(), offering);
- }
-
- userVmResponse.setServiceOfferingId(offering.getId());
- userVmResponse.setServiceOfferingName(offering.getName());
- userVmResponse.setCpuNumber(offering.getCpu());
- userVmResponse.setCpuSpeed(offering.getSpeed());
- userVmResponse.setMemory(offering.getRamSize());
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.iso)) {
+ // ISO Info
+ VMTemplateVO iso = templates.get(userVm.getIsoId());
+ if (iso == null) {
+ iso = ApiDBUtils.findTemplateById(userVm.getIsoId());
+ if (iso != null) {
+ templates.put(iso.getId(), iso);
+ }
+ }
+
+ if (iso != null) {
+ userVmResponse.setIsoId(iso.getId());
+ userVmResponse.setIsoName(iso.getName());
+ }
}
- if (details.contains(VMDetails.all) || details.contains(VMDetails.volume)){
- VolumeVO rootVolume = ApiDBUtils.findRootVolume(userVm.getId());
- if (rootVolume != null) {
- userVmResponse.setRootDeviceId(rootVolume.getDeviceId());
- String rootDeviceType = "Not created";
- if (rootVolume.getPoolId() != null) {
- StoragePoolVO storagePool = ApiDBUtils.findStoragePoolById(rootVolume.getPoolId());
- rootDeviceType = storagePool.getPoolType().toString();
- }
- userVmResponse.setRootDeviceType(rootDeviceType);
- }
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.servoff)) {
+ // Service Offering Info
+ ServiceOffering offering = serviceOfferings.get(userVm.getServiceOfferingId());
+
+ if (offering == null) {
+ offering = ApiDBUtils.findServiceOfferingById(userVm.getServiceOfferingId());
+ serviceOfferings.put(offering.getId(), offering);
+ }
+
+ userVmResponse.setServiceOfferingId(offering.getId());
+ userVmResponse.setServiceOfferingName(offering.getName());
+ userVmResponse.setCpuNumber(offering.getCpu());
+ userVmResponse.setCpuSpeed(offering.getSpeed());
+ userVmResponse.setMemory(offering.getRamSize());
}
- if (details.contains(VMDetails.all) || details.contains(VMDetails.stats)){
- // stats calculation
- DecimalFormat decimalFormat = new DecimalFormat("#.##");
- String cpuUsed = null;
- VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId());
- if (vmStats != null) {
- float cpuUtil = (float) vmStats.getCPUUtilization();
- cpuUsed = decimalFormat.format(cpuUtil) + "%";
- userVmResponse.setCpuUsed(cpuUsed);
-
- Double networkKbRead = Double.valueOf(vmStats.getNetworkReadKBs());
- userVmResponse.setNetworkKbsRead(networkKbRead.longValue());
-
- Double networkKbWrite = Double.valueOf(vmStats.getNetworkWriteKBs());
- userVmResponse.setNetworkKbsWrite(networkKbWrite.longValue());
- }
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.volume)) {
+ VolumeVO rootVolume = ApiDBUtils.findRootVolume(userVm.getId());
+ if (rootVolume != null) {
+ userVmResponse.setRootDeviceId(rootVolume.getDeviceId());
+ String rootDeviceType = "Not created";
+ if (rootVolume.getPoolId() != null) {
+ StoragePoolVO storagePool = ApiDBUtils.findStoragePoolById(rootVolume.getPoolId());
+ rootDeviceType = storagePool.getPoolType().toString();
+ }
+ userVmResponse.setRootDeviceType(rootDeviceType);
+ }
+ }
+
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.stats)) {
+ // stats calculation
+ DecimalFormat decimalFormat = new DecimalFormat("#.##");
+ String cpuUsed = null;
+ VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId());
+ if (vmStats != null) {
+ float cpuUtil = (float) vmStats.getCPUUtilization();
+ cpuUsed = decimalFormat.format(cpuUtil) + "%";
+ userVmResponse.setCpuUsed(cpuUsed);
+
+ Double networkKbRead = Double.valueOf(vmStats.getNetworkReadKBs());
+ userVmResponse.setNetworkKbsRead(networkKbRead.longValue());
+
+ Double networkKbWrite = Double.valueOf(vmStats.getNetworkWriteKBs());
+ userVmResponse.setNetworkKbsWrite(networkKbWrite.longValue());
+ }
}
userVmResponse.setGuestOsId(userVm.getGuestOSId());
-
- if (details.contains(VMDetails.all) || details.contains(VMDetails.secgrp)){
- // security groups - list only when zone is security group enabled
- if (zone.isSecurityGroupEnabled()) {
- List securityGroups = ApiDBUtils.getSecurityGroupsForVm(userVm.getId());
- List securityGroupResponse = new ArrayList();
- for(SecurityGroupVO grp : securityGroups) {
- SecurityGroupResponse resp = new SecurityGroupResponse();
- resp.setId(grp.getId());
- resp.setName(grp.getName());
- resp.setDescription(grp.getDescription());
- resp.setObjectName("securitygroup");
- securityGroupResponse.add(resp);
- }
- userVmResponse.setSecurityGroupList(securityGroupResponse);
- }
+
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.secgrp)) {
+ // security groups - list only when zone is security group enabled
+ if (zone.isSecurityGroupEnabled()) {
+ List securityGroups = ApiDBUtils.getSecurityGroupsForVm(userVm.getId());
+ List securityGroupResponse = new ArrayList();
+ for (SecurityGroupVO grp : securityGroups) {
+ SecurityGroupResponse resp = new SecurityGroupResponse();
+ resp.setId(grp.getId());
+ resp.setName(grp.getName());
+ resp.setDescription(grp.getDescription());
+ resp.setObjectName("securitygroup");
+ securityGroupResponse.add(resp);
+ }
+ userVmResponse.setSecurityGroupList(securityGroupResponse);
+ }
}
-
- if (details.contains(VMDetails.all) || details.contains(VMDetails.nics)){
- List nicProfiles = ApiDBUtils.getNics(userVm);
- List nicResponses = new ArrayList();
- for (NicProfile singleNicProfile : nicProfiles) {
- NicResponse nicResponse = new NicResponse();
- nicResponse.setId(singleNicProfile.getId());
- nicResponse.setIpaddress(singleNicProfile.getIp4Address());
- nicResponse.setGateway(singleNicProfile.getGateway());
- nicResponse.setNetmask(singleNicProfile.getNetmask());
- nicResponse.setNetworkid(singleNicProfile.getNetworkId());
- if (acct.getType() == Account.ACCOUNT_TYPE_ADMIN) {
- if (singleNicProfile.getBroadCastUri() != null) {
- nicResponse.setBroadcastUri(singleNicProfile.getBroadCastUri().toString());
- }
- if (singleNicProfile.getIsolationUri() != null) {
- nicResponse.setIsolationUri(singleNicProfile.getIsolationUri().toString());
- }
- }
-
- //Long networkId = singleNicProfile.getNetworkId();
- Network network = networks.get(singleNicProfile.getNetworkId());
- if (network == null) {
- network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
- networks.put(singleNicProfile.getNetworkId(), network);
- }
-
- nicResponse.setTrafficType(network.getTrafficType().toString());
- nicResponse.setType(network.getGuestType().toString());
- nicResponse.setIsDefault(singleNicProfile.isDefaultNic());
- nicResponse.setObjectName("nic");
- nicResponses.add(nicResponse);
- }
- userVmResponse.setNics(nicResponses);
+
+ if (details.contains(VMDetails.all) || details.contains(VMDetails.nics)) {
+ List nicProfiles = ApiDBUtils.getNics(userVm);
+ List nicResponses = new ArrayList();
+ for (NicProfile singleNicProfile : nicProfiles) {
+ NicResponse nicResponse = new NicResponse();
+ nicResponse.setId(singleNicProfile.getId());
+ nicResponse.setIpaddress(singleNicProfile.getIp4Address());
+ nicResponse.setGateway(singleNicProfile.getGateway());
+ nicResponse.setNetmask(singleNicProfile.getNetmask());
+ nicResponse.setNetworkid(singleNicProfile.getNetworkId());
+ if (acct.getType() == Account.ACCOUNT_TYPE_ADMIN) {
+ if (singleNicProfile.getBroadCastUri() != null) {
+ nicResponse.setBroadcastUri(singleNicProfile.getBroadCastUri().toString());
+ }
+ if (singleNicProfile.getIsolationUri() != null) {
+ nicResponse.setIsolationUri(singleNicProfile.getIsolationUri().toString());
+ }
+ }
+
+ // Long networkId = singleNicProfile.getNetworkId();
+ Network network = networks.get(singleNicProfile.getNetworkId());
+ if (network == null) {
+ network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
+ networks.put(singleNicProfile.getNetworkId(), network);
+ }
+
+ nicResponse.setTrafficType(network.getTrafficType().toString());
+ nicResponse.setType(network.getGuestType().toString());
+ nicResponse.setIsDefault(singleNicProfile.isDefaultNic());
+ nicResponse.setObjectName("nic");
+ nicResponses.add(nicResponse);
+ }
+ userVmResponse.setNics(nicResponses);
}
-
+
userVmResponse.setObjectName(objectName);
vmResponses.add(userVmResponse);
- }
-
+ }
+
return vmResponses;
}
@@ -1455,22 +1449,22 @@ public class ApiResponseHelper implements ResponseGenerator {
public List createUserVmResponse(String objectName, UserVm... userVms) {
Account caller = UserContext.current().getCaller();
boolean caller_is_admin = ((caller == null) || (caller.getType() == Account.ACCOUNT_TYPE_ADMIN));
-
+
Hashtable vmDataList = new Hashtable();
// Initialise the vmdatalist with the input data
for (UserVm userVm : userVms) {
UserVmData userVmData = newUserVmData(userVm);
vmDataList.put(userVm.getId(), userVmData);
}
-
+
vmDataList = ApiDBUtils.listVmDetails(vmDataList);
-
- //initialize vmresponse from vmdatalist
+
+ // initialize vmresponse from vmdatalist
List vmResponses = new ArrayList();
DecimalFormat decimalFormat = new DecimalFormat("#.##");
- for (UserVmData uvd: vmDataList.values()){
+ for (UserVmData uvd : vmDataList.values()) {
UserVmResponse userVmResponse = newUserVmResponse(uvd, caller_is_admin);
-
+
// stats calculation
String cpuUsed = null;
// VmStats vmStats = ApiDBUtils.getVmStatistics(userVmResponse.getId());
@@ -1487,16 +1481,15 @@ public class ApiResponseHelper implements ResponseGenerator {
userVmResponse.setNetworkKbsWrite(networkKbWrite.longValue());
}
userVmResponse.setObjectName(objectName);
-
+
vmResponses.add(userVmResponse);
}
return vmResponses;
}
-
@Override
public DomainRouterResponse createDomainRouterResponse(VirtualRouter router) {
- Account caller = UserContext.current().getCaller();
+ Account caller = UserContext.current().getCaller();
Map serviceOfferings = new HashMap();
DomainRouterResponse routerResponse = new DomainRouterResponse();
@@ -1510,7 +1503,7 @@ public class ApiResponseHelper implements ResponseGenerator {
routerResponse.setRedundantState(router.getRedundantState().toString());
if (caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_ADMIN) {
- if (router.getHostId() != null) {
+ if (router.getHostId() != null) {
routerResponse.setHostId(router.getHostId());
routerResponse.setHostName(ApiDBUtils.findHostById(router.getHostId()).getName());
}
@@ -1553,7 +1546,6 @@ public class ApiResponseHelper implements ResponseGenerator {
populateOwner(routerResponse, router);
-
DataCenter zone = ApiDBUtils.findZoneById(router.getDataCenterIdToDeployIn());
if (zone != null) {
routerResponse.setZoneName(zone.getName());
@@ -1570,7 +1562,7 @@ public class ApiResponseHelper implements ResponseGenerator {
SystemVmResponse vmResponse = new SystemVmResponse();
if (vm.getType() == Type.SecondaryStorageVm || vm.getType() == Type.ConsoleProxy) {
// SystemVm vm = (SystemVm) systemVM;
- vmResponse.setId(vm.getId());
+ vmResponse.setId(vm.getId());
vmResponse.setObjectId(vm.getId());
vmResponse.setSystemVmType(vm.getType().toString().toLowerCase());
vmResponse.setZoneId(vm.getDataCenterIdToDeployIn());
@@ -1592,10 +1584,10 @@ public class ApiResponseHelper implements ResponseGenerator {
// for console proxies, add the active sessions
if (vm.getType() == Type.ConsoleProxy) {
ConsoleProxyVO proxy = ApiDBUtils.findConsoleProxy(vm.getId());
- //proxy can be already destroyed
+ // proxy can be already destroyed
if (proxy != null) {
vmResponse.setActiveViewerSessions(proxy.getActiveSession());
- }
+ }
}
DataCenter zone = ApiDBUtils.findZoneById(vm.getDataCenterIdToDeployIn());
@@ -1608,7 +1600,7 @@ public class ApiResponseHelper implements ResponseGenerator {
List nicProfiles = ApiDBUtils.getNics(vm);
for (NicProfile singleNicProfile : nicProfiles) {
Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
- if (network != null) {
+ if (network != null) {
if (network.getTrafficType() == TrafficType.Management) {
vmResponse.setPrivateIp(singleNicProfile.getIp4Address());
vmResponse.setPrivateMacAddress(singleNicProfile.getMacAddress());
@@ -1617,7 +1609,7 @@ public class ApiResponseHelper implements ResponseGenerator {
vmResponse.setLinkLocalIp(singleNicProfile.getIp4Address());
vmResponse.setLinkLocalMacAddress(singleNicProfile.getMacAddress());
vmResponse.setLinkLocalNetmask(singleNicProfile.getNetmask());
- } else if (network.getTrafficType() == TrafficType.Public){
+ } else if (network.getTrafficType() == TrafficType.Public) {
vmResponse.setPublicIp(singleNicProfile.getIp4Address());
vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
vmResponse.setPublicNetmask(singleNicProfile.getNetmask());
@@ -1683,7 +1675,7 @@ public class ApiResponseHelper implements ResponseGenerator {
vpnResponse.setDomainId(vpn.getDomainId());
populateOwner(vpnResponse, vpn);
-
+
vpnResponse.setState(vpn.getState().toString());
vpnResponse.setObjectName("remoteaccessvpn");
@@ -1705,7 +1697,7 @@ public class ApiResponseHelper implements ResponseGenerator {
Account caller = UserContext.current().getCaller();
if (result.getFormat() == ImageFormat.ISO) { // Templates are always bootable
- response.setBootable(result.isBootable());
+ response.setBootable(result.isBootable());
} else if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
response.setHypervisor(result.getHypervisorType().toString());// hypervisors are associated with templates
}
@@ -1714,7 +1706,7 @@ public class ApiResponseHelper implements ResponseGenerator {
Account owner = ApiDBUtils.findAccountById(result.getAccountId());
populateAccount(response, owner.getId());
populateDomain(response, owner.getDomainId());
-
+
response.setObjectName("iso");
return response;
}
@@ -1729,7 +1721,7 @@ public class ApiResponseHelper implements ResponseGenerator {
return responses;
}
dcs.addAll(ApiDBUtils.listZones());
- for (DataCenterVO dc : dcs ) {
+ for (DataCenterVO dc : dcs) {
responses.addAll(createTemplateResponses(templateId, dc.getId(), readyOnly));
}
return responses;
@@ -1763,7 +1755,7 @@ public class ApiResponseHelper implements ResponseGenerator {
if (template.getTemplateType() != null) {
templateResponse.setTemplateType(template.getTemplateType().toString());
}
-
+
Account caller = UserContext.current().getCaller();
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
templateResponse.setHypervisor(template.getHypervisorType().toString());
@@ -1840,12 +1832,12 @@ public class ApiResponseHelper implements ResponseGenerator {
if (template.getTemplateType() != null) {
templateResponse.setTemplateType(template.getTemplateType().toString());
}
-
+
Account caller = UserContext.current().getCaller();
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
templateResponse.setHypervisor(template.getHypervisorType().toString());
}
-
+
templateResponse.setDetails(template.getDetails());
GuestOS os = ApiDBUtils.findGuestOSById(template.getGuestOSId());
@@ -1910,12 +1902,13 @@ public class ApiResponseHelper implements ResponseGenerator {
responses.add(templateResponse);
return responses;
}
+
@Override
public List createIsoResponses(long isoId, Long zoneId, boolean readyOnly) {
List isoResponses = new ArrayList();
VirtualMachineTemplate iso = findTemplateById(isoId);
- if ( iso.getTemplateType() == TemplateType.PERHOST) {
+ if (iso.getTemplateType() == TemplateType.PERHOST) {
TemplateResponse isoResponse = new TemplateResponse();
isoResponse.setId(iso.getId());
isoResponse.setName(iso.getName());
@@ -1931,24 +1924,24 @@ public class ApiResponseHelper implements ResponseGenerator {
isoResponse.setChecksum(iso.getChecksum());
isoResponse.setPasswordEnabled(false);
isoResponse.setDetails(iso.getDetails());
-
+
// add account ID and name
Account owner = ApiDBUtils.findAccountById(iso.getAccountId());
populateAccount(isoResponse, owner.getId());
populateDomain(isoResponse, owner.getDomainId());
-
+
isoResponse.setObjectName("iso");
isoResponses.add(isoResponse);
return isoResponses;
} else {
- if (zoneId == null || zoneId == -1 ) {
+ if (zoneId == null || zoneId == -1) {
isoResponses = createSwiftIsoResponses(iso);
if (!isoResponses.isEmpty()) {
return isoResponses;
}
List dcs = new ArrayList();
dcs.addAll(ApiDBUtils.listZones());
- for (DataCenterVO dc : dcs ) {
+ for (DataCenterVO dc : dcs) {
isoResponses.addAll(createIsoResponses(iso, dc.getId(), readyOnly));
}
return isoResponses;
@@ -2016,7 +2009,7 @@ public class ApiResponseHelper implements ResponseGenerator {
long isoId = iso.getId();
List isoResponses = new ArrayList();
VMTemplateHostVO isoHost = ApiDBUtils.findTemplateHostRef(isoId, zoneId, readyOnly);
- if( isoHost == null ) {
+ if (isoHost == null) {
return isoResponses;
}
TemplateResponse isoResponse = new TemplateResponse();
@@ -2043,7 +2036,7 @@ public class ApiResponseHelper implements ResponseGenerator {
isoResponse.setOsTypeId(-1L);
isoResponse.setOsTypeName("");
}
-
+
Account account = ApiDBUtils.findAccountByIdIncludingRemoved(iso.getAccountId());
populateAccount(isoResponse, account.getId());
populateDomain(isoResponse, account.getDomainId());
@@ -2153,10 +2146,11 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setResponses(netGrpResponses);
return response;
}
+
@Override
public SecurityGroupResponse createSecurityGroupResponse(SecurityGroup group) {
SecurityGroupResponse response = new SecurityGroupResponse();
-
+
populateOwner(response, group);
response.setDescription(group.getDescription());
@@ -2200,32 +2194,31 @@ public class ApiResponseHelper implements ResponseGenerator {
jobResponse.setUserId(job.getUserId());
jobResponse.setCmd(job.getCmd());
jobResponse.setCreated(job.getCreated());
- jobResponse.setJobId(job.getId());
- jobResponse.setJobStatus(job.getStatus());
- jobResponse.setJobProcStatus(job.getProcessStatus());
+ jobResponse.setJobId(job.getId());
+ jobResponse.setJobStatus(job.getStatus());
+ jobResponse.setJobProcStatus(job.getProcessStatus());
if (job.getInstanceType() != null && job.getInstanceId() != null) {
jobResponse.setJobInstanceType(job.getInstanceType().toString());
jobResponse.setJobInstanceId(job.getInstanceId());
}
jobResponse.setJobResultCode(job.getResultCode());
-
+
boolean savedValue = SerializationContext.current().getUuidTranslation();
SerializationContext.current().setUuidTranslation(false);
jobResponse.setJobResult((ResponseObject) ApiSerializerHelper.fromSerializedString(job.getResult()));
SerializationContext.current().setUuidTranslation(savedValue);
-
+
Object resultObject = ApiSerializerHelper.fromSerializedString(job.getResult());
if (resultObject != null) {
Class> clz = resultObject.getClass();
if (clz.isPrimitive() || clz.getSuperclass() == Number.class || clz == String.class || clz == Date.class) {
jobResponse.setJobResultType("text");
} else {
- jobResponse.setJobResultType("object");
+ jobResponse.setJobResultType("object");
}
}
-
-
+
jobResponse.setObjectName("asyncjobs");
return jobResponse;
}
@@ -2260,9 +2253,9 @@ public class ApiResponseHelper implements ResponseGenerator {
responseEvent.setLevel(event.getLevel());
responseEvent.setParentId(event.getStartId());
responseEvent.setState(event.getState());
-
+
populateOwner(responseEvent, event);
-
+
User user = ApiDBUtils.findUserById(event.getUserId());
if (user != null) {
responseEvent.setUsername(user.getUsername());
@@ -2272,7 +2265,6 @@ public class ApiResponseHelper implements ResponseGenerator {
return responseEvent;
}
-
private List sumCapacities(List extends Capacity> hostCapacities) {
Map totalCapacityMap = new HashMap();
Map usedCapacityMap = new HashMap();
@@ -2292,17 +2284,17 @@ public class ApiResponseHelper implements ResponseGenerator {
// collect all the capacity types, sum allocated/used and sum total...get one capacity number for each
for (Capacity capacity : hostCapacities) {
-
- //check if zone exist
+
+ // check if zone exist
DataCenter zone = ApiDBUtils.findZoneById(capacity.getDataCenterId());
if (zone == null) {
continue;
}
-
+
short capacityType = capacity.getCapacityType();
- //If local storage then ignore
- if ( (capacityType == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED || capacityType == Capacity.CAPACITY_TYPE_STORAGE)
+ // If local storage then ignore
+ if ((capacityType == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED || capacityType == Capacity.CAPACITY_TYPE_STORAGE)
&& poolIdsToIgnore.contains(capacity.getHostOrPoolId())) {
continue;
}
@@ -2339,11 +2331,16 @@ public class ApiResponseHelper implements ResponseGenerator {
if (capacityType == Capacity.CAPACITY_TYPE_CPU || capacityType == Capacity.CAPACITY_TYPE_MEMORY) { // Reserved
// Capacity
- // accounts for
- // stopped vms
- // that have been
- // stopped within
- // an interval
+ // accounts
+// for
+ // stopped
+// vms
+ // that
+// have been
+ // stopped
+// within
+ // an
+// interval
usedCapacity += capacity.getReservedCapacity();
}
@@ -2376,11 +2373,14 @@ public class ApiResponseHelper implements ResponseGenerator {
// accounts
// for
// stopped
- // vms that
- // have been
- // stopped
- // within an
- // interval
+ // vms
+// that
+ // have
+// been
+ // stopped
+ // within
+// an
+ // interval
usedCapacity += capacity.getReservedCapacity();
}
@@ -2411,8 +2411,8 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public List createCapacityResponse(List extends Capacity> result, DecimalFormat format) {
List capacityResponses = new ArrayList();
- //List summedCapacities = sumCapacities(result);
- for (Capacity summedCapacity : result) {
+ // List summedCapacities = sumCapacities(result);
+ for (Capacity summedCapacity : result) {
CapacityResponse capacityResponse = new CapacityResponse();
capacityResponse.setCapacityTotal(summedCapacity.getTotalCapacity());
capacityResponse.setCapacityType(summedCapacity.getCapacityType());
@@ -2421,20 +2421,20 @@ public class ApiResponseHelper implements ResponseGenerator {
capacityResponse.setPodId(summedCapacity.getPodId());
HostPodVO pod = ApiDBUtils.findPodById(summedCapacity.getPodId());
if (pod != null) {
- capacityResponse.setPodName(pod.getName());
+ capacityResponse.setPodName(pod.getName());
}
}
if (summedCapacity.getClusterId() != null) {
capacityResponse.setClusterId(summedCapacity.getClusterId());
ClusterVO cluster = ApiDBUtils.findClusterById(summedCapacity.getClusterId());
if (cluster != null) {
- capacityResponse.setClusterName(cluster.getName());
- if (summedCapacity.getPodId() == null){
- long podId = cluster.getPodId();
- capacityResponse.setPodId(podId);
- capacityResponse.setPodName(ApiDBUtils.findPodById(podId).getName());
- }
- }
+ capacityResponse.setClusterName(cluster.getName());
+ if (summedCapacity.getPodId() == null) {
+ long podId = cluster.getPodId();
+ capacityResponse.setPodId(podId);
+ capacityResponse.setPodName(ApiDBUtils.findPodById(podId).getName());
+ }
+ }
}
capacityResponse.setZoneId(summedCapacity.getDataCenterId());
capacityResponse.setZoneName(ApiDBUtils.findZoneById(summedCapacity.getDataCenterId()).getName());
@@ -2469,8 +2469,8 @@ public class ApiResponseHelper implements ResponseGenerator {
if (isAdmin && (templateOwnerDomain != null)) {
response.setDomainId(templateOwnerDomain);
}
-
- //Set accounts
+
+ // Set accounts
List projectIds = new ArrayList();
List regularAccounts = new ArrayList();
for (String accountName : accountNames) {
@@ -2478,24 +2478,24 @@ public class ApiResponseHelper implements ResponseGenerator {
if (account.getType() != Account.ACCOUNT_TYPE_PROJECT) {
regularAccounts.add(accountName);
} else {
- //convert account to projectIds
+ // convert account to projectIds
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
- if(project.getUuid() != null && !project.getUuid().isEmpty())
+ if (project.getUuid() != null && !project.getUuid().isEmpty())
projectIds.add(project.getUuid());
else
- projectIds.add(String.valueOf(project.getId()));
+ projectIds.add(String.valueOf(project.getId()));
}
}
-
+
if (!projectIds.isEmpty()) {
response.setProjectIds(projectIds);
}
-
+
if (!regularAccounts.isEmpty()) {
response.setAccountNames(regularAccounts);
}
-
+
response.setObjectName("templatepermission");
return response;
}
@@ -2525,7 +2525,7 @@ public class ApiResponseHelper implements ResponseGenerator {
account = ApiDBUtils.findAccountById(securityGroup.getAccountId());
securiytGroupAccounts.put(securityGroup.getAccountId(), account);
}
-
+
populateAccount(response, account.getId());
populateDomain(response, account.getDomainId());
@@ -2594,32 +2594,32 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setConserveMode(offering.isConserveMode());
response.setSpecifyIpRanges(offering.getSpecifyIpRanges());
response.setAvailability(offering.getAvailability().toString());
- response.setNetworkRate(ApiDBUtils.getNetworkRate(offering.getId()));
+ response.setNetworkRate(ApiDBUtils.getNetworkRate(offering.getId()));
if (offering.getServiceOfferingId() != null) {
- response.setServiceOfferingId(offering.getServiceOfferingId());
+ response.setServiceOfferingId(offering.getServiceOfferingId());
} else {
response.setServiceOfferingId(ApiDBUtils.findDefaultRouterServiceOffering());
- }
+ }
if (offering.getGuestType() != null) {
response.setGuestIpType(offering.getGuestType().toString());
}
-
+
response.setState(offering.getState().name());
-
+
Map> serviceProviderMap = ApiDBUtils.listNetworkOfferingServices(offering.getId());
List serviceResponses = new ArrayList();
for (Service service : serviceProviderMap.keySet()) {
ServiceResponse svcRsp = new ServiceResponse();
- //skip gateway service
+ // skip gateway service
if (service == Service.Gateway) {
- continue;
+ continue;
}
svcRsp.setName(service.getName());
List providers = new ArrayList();
for (Provider provider : serviceProviderMap.get(service)) {
if (provider != null) {
- ProviderResponse providerRsp = new ProviderResponse();
- providerRsp.setName(provider.getName());
+ ProviderResponse providerRsp = new ProviderResponse();
+ providerRsp.setName(provider.getName());
providers.add(providerRsp);
}
}
@@ -2627,37 +2627,37 @@ public class ApiResponseHelper implements ResponseGenerator {
if (Service.Lb == service) {
List lbCapResponse = new ArrayList();
-
+
CapabilityResponse lbIsoaltion = new CapabilityResponse();
lbIsoaltion.setName(Capability.SupportedLBIsolation.getName());
- lbIsoaltion.setValue(offering.getDedicatedLB()?"dedicated":"shared");
+ lbIsoaltion.setValue(offering.getDedicatedLB() ? "dedicated" : "shared");
lbCapResponse.add(lbIsoaltion);
-
+
CapabilityResponse eLb = new CapabilityResponse();
eLb.setName(Capability.ElasticLb.getName());
- eLb.setValue(offering.getElasticLb()?"true":"false");
+ eLb.setValue(offering.getElasticLb() ? "true" : "false");
lbCapResponse.add(eLb);
-
+
svcRsp.setCapabilities(lbCapResponse);
} else if (Service.SourceNat == service) {
List capabilities = new ArrayList();
CapabilityResponse sharedSourceNat = new CapabilityResponse();
- sharedSourceNat.setName(Capability.SupportedSourceNatTypes.getName());
- sharedSourceNat.setValue(offering.getSharedSourceNat()?"perzone":"peraccount");
+ sharedSourceNat.setName(Capability.SupportedSourceNatTypes.getName());
+ sharedSourceNat.setValue(offering.getSharedSourceNat() ? "perzone" : "peraccount");
capabilities.add(sharedSourceNat);
-
+
CapabilityResponse redundantRouter = new CapabilityResponse();
redundantRouter.setName(Capability.RedundantRouter.getName());
- redundantRouter.setValue(offering.getRedundantRouter()?"true":"false");
+ redundantRouter.setValue(offering.getRedundantRouter() ? "true" : "false");
capabilities.add(redundantRouter);
-
+
svcRsp.setCapabilities(capabilities);
} else if (service == Service.StaticNat) {
List staticNatCapResponse = new ArrayList();
-
+
CapabilityResponse eIp = new CapabilityResponse();
eIp.setName(Capability.ElasticIp.getName());
- eIp.setValue(offering.getElasticLb()?"true":"false");
+ eIp.setValue(offering.getElasticLb() ? "true" : "false");
staticNatCapResponse.add(eIp);
svcRsp.setCapabilities(staticNatCapResponse);
@@ -2685,30 +2685,30 @@ public class ApiResponseHelper implements ResponseGenerator {
if (network.getTrafficType() != null) {
response.setTrafficType(network.getTrafficType().name());
}
-
+
if (network.getGuestType() != null) {
response.setType(network.getGuestType().toString());
}
-
+
response.setGateway(network.getGateway());
-
- //FIXME - either set netmask or cidr
+
+ // FIXME - either set netmask or cidr
response.setCidr(network.getCidr());
- if(network.getCidr() != null){
- response.setNetmask(NetUtils.cidr2Netmask(network.getCidr()));
+ if (network.getCidr() != null) {
+ response.setNetmask(NetUtils.cidr2Netmask(network.getCidr()));
}
-
- //FIXME - either set broadcast URI or vlan
+
+ // FIXME - either set broadcast URI or vlan
if (network.getBroadcastUri() != null) {
- String broadcastUri = network.getBroadcastUri().toString();
+ String broadcastUri = network.getBroadcastUri().toString();
response.setBroadcastUri(broadcastUri);
String vlan = broadcastUri.substring("vlan://".length(), broadcastUri.length());
response.setVlan(vlan);
}
-
+
DataCenter zone = ApiDBUtils.findZoneById(network.getDataCenterId());
response.setZoneId(network.getDataCenterId());
- response.setZoneName(zone.getName());
+ response.setZoneName(zone.getName());
response.setPhysicalNetworkId(network.getPhysicalNetworkId());
// populate network offering information
@@ -2737,9 +2737,9 @@ public class ApiResponseHelper implements ResponseGenerator {
if (serviceCapabilitiesMap != null) {
for (Service service : serviceCapabilitiesMap.keySet()) {
ServiceResponse serviceResponse = new ServiceResponse();
- //skip gateway service
+ // skip gateway service
if (service == Service.Gateway) {
- continue;
+ continue;
}
serviceResponse.setName(service.getName());
@@ -2763,14 +2763,14 @@ public class ApiResponseHelper implements ResponseGenerator {
}
}
response.setServices(serviceResponses);
-
+
if (network.getAclType() == null || network.getAclType() == ACLType.Account) {
- populateOwner(response, network);
+ populateOwner(response, network);
} else {
- //get domain from network_domain table
- Pair domainNetworkDetails = ApiDBUtils.getDomainNetworkDetails(network.getId());
- response.setDomainId(domainNetworkDetails.first());
- response.setSubdomainAccess(domainNetworkDetails.second());
+ // get domain from network_domain table
+ Pair domainNetworkDetails = ApiDBUtils.getDomainNetworkDetails(network.getId());
+ response.setDomainId(domainNetworkDetails.first());
+ response.setSubdomainAccess(domainNetworkDetails.second());
}
Long dedicatedDomainId = ApiDBUtils.getDedicatedNetworkDomain(network.getId());
@@ -2779,7 +2779,7 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setDomainId(dedicatedDomainId);
response.setDomainName(domain.getName());
}
-
+
response.setSpecifyIpRanges(network.getSpecifyIpRanges());
response.setObjectName("network");
@@ -2787,7 +2787,7 @@ public class ApiResponseHelper implements ResponseGenerator {
}
@Override
- public Long getSecurityGroupId (String groupName, long accountId) {
+ public Long getSecurityGroupId(String groupName, long accountId) {
SecurityGroup sg = ApiDBUtils.getSecurityGroup(groupName, accountId);
if (sg == null) {
return null;
@@ -2807,14 +2807,13 @@ public class ApiResponseHelper implements ResponseGenerator {
Domain domain = ApiDBUtils.findDomainById(project.getDomainId());
response.setDomainId(domain.getId());
response.setDomain(domain.getName());
-
+
response.setOwner(ApiDBUtils.getProjectOwner(project.getId()).getAccountName());
response.setObjectName("project");
return response;
}
-
-
+
@Override
public FirewallResponse createFirewallResponse(FirewallRule fwRule) {
FirewallResponse response = new FirewallResponse();
@@ -2849,10 +2848,8 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setObjectName("firewallrule");
return response;
}
-
-
- public UserVmData newUserVmData(UserVm userVm){
+ public UserVmData newUserVmData(UserVm userVm) {
UserVmData userVmData = new UserVmData();
userVmData.setId(userVm.getId());
userVmData.setName(userVm.getHostName());
@@ -2864,12 +2861,12 @@ public class ApiResponseHelper implements ResponseGenerator {
}
if (userVm.getDisplayName() != null) {
userVmData.setDisplayName(userVm.getDisplayName());
- }
+ }
userVmData.setDomainId(userVm.getDomainId());
Account caller = UserContext.current().getCaller();
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
- if (userVm.getHypervisorType() != null) {
+ if (userVm.getHypervisorType() != null) {
userVmData.setHypervisor(userVm.getHypervisorType().toString());
}
}
@@ -2879,10 +2876,10 @@ public class ApiResponseHelper implements ResponseGenerator {
}
return userVmData;
}
-
- public UserVmResponse newUserVmResponse(UserVmData userVmData, boolean caller_is_admin){
+
+ public UserVmResponse newUserVmResponse(UserVmData userVmData, boolean caller_is_admin) {
UserVmResponse userVmResponse = new UserVmResponse();
-
+
userVmResponse.setHypervisor(userVmData.getHypervisor());
userVmResponse.setId(userVmData.getId());
userVmResponse.setName(userVmData.getName());
@@ -2890,7 +2887,7 @@ public class ApiResponseHelper implements ResponseGenerator {
populateAccount(userVmResponse, userVmData.getAccountId());
populateDomain(userVmResponse, userVmData.getDomainId());
-
+
userVmResponse.setCreated(userVmData.getCreated());
userVmResponse.setState(userVmData.getState());
userVmResponse.setHaEnable(userVmData.getHaEnable());
@@ -2898,7 +2895,7 @@ public class ApiResponseHelper implements ResponseGenerator {
userVmResponse.setGroup(userVmData.getGroup());
userVmResponse.setZoneId(userVmData.getZoneId());
userVmResponse.setZoneName(userVmData.getZoneName());
- if (caller_is_admin){
+ if (caller_is_admin) {
userVmResponse.setHostId(userVmData.getHostId());
userVmResponse.setHostName(userVmData.getHostName());
}
@@ -2926,19 +2923,19 @@ public class ApiResponseHelper implements ResponseGenerator {
userVmResponse.setForVirtualNetwork(userVmData.getForVirtualNetwork());
Set securityGroupResponse = new HashSet();
- for (SecurityGroupData sgd: userVmData.getSecurityGroupList()){
+ for (SecurityGroupData sgd : userVmData.getSecurityGroupList()) {
if (sgd.getId() != null) {
SecurityGroupResponse sgr = new SecurityGroupResponse();
sgr.setId(sgd.getId());
sgr.setName(sgd.getName());
sgr.setDescription(sgd.getDescription());
-
+
Account account = ApiDBUtils.findAccountByNameDomain(sgd.getAccountName(), sgd.getDomainId());
if (account != null) {
populateAccount(sgr, account.getId());
populateDomain(sgr, account.getDomainId());
}
-
+
sgr.setObjectName(sgd.getObjectName());
securityGroupResponse.add(sgr);
}
@@ -2946,7 +2943,7 @@ public class ApiResponseHelper implements ResponseGenerator {
userVmResponse.setSecurityGroupList(new ArrayList(securityGroupResponse));
Set nicResponses = new HashSet();
- for (NicData nd: userVmData.getNics()){
+ for (NicData nd : userVmData.getNics()) {
NicResponse nr = new NicResponse();
nr.setId(nd.getId());
nr.setNetworkid(nd.getNetworkid());
@@ -2966,9 +2963,9 @@ public class ApiResponseHelper implements ResponseGenerator {
return userVmResponse;
}
-
+
@Override
- public HypervisorCapabilitiesResponse createHypervisorCapabilitiesResponse(HypervisorCapabilities hpvCapabilities){
+ public HypervisorCapabilitiesResponse createHypervisorCapabilitiesResponse(HypervisorCapabilities hpvCapabilities) {
HypervisorCapabilitiesResponse hpvCapabilitiesResponse = new HypervisorCapabilitiesResponse();
hpvCapabilitiesResponse.setId(hpvCapabilities.getId());
hpvCapabilitiesResponse.setHypervisor(hpvCapabilities.getHypervisorType());
@@ -2977,28 +2974,28 @@ public class ApiResponseHelper implements ResponseGenerator {
hpvCapabilitiesResponse.setMaxGuestsLimit(hpvCapabilities.getMaxGuestsLimit());
return hpvCapabilitiesResponse;
}
-
+
private void populateOwner(ControlledEntityResponse response, ControlledEntity object) {
Account account = ApiDBUtils.findAccountByIdIncludingRemoved(object.getAccountId());
-
+
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
- //find the project
+ // find the project
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
response.setProjectId(project.getId());
response.setProjectName(project.getName());
} else {
response.setAccountName(account.getAccountName());
}
-
+
Domain domain = ApiDBUtils.findDomainById(object.getDomainId());
response.setDomainId(domain.getId());
response.setDomainName(domain.getName());
}
-
+
private void populateAccount(ControlledEntityResponse response, long accountId) {
Account account = ApiDBUtils.findAccountByIdIncludingRemoved(accountId);
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
- //find the project
+ // find the project
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
response.setProjectId(project.getId());
response.setProjectName(project.getName());
@@ -3006,29 +3003,29 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setAccountName(account.getAccountName());
}
}
-
+
private void populateDomain(ControlledEntityResponse response, long domainId) {
Domain domain = ApiDBUtils.findDomainById(domainId);
-
+
response.setDomainId(domain.getId());
response.setDomainName(domain.getName());
}
-
- @Override
+
+ @Override
public ProjectAccountResponse createProjectAccountResponse(ProjectAccount projectAccount) {
Account account = ApiDBUtils.findAccountById(projectAccount.getAccountId());
ProjectAccountResponse projectAccountResponse = new ProjectAccountResponse();
-
+
long projectId = projectAccount.getProjectId();
projectAccountResponse.setProjectId(projectId);
projectAccountResponse.setProjectName(ApiDBUtils.findProjectById(projectId).getName());
-
+
projectAccountResponse.setId(account.getId());
projectAccountResponse.setAccountName(account.getAccountName());
projectAccountResponse.setAccountType(account.getType());
projectAccountResponse.setRole(projectAccount.getAccountRole().toString());
populateDomain(projectAccountResponse, account.getDomainId());
-
+
// add all the users for an account as part of the response obj
List usersForAccount = ApiDBUtils.listUsersByAccount(account.getAccountId());
List userResponseList = new ArrayList();
@@ -3039,10 +3036,10 @@ public class ApiResponseHelper implements ResponseGenerator {
projectAccountResponse.setUsers(userResponseList);
projectAccountResponse.setObjectName("projectaccount");
-
- return projectAccountResponse;
+
+ return projectAccountResponse;
}
-
+
@Override
public ProjectInvitationResponse createProjectInvitationResponse(ProjectInvitation invite) {
ProjectInvitationResponse response = new ProjectInvitationResponse();
@@ -3050,23 +3047,23 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setProjectId(invite.getProjectId());
response.setProjectName(ApiDBUtils.findProjectById(invite.getProjectId()).getName());
response.setInvitationState(invite.getState().toString());
-
+
if (invite.getForAccountId() != null) {
Account account = ApiDBUtils.findAccountById(invite.getForAccountId());
response.setAccountName(account.getAccountName());
-
+
} else {
response.setEmail(invite.getEmail());
}
-
+
populateDomain(response, invite.getInDomainId());
-
+
response.setObjectName("projectinvitation");
return response;
}
-
+
@Override
- public SystemVmInstanceResponse createSystemVmInstanceResponse(VirtualMachine vm){
+ public SystemVmInstanceResponse createSystemVmInstanceResponse(VirtualMachine vm) {
SystemVmInstanceResponse vmResponse = new SystemVmInstanceResponse();
vmResponse.setId(vm.getId());
vmResponse.setSystemVmType(vm.getType().toString().toLowerCase());
@@ -3078,8 +3075,8 @@ public class ApiResponseHelper implements ResponseGenerator {
vmResponse.setState(vm.getState().toString());
}
if (vm.getType() == Type.DomainRouter) {
- VirtualRouter router = (VirtualRouter)vm;
- if(router.getRole() != null){
+ VirtualRouter router = (VirtualRouter) vm;
+ if (router.getRole() != null) {
vmResponse.setRole(router.getRole().toString());
}
}
@@ -3090,67 +3087,67 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public PhysicalNetworkResponse createPhysicalNetworkResponse(PhysicalNetwork result) {
PhysicalNetworkResponse response = new PhysicalNetworkResponse();
-
+
response.setZoneId(result.getDataCenterId());
response.setNetworkSpeed(result.getSpeed());
response.setVlan(result.getVnet());
response.setDomainId(result.getDomainId());
response.setId(result.getUuid());
- if(result.getBroadcastDomainRange() != null){
+ if (result.getBroadcastDomainRange() != null) {
response.setBroadcastDomainRange(result.getBroadcastDomainRange().toString());
}
response.setIsolationMethods(result.getIsolationMethods());
response.setTags(result.getTags());
- if(result.getState() != null){
+ if (result.getState() != null) {
response.setState(result.getState().toString());
}
-
+
response.setName(result.getName());
-
+
response.setObjectName("physicalnetwork");
return response;
}
@Override
- public ServiceResponse createNetworkServiceResponse(Service service){
+ public ServiceResponse createNetworkServiceResponse(Service service) {
ServiceResponse response = new ServiceResponse();
response.setName(service.getName());
-
+
// set list of capabilities required for the service
List capabilityResponses = new ArrayList();
Capability[] capabilities = service.getCapabilities();
- for(Capability cap : capabilities){
+ for (Capability cap : capabilities) {
CapabilityResponse capabilityResponse = new CapabilityResponse();
capabilityResponse.setName(cap.getName());
capabilityResponse.setObjectName("capability");
- if (cap.getName().equals(Capability.SupportedLBIsolation.getName()) ||
- cap.getName().equals(Capability.SupportedSourceNatTypes.getName()) ||
- cap.getName().equals(Capability.RedundantRouter.getName()) ) {
- capabilityResponse.setCanChoose(true);
- } else {
- capabilityResponse.setCanChoose(false);
- }
+ if (cap.getName().equals(Capability.SupportedLBIsolation.getName()) ||
+ cap.getName().equals(Capability.SupportedSourceNatTypes.getName()) ||
+ cap.getName().equals(Capability.RedundantRouter.getName())) {
+ capabilityResponse.setCanChoose(true);
+ } else {
+ capabilityResponse.setCanChoose(false);
+ }
capabilityResponses.add(capabilityResponse);
}
response.setCapabilities(capabilityResponses);
-
- //set list of providers providing this service
+
+ // set list of providers providing this service
List extends Network.Provider> serviceProviders = ApiDBUtils.getProvidersForService(service);
List serviceProvidersResponses = new ArrayList();
for (Network.Provider serviceProvider : serviceProviders) {
- //return only Virtual Router as a provider for the firewall
- if (service == Service.Firewall && !(serviceProvider == Provider.VirtualRouter)) {
- continue;
- }
-
+ // return only Virtual Router as a provider for the firewall
+ if (service == Service.Firewall && !(serviceProvider == Provider.VirtualRouter)) {
+ continue;
+ }
+
ProviderResponse serviceProviderResponse = createServiceProviderResponse(serviceProvider);
serviceProvidersResponses.add(serviceProviderResponse);
}
response.setProviders(serviceProvidersResponses);
-
+
response.setObjectName("networkservice");
return response;
-
+
}
private ProviderResponse createServiceProviderResponse(Provider serviceProvider) {
@@ -3160,23 +3157,23 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setCanEnableIndividualServices(canEnableIndividualServices);
return response;
}
-
+
@Override
- public ProviderResponse createNetworkServiceProviderResponse(PhysicalNetworkServiceProvider result){
+ public ProviderResponse createNetworkServiceProviderResponse(PhysicalNetworkServiceProvider result) {
ProviderResponse response = new ProviderResponse();
response.setId(result.getUuid());
response.setName(result.getProviderName());
response.setPhysicalNetworkId(result.getPhysicalNetworkId());
response.setDestinationPhysicalNetworkId(result.getDestinationPhysicalNetworkId());
response.setState(result.getState().toString());
-
- //set enabled services
+
+ // set enabled services
List services = new ArrayList();
- for (Service service: result.getEnabledServices()){
+ for (Service service : result.getEnabledServices()) {
services.add(service.getName());
}
response.setServices(services);
-
+
response.setObjectName("networkserviceprovider");
return response;
}
@@ -3190,22 +3187,22 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setXenLabel(result.getXenNetworkLabel());
response.setKvmLabel(result.getKvmNetworkLabel());
response.setVmwareLabel(result.getVmwareNetworkLabel());
-
+
response.setObjectName("traffictype");
return response;
}
-
-
- @Override
- public VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result) {
- VirtualRouterProviderResponse response = new VirtualRouterProviderResponse();
- response.setId(result.getId());
- response.setNspId(result.getNspId());
- response.setEnabled(result.isEnabled());
-
- response.setObjectName("virtualrouterelement");
- return response;
+
+ @Override
+ public VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result) {
+ VirtualRouterProviderResponse response = new VirtualRouterProviderResponse();
+ response.setId(result.getId());
+ response.setNspId(result.getNspId());
+ response.setEnabled(result.isEnabled());
+
+ response.setObjectName("virtualrouterelement");
+ return response;
}
+
@Override
public LBStickinessResponse createLBStickinessPolicyResponse(
StickinessPolicy stickinessPolicy, LoadBalancer lb) {
@@ -3230,13 +3227,14 @@ public class ApiResponseHelper implements ResponseGenerator {
spResponse.setObjectName("stickinesspolicies");
return spResponse;
}
-
+
@Override
public LBStickinessResponse createLBStickinessPolicyResponse(
List extends StickinessPolicy> stickinessPolicies, LoadBalancer lb) {
LBStickinessResponse spResponse = new LBStickinessResponse();
- if (lb == null) return spResponse ;
+ if (lb == null)
+ return spResponse;
spResponse.setlbRuleId(lb.getId());
Account account = ApiDBUtils.findAccountById(lb.getAccountId());
if (account != null) {
@@ -3272,17 +3270,18 @@ public class ApiResponseHelper implements ResponseGenerator {
return lr;
}
- @Override
+ @Override
public StorageNetworkIpRangeResponse createStorageNetworkIpRangeResponse(StorageNetworkIpRange result) {
- StorageNetworkIpRangeResponse response = new StorageNetworkIpRangeResponse();
- response.setUuid(result.getUuid());
- response.setVlan(result.getVlan());
- response.setEndIp(result.getEndIp());
- response.setStartIp(result.getStartIp());
- response.setPodUuid(result.getPodUuid());
- response.setZoneUuid(result.getZoneUuid());
- response.setNetworkUuid(result.getNetworkUuid());
- response.setObjectName("storagenetworkiprange");
- return response;
- }
-}
+ StorageNetworkIpRangeResponse response = new StorageNetworkIpRangeResponse();
+ response.setUuid(result.getUuid());
+ response.setVlan(result.getVlan());
+ response.setEndIp(result.getEndIp());
+ response.setStartIp(result.getStartIp());
+ response.setPodUuid(result.getPodUuid());
+ response.setZoneUuid(result.getZoneUuid());
+ response.setNetworkUuid(result.getNetworkUuid());
+ response.setObjectName("storagenetworkiprange");
+ return response;
+ }
+
+}
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index aad5e4b379b..5676b3c3169 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -1,4 +1,5 @@
/**
+
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
@@ -142,7 +143,7 @@ public class ApiServer implements HttpRequestHandler {
private static List