Merge branch 'master' of ssh://git.cloud.com/var/lib/git/cloudstack-oss

This commit is contained in:
Sam Robertson 2012-02-03 16:59:25 -08:00
commit c358f469c0
176 changed files with 8083 additions and 7451 deletions

View File

@ -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
}
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
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<String, String> 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<String, Object> unpackParams(Map<String, String> params) {
Map<String, Object> lowercaseParams = new HashMap<String, Object>();
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<Integer, Map> mapArray = null;
Map<String, Object> 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<Integer, Map>();
mapValue = new HashMap<String, Object>();
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<String, Object>();
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("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
sb.append("<" + getCommandName() + ">");
sb.append("<errorcode>" + apiException.getErrorCode() + "</errorcode>");
sb.append("<description>" + escapeXml(apiException.getDescription()) + "</description>");
sb.append("</" + getCommandName() + " cloud-stack-version=\""+_mgr.getVersion()+ "\">");
}
return sb.toString();
}
public String buildResponse(List<Pair<String, Object>> 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<String, Object> unpackParams(Map<String, String> params) {
Map<String, Object> lowercaseParams = new HashMap<String, Object>();
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<Integer, Map> mapArray = null;
Map<String, Object> 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<Integer, Map>();
mapValue = new HashMap<String, Object>();
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<String, Object>();
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("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
prefixSb.append("<" + getCommandName() + " cloud-stack-version=\""+_mgr.getVersion()+ "\">");
}
int i = 0;
for (Pair<String, Object> 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("&lt;");
} else if (c == '>') {
sOUT.append("&gt;");
} else if (c == '&') {
sOUT.append("&amp;");
} else if (c == '"') {
sOUT.append("&quot;");
} else if (c == '\'') {
sOUT.append("&apos;");
} 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("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
sb.append("<" + getCommandName() + ">");
sb.append("<errorcode>" + apiException.getErrorCode() + "</errorcode>");
sb.append("<description>" + escapeXml(apiException.getDescription()) + "</description>");
sb.append("</" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
}
return sb.toString();
}
public String buildResponse(List<Pair<String, Object>> 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("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
prefixSb.append("<" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
}
int i = 0;
for (Pair<String, Object> 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("&lt;");
} else if (c == '>') {
sOUT.append("&gt;");
} else if (c == '&') {
sOUT.append("&amp;");
} else if (c == '"') {
sOUT.append("&quot;");
} else if (c == '\'') {
sOUT.append("&apos;");
} 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<String, String> map) {
this.fullUrlParams = map;
this.fullUrlParams = map;
}
public Map<String, String> 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;
}
}
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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() {

View File

@ -18,5 +18,5 @@
package com.cloud.api;
public interface Identity {
String getUuid();
String getUuid();
}

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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<UserVmResponse> createUserVmResponse(String objectName, UserVm... userVms);
List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVm... userVms);
@ -159,7 +158,7 @@ public interface ResponseGenerator {
DomainRouterResponse createDomainRouterResponse(VirtualRouter router);
HostResponse createHostResponse(Host host, EnumSet<HostDetails> 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<TemplateResponse> createTemplateResponses(long templateId, Long zoneId, boolean readyOnly);
List<TemplateResponse> 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);

View File

@ -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

View File

@ -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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*
*/
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");
}
}
}

View File

@ -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);

View File

@ -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();
}

View File

@ -19,8 +19,8 @@
package com.cloud.async;
public interface SyncQueueItem {
String getContentType();
Long getContentId();
String getContentType();
Long getContentId();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -72,3 +72,4 @@ public interface EntityManager {
public <T, K extends Serializable> void remove(Class<T> entityType, K id);
}

View File

@ -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<String, String> getDetails();
void setDetails(Map<String, String> details);
AllocationState getAllocationState();
String getZoneToken();
String getZoneToken();
}

View File

@ -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();

View File

@ -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();
}

View File

@ -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();
}
public VlanType getVlanType();
public Long getNetworkId();
public Long getPhysicalNetworkId();
}

View File

@ -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;

View File

@ -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<Volume, StoragePool> 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<Volume, StoragePool> 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();
}
}

View File

@ -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();

View File

@ -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<Long> _dcIds;
private Set<Long> _podIds;
private Set<Long> _clusterIds;
private Set<Long> _hostIds;
private Set<Long> _poolIds;
public ExcludeList(){
public ExcludeList() {
}
public ExcludeList(Set<Long> _dcIds, Set<Long> _podIds, Set<Long> _clusterIds, Set<Long> _hostIds, Set<Long> _poolIds){
this._dcIds = _dcIds;
this._podIds = _podIds;
this._clusterIds = _clusterIds;
this._poolIds = _poolIds;
public ExcludeList(Set<Long> _dcIds, Set<Long> _podIds, Set<Long> _clusterIds, Set<Long> _hostIds, Set<Long> _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<Long>();
}
if (_poolIds == null) {
_poolIds = new HashSet<Long>();
}
_poolIds.add(poolId);
}
public void addDataCenter(long dataCenterId) {
if (_dcIds == null) {
_dcIds = new HashSet<Long>();
}
_dcIds.add(dataCenterId);
}
public void addPod(long podId) {
if (_podIds == null) {
_podIds = new HashSet<Long>();
}
_podIds.add(podId);
}
public void addCluster(long clusterId) {
if (_clusterIds == null) {
_clusterIds = new HashSet<Long>();
}
_clusterIds.add(clusterId);
}
public void addHost(long hostId) {
if (_hostIds == null) {
_hostIds = new HashSet<Long>();
}
_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<Long> getDataCentersToAvoid(){
return _dcIds;
public Set<Long> getDataCentersToAvoid() {
return _dcIds;
}
public Set<Long> getPodsToAvoid(){
return _podIds;
public Set<Long> getPodsToAvoid() {
return _podIds;
}
public Set<Long> getClustersToAvoid(){
return _clusterIds;
public Set<Long> getClustersToAvoid() {
return _clusterIds;
}
public Set<Long> getHostsToAvoid(){
return _hostIds;
public Set<Long> getHostsToAvoid() {
return _hostIds;
}
public Set<Long> getPoolsToAvoid(){
return _poolIds;
public Set<Long> getPoolsToAvoid() {
return _poolIds;
}
}
}

View File

@ -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();

View File

@ -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 {

View File

@ -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();
}

View File

@ -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";
}
}

View File

@ -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?
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -84,7 +84,7 @@ public interface NetworkService {
Integer getNetworkRate(long networkId, Long vmId);
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> 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<Pair<TrafficType, String>> listTrafficTypeImplementor(ListTrafficTypeImplementorsCmd cmd);
}

View File

@ -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 <T> 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 <T> 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;

View File

@ -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<String> getTags();
List<String> getIsolationMethods();
Long getDomainId();
@ -67,6 +67,6 @@ public interface PhysicalNetwork {
String getUuid();
String getName();
String getName();
}

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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<StorageNetworkIpRange> listIpRange(listStorageNetworkIpRangeCmd cmd);
StorageNetworkIpRange updateIpRange(UpdateStorageNetworkIpRangeCmd cmd);
List<StorageNetworkIpRange> listIpRange(listStorageNetworkIpRangeCmd cmd);
StorageNetworkIpRange updateIpRange(UpdateStorageNetworkIpRangeCmd cmd);
}

View File

@ -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;

View File

@ -23,8 +23,12 @@ public interface VirtualRouterProvider {
VirtualRouter,
ElasticLoadBalancerVm
}
public VirtualRouterProviderType getType();
public long getId();
public boolean isEnabled();
public long getNspId();
}

View File

@ -25,12 +25,12 @@ public interface VpnUser extends ControlledEntity {
Revoke,
Active
}
long getId();
String getUsername();
String getPassword();
State getState();
}

View File

@ -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);
}

View File

@ -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<Long> vmIds);
boolean removeFromLoadBalancer(long lbRuleId, List<Long> 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<LoadBalancingRule> listByNetworkId(long networkId);
LoadBalancer findById(long LoadBalancer);
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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<String> getSourceCidrs(long ruleId);
boolean disableStaticNat(long ipId) throws ResourceUnavailableException, NetworkRuleConflictException, InsufficientAddressCapacityException;
boolean disableStaticNat(long ipId) throws ResourceUnavailableException, NetworkRuleConflictException, InsufficientAddressCapacityException;
}

View File

@ -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();

View File

@ -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<Pair<String, String>> getParams(); /* get params in Map <string,String> format */
public String getUuid();
}

View File

@ -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);

View File

@ -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();
}

View File

@ -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();

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();

View File

@ -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();
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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<ResourceState> from = s_fsm.getFromStates(this, a);
return from.toArray(new ResourceState[from.size()]);
}
public Set<Event> getPossibleEvents() {
return s_fsm.getPossibleEvents(this);
}
public static String[] toString(ResourceState... states) {
String[] strs = new String[states.length];
for (int i=0; i<states.length; i++) {
for (int i = 0; i < states.length; i++) {
strs[i] = states[i].toString();
}
return strs;
}
protected static final StateMachine<ResourceState, Event> s_fsm = new StateMachine<ResourceState, Event>();
static {
s_fsm.addTransition(null, Event.InternalCreated, ResourceState.Enabled);

View File

@ -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;
}

View File

@ -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<? extends Host>> List of all Hosts in VM's cluster and list of Hosts with enough capacity
* @return Pair<List<? extends Host>, List<? extends Host>> List of all Hosts in VM's cluster and list of Hosts with
* enough capacity
*/
Pair<List<? extends Host>, List<? extends Host>> listHostsForMigrationOfVM(Long vmId, Long startIndex, Long pageSize);

View File

@ -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();
}

View File

@ -19,13 +19,13 @@ package com.cloud.storage;
/**
* @author ahuang
*
*
*/
public interface GuestOsCategory {
long getId();
String getName();
void setName(String name);
}

View File

@ -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();
}
}

View File

@ -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<StoragePoolType> getNonSharedStoragePoolTypes(){
List<StoragePoolType> nonSharedStoragePoolTypes = new ArrayList<StoragePoolType>();
for(StoragePoolType storagePoolType : StoragePoolType.values()){
if (!storagePoolType.isShared()){
nonSharedStoragePoolTypes.add(storagePoolType);
}
}
return nonSharedStoragePoolTypes;
public static List<StoragePoolType> getNonSharedStoragePoolTypes() {
List<StoragePoolType> nonSharedStoragePoolTypes = new ArrayList<StoragePoolType>();
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
}
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -74,9 +74,9 @@ public interface Volume extends ControlledEntity, BasedOn, StateObject<Volume.St
}
enum Event {
CreateRequested,
OperationFailed,
OperationSucceeded,
CreateRequested,
OperationFailed,
OperationSucceeded,
OperationRetry,
MigrationRequested,
SnapshotRequested,
@ -132,10 +132,10 @@ public interface Volume extends ControlledEntity, BasedOn, StateObject<Volume.St
String getChainInfo();
boolean isRecreatable();
public long getUpdatedCount();
public void incrUpdatedCount();
public Date getUpdated();
}

View File

@ -16,11 +16,11 @@
*
*/
package com.cloud.storage;
public interface VolumeStats {
/**
* @return bytes used by the volume
*/
public long getBytesUsed();
}
package com.cloud.storage;
public interface VolumeStats {
/**
* @return bytes used by the volume
*/
public long getBytesUsed();
}

Some files were not shown because too many files have changed in this diff Show More