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 * 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. * access must inherit this interface.
* *
*/ */
public interface ControlledEntity extends OwnedBy, PartOf { public interface ControlledEntity extends OwnedBy, PartOf {
public enum ACLType { public enum ACLType {
Account, Account,
Domain Domain
} }
} }

View File

@ -32,60 +32,74 @@ import com.cloud.utils.component.Adapter;
/** /**
* SecurityChecker checks the ownership and access control to objects within * 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 interface SecurityChecker extends Adapter {
public enum AccessType { public enum AccessType {
ListEntry, ListEntry,
ModifyEntry, ModifyEntry,
ModifyProject, ModifyProject,
UseNetwork UseNetwork
} }
/** /**
* Checks if the account owns the object. * Checks if the account owns the object.
* *
* @param caller account to check against. * @param caller
* @param object object that the account is trying to access. * account to check against.
* @return true if access allowed. false if this adapter cannot authenticate ownership. * @param object
* @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed. * 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; boolean checkAccess(Account caller, Domain domain) throws PermissionDeniedException;
/** /**
* Checks if the user belongs to an account that owns the object. * Checks if the user belongs to an account that owns the object.
* *
* @param user user to check against. * @param user
* @param object object that the account is trying to access. * user to check against.
* @return true if access allowed. false if this adapter cannot authenticate ownership. * @param object
* @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed. * 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; boolean checkAccess(User user, Domain domain) throws PermissionDeniedException;
/** /**
* Checks if the account can access the object. * Checks if the account can access the object.
* *
* @param caller account to check against. * @param caller
* @param entity object that the account is trying to access. * account to check against.
* @param accessType TODO * @param entity
* @return true if access allowed. false if this adapter cannot provide permission. * object that the account is trying to access.
* @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed. * @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; boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType) throws PermissionDeniedException;
/** /**
* Checks if the user belongs to an account that can access the object. * Checks if the user belongs to an account that can access the object.
* *
* @param user user to check against. * @param user
* @param entity object that the account is trying to access. * user to check against.
* @return true if access allowed. false if this adapter cannot authenticate ownership. * @param entity
* @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed. * 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(User user, ControlledEntity entity) throws PermissionDeniedException;
boolean checkAccess(Account account, DataCenter zone) throws PermissionDeniedException; boolean checkAccess(Account account, DataCenter zone) throws PermissionDeniedException;
public boolean checkAccess(Account account, ServiceOffering so) 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; 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 * 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. * queryAsyncJobResult API command.
*/ */
public abstract class BaseAsyncCmd extends BaseCmd { public abstract class BaseAsyncCmd extends BaseCmd {
public static final String ipAddressSyncObject = "ipaddress"; public static final String ipAddressSyncObject = "ipaddress";
public static final String networkSyncObject = "network"; public static final String networkSyncObject = "network";
private AsyncJob job; private AsyncJob job;
@Parameter(name="starteventid", type=CommandType.LONG) @Parameter(name = "starteventid", type = CommandType.LONG)
private Long startEventId; private Long startEventId;
/** /**
* For proper tracking of async commands through the system, events must be generated when the command is * 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. * 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. * @return a string representing the type of event, e.g. VM.START, VOLUME.CREATE.
*/ */
public abstract String getEventType(); public abstract String getEventType();
/** /**
* For proper tracking of async commands through the system, events must be generated when the command is * 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. * 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 * @return a string representing a description of the event
*/ */
public abstract String getEventDescription(); public abstract String getEventDescription();
@ -73,7 +74,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
public void setStartEventId(Long startEventId) { public void setStartEventId(Long startEventId) {
this.startEventId = startEventId; this.startEventId = startEventId;
} }
/** /**
* Async commands that want to be tracked as part of the listXXX commands need to * 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() * 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 * getObjectType() should return a type from the AsyncJob.Type enumeration
*/ */
public Long getInstanceId() { public Long getInstanceId() {
return null; return null;
} }
public AsyncJob.Type getInstanceType() { public AsyncJob.Type getInstanceType() {
return AsyncJob.Type.None; return AsyncJob.Type.None;
} }
public String getSyncObjType() { public String getSyncObjType() {
return null; return null;
} }
@ -101,33 +102,34 @@ public abstract class BaseAsyncCmd extends BaseCmd {
return job; return job;
} }
protected long saveStartedEvent(){ protected long saveStartedEvent() {
return saveStartedEvent(getEventType(), "Executing job for "+getEventDescription(), getStartEventId()); 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(); UserContext ctx = UserContext.current();
Long userId = ctx.getCallerUserId(); Long userId = ctx.getCallerUserId();
userId = (userId == null) ? User.UID_SYSTEM : userId; userId = (userId == null) ? User.UID_SYSTEM : userId;
Long startEvent = startEventId; Long startEvent = startEventId;
if(startEvent == null){ if (startEvent == null) {
startEvent = 0L; startEvent = 0L;
} }
return _mgr.saveStartedEvent((userId == null) ? User.UID_SYSTEM : userId, getEntityOwnerId(), eventType, description, startEvent); 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()); 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(); UserContext ctx = UserContext.current();
Long userId = ctx.getCallerUserId(); Long userId = ctx.getCallerUserId();
userId = (userId == null) ? User.UID_SYSTEM : userId; userId = (userId == null) ? User.UID_SYSTEM : userId;
Long startEvent = startEventId; Long startEvent = startEventId;
if(startEvent == null){ if (startEvent == null) {
startEvent = 0L; startEvent = 0L;
} }
return _mgr.saveCompletedEvent((userId == null) ? User.UID_SYSTEM : userId, getEntityOwnerId(), level, eventType, description, startEvent); 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; import com.cloud.exception.ResourceAllocationException;
public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd { public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
@Parameter(name="id", type=CommandType.LONG) @Parameter(name = "id", type = CommandType.LONG)
private Long id; private Long id;
public abstract void create() throws ResourceAllocationException; public abstract void create() throws ResourceAllocationException;
public Long getEntityId() { public Long getEntityId() {
@ -34,7 +34,7 @@ public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
public void setEntityId(Long id) { public void setEntityId(Long id) {
this.id = id; this.id = id;
} }
public abstract String getEntityTable(); public abstract String getEntityTable();
public String getResponse(long jobId, long objectId, String objectEntityTable) { public String getResponse(long jobId, long objectId, String objectEntityTable) {
@ -53,4 +53,5 @@ public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
public String getCreateEventDescription() { public String getCreateEventDescription() {
return null; return null;
} }
} }

View File

@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * 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.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -28,7 +28,6 @@ import java.util.regex.Pattern;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.api.response.TrafficTypeImplementorResponse;
import com.cloud.configuration.ConfigurationService; import com.cloud.configuration.ConfigurationService;
import com.cloud.consoleproxy.ConsoleProxyService; import com.cloud.consoleproxy.ConsoleProxyService;
import com.cloud.dao.EntityManager; import com.cloud.dao.EntityManager;
@ -63,66 +62,66 @@ import com.cloud.utils.Pair;
import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.component.ComponentLocator;
import com.cloud.vm.BareMetalVmService; import com.cloud.vm.BareMetalVmService;
import com.cloud.vm.UserVmService; import com.cloud.vm.UserVmService;
public abstract class BaseCmd { public abstract class BaseCmd {
private static final Logger s_logger = Logger.getLogger(BaseCmd.class.getName()); 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 String USER_ERROR_MESSAGE = "Internal error executing command, please contact your system administrator";
public static final int PROGRESS_INSTANCE_CREATED = 1; public static final int PROGRESS_INSTANCE_CREATED = 1;
public static final String RESPONSE_TYPE_XML = "xml"; public static final String RESPONSE_TYPE_XML = "xml";
public static final String RESPONSE_TYPE_JSON = "json"; public static final String RESPONSE_TYPE_JSON = "json";
public enum CommandType { public enum CommandType {
BOOLEAN, DATE, FLOAT, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE BOOLEAN, DATE, FLOAT, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE
} }
// FIXME: Extract these out into a separate file // FIXME: Extract these out into a separate file
// Client error codes // Client error codes
public static final int MALFORMED_PARAMETER_ERROR = 430; public static final int MALFORMED_PARAMETER_ERROR = 430;
public static final int PARAM_ERROR = 431; public static final int PARAM_ERROR = 431;
public static final int UNSUPPORTED_ACTION_ERROR = 432; public static final int UNSUPPORTED_ACTION_ERROR = 432;
public static final int PAGE_LIMIT_EXCEED = 433; public static final int PAGE_LIMIT_EXCEED = 433;
// Server error codes // Server error codes
public static final int INTERNAL_ERROR = 530; public static final int INTERNAL_ERROR = 530;
public static final int ACCOUNT_ERROR = 531; public static final int ACCOUNT_ERROR = 531;
public static final int ACCOUNT_RESOURCE_LIMIT_ERROR= 532; public static final int ACCOUNT_RESOURCE_LIMIT_ERROR = 532;
public static final int INSUFFICIENT_CAPACITY_ERROR = 533; public static final int INSUFFICIENT_CAPACITY_ERROR = 533;
public static final int RESOURCE_UNAVAILABLE_ERROR = 534; public static final int RESOURCE_UNAVAILABLE_ERROR = 534;
public static final int RESOURCE_ALLOCATION_ERROR = 534; public static final int RESOURCE_ALLOCATION_ERROR = 534;
public static final int RESOURCE_IN_USE_ERROR = 536; public static final int RESOURCE_IN_USE_ERROR = 536;
public static final int NETWORK_RULE_CONFLICT_ERROR = 537; public static final int NETWORK_RULE_CONFLICT_ERROR = 537;
public static final DateFormat INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); 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 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]+"); 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 static final DateFormat _outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
private Object _responseObject = null; private Object _responseObject = null;
private Map<String, String> fullUrlParams; private Map<String, String> fullUrlParams;
@Parameter(name="response", type=CommandType.STRING) @Parameter(name = "response", type = CommandType.STRING)
private String responseType; private String responseType;
public static ComponentLocator s_locator; public static ComponentLocator s_locator;
public static ConfigurationService _configService; public static ConfigurationService _configService;
public static AccountService _accountService; public static AccountService _accountService;
public static UserVmService _userVmService; public static UserVmService _userVmService;
public static ManagementService _mgr; public static ManagementService _mgr;
public static StorageService _storageService; public static StorageService _storageService;
public static ResourceService _resourceService; public static ResourceService _resourceService;
public static NetworkService _networkService; public static NetworkService _networkService;
public static TemplateService _templateService; public static TemplateService _templateService;
public static SecurityGroupService _securityGroupService; public static SecurityGroupService _securityGroupService;
public static SnapshotService _snapshotService; public static SnapshotService _snapshotService;
public static ConsoleProxyService _consoleProxyService; public static ConsoleProxyService _consoleProxyService;
public static VirtualNetworkApplianceService _routerService; public static VirtualNetworkApplianceService _routerService;
public static ResponseGenerator _responseGenerator; public static ResponseGenerator _responseGenerator;
public static EntityManager _entityMgr; public static EntityManager _entityMgr;
public static RulesService _rulesService; public static RulesService _rulesService;
public static LoadBalancingRulesService _lbService; public static LoadBalancingRulesService _lbService;
public static RemoteAccessVpnService _ravService; public static RemoteAccessVpnService _ravService;
public static BareMetalVmService _bareMetalVmService; public static BareMetalVmService _bareMetalVmService;
public static ProjectService _projectService; public static ProjectService _projectService;
public static FirewallService _firewallService; public static FirewallService _firewallService;
@ -130,26 +129,26 @@ public abstract class BaseCmd {
public static ResourceLimitService _resourceLimitService; public static ResourceLimitService _resourceLimitService;
public static IdentityService _identityService; public static IdentityService _identityService;
public static StorageNetworkService _storageNetworkService; public static StorageNetworkService _storageNetworkService;
static void setComponents(ResponseGenerator generator) { static void setComponents(ResponseGenerator generator) {
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name); ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
_mgr = (ManagementService)ComponentLocator.getComponent(ManagementService.Name); _mgr = (ManagementService) ComponentLocator.getComponent(ManagementService.Name);
_accountService = locator.getManager(AccountService.class); _accountService = locator.getManager(AccountService.class);
_configService = locator.getManager(ConfigurationService.class); _configService = locator.getManager(ConfigurationService.class);
_userVmService = locator.getManager(UserVmService.class); _userVmService = locator.getManager(UserVmService.class);
_storageService = locator.getManager(StorageService.class); _storageService = locator.getManager(StorageService.class);
_resourceService = locator.getManager(ResourceService.class); _resourceService = locator.getManager(ResourceService.class);
_networkService = locator.getManager(NetworkService.class); _networkService = locator.getManager(NetworkService.class);
_templateService = locator.getManager(TemplateService.class); _templateService = locator.getManager(TemplateService.class);
_securityGroupService = locator.getManager(SecurityGroupService.class); _securityGroupService = locator.getManager(SecurityGroupService.class);
_snapshotService = locator.getManager(SnapshotService.class); _snapshotService = locator.getManager(SnapshotService.class);
_consoleProxyService = locator.getManager(ConsoleProxyService.class); _consoleProxyService = locator.getManager(ConsoleProxyService.class);
_routerService = locator.getManager(VirtualNetworkApplianceService.class); _routerService = locator.getManager(VirtualNetworkApplianceService.class);
_entityMgr = locator.getManager(EntityManager.class); _entityMgr = locator.getManager(EntityManager.class);
_rulesService = locator.getManager(RulesService.class); _rulesService = locator.getManager(RulesService.class);
_lbService = locator.getManager(LoadBalancingRulesService.class); _lbService = locator.getManager(LoadBalancingRulesService.class);
_ravService = locator.getManager(RemoteAccessVpnService.class); _ravService = locator.getManager(RemoteAccessVpnService.class);
_responseGenerator = generator; _responseGenerator = generator;
_bareMetalVmService = locator.getManager(BareMetalVmService.class); _bareMetalVmService = locator.getManager(BareMetalVmService.class);
_projectService = locator.getManager(ProjectService.class); _projectService = locator.getManager(ProjectService.class);
_firewallService = locator.getManager(FirewallService.class); _firewallService = locator.getManager(FirewallService.class);
@ -157,337 +156,342 @@ public abstract class BaseCmd {
_resourceLimitService = locator.getManager(ResourceLimitService.class); _resourceLimitService = locator.getManager(ResourceLimitService.class);
_identityService = locator.getManager(IdentityService.class); _identityService = locator.getManager(IdentityService.class);
_storageNetworkService = locator.getManager(StorageNetworkService.class); _storageNetworkService = locator.getManager(StorageNetworkService.class);
} }
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException; public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
public String getResponseType() { public String getResponseType() {
if (responseType == null) { if (responseType == null) {
return RESPONSE_TYPE_XML; return RESPONSE_TYPE_XML;
} }
return responseType; return responseType;
} }
public void setResponseType(String responseType) { public void setResponseType(String responseType) {
this.responseType = responseType; this.responseType = responseType;
} }
public abstract String getCommandName(); public abstract String getCommandName();
/** /**
* For commands the API framework needs to know the owner of the object being acted upon. This method is * For commands the API framework needs to know the owner of the object being acted upon. This method is
* used to determine that information. * used to determine that information.
* @return the id of the account that owns the object being acted upon *
*/ * @return the id of the account that owns the object being acted upon
public abstract long getEntityOwnerId(); */
public abstract long getEntityOwnerId();
public Object getResponseObject() {
return _responseObject; public Object getResponseObject() {
} return _responseObject;
}
public void setResponseObject(Object responseObject) {
_responseObject = responseObject; public void setResponseObject(Object responseObject) {
} _responseObject = responseObject;
}
public static String getDateString(Date date) {
if (date == null) { public static String getDateString(Date date) {
return ""; if (date == null) {
} return "";
String formattedString = null; }
synchronized(_outputFormat) { String formattedString = null;
formattedString = _outputFormat.format(date); synchronized (_outputFormat) {
} formattedString = _outputFormat.format(date);
return formattedString; }
} 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"}) // FIXME: move this to a utils method so that maps can be unpacked and integer/long values can be appropriately cast
public Map<String, Object> unpackParams(Map<String, String> params) { @SuppressWarnings({ "unchecked", "rawtypes" })
Map<String, Object> lowercaseParams = new HashMap<String, Object>(); public Map<String, Object> unpackParams(Map<String, String> params) {
for (String key : params.keySet()) { Map<String, Object> lowercaseParams = new HashMap<String, Object>();
int arrayStartIndex = key.indexOf('['); for (String key : params.keySet()) {
int arrayStartLastIndex = key.lastIndexOf('['); int arrayStartIndex = key.indexOf('[');
if (arrayStartIndex != arrayStartLastIndex) { int arrayStartLastIndex = key.lastIndexOf('[');
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 != 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 (arrayStartIndex > 0) {
if ((arrayEndIndex < arrayStartIndex) || (arrayEndIndex != arrayEndLastIndex)) { int arrayEndIndex = key.indexOf(']');
// malformed parameter int arrayEndLastIndex = key.lastIndexOf(']');
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 ((arrayEndIndex < arrayStartIndex) || (arrayEndIndex != arrayEndLastIndex)) {
} // malformed parameter
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
// Now that we have an array object, check for a field name in the case of a complex object + "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
int fieldIndex = key.indexOf('.'); }
String fieldName = null;
if (fieldIndex < arrayEndIndex) { // Now that we have an array object, check for a field name in the case of a complex object
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"); int fieldIndex = key.indexOf('.');
} else { String fieldName = null;
fieldName = key.substring(fieldIndex + 1); 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");
// parse the parameter name as the text before the first '[' character } else {
String paramName = key.substring(0, arrayStartIndex); fieldName = key.substring(fieldIndex + 1);
paramName = paramName.toLowerCase(); }
Map<Integer, Map> mapArray = null; // parse the parameter name as the text before the first '[' character
Map<String, Object> mapValue = null; String paramName = key.substring(0, arrayStartIndex);
String indexStr = key.substring(arrayStartIndex+1, arrayEndIndex); paramName = paramName.toLowerCase();
int index = 0;
boolean parsedIndex = false; Map<Integer, Map> mapArray = null;
try { Map<String, Object> mapValue = null;
if (indexStr != null) { String indexStr = key.substring(arrayStartIndex + 1, arrayEndIndex);
index = Integer.parseInt(indexStr); int index = 0;
parsedIndex = true; boolean parsedIndex = false;
} try {
} catch (NumberFormatException nfe) { if (indexStr != null) {
s_logger.warn("Invalid parameter " + key + " received, unable to parse object array, returning an error."); index = Integer.parseInt(indexStr);
} parsedIndex = true;
}
if (!parsedIndex) { } catch (NumberFormatException nfe) {
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"); s_logger.warn("Invalid parameter " + key + " received, unable to parse object array, returning an error.");
} }
Object value = lowercaseParams.get(paramName); if (!parsedIndex) {
if (value == null) { throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
// for now, assume object array with sub fields + "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
mapArray = new HashMap<Integer, Map>(); }
mapValue = new HashMap<String, Object>();
mapArray.put(Integer.valueOf(index), mapValue); Object value = lowercaseParams.get(paramName);
} else if (value instanceof Map) { if (value == null) {
mapArray = (HashMap)value; // for now, assume object array with sub fields
mapValue = mapArray.get(Integer.valueOf(index)); mapArray = new HashMap<Integer, Map>();
if (mapValue == null) { mapValue = new HashMap<String, Object>();
mapValue = new HashMap<String, Object>(); mapArray.put(Integer.valueOf(index), mapValue);
mapArray.put(Integer.valueOf(index), mapValue); } else if (value instanceof Map) {
} mapArray = (HashMap) value;
} mapValue = mapArray.get(Integer.valueOf(index));
if (mapValue == null) {
// we are ready to store the value for a particular field into the map for this object mapValue = new HashMap<String, Object>();
mapValue.put(fieldName, params.get(key)); mapArray.put(Integer.valueOf(index), mapValue);
}
lowercaseParams.put(paramName, mapArray); }
} else {
lowercaseParams.put(key.toLowerCase(), params.get(key)); // we are ready to store the value for a particular field into the map for this object
} mapValue.put(fieldName, params.get(key));
}
return lowercaseParams; lowercaseParams.put(paramName, mapArray);
} } else {
lowercaseParams.put(key.toLowerCase(), params.get(key));
public String buildResponse(ServerApiException apiException, String responseType) { }
StringBuffer sb = new StringBuffer(); }
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { return lowercaseParams;
// JSON response }
sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloud-stack-version\":\""+_mgr.getVersion()+"\"},");
sb.append("\"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }"); public String buildResponse(ServerApiException apiException, String responseType) {
} else { StringBuffer sb = new StringBuffer();
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)) { if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
prefixSb.append("{ \"" + getCommandName() + "\" : { \"@attributes\":{\"cloud-stack-version\":\""+ _mgr.getVersion()+"\"},"); // JSON response
} else { sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},");
prefixSb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); sb.append("\"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }");
prefixSb.append("<" + getCommandName() + " cloud-stack-version=\""+_mgr.getVersion()+ "\">"); } else {
} sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
sb.append("<" + getCommandName() + ">");
int i = 0; sb.append("<errorcode>" + apiException.getErrorCode() + "</errorcode>");
for (Pair<String, Object> tagData : tagList) { sb.append("<description>" + escapeXml(apiException.getDescription()) + "</description>");
String tagName = tagData.first(); sb.append("</" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
Object tagValue = tagData.second(); }
if (tagValue instanceof Object[]) { return sb.toString();
Object[] subObjects = (Object[])tagValue; }
if (subObjects.length < 1) {
continue; public String buildResponse(List<Pair<String, Object>> tagList, String responseType) {
} StringBuffer prefixSb = new StringBuffer();
writeObjectArray(responseType, suffixSb, i++, tagName, subObjects); StringBuffer suffixSb = new StringBuffer();
} else {
writeNameValuePair(suffixSb, tagName, tagValue, responseType, i++); // 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 {
if(suffixSb.length() > 0){ prefixSb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)){ // append comma only if we have some suffix else not as per strict Json syntax. prefixSb.append("<" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
prefixSb.append(","); }
}
prefixSb.append(suffixSb); int i = 0;
} for (Pair<String, Object> tagData : tagList) {
// close the response String tagName = tagData.first();
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { Object tagValue = tagData.second();
prefixSb.append("} }"); if (tagValue instanceof Object[]) {
} else { Object[] subObjects = (Object[]) tagValue;
prefixSb.append("</" + getCommandName() + ">"); if (subObjects.length < 1) {
} continue;
return prefixSb.toString(); }
} writeObjectArray(responseType, suffixSb, i++, tagName, subObjects);
} else {
private void writeNameValuePair(StringBuffer sb, String tagName, Object tagValue, String responseType, int propertyCount) { writeNameValuePair(suffixSb, tagName, tagValue, responseType, i++);
if (tagValue == null) { }
return; }
}
if (suffixSb.length() > 0) {
if (tagValue instanceof Object[]) { if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { // append comma only if we have some suffix else
Object[] subObjects = (Object[])tagValue; // not as per strict Json syntax.
if (subObjects.length < 1) { prefixSb.append(",");
return; }
} prefixSb.append(suffixSb);
writeObjectArray(responseType, sb, propertyCount, tagName, subObjects); }
} else { // close the response
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
String seperator = ((propertyCount > 0) ? ", " : ""); prefixSb.append("} }");
sb.append(seperator + "\"" + tagName + "\" : \"" + escapeJSON(tagValue.toString()) + "\""); } else {
} else { prefixSb.append("</" + getCommandName() + ">");
sb.append("<" + tagName + ">" + escapeXml(tagValue.toString()) + "</" + tagName + ">"); }
} return prefixSb.toString();
} }
}
private void writeNameValuePair(StringBuffer sb, String tagName, Object tagValue, String responseType, int propertyCount) {
@SuppressWarnings("rawtypes") if (tagValue == null) {
private void writeObjectArray(String responseType, StringBuffer sb, int propertyCount, String tagName, Object[] subObjects) { return;
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { }
String separator = ((propertyCount > 0) ? ", " : "");
sb.append(separator); if (tagValue instanceof Object[]) {
} Object[] subObjects = (Object[]) tagValue;
int j = 0; if (subObjects.length < 1) {
for (Object subObject : subObjects) { return;
if (subObject instanceof List) { }
List subObjList = (List)subObject; writeObjectArray(responseType, sb, propertyCount, tagName, subObjects);
writeSubObject(sb, tagName, subObjList, responseType, j++); } else {
} if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
} String seperator = ((propertyCount > 0) ? ", " : "");
sb.append(seperator + "\"" + tagName + "\" : \"" + escapeJSON(tagValue.toString()) + "\"");
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { } else {
sb.append("]"); sb.append("<" + tagName + ">" + escapeXml(tagValue.toString()) + "</" + tagName + ">");
} }
} }
}
@SuppressWarnings("rawtypes")
private void writeSubObject(StringBuffer sb, String tagName, List tagList, String responseType, int objectCount) { @SuppressWarnings("rawtypes")
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { private void writeObjectArray(String responseType, StringBuffer sb, int propertyCount, String tagName, Object[] subObjects) {
sb.append(((objectCount == 0) ? "\"" + tagName + "\" : [ { " : ", { ")); if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
} else { String separator = ((propertyCount > 0) ? ", " : "");
sb.append("<" + tagName + ">"); sb.append(separator);
} }
int j = 0;
int i = 0; for (Object subObject : subObjects) {
for (Object tag : tagList) { if (subObject instanceof List) {
if (tag instanceof Pair) { List subObjList = (List) subObject;
Pair nameValuePair = (Pair)tag; writeSubObject(sb, tagName, subObjList, responseType, j++);
writeNameValuePair(sb, (String)nameValuePair.first(), nameValuePair.second(), responseType, i++); }
} }
}
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { sb.append("]");
sb.append("}"); }
} else { }
sb.append("</" + tagName + ">");
} @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 + "\" : [ { " : ", { "));
* Escape xml response set to false by default. API commands to override this method to allow escaping } else {
*/ sb.append("<" + tagName + ">");
public boolean requireXmlEscape() { }
return true;
} int i = 0;
for (Object tag : tagList) {
private String escapeXml(String xml){ if (tag instanceof Pair) {
if(!requireXmlEscape()){ Pair nameValuePair = (Pair) tag;
return xml; writeNameValuePair(sb, (String) nameValuePair.first(), nameValuePair.second(), responseType, i++);
} }
int iLen = xml.length(); }
if (iLen == 0) {
return xml; if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
} sb.append("}");
StringBuffer sOUT = new StringBuffer(iLen + 256); } else {
int i = 0; sb.append("</" + tagName + ">");
for (; i < iLen; i++) { }
char c = xml.charAt(i); }
if (c == '<') {
sOUT.append("&lt;"); /**
} else if (c == '>') { * Escape xml response set to false by default. API commands to override this method to allow escaping
sOUT.append("&gt;"); */
} else if (c == '&') { public boolean requireXmlEscape() {
sOUT.append("&amp;"); return true;
} else if (c == '"') { }
sOUT.append("&quot;");
} else if (c == '\'') { private String escapeXml(String xml) {
sOUT.append("&apos;"); if (!requireXmlEscape()) {
} else { return xml;
sOUT.append(c); }
} int iLen = xml.length();
} if (iLen == 0) {
return sOUT.toString(); return xml;
} }
StringBuffer sOUT = new StringBuffer(iLen + 256);
private static String escapeJSON(String str) { int i = 0;
if (str == null) { for (; i < iLen; i++) {
return str; char c = xml.charAt(i);
} if (c == '<') {
sOUT.append("&lt;");
return str.replace("\"", "\\\""); } else if (c == '>') {
} sOUT.append("&gt;");
} else if (c == '&') {
protected long getInstanceIdFromJobSuccessResult(String result) { sOUT.append("&amp;");
s_logger.debug("getInstanceIdFromJobSuccessResult not overridden in subclass " + this.getClass().getName()); } else if (c == '"') {
return 0; sOUT.append("&quot;");
} } else if (c == '\'') {
sOUT.append("&apos;");
public static boolean isAdmin(short accountType) { } else {
return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || sOUT.append(c);
(accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) || }
(accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || }
(accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)); 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) { public static boolean isRootAdmin(short accountType) {
return ((accountType == Account.ACCOUNT_TYPE_ADMIN)); return ((accountType == Account.ACCOUNT_TYPE_ADMIN));
} }
public void setFullUrlParams(Map<String, String> map) { public void setFullUrlParams(Map<String, String> map) {
this.fullUrlParams = map; this.fullUrlParams = map;
} }
public Map<String, String> getFullUrlParams() { public Map<String, String> getFullUrlParams() {
return this.fullUrlParams; return this.fullUrlParams;
} }
public Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly) { public Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly) {
if (accountName != null) { if (accountName != null) {
if (domainId == null) { if (domainId == null) {
throw new InvalidParameterValueException("Account must be specified with domainId parameter"); throw new InvalidParameterValueException("Account must be specified with domainId parameter");
} }
Domain domain = _domainService.getDomain(domainId); Domain domain = _domainService.getDomain(domainId);
if (domain == null) { if (domain == null) {
throw new InvalidParameterValueException("Unable to find domain by id=" + domainId); throw new InvalidParameterValueException("Unable to find domain by id=" + domainId);
} }
Account account = _accountService.getActiveAccountByName(accountName, domainId); Account account = _accountService.getActiveAccountByName(accountName, domainId);
if (account != null && account.getType() != Account.ACCOUNT_TYPE_PROJECT) { 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(); return account.getId();
} else { } else {
throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + " as it's no longer active"); throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + " as it's no longer active");
} }
} else { } else {
throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain id=" + domainId); throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain id=" + domainId);
} }
} }
if (projectId != null) { if (projectId != null) {
Project project = _projectService.getProject(projectId); Project project = _projectService.getProject(projectId);
if (project != null) { if (project != null) {
@ -501,5 +505,5 @@ public abstract class BaseCmd {
} }
} }
return null; return null;
} }
} }

View File

@ -18,11 +18,10 @@
package com.cloud.api; package com.cloud.api;
public abstract class BaseListAccountResourcesCmd extends BaseListDomainResourcesCmd{ 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;
@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() { public String getAccountName() {
return accountName; return accountName;

View File

@ -39,8 +39,6 @@ public abstract class BaseListCmd extends BaseCmd {
@Parameter(name = ApiConstants.PAGE_SIZE, type = CommandType.INTEGER) @Parameter(name = ApiConstants.PAGE_SIZE, type = CommandType.INTEGER)
private Integer pageSize; private Integer pageSize;
// /////////////////////////////////////////////////// // ///////////////////////////////////////////////////
// ///////////////// Accessors /////////////////////// // ///////////////// Accessors ///////////////////////
@ -58,18 +56,18 @@ public abstract class BaseListCmd extends BaseCmd {
if (pageSize != null && MAX_PAGESIZE != null && pageSize.longValue() > MAX_PAGESIZE.longValue()) { 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()); 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) { if (pageSize != null && pageSize.longValue() == PAGESIZE_UNLIMITED && page != null) {
throw new InvalidParameterValueException("Can't specify page parameter when pagesize is -1 (Unlimited)"); throw new InvalidParameterValueException("Can't specify page parameter when pagesize is -1 (Unlimited)");
} }
return pageSize; return pageSize;
} }
static void configure() { static void configure() {
if (_configService.getDefaultPageSize().longValue() != PAGESIZE_UNLIMITED) { if (_configService.getDefaultPageSize().longValue() != PAGESIZE_UNLIMITED) {
MAX_PAGESIZE = _configService.getDefaultPageSize(); MAX_PAGESIZE = _configService.getDefaultPageSize();
} }
} }
@Override @Override
@ -82,11 +80,11 @@ public abstract class BaseListCmd extends BaseCmd {
Long defaultPageSize = MAX_PAGESIZE; Long defaultPageSize = MAX_PAGESIZE;
Integer pageSizeInt = getPageSize(); Integer pageSizeInt = getPageSize();
if (pageSizeInt != null) { if (pageSizeInt != null) {
if (pageSizeInt.longValue() == PAGESIZE_UNLIMITED) { if (pageSizeInt.longValue() == PAGESIZE_UNLIMITED) {
defaultPageSize = null; defaultPageSize = null;
} else { } else {
defaultPageSize = pageSizeInt.longValue(); defaultPageSize = pageSizeInt.longValue();
} }
} }
return defaultPageSize; return defaultPageSize;
} }

View File

@ -18,26 +18,26 @@
package com.cloud.api; package com.cloud.api;
public abstract class BaseListDomainResourcesCmd extends BaseListCmd{ 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") @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; private Boolean listAll;
@IdentityMapper(entityTableName="domain") @IdentityMapper(entityTableName = "domain")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="list only resources belonging to the domain specified") @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.LONG, description = "list only resources belonging to the domain specified")
private Long domainId; 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; private Boolean recursive;
public boolean listAll() { public boolean listAll() {
return listAll == null ? false : listAll; return listAll == null ? false : listAll;
} }
public boolean isRecursive() { public boolean isRecursive() {
return recursive == null ? false : recursive; return recursive == null ? false : recursive;
} }
public Long getDomainId() { public Long getDomainId() {
return domainId; return domainId;
} }

View File

@ -18,10 +18,10 @@
package com.cloud.api; package com.cloud.api;
public abstract class BaseListProjectAndAccountResourcesCmd extends BaseListAccountResourcesCmd{ public abstract class BaseListProjectAndAccountResourcesCmd extends BaseListAccountResourcesCmd {
@IdentityMapper(entityTableName="projects") @IdentityMapper(entityTableName = "projects")
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list firewall rules by project") @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.LONG, description = "list firewall rules by project")
private Long projectId; private Long projectId;
public Long getProjectId() { public Long getProjectId() {

View File

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

View File

@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({FIELD}) @Target({ FIELD })
public @interface IdentityMapper { public @interface IdentityMapper {
String entityTableName(); String entityTableName();
} }

View File

@ -18,30 +18,29 @@
package com.cloud.api; package com.cloud.api;
public class IdentityProxy { public class IdentityProxy {
private String _tableName; private String _tableName;
private Long _value; private Long _value;
public IdentityProxy() { public IdentityProxy() {
} }
public IdentityProxy(String tableName) { public IdentityProxy(String tableName) {
_tableName = tableName; _tableName = tableName;
} }
public String getTableName() { public String getTableName() {
return _tableName; return _tableName;
} }
public void setTableName(String tableName) { public void setTableName(String tableName) {
_tableName = tableName; _tableName = tableName;
} }
public Long getValue() { public Long getValue() {
return _value; return _value;
} }
public void setValue(Long value) { public void setValue(Long value) {
_value = value; _value = value;
} }
} }

View File

@ -18,7 +18,9 @@
package com.cloud.api; package com.cloud.api;
public interface IdentityService { public interface IdentityService {
Long getIdentityId(IdentityMapper mapper, String identityString); Long getIdentityId(IdentityMapper mapper, String identityString);
Long getIdentityId(String tableName, 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; import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({TYPE}) @Target({ TYPE })
public @interface Implementation { public @interface Implementation {
Class<?> responseObject(); Class<?> responseObject();
String description() default ""; String description() default "";
String usage() default ""; String usage() default "";
boolean includeInApiDoc() default true; boolean includeInApiDoc() default true;
String since() default ""; String since() default "";
} }

View File

@ -27,16 +27,23 @@ import java.lang.annotation.Target;
import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.BaseCmd.CommandType;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({FIELD}) @Target({ FIELD })
public @interface Parameter { public @interface Parameter {
String name() default ""; String name() default "";
String description() default ""; String description() default "";
boolean required() default false; boolean required() default false;
CommandType type() default CommandType.OBJECT; CommandType type() default CommandType.OBJECT;
CommandType collectionType() default CommandType.OBJECT; CommandType collectionType() default CommandType.OBJECT;
boolean expose() default true; boolean expose() default true;
boolean includeInApiDoc() default true; boolean includeInApiDoc() default true;
int length() default 255; int length() default 255;
String since() default ""; 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.InstanceGroupResponse;
import com.cloud.api.response.IpForwardingRuleResponse; import com.cloud.api.response.IpForwardingRuleResponse;
import com.cloud.api.response.LBStickinessResponse; import com.cloud.api.response.LBStickinessResponse;
import com.cloud.api.response.LDAPConfigResponse;
import com.cloud.api.response.ListResponse; import com.cloud.api.response.ListResponse;
import com.cloud.api.response.LoadBalancerResponse; 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.NetworkOfferingResponse;
import com.cloud.api.response.NetworkResponse; import com.cloud.api.response.NetworkResponse;
import com.cloud.api.response.PhysicalNetworkResponse; 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.LoadBalancer;
import com.cloud.network.rules.PortForwardingRule; import com.cloud.network.rules.PortForwardingRule;
import com.cloud.network.rules.StaticNatRule; 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.SecurityGroup;
import com.cloud.network.security.SecurityGroupRules; import com.cloud.network.security.SecurityGroupRules;
import com.cloud.network.security.SecurityRule;
import com.cloud.offering.DiskOffering; import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering; import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering; import com.cloud.offering.ServiceOffering;
@ -149,7 +148,7 @@ public interface ResponseGenerator {
SnapshotResponse createSnapshotResponse(Snapshot snapshot); SnapshotResponse createSnapshotResponse(Snapshot snapshot);
SnapshotPolicyResponse createSnapshotPolicyResponse(SnapshotPolicy policy); SnapshotPolicyResponse createSnapshotPolicyResponse(SnapshotPolicy policy);
List<UserVmResponse> createUserVmResponse(String objectName, UserVm... userVms); List<UserVmResponse> createUserVmResponse(String objectName, UserVm... userVms);
List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVm... userVms); List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVm... userVms);
@ -159,7 +158,7 @@ public interface ResponseGenerator {
DomainRouterResponse createDomainRouterResponse(VirtualRouter router); DomainRouterResponse createDomainRouterResponse(VirtualRouter router);
HostResponse createHostResponse(Host host, EnumSet<HostDetails> details); HostResponse createHostResponse(Host host, EnumSet<HostDetails> details);
HostResponse createHostResponse(Host host); HostResponse createHostResponse(Host host);
VlanIpRangeResponse createVlanIpRangeResponse(Vlan vlan); VlanIpRangeResponse createVlanIpRangeResponse(Vlan vlan);
@ -167,10 +166,10 @@ public interface ResponseGenerator {
IPAddressResponse createIPAddressResponse(IpAddress ipAddress); IPAddressResponse createIPAddressResponse(IpAddress ipAddress);
LoadBalancerResponse createLoadBalancerResponse(LoadBalancer loadBalancer); LoadBalancerResponse createLoadBalancerResponse(LoadBalancer loadBalancer);
LBStickinessResponse createLBStickinessPolicyResponse(List<? extends StickinessPolicy> stickinessPolicies, LoadBalancer lb); 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); PodResponse createPodResponse(Pod pod, Boolean showCapacities);
@ -205,6 +204,7 @@ public interface ResponseGenerator {
VpnUsersResponse createVpnUserResponse(VpnUser user); VpnUsersResponse createVpnUserResponse(VpnUser user);
RemoteAccessVpnResponse createRemoteAccessVpnResponse(RemoteAccessVpn vpn); RemoteAccessVpnResponse createRemoteAccessVpnResponse(RemoteAccessVpn vpn);
List<TemplateResponse> createTemplateResponses(long templateId, Long zoneId, boolean readyOnly); List<TemplateResponse> createTemplateResponses(long templateId, Long zoneId, boolean readyOnly);
List<TemplateResponse> createTemplateResponses(long templateId, Long snapshotId, Long volumeId, boolean readyOnly); List<TemplateResponse> createTemplateResponses(long templateId, Long snapshotId, Long volumeId, boolean readyOnly);
@ -252,7 +252,7 @@ public interface ResponseGenerator {
FirewallResponse createFirewallResponse(FirewallRule fwRule); FirewallResponse createFirewallResponse(FirewallRule fwRule);
HypervisorCapabilitiesResponse createHypervisorCapabilitiesResponse(HypervisorCapabilities hpvCapabilities); HypervisorCapabilitiesResponse createHypervisorCapabilitiesResponse(HypervisorCapabilities hpvCapabilities);
ProjectAccountResponse createProjectAccountResponse(ProjectAccount projectAccount); ProjectAccountResponse createProjectAccountResponse(ProjectAccount projectAccount);
ProjectInvitationResponse createProjectInvitationResponse(ProjectInvitation invite); ProjectInvitationResponse createProjectInvitationResponse(ProjectInvitation invite);
@ -268,7 +268,7 @@ public interface ResponseGenerator {
ProviderResponse createNetworkServiceProviderResponse(PhysicalNetworkServiceProvider result); ProviderResponse createNetworkServiceProviderResponse(PhysicalNetworkServiceProvider result);
TrafficTypeResponse createTrafficTypeResponse(PhysicalNetworkTrafficType result); TrafficTypeResponse createTrafficTypeResponse(PhysicalNetworkTrafficType result);
VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result); VirtualRouterProviderResponse createVirtualRouterProviderResponse(VirtualRouterProvider result);
LDAPConfigResponse createLDAPConfigResponse(String hostname, Integer port, Boolean useSSL, String queryFilter, String baseSearch, String dn); 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 { public interface ResponseObject {
/** /**
* Get the name of the API response * Get the name of the API response
*
* @return the name of the API response * @return the name of the API response
*/ */
String getResponseName(); String getResponseName();
/** /**
* Set the name of the API response * Set the name of the API response
*
* @param name * @param name
*/ */
void setResponseName(String name); void setResponseName(String name);
/** /**
* Get the name of the API object * Get the name of the API object
*
* @return the name of the API object * @return the name of the API object
*/ */
String getObjectName(); String getObjectName();
/** /**
* Set the name of the APIobject * Set the name of the APIobject
*
* @param name * @param name
*/ */
void setObjectName(String name); void setObjectName(String name);
/** /**
* Returns the object Id * Returns the object Id
*/ */
Long getObjectId(); Long getObjectId();
/** /**
* Returns the job id * Returns the job id
* @return *
* @return
*/ */
Long getJobId(); Long getJobId();
/** /**
* Sets the job id * Sets the job id
*
* @param jobId * @param jobId
*/ */
void setJobId(Long jobId); void setJobId(Long jobId);
/** /**
* Returns the job status * Returns the job status
*
* @return * @return
*/ */
Integer getJobStatus(); Integer getJobStatus();
/** /**
* *
* @param jobStatus * @param jobStatus

View File

@ -16,34 +16,36 @@
* *
*/ */
package com.cloud.api; package com.cloud.api;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ServerApiException extends RuntimeException { public class ServerApiException extends RuntimeException {
private int _errorCode; private int _errorCode;
private String _description; private String _description;
public ServerApiException() { public ServerApiException() {
_errorCode = 0; _errorCode = 0;
_description = null; _description = null;
} }
public ServerApiException(int errorCode, String description) { public ServerApiException(int errorCode, String description) {
_errorCode = errorCode; _errorCode = errorCode;
_description = description; _description = description;
} }
public int getErrorCode() { public int getErrorCode() {
return _errorCode; return _errorCode;
} }
public void setErrorCode(int errorCode) {
_errorCode = errorCode; public void setErrorCode(int errorCode) {
} _errorCode = errorCode;
}
public String getDescription() {
return _description; public String getDescription() {
} return _description;
public void setDescription(String description) { }
_description = description;
} public void setDescription(String description) {
} _description = description;
}
}

View File

@ -1,4 +1,5 @@
/** /**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved. * Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
* *
* This software is licensed under the GNU General Public License v3 or later. * 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 * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.cloud.api.commands; package com.cloud.api.commands;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants; import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd; import com.cloud.api.BaseCmd;
import com.cloud.api.IdentityMapper; import com.cloud.api.IdentityMapper;
import com.cloud.api.Implementation; import com.cloud.api.Implementation;
import com.cloud.api.Parameter; import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException; import com.cloud.api.ServerApiException;
import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.SecurityGroupResponse;
import com.cloud.api.response.SecurityGroupResponse; import com.cloud.network.security.SecurityGroup;
import com.cloud.network.security.SecurityGroup; import com.cloud.user.Account;
import com.cloud.user.Account; import com.cloud.user.UserContext;
import com.cloud.user.UserContext;
@Implementation(responseObject = SecurityGroupResponse.class, description = "Creates a security group")
@Implementation(responseObject=SecurityGroupResponse.class, description="Creates a security group") public class CreateSecurityGroupCmd extends BaseCmd {
public class CreateSecurityGroupCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateSecurityGroupCmd.class.getName());
public static final Logger s_logger = Logger.getLogger(CreateSecurityGroupCmd.class.getName());
private static final String s_name = "createsecuritygroupresponse";
private static final String s_name = "createsecuritygroupresponse";
// ///////////////////////////////////////////////////
///////////////////////////////////////////////////// // ////////////// API parameters /////////////////////
//////////////// API parameters ///////////////////// // ///////////////////////////////////////////////////
/////////////////////////////////////////////////////
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an optional account for the security group. Must be used with domainId.")
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the security group. Must be used with domainId.") private String accountName;
private String accountName;
@IdentityMapper(entityTableName = "domain")
@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.")
@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;
private Long domainId;
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "the description of the security group")
@Parameter(name=ApiConstants.DESCRIPTION, type=CommandType.STRING, description="the description of the security group") private String description;
private String description;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the security group")
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="name of the security group")
private String securityGroupName; private String securityGroupName;
@IdentityMapper(entityTableName="projects") @IdentityMapper(entityTableName = "projects")
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Deploy vm for the project") @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.LONG, description = "Deploy vm for the project")
private Long projectId; private Long projectId;
// ///////////////////////////////////////////////////
///////////////////////////////////////////////////// // ///////////////// Accessors ///////////////////////
/////////////////// Accessors /////////////////////// // ///////////////////////////////////////////////////
/////////////////////////////////////////////////////
public String getAccountName() {
public String getAccountName() { return accountName;
return accountName;
}
public String getDescription() {
return description;
}
public Long getDomainId() {
return domainId;
}
public String getSecurityGroupName() {
return securityGroupName;
} }
public String getDescription() {
return description;
}
public Long getDomainId() {
return domainId;
}
public String getSecurityGroupName() {
return securityGroupName;
}
public Long getProjectId() { public Long getProjectId() {
return projectId; return projectId;
} }
// ///////////////////////////////////////////////////
///////////////////////////////////////////////////// // ///////////// API Implementation///////////////////
/////////////// API Implementation/////////////////// // ///////////////////////////////////////////////////
/////////////////////////////////////////////////////
@Override
@Override public String getCommandName() {
public String getCommandName() { return s_name;
return s_name; }
}
@Override
@Override public long getEntityOwnerId() {
public long getEntityOwnerId() { Account account = UserContext.current().getCaller();
Account account = UserContext.current().getCaller(); if ((account == null) || isAdmin(account.getType())) {
if ((account == null) || isAdmin(account.getType())) { if ((domainId != null) && (accountName != null)) {
if ((domainId != null) && (accountName != null)) { Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId); if (userAccount != null) {
if (userAccount != null) { return userAccount.getId();
return userAccount.getId(); }
} }
} }
}
if (account != null) {
if (account != null) { return account.getId();
return account.getId(); }
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked // tracked
} }
@Override @Override
public void execute(){ public void execute() {
SecurityGroup group = _securityGroupService.createSecurityGroup(this); SecurityGroup group = _securityGroupService.createSecurityGroup(this);
if (group != null) { if (group != null) {
SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponse(group); SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponse(group);
response.setResponseName(getCommandName()); response.setResponseName(getCommandName());
this.setResponseObject(response); this.setResponseObject(response);
} else { } else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create security group"); 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.user.UserContext;
import com.cloud.vm.InstanceGroup; import com.cloud.vm.InstanceGroup;
@Implementation(description="Creates a vm group", responseObject=InstanceGroupResponse.class) @Implementation(description = "Creates a vm group", responseObject = InstanceGroupResponse.class)
public class CreateVMGroupCmd extends BaseCmd{ public class CreateVMGroupCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateVMGroupCmd.class.getName()); public static final Logger s_logger = Logger.getLogger(CreateVMGroupCmd.class.getName());
private static final String s_name = "createinstancegroupresponse"; 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; 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; private String accountName;
@IdentityMapper(entityTableName="domain") @IdentityMapper(entityTableName = "domain")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID of account owning the instance group") @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.LONG, description = "the domain ID of account owning the instance group")
private Long domainId; private Long domainId;
@IdentityMapper(entityTableName="projects") @IdentityMapper(entityTableName = "projects")
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="The project of the instance group") @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.LONG, description = "The project of the instance group")
private Long projectId; private Long projectId;
///////////////////////////////////////////////////// // ///////////////////////////////////////////////////
/////////////////// Accessors /////////////////////// // ///////////////// Accessors ///////////////////////
///////////////////////////////////////////////////// // ///////////////////////////////////////////////////
public String getGroupName() { public String getGroupName() {
return groupName; return groupName;
@ -68,32 +68,32 @@ public class CreateVMGroupCmd extends BaseCmd{
public Long getDomainId() { public Long getDomainId() {
return domainId; return domainId;
} }
public Long getProjectId() { public Long getProjectId() {
return projectId; return projectId;
} }
///////////////////////////////////////////////////// // ///////////////////////////////////////////////////
/////////////// API Implementation/////////////////// // ///////////// API Implementation///////////////////
///////////////////////////////////////////////////// // ///////////////////////////////////////////////////
@Override @Override
public String getCommandName() { public String getCommandName() {
return s_name; return s_name;
} }
@Override @Override
public long getEntityOwnerId() { public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); Long accountId = finalyzeAccountId(accountName, domainId, projectId, true);
if (accountId == null) { if (accountId == null) {
return UserContext.current().getCaller().getId(); return UserContext.current().getCaller().getId();
} }
return accountId; return accountId;
} }
@Override @Override
public void execute(){ public void execute() {
InstanceGroup result = _userVmService.createVmGroup(this); InstanceGroup result = _userVmService.createVmGroup(this);
if (result != null) { if (result != null) {
InstanceGroupResponse response = _responseGenerator.createInstanceGroupResponse(result); InstanceGroupResponse response = _responseGenerator.createInstanceGroupResponse(result);

View File

@ -21,10 +21,10 @@ import java.util.Date;
import com.cloud.api.Identity; import com.cloud.api.Identity;
public interface AsyncJob extends Identity{ public interface AsyncJob extends Identity {
public enum Type { public enum Type {
None, None,
VirtualMachine, VirtualMachine,
DomainRouter, DomainRouter,
Volume, Volume,
ConsoleProxy, ConsoleProxy,
@ -38,29 +38,52 @@ public interface AsyncJob extends Identity{
SecurityGroup, SecurityGroup,
PhysicalNetwork PhysicalNetwork
} }
Long getId(); Long getId();
long getUserId(); long getUserId();
long getAccountId(); long getAccountId();
String getCmd(); String getCmd();
int getCmdVersion(); int getCmdVersion();
String getCmdInfo(); String getCmdInfo();
int getCallbackType(); int getCallbackType();
String getCallbackAddress(); String getCallbackAddress();
int getStatus(); int getStatus();
int getProcessStatus(); int getProcessStatus();
int getResultCode(); int getResultCode();
String getResult(); String getResult();
Long getInitMsid(); Long getInitMsid();
Long getCompleteMsid(); Long getCompleteMsid();
Date getCreated(); Date getCreated();
Date getLastUpdated(); Date getLastUpdated();
Date getLastPolled(); Date getLastPolled();
Date getRemoved(); Date getRemoved();
Type getInstanceType(); Type getInstanceType();
Long getInstanceId(); Long getInstanceId();
String getSessionKey(); String getSessionKey();
String getCmdOriginator(); String getCmdOriginator();
boolean isFromPreviousSession(); boolean isFromPreviousSession();
SyncQueueItem getSyncSource(); SyncQueueItem getSyncSource();
} }

View File

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

View File

@ -19,7 +19,7 @@ package com.cloud.capacity;
/** /**
* @author ahuang * @author ahuang
* *
*/ */
public interface Capacity { public interface Capacity {
public static final short CAPACITY_TYPE_MEMORY = 0; 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_VLAN = 7;
public static final short CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8; public static final short CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP = 8;
public static final short CAPACITY_TYPE_LOCAL_STORAGE = 9; public static final short CAPACITY_TYPE_LOCAL_STORAGE = 9;
public long getId(); public long getId();
public Long getHostOrPoolId(); public Long getHostOrPoolId();
public long getDataCenterId(); public long getDataCenterId();
public Long getPodId(); public Long getPodId();
public Long getClusterId(); public Long getClusterId();
public long getUsedCapacity(); public long getUsedCapacity();
public long getTotalCapacity(); public long getTotalCapacity();
public short getCapacityType(); public short getCapacityType();
long getReservedCapacity(); long getReservedCapacity();
} }

View File

@ -16,18 +16,17 @@
* *
*/ */
package com.cloud.cluster; package com.cloud.cluster;
public interface ManagementServerHost { public interface ManagementServerHost {
public static enum State { Up, Starting, Down }; public static enum State {
Up, Starting, Down
};
long getMsid(); long getMsid();
State getState(); State getState();
String getVersion(); String getVersion();
} }

View File

@ -18,13 +18,12 @@
package com.cloud.configuration; package com.cloud.configuration;
public interface Configuration {
public String getCategory();
public interface Configuration{
public String getCategory();
public String getInstance(); public String getInstance();
public String getComponent(); public String getComponent();
public String getName(); public String getName();
@ -33,5 +32,4 @@ public interface Configuration{
public String getDescription(); public String getDescription();
} }

View File

@ -68,7 +68,8 @@ public interface ConfigurationService {
* Create a service offering through the API * Create a service offering through the API
* *
* @param cmd * @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 * @return the newly created service offering if successful, null otherwise
*/ */
ServiceOffering createServiceOffering(CreateServiceOfferingCmd cmd); ServiceOffering createServiceOffering(CreateServiceOfferingCmd cmd);
@ -130,13 +131,21 @@ public interface ConfigurationService {
/** /**
* Creates a new pod based on the parameters specified in the command object * Creates a new pod based on the parameters specified in the command object
* @param zoneId TODO *
* @param name TODO * @param zoneId
* @param startIp TODO * TODO
* @param endIp TODO * @param name
* @param gateway TODO * TODO
* @param netmask TODO * @param startIp
* @param allocationState TODO * TODO
* @param endIp
* TODO
* @param gateway
* TODO
* @param netmask
* TODO
* @param allocationState
* TODO
* @return the new pod if successful, null otherwise * @return the new pod if successful, null otherwise
* @throws * @throws
* @throws * @throws
@ -188,12 +197,14 @@ public interface ConfigurationService {
boolean deleteZone(DeleteZoneCmd cmd); 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 * virtual public network (2) pod-wide direct attached VLANs (3) account-specific direct attached VLANs
* *
* @param userId * @param userId
* @param vlanType * @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) * attached to UserVMs)
* @param zoneId * @param zoneId
* @param accountId * @param accountId

View File

@ -18,16 +18,16 @@
package com.cloud.configuration; package com.cloud.configuration;
public interface Resource { public interface Resource {
public static final short RESOURCE_UNLIMITED = -1; public static final short RESOURCE_UNLIMITED = -1;
public enum ResourceType{ public enum ResourceType {
user_vm ("user_vm", 0, ResourceOwnerType.Account, ResourceOwnerType.Domain), user_vm("user_vm", 0, ResourceOwnerType.Account, ResourceOwnerType.Domain),
public_ip ("public_ip", 1, ResourceOwnerType.Account, ResourceOwnerType.Domain), public_ip("public_ip", 1, ResourceOwnerType.Account, ResourceOwnerType.Domain),
volume ("volume", 2, ResourceOwnerType.Account, ResourceOwnerType.Domain), volume("volume", 2, ResourceOwnerType.Account, ResourceOwnerType.Domain),
snapshot ("snapshot", 3, ResourceOwnerType.Account, ResourceOwnerType.Domain), snapshot("snapshot", 3, ResourceOwnerType.Account, ResourceOwnerType.Domain),
template ("template", 4, ResourceOwnerType.Account, ResourceOwnerType.Domain), template("template", 4, ResourceOwnerType.Account, ResourceOwnerType.Domain),
project ("project", 5, ResourceOwnerType.Account, ResourceOwnerType.Domain); project("project", 5, ResourceOwnerType.Account, ResourceOwnerType.Domain);
private String name; private String name;
private ResourceOwnerType[] supportedOwners; private ResourceOwnerType[] supportedOwners;
@ -37,7 +37,7 @@ public interface Resource {
this.name = name; this.name = name;
this.supportedOwners = supportedOwners; this.supportedOwners = supportedOwners;
this.ordinal = ordinal; this.ordinal = ordinal;
} }
public String getName() { public String getName() {
return name; return name;
@ -51,22 +51,22 @@ public interface Resource {
boolean success = false; boolean success = false;
if (supportedOwners != null) { if (supportedOwners != null) {
int length = supportedOwners.length; 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())) { if (supportedOwners[i].getName().equalsIgnoreCase(ownerType.getName())) {
success = true; success = true;
break; break;
} }
} }
} }
return success; return success;
} }
public int getOrdinal() { public int getOrdinal() {
return ordinal; return ordinal;
} }
} }
public static class ResourceOwnerType { public static class ResourceOwnerType {
public static final ResourceOwnerType Account = new ResourceOwnerType("Account"); public static final ResourceOwnerType Account = new ResourceOwnerType("Account");
@ -82,11 +82,11 @@ public interface Resource {
return name; return name;
} }
} }
ResourceType getType(); ResourceType getType();
long getOwnerId(); long getOwnerId();
ResourceOwnerType getResourceOwnerType(); ResourceOwnerType getResourceOwnerType();
} }

View File

@ -18,12 +18,12 @@
package com.cloud.configuration; package com.cloud.configuration;
public interface ResourceCount extends Resource{ public interface ResourceCount extends Resource {
public Long getId(); public Long getId();
public long getCount(); public long getCount();
public void setCount(long count); public void setCount(long count);
} }

View File

@ -18,12 +18,12 @@
package com.cloud.configuration; package com.cloud.configuration;
public interface ResourceLimit extends Resource{ public interface ResourceLimit extends Resource {
public Long getId(); public Long getId();
public Long getMax(); public Long getMax();
public void setMax(Long max); 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); public <T, K extends Serializable> void remove(Class<T> entityType, K id);
} }

View File

@ -34,28 +34,49 @@ public interface DataCenter extends Grouping {
Basic, Basic,
Advanced, Advanced,
} }
long getId(); long getId();
String getDns1(); String getDns1();
String getDns2(); String getDns2();
String getName(); String getName();
Long getDomainId(); Long getDomainId();
String getDescription(); String getDescription();
String getDomain(); String getDomain();
NetworkType getNetworkType(); NetworkType getNetworkType();
String getInternalDns1(); String getInternalDns1();
String getInternalDns2(); String getInternalDns2();
String getDnsProvider(); String getDnsProvider();
String getGatewayProvider(); String getGatewayProvider();
String getFirewallProvider(); String getFirewallProvider();
String getDhcpProvider(); String getDhcpProvider();
String getLoadBalancerProvider(); String getLoadBalancerProvider();
String getUserDataProvider(); String getUserDataProvider();
String getVpnProvider(); String getVpnProvider();
boolean isSecurityGroupEnabled(); boolean isSecurityGroupEnabled();
Map<String, String> getDetails(); Map<String, String> getDetails();
void setDetails(Map<String, String> details); void setDetails(Map<String, String> details);
AllocationState getAllocationState(); AllocationState getAllocationState();
String getZoneToken();
String getZoneToken();
} }

View File

@ -22,32 +22,31 @@
package com.cloud.dc; package com.cloud.dc;
import com.cloud.org.Grouping; import com.cloud.org.Grouping;
import com.cloud.org.Grouping.AllocationState;
/** /**
* Represents one pod in the cloud stack. * Represents one pod in the cloud stack.
* *
*/ */
public interface Pod extends Grouping { public interface Pod extends Grouping {
/** /**
* @return unique id mapped to the pod. * @return unique id mapped to the pod.
*/ */
long getId(); long getId();
String getCidrAddress(); String getCidrAddress();
int getCidrSize(); int getCidrSize();
String getGateway(); String getGateway();
long getDataCenterId(); long getDataCenterId();
//String getUniqueName(); // String getUniqueName();
String getDescription(); String getDescription();
String getName(); String getName();
AllocationState getAllocationState(); AllocationState getAllocationState();
boolean getExternalDhcp(); boolean getExternalDhcp();

View File

@ -1,17 +1,17 @@
package com.cloud.dc; package com.cloud.dc;
public interface StorageNetworkIpRange { public interface StorageNetworkIpRange {
String getUuid(); String getUuid();
Integer getVlan();
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; package com.cloud.dc;
public interface Vlan { public interface Vlan {
public enum VlanType { public enum VlanType {
DirectAttached, DirectAttached,
VirtualNetwork VirtualNetwork
} }
public final static String UNTAGGED = "untagged";
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 String getIpRange();
public Long getNetworkId();
public Long getPhysicalNetworkId();
} public VlanType getVlanType();
public Long getNetworkId();
public Long getPhysicalNetworkId();
}

View File

@ -28,11 +28,11 @@ public class DataCenterDeployment implements DeploymentPlan {
Long _physicalNetworkId; Long _physicalNetworkId;
ExcludeList _avoids = null; ExcludeList _avoids = null;
boolean _recreateDisks; boolean _recreateDisks;
public DataCenterDeployment(long dataCenterId) { public DataCenterDeployment(long dataCenterId) {
this(dataCenterId, null, null, null, null, null); this(dataCenterId, null, null, null, null, null);
} }
public DataCenterDeployment(long dataCenterId, Long podId, Long clusterId, Long hostId, Long poolId, Long physicalNetworkId) { public DataCenterDeployment(long dataCenterId, Long podId, Long clusterId, Long hostId, Long poolId, Long physicalNetworkId) {
_dcId = dataCenterId; _dcId = dataCenterId;
_podId = podId; _podId = podId;
@ -41,7 +41,7 @@ public class DataCenterDeployment implements DeploymentPlan {
_poolId = poolId; _poolId = poolId;
_physicalNetworkId = physicalNetworkId; _physicalNetworkId = physicalNetworkId;
} }
@Override @Override
public long getDataCenterId() { public long getDataCenterId() {
return _dcId; return _dcId;
@ -58,10 +58,10 @@ public class DataCenterDeployment implements DeploymentPlan {
} }
@Override @Override
public Long getHostId(){ public Long getHostId() {
return _hostId; return _hostId;
} }
@Override @Override
public Long getPoolId() { public Long getPoolId() {
return _poolId; return _poolId;
@ -76,7 +76,7 @@ public class DataCenterDeployment implements DeploymentPlan {
public void setAvoids(ExcludeList avoids) { public void setAvoids(ExcludeList avoids) {
_avoids = avoids; _avoids = avoids;
} }
@Override @Override
public Long getPhysicalNetworkId() { public Long getPhysicalNetworkId() {
return _physicalNetworkId; return _physicalNetworkId;

View File

@ -41,19 +41,19 @@ public class DeployDestination {
public DataCenter getDataCenter() { public DataCenter getDataCenter() {
return _dc; return _dc;
} }
public Pod getPod() { public Pod getPod() {
return _pod; return _pod;
} }
public Cluster getCluster() { public Cluster getCluster() {
return _cluster; return _cluster;
} }
public Host getHost() { public Host getHost() {
return _host; return _host;
} }
public Map<Volume, StoragePool> getStorageForDisks() { public Map<Volume, StoragePool> getStorageForDisks() {
return _storage; return _storage;
} }
@ -64,23 +64,23 @@ public class DeployDestination {
_cluster = cluster; _cluster = cluster;
_host = host; _host = host;
} }
public DeployDestination(DataCenter dc, Pod pod, Cluster cluster, Host host, Map<Volume, StoragePool> storage) { 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; _storage = storage;
} }
public DeployDestination() { public DeployDestination() {
} }
@Override @Override
public int hashCode() { public int hashCode() {
return NumbersUtil.hash(_host.getId()); return NumbersUtil.hash(_host.getId());
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
DeployDestination that = (DeployDestination)obj; DeployDestination that = (DeployDestination) obj;
if (this._dc == null || that._dc == null) { if (this._dc == null || that._dc == null) {
return false; return false;
} }
@ -104,47 +104,47 @@ public class DeployDestination {
} }
return this._host.getId() == that._host.getId(); return this._host.getId() == that._host.getId();
} }
@Override @Override
public String toString() { public String toString() {
Long dcId = null; Long dcId = null;
Long podId = null; Long podId = null;
Long clusterId = null; Long clusterId = null;
Long hostId = null; Long hostId = null;
if (_dc != null) { if (_dc != null) {
dcId = _dc.getId(); dcId = _dc.getId();
} }
if (_pod != null) { if (_pod != null) {
podId = _pod.getId(); podId = _pod.getId();
} }
if (_cluster != null) { if (_cluster != null) {
clusterId = _cluster.getId(); clusterId = _cluster.getId();
} }
if (_host != null) { if (_host != null) {
hostId = _host.getId(); hostId = _host.getId();
} }
StringBuilder destination = new StringBuilder("Dest[Zone(Id)-Pod(Id)-Cluster(Id)-Host(Id)-Storage(Volume(Id|Type-->Pool(Id))] : Dest["); 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("Zone(").append(dcId).append(")").append("-");
destination.append("Pod(").append(podId).append(")").append("-"); destination.append("Pod(").append(podId).append(")").append("-");
destination.append("Cluster(").append(clusterId).append(")").append("-"); destination.append("Cluster(").append(clusterId).append(")").append("-");
destination.append("Host(").append(hostId).append(")").append("-"); destination.append("Host(").append(hostId).append(")").append("-");
destination.append("Storage("); destination.append("Storage(");
if(_storage != null){ if (_storage != null) {
String storageStr = ""; String storageStr = "";
for(Volume vol : _storage.keySet()){ for (Volume vol : _storage.keySet()) {
if(!storageStr.equals("")){ if (!storageStr.equals("")) {
storageStr = storageStr + ", "; storageStr = storageStr + ", ";
} }
storageStr = storageStr + "Volume(" + vol.getId() + "|"+ vol.getVolumeType().name() + "-->Pool("+_storage.get(vol).getId()+")"; storageStr = storageStr + "Volume(" + vol.getId() + "|" + vol.getVolumeType().name() + "-->Pool(" + _storage.get(vol).getId() + ")";
} }
destination.append(storageStr); destination.append(storageStr);
} }
return destination.append(")]").toString(); return destination.append(")]").toString();
} }
} }

View File

@ -20,47 +20,47 @@ package com.cloud.deploy;
import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.deploy.DeploymentPlanner.ExcludeList;
/** /**
* Describes how a VM should be deployed. * Describes how a VM should be deployed.
*/ */
public interface DeploymentPlan { public interface DeploymentPlan {
// TODO: This interface is not fully developed. It really // TODO: This interface is not fully developed. It really
// should be more complicated than this and allow a // should be more complicated than this and allow a
// number of parameters to be specified. // number of parameters to be specified.
/** /**
* @return data center the VM should deploy in. * @return data center the VM should deploy in.
*/ */
public long getDataCenterId(); public long getDataCenterId();
/** /**
* @return pod the Vm should deploy in; null if no preference. * @return pod the Vm should deploy in; null if no preference.
*/ */
public Long getPodId(); public Long getPodId();
/** /**
* @return cluster the VM should deploy in; null if no preference. * @return cluster the VM should deploy in; null if no preference.
*/ */
public Long getClusterId(); public Long getClusterId();
/** /**
* @return host the VM should deploy in; null if no preference. * @return host the VM should deploy in; null if no preference.
*/ */
public Long getHostId(); public Long getHostId();
/** /**
* @return pool the VM should be created in; null if no preference. * @return pool the VM should be created in; null if no preference.
*/ */
public Long getPoolId(); public Long getPoolId();
/** /**
* @param avoids * @param avoids
* Set the ExcludeList to avoid for deployment * Set the ExcludeList to avoid for deployment
*/ */
public void setAvoids(ExcludeList avoids); public void setAvoids(ExcludeList avoids);
/** /**
* @return * @return
* the ExcludeList to avoid for deployment * the ExcludeList to avoid for deployment
*/ */
public ExcludeList getAvoids(); 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. * plan is called to determine where a virtual machine should be running.
* *
* @param vm virtual machine. * @param vm
* @param plan deployment plan that tells you where it's being deployed to. * virtual machine.
* @param avoid avoid these data centers, pods, clusters, or hosts. * @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. * @return DeployDestination for that virtual machine.
*/ */
DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException; DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException;
/** /**
* check() is called right before the virtual machine starts to make sure * check() is called right before the virtual machine starts to make sure
* the host has enough capacity. * the host has enough capacity.
* *
* @param vm virtual machine in question. * @param vm
* @param plan deployment plan used to determined the deploy destination. * virtual machine in question.
* @param dest destination returned by plan. * @param plan
* @param avoid what to avoid. * deployment plan used to determined the deploy destination.
* @return true if it's okay to start; false if not. If false, the exclude list will include what should be excluded. * @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); 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 * make sure only one planer->canHandle return true in the planner list
* *
* @param vm virtual machine. * @param vm
* @param plan deployment plan that tells you where it's being deployed to. * virtual machine.
* @param avoid avoid these data centers, pods, clusters, or hosts. * @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 * @return true if it's okay to allocate; false or not
*/ */
boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid); boolean canHandle(VirtualMachineProfile<? extends VirtualMachine> vm, DeploymentPlan plan, ExcludeList avoid);
public enum AllocationAlgorithm { public enum AllocationAlgorithm {
random, random,
firstfit, firstfit,
userdispersing, userdispersing,
userconcentratedpod; userconcentratedpod;
} }
public static class ExcludeList { public static class ExcludeList {
private Set<Long> _dcIds; private Set<Long> _dcIds;
private Set<Long> _podIds; private Set<Long> _podIds;
private Set<Long> _clusterIds; private Set<Long> _clusterIds;
private Set<Long> _hostIds; private Set<Long> _hostIds;
private Set<Long> _poolIds; 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){ public ExcludeList(Set<Long> _dcIds, Set<Long> _podIds, Set<Long> _clusterIds, Set<Long> _hostIds, Set<Long> _poolIds) {
this._dcIds = _dcIds; this._dcIds = _dcIds;
this._podIds = _podIds; this._podIds = _podIds;
this._clusterIds = _clusterIds; this._clusterIds = _clusterIds;
this._poolIds = _poolIds; this._poolIds = _poolIds;
} }
public boolean add(InsufficientCapacityException e) { public boolean add(InsufficientCapacityException e) {
Class<?> scope = e.getScope(); Class<?> scope = e.getScope();
if (scope == null) { if (scope == null) {
return false; return false;
} }
if (Host.class.isAssignableFrom(scope)) { if (Host.class.isAssignableFrom(scope)) {
addHost(e.getId()); addHost(e.getId());
} else if (Pod.class.isAssignableFrom(scope)) { } else if (Pod.class.isAssignableFrom(scope)) {
@ -117,17 +129,17 @@ public interface DeploymentPlanner extends Adapter {
} else { } else {
return false; return false;
} }
return true; return true;
} }
public boolean add(ResourceUnavailableException e) { public boolean add(ResourceUnavailableException e) {
Class<?> scope = e.getScope(); Class<?> scope = e.getScope();
if (scope == null) { if (scope == null) {
return false; return false;
} }
if (Host.class.isAssignableFrom(scope)) { if (Host.class.isAssignableFrom(scope)) {
addHost(e.getResourceId()); addHost(e.getResourceId());
} else if (Pod.class.isAssignableFrom(scope)) { } else if (Pod.class.isAssignableFrom(scope)) {
@ -141,109 +153,109 @@ public interface DeploymentPlanner extends Adapter {
} else { } else {
return false; return false;
} }
return true; return true;
} }
public void addPool(long poolId) { public void addPool(long poolId) {
if (_poolIds == null) { if (_poolIds == null) {
_poolIds = new HashSet<Long>(); _poolIds = new HashSet<Long>();
} }
_poolIds.add(poolId); _poolIds.add(poolId);
} }
public void addDataCenter(long dataCenterId) { public void addDataCenter(long dataCenterId) {
if (_dcIds == null) { if (_dcIds == null) {
_dcIds = new HashSet<Long>(); _dcIds = new HashSet<Long>();
} }
_dcIds.add(dataCenterId); _dcIds.add(dataCenterId);
} }
public void addPod(long podId) { public void addPod(long podId) {
if (_podIds == null) { if (_podIds == null) {
_podIds = new HashSet<Long>(); _podIds = new HashSet<Long>();
} }
_podIds.add(podId); _podIds.add(podId);
} }
public void addCluster(long clusterId) { public void addCluster(long clusterId) {
if (_clusterIds == null) { if (_clusterIds == null) {
_clusterIds = new HashSet<Long>(); _clusterIds = new HashSet<Long>();
} }
_clusterIds.add(clusterId); _clusterIds.add(clusterId);
} }
public void addHost(long hostId) { public void addHost(long hostId) {
if (_hostIds == null) { if (_hostIds == null) {
_hostIds = new HashSet<Long>(); _hostIds = new HashSet<Long>();
} }
_hostIds.add(hostId); _hostIds.add(hostId);
} }
public boolean shouldAvoid(Host host) { public boolean shouldAvoid(Host host) {
if (_dcIds != null && _dcIds.contains(host.getDataCenterId())) { if (_dcIds != null && _dcIds.contains(host.getDataCenterId())) {
return true; return true;
} }
if (_podIds != null && _podIds.contains(host.getPodId())) { if (_podIds != null && _podIds.contains(host.getPodId())) {
return true; return true;
} }
if (_clusterIds != null && _clusterIds.contains(host.getClusterId())) { if (_clusterIds != null && _clusterIds.contains(host.getClusterId())) {
return true; return true;
} }
if (_hostIds != null && _hostIds.contains(host.getId())) { if (_hostIds != null && _hostIds.contains(host.getId())) {
return true; return true;
} }
return false; return false;
} }
public boolean shouldAvoid(Cluster cluster) { public boolean shouldAvoid(Cluster cluster) {
if (_dcIds != null && _dcIds.contains(cluster.getDataCenterId())) { if (_dcIds != null && _dcIds.contains(cluster.getDataCenterId())) {
return true; return true;
} }
if (_podIds != null && _podIds.contains(cluster.getPodId())) { if (_podIds != null && _podIds.contains(cluster.getPodId())) {
return true; return true;
} }
if (_clusterIds != null && _clusterIds.contains(cluster.getId())) { if (_clusterIds != null && _clusterIds.contains(cluster.getId())) {
return true; return true;
} }
return false; return false;
} }
public boolean shouldAvoid(Pod pod) { public boolean shouldAvoid(Pod pod) {
if (_dcIds != null && _dcIds.contains(pod.getDataCenterId())) { if (_dcIds != null && _dcIds.contains(pod.getDataCenterId())) {
return true; return true;
} }
if (_podIds != null && _podIds.contains(pod.getId())) { if (_podIds != null && _podIds.contains(pod.getId())) {
return true; return true;
} }
return false; return false;
} }
public boolean shouldAvoid(StoragePool pool) { public boolean shouldAvoid(StoragePool pool) {
if (_dcIds != null && _dcIds.contains(pool.getDataCenterId())) { if (_dcIds != null && _dcIds.contains(pool.getDataCenterId())) {
return true; return true;
} }
if (_podIds != null && _podIds.contains(pool.getPodId())) { if (_podIds != null && _podIds.contains(pool.getPodId())) {
return true; return true;
} }
if (_clusterIds != null && _clusterIds.contains(pool.getClusterId())) { if (_clusterIds != null && _clusterIds.contains(pool.getClusterId())) {
return true; return true;
} }
if (_poolIds != null && _poolIds.contains(pool.getId())) { if (_poolIds != null && _poolIds.contains(pool.getId())) {
return true; return true;
} }
return false; return false;
} }
@ -252,26 +264,26 @@ public interface DeploymentPlanner extends Adapter {
return true; return true;
} }
return false; return false;
} }
public Set<Long> getDataCentersToAvoid(){ public Set<Long> getDataCentersToAvoid() {
return _dcIds; return _dcIds;
} }
public Set<Long> getPodsToAvoid(){ public Set<Long> getPodsToAvoid() {
return _podIds; return _podIds;
} }
public Set<Long> getClustersToAvoid(){ public Set<Long> getClustersToAvoid() {
return _clusterIds; return _clusterIds;
} }
public Set<Long> getHostsToAvoid(){ public Set<Long> getHostsToAvoid() {
return _hostIds; return _hostIds;
} }
public Set<Long> getPoolsToAvoid(){ public Set<Long> getPoolsToAvoid() {
return _poolIds; return _poolIds;
} }
} }
} }

View File

@ -30,29 +30,31 @@ import com.cloud.user.OwnedBy;
*/ */
public interface Domain extends OwnedBy { public interface Domain extends OwnedBy {
public static final long ROOT_DOMAIN = 1L; public static final long ROOT_DOMAIN = 1L;
enum State {Active, Inactive}; enum State {
Active, Inactive
};
long getId(); long getId();
Long getParent(); Long getParent();
void setParent(Long parent); void setParent(Long parent);
String getName(); String getName();
void setName(String name); void setName(String name);
Date getRemoved(); Date getRemoved();
String getPath(); String getPath();
void setPath(String path); void setPath(String path);
int getLevel(); int getLevel();
int getChildCount(); int getChildCount();
long getNextChildSeq(); long getNextChildSeq();
State getState(); State getState();

View File

@ -22,7 +22,7 @@
package com.cloud.domain; 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. * in a domain.
*/ */
public interface PartOf { 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.Retention;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@Target({TYPE, METHOD}) @Target({ TYPE, METHOD })
@Retention(RUNTIME) @Retention(RUNTIME)
public @interface ActionEvent { public @interface ActionEvent {
boolean create() default false; boolean create() default false;
boolean async() default false; boolean async() default false;
String eventType(); String eventType();
String eventDescription(); String eventDescription();
} }

View File

@ -16,171 +16,171 @@
* *
*/ */
package com.cloud.event; package com.cloud.event;
public class EventTypes { public class EventTypes {
// VM Events // VM Events
public static final String EVENT_VM_CREATE = "VM.CREATE"; public static final String EVENT_VM_CREATE = "VM.CREATE";
public static final String EVENT_VM_DESTROY = "VM.DESTROY"; public static final String EVENT_VM_DESTROY = "VM.DESTROY";
public static final String EVENT_VM_START = "VM.START"; public static final String EVENT_VM_START = "VM.START";
public static final String EVENT_VM_STOP = "VM.STOP"; public static final String EVENT_VM_STOP = "VM.STOP";
public static final String EVENT_VM_REBOOT = "VM.REBOOT"; public static final String EVENT_VM_REBOOT = "VM.REBOOT";
public static final String EVENT_VM_UPDATE = "VM.UPDATE"; public static final String EVENT_VM_UPDATE = "VM.UPDATE";
public static final String EVENT_VM_UPGRADE = "VM.UPGRADE"; public static final String EVENT_VM_UPGRADE = "VM.UPGRADE";
public static final String EVENT_VM_RESETPASSWORD = "VM.RESETPASSWORD"; public static final String EVENT_VM_RESETPASSWORD = "VM.RESETPASSWORD";
public static final String EVENT_VM_MIGRATE = "VM.MIGRATE"; public static final String EVENT_VM_MIGRATE = "VM.MIGRATE";
public static final String EVENT_VM_MOVE = "VM.MOVE"; public static final String EVENT_VM_MOVE = "VM.MOVE";
public static final String EVENT_VM_RESTORE = "VM.RESTORE"; 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 // Domain Router
public static final String EVENT_PROXY_CREATE = "PROXY.CREATE"; public static final String EVENT_ROUTER_CREATE = "ROUTER.CREATE";
public static final String EVENT_PROXY_DESTROY = "PROXY.DESTROY"; public static final String EVENT_ROUTER_DESTROY = "ROUTER.DESTROY";
public static final String EVENT_PROXY_START = "PROXY.START"; public static final String EVENT_ROUTER_START = "ROUTER.START";
public static final String EVENT_PROXY_STOP = "PROXY.STOP"; public static final String EVENT_ROUTER_STOP = "ROUTER.STOP";
public static final String EVENT_PROXY_REBOOT = "PROXY.REBOOT"; public static final String EVENT_ROUTER_REBOOT = "ROUTER.REBOOT";
public static final String EVENT_PROXY_HA = "PROXY.HA"; public static final String EVENT_ROUTER_HA = "ROUTER.HA";
public static final String EVENT_ROUTER_UPGRADE = "ROUTER.UPGRADE";
// VNC Console Events // Console proxy
public static final String EVENT_VNC_CONNECT = "VNC.CONNECT"; public static final String EVENT_PROXY_CREATE = "PROXY.CREATE";
public static final String EVENT_VNC_DISCONNECT = "VNC.DISCONNECT"; 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 // VNC Console Events
public static final String EVENT_NET_IP_ASSIGN = "NET.IPASSIGN"; public static final String EVENT_VNC_CONNECT = "VNC.CONNECT";
public static final String EVENT_NET_IP_RELEASE = "NET.IPRELEASE"; public static final String EVENT_VNC_DISCONNECT = "VNC.DISCONNECT";
public static final String EVENT_NET_RULE_ADD = "NET.RULEADD";
public static final String EVENT_NET_RULE_DELETE = "NET.RULEDELETE"; // 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_NET_RULE_MODIFY = "NET.RULEMODIFY";
public static final String EVENT_NETWORK_CREATE = "NETWORK.CREATE"; public static final String EVENT_NETWORK_CREATE = "NETWORK.CREATE";
public static final String EVENT_NETWORK_DELETE = "NETWORK.DELETE"; public static final String EVENT_NETWORK_DELETE = "NETWORK.DELETE";
public static final String EVENT_NETWORK_UPDATE = "NETWORK.UPDATE"; public static final String EVENT_NETWORK_UPDATE = "NETWORK.UPDATE";
public static final String EVENT_FIREWALL_OPEN = "FIREWALL.OPEN"; public static final String EVENT_FIREWALL_OPEN = "FIREWALL.OPEN";
public static final String EVENT_FIREWALL_CLOSE = "FIREWALL.CLOSE"; public static final String EVENT_FIREWALL_CLOSE = "FIREWALL.CLOSE";
// Load Balancers // 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_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_CREATE = "LB.CREATE";
public static final String EVENT_LOAD_BALANCER_DELETE = "LB.DELETE"; 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_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"; public static final String EVENT_LOAD_BALANCER_UPDATE = "LB.UPDATE";
// Account events // Account events
public static final String EVENT_ACCOUNT_DISABLE = "ACCOUNT.DISABLE"; public static final String EVENT_ACCOUNT_DISABLE = "ACCOUNT.DISABLE";
public static final String EVENT_ACCOUNT_CREATE = "ACCOUNT.CREATE"; public static final String EVENT_ACCOUNT_CREATE = "ACCOUNT.CREATE";
public static final String EVENT_ACCOUNT_DELETE = "ACCOUNT.DELETE"; 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 // UserVO Events
public static final String EVENT_TEMPLATE_CREATE = "TEMPLATE.CREATE"; public static final String EVENT_USER_LOGIN = "USER.LOGIN";
public static final String EVENT_TEMPLATE_DELETE = "TEMPLATE.DELETE"; public static final String EVENT_USER_LOGOUT = "USER.LOGOUT";
public static final String EVENT_TEMPLATE_UPDATE = "TEMPLATE.UPDATE"; 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_START = "TEMPLATE.DOWNLOAD.START";
public static final String EVENT_TEMPLATE_DOWNLOAD_SUCCESS = "TEMPLATE.DOWNLOAD.SUCCESS"; 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_DOWNLOAD_FAILED = "TEMPLATE.DOWNLOAD.FAILED";
public static final String EVENT_TEMPLATE_COPY = "TEMPLATE.COPY"; public static final String EVENT_TEMPLATE_COPY = "TEMPLATE.COPY";
public static final String EVENT_TEMPLATE_EXTRACT = "TEMPLATE.EXTRACT"; public static final String EVENT_TEMPLATE_EXTRACT = "TEMPLATE.EXTRACT";
public static final String EVENT_TEMPLATE_UPLOAD = "TEMPLATE.UPLOAD"; 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 // Volume Events
public static final String EVENT_VOLUME_CREATE = "VOLUME.CREATE"; public static final String EVENT_VOLUME_CREATE = "VOLUME.CREATE";
public static final String EVENT_VOLUME_DELETE = "VOLUME.DELETE"; public static final String EVENT_VOLUME_DELETE = "VOLUME.DELETE";
public static final String EVENT_VOLUME_ATTACH = "VOLUME.ATTACH"; public static final String EVENT_VOLUME_ATTACH = "VOLUME.ATTACH";
public static final String EVENT_VOLUME_DETACH = "VOLUME.DETACH"; public static final String EVENT_VOLUME_DETACH = "VOLUME.DETACH";
public static final String EVENT_VOLUME_EXTRACT = "VOLUME.EXTRACT"; public static final String EVENT_VOLUME_EXTRACT = "VOLUME.EXTRACT";
public static final String EVENT_VOLUME_UPLOAD = "VOLUME.UPLOAD"; public static final String EVENT_VOLUME_UPLOAD = "VOLUME.UPLOAD";
public static final String EVENT_VOLUME_MIGRATE = "VOLUME.MIGRATE"; public static final String EVENT_VOLUME_MIGRATE = "VOLUME.MIGRATE";
// Domains // Domains
public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE"; public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE";
public static final String EVENT_DOMAIN_DELETE = "DOMAIN.DELETE"; public static final String EVENT_DOMAIN_DELETE = "DOMAIN.DELETE";
public static final String EVENT_DOMAIN_UPDATE = "DOMAIN.UPDATE"; public static final String EVENT_DOMAIN_UPDATE = "DOMAIN.UPDATE";
// Snapshots // Snapshots
public static final String EVENT_SNAPSHOT_CREATE = "SNAPSHOT.CREATE"; public static final String EVENT_SNAPSHOT_CREATE = "SNAPSHOT.CREATE";
public static final String EVENT_SNAPSHOT_DELETE = "SNAPSHOT.DELETE"; 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_CREATE = "SNAPSHOTPOLICY.CREATE";
public static final String EVENT_SNAPSHOT_POLICY_UPDATE = "SNAPSHOTPOLICY.UPDATE"; 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 // ISO
public static final String EVENT_ISO_CREATE = "ISO.CREATE"; public static final String EVENT_ISO_CREATE = "ISO.CREATE";
public static final String EVENT_ISO_DELETE = "ISO.DELETE"; public static final String EVENT_ISO_DELETE = "ISO.DELETE";
public static final String EVENT_ISO_COPY = "ISO.COPY"; public static final String EVENT_ISO_COPY = "ISO.COPY";
public static final String EVENT_ISO_ATTACH = "ISO.ATTACH"; public static final String EVENT_ISO_ATTACH = "ISO.ATTACH";
public static final String EVENT_ISO_DETACH = "ISO.DETACH"; public static final String EVENT_ISO_DETACH = "ISO.DETACH";
public static final String EVENT_ISO_EXTRACT = "ISO.EXTRACT"; 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_CREATE = "SSVM.CREATE";
public static final String EVENT_SSVM_DESTROY = "SSVM.DESTROY"; public static final String EVENT_SSVM_DESTROY = "SSVM.DESTROY";
public static final String EVENT_SSVM_START = "SSVM.START"; public static final String EVENT_SSVM_START = "SSVM.START";
public static final String EVENT_SSVM_STOP = "SSVM.STOP"; public static final String EVENT_SSVM_STOP = "SSVM.STOP";
public static final String EVENT_SSVM_REBOOT = "SSVM.REBOOT"; public static final String EVENT_SSVM_REBOOT = "SSVM.REBOOT";
public static final String EVENT_SSVM_HA = "SSVM.HA"; public static final String EVENT_SSVM_HA = "SSVM.HA";
// Service Offerings // Service Offerings
public static final String EVENT_SERVICE_OFFERING_CREATE = "SERVICE.OFFERING.CREATE"; 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_EDIT = "SERVICE.OFFERING.EDIT";
public static final String EVENT_SERVICE_OFFERING_DELETE = "SERVICE.OFFERING.DELETE"; 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_CREATE = "DISK.OFFERING.CREATE";
public static final String EVENT_DISK_OFFERING_EDIT = "DISK.OFFERING.EDIT"; public static final String EVENT_DISK_OFFERING_EDIT = "DISK.OFFERING.EDIT";
public static final String EVENT_DISK_OFFERING_DELETE = "DISK.OFFERING.DELETE"; 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_CREATE = "NETWORK.OFFERING.CREATE";
public static final String EVENT_NETWORK_OFFERING_ASSIGN = "NETWORK.OFFERING.ASSIGN"; 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_EDIT = "NETWORK.OFFERING.EDIT";
public static final String EVENT_NETWORK_OFFERING_REMOVE = "NETWORK.OFFERING.REMOVE"; public static final String EVENT_NETWORK_OFFERING_REMOVE = "NETWORK.OFFERING.REMOVE";
public static final String EVENT_NETWORK_OFFERING_DELETE = "NETWORK.OFFERING.DELETE"; public static final String EVENT_NETWORK_OFFERING_DELETE = "NETWORK.OFFERING.DELETE";
// Pods // Pods
public static final String EVENT_POD_CREATE = "POD.CREATE"; public static final String EVENT_POD_CREATE = "POD.CREATE";
public static final String EVENT_POD_EDIT = "POD.EDIT"; public static final String EVENT_POD_EDIT = "POD.EDIT";
public static final String EVENT_POD_DELETE = "POD.DELETE"; public static final String EVENT_POD_DELETE = "POD.DELETE";
// Zones // Zones
public static final String EVENT_ZONE_CREATE = "ZONE.CREATE"; public static final String EVENT_ZONE_CREATE = "ZONE.CREATE";
public static final String EVENT_ZONE_EDIT = "ZONE.EDIT"; public static final String EVENT_ZONE_EDIT = "ZONE.EDIT";
public static final String EVENT_ZONE_DELETE = "ZONE.DELETE"; public static final String EVENT_ZONE_DELETE = "ZONE.DELETE";
// VLANs/IP ranges // VLANs/IP ranges
public static final String EVENT_VLAN_IP_RANGE_CREATE = "VLAN.IP.RANGE.CREATE"; 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_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";
// Configuration Table public static final String EVENT_STORAGE_IP_RANGE_CREATE = "STORAGE.IP.RANGE.CREATE";
public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT"; 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 // Configuration Table
public static final String EVENT_SECURITY_GROUP_AUTHORIZE_INGRESS = "SG.AUTH.INGRESS"; 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_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_REVOKE_EGRESS = "SG.REVOKE.EGRESS";
public static final String EVENT_SECURITY_GROUP_CREATE = "SG.CREATE"; public static final String EVENT_SECURITY_GROUP_CREATE = "SG.CREATE";
public static final String EVENT_SECURITY_GROUP_DELETE = "SG.DELETE"; 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_CANCEL_PRIMARY_STORAGE = "MAINT.CANCEL.PS";
public static final String EVENT_MAINTENANCE_PREPARE = "MAINT.PREPARE"; public static final String EVENT_MAINTENANCE_PREPARE = "MAINT.PREPARE";
public static final String EVENT_MAINTENANCE_PREPARE_PRIMARY_STORAGE = "MAINT.PREPARE.PS"; 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_CREATE = "VPN.REMOTE.ACCESS.CREATE";
public static final String EVENT_REMOTE_ACCESS_VPN_DESTROY = "VPN.REMOTE.ACCESS.DESTROY"; 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_ADD = "VPN.USER.ADD";
public static final String EVENT_VPN_USER_REMOVE = "VPN.USER.REMOVE"; 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_CREATE = "PHYSICAL.NETWORK.CREATE";
public static final String EVENT_PHYSICAL_NETWORK_DELETE = "PHYSICAL.NETWORK.DELETE"; public static final String EVENT_PHYSICAL_NETWORK_DELETE = "PHYSICAL.NETWORK.DELETE";
public static final String EVENT_PHYSICAL_NETWORK_UPDATE = "PHYSICAL.NETWORK.UPDATE"; 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_CREATE = "SERVICE.PROVIDER.CREATE";
public static final String EVENT_SERVICE_PROVIDER_DELETE = "SERVICE.PROVIDER.DELETE"; public static final String EVENT_SERVICE_PROVIDER_DELETE = "SERVICE.PROVIDER.DELETE";
public static final String EVENT_SERVICE_PROVIDER_UPDATE = "SERVICE.PROVIDER.UPDATE"; 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_CREATE = "TRAFFIC.TYPE.CREATE";
public static final String EVENT_TRAFFIC_TYPE_DELETE = "TRAFFIC.TYPE.DELETE"; public static final String EVENT_TRAFFIC_TYPE_DELETE = "TRAFFIC.TYPE.DELETE";
public static final String EVENT_TRAFFIC_TYPE_UPDATE = "TRAFFIC.TYPE.UPDATE"; public static final String EVENT_TRAFFIC_TYPE_UPDATE = "TRAFFIC.TYPE.UPDATE";
// external network device events // 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_DELETE = "PHYSICAL.LOADBALANCER.DELETE";
public static final String EVENT_EXTERAL_LB_DEVICE_CONFIGURE = "PHYSICAL.LOADBALANCER.CONFIGURE"; 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_DELETE = "PHYSICAL.FIREWALL.DELETE";
public static final String EVENT_EXTERAL_FIREWALL_DEVICE_CONFIGURE = "PHYSICAL.FIREWALL.CONFIGURE"; 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; import com.cloud.utils.exception.CloudRuntimeException;
public class AccountLimitException extends CloudRuntimeException { public class AccountLimitException extends CloudRuntimeException {
private static final long serialVersionUID = SerialVersionUID.AccountLimitException; private static final long serialVersionUID = SerialVersionUID.AccountLimitException;
protected AccountLimitException() { protected AccountLimitException() {
super(); super();
} }
public AccountLimitException(String msg) { public AccountLimitException(String msg) {
super(msg); super(msg);
} }
public AccountLimitException(String msg, Throwable cause) { public AccountLimitException(String msg, Throwable cause) {
super(msg, 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 { public class InsufficientAddressCapacityException extends InsufficientNetworkCapacityException {
private static final long serialVersionUID = SerialVersionUID.InsufficientAddressCapacityException; private static final long serialVersionUID = SerialVersionUID.InsufficientAddressCapacityException;
public InsufficientAddressCapacityException(String msg, Class<?> scope, Long id) { public InsufficientAddressCapacityException(String msg, Class<?> scope, Long id) {
super(msg, scope, id); super(msg, scope, id);
} }
protected InsufficientAddressCapacityException() { protected InsufficientAddressCapacityException() {
super(); super();
} }
} }

View File

@ -20,13 +20,10 @@ package com.cloud.exception;
public class InternalErrorException extends ManagementServerException { 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 * @author chiradeep
* *
*/ */
public class InvalidParameterValueException extends CloudRuntimeException { public class InvalidParameterValueException extends CloudRuntimeException {
private static final long serialVersionUID = -2232066904895010203L; private static final long serialVersionUID = -2232066904895010203L;
public InvalidParameterValueException(String message) { public InvalidParameterValueException(String message) {
super(message); super(message);
} }
} }

View File

@ -21,24 +21,18 @@ import com.cloud.utils.SerialVersionUID;
/** /**
* @author chiradeep * @author chiradeep
* *
*/ */
public class ManagementServerException extends Exception { 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; package com.cloud.exception;
public class NetworkRuleConflictException extends public class NetworkRuleConflictException extends
ManagementServerException { ManagementServerException {
private static final long serialVersionUID = -294905017911859479L; private static final long serialVersionUID = -294905017911859479L;
public NetworkRuleConflictException(String message) { public NetworkRuleConflictException(String message) {
super(message); super(message);
} }
} }

View File

@ -26,43 +26,43 @@ import com.cloud.utils.exception.CloudRuntimeException;
/** /**
* @author chiradeep * @author chiradeep
* *
*/ */
public class PermissionDeniedException extends CloudRuntimeException { public class PermissionDeniedException extends CloudRuntimeException {
private static final long serialVersionUID = SerialVersionUID.PermissionDeniedException; private static final long serialVersionUID = SerialVersionUID.PermissionDeniedException;
public PermissionDeniedException(String message) { public PermissionDeniedException(String message) {
super(message); super(message);
} }
protected PermissionDeniedException() { protected PermissionDeniedException() {
super(); super();
} }
List<? extends ControlledEntity> violations; List<? extends ControlledEntity> violations;
Account account; Account account;
public PermissionDeniedException(String message, Account account, List<? extends ControlledEntity> violations) { public PermissionDeniedException(String message, Account account, List<? extends ControlledEntity> violations) {
super(message); super(message);
this.violations = violations; this.violations = violations;
this.account = account; this.account = account;
} }
public Account getAccount() { public Account getAccount() {
return account; return account;
} }
public List<? extends ControlledEntity> getEntitiesInViolation() { public List<? extends ControlledEntity> getEntitiesInViolation() {
return violations; return violations;
} }
public void addDetails(Account account, List<? extends ControlledEntity> violations) { public void addDetails(Account account, List<? extends ControlledEntity> violations) {
this.account = account; this.account = account;
this.violations = violations; this.violations = violations;
} }
public void addViolations(List<? extends ControlledEntity> violations) { public void addViolations(List<? extends ControlledEntity> violations) {
this.violations = violations; this.violations = violations;
} }
} }

View File

@ -22,16 +22,16 @@ import com.cloud.configuration.Resource.ResourceType;
public class ResourceAllocationException extends ManagementServerException { public class ResourceAllocationException extends ManagementServerException {
private static final long serialVersionUID = -2232066904895010203L; private static final long serialVersionUID = -2232066904895010203L;
private ResourceType resourceType; private ResourceType resourceType;
public ResourceAllocationException(String message, ResourceType resourceType) { public ResourceAllocationException(String message, ResourceType resourceType) {
super(message); super(message);
this.resourceType = resourceType; this.resourceType = resourceType;
} }
public ResourceType getResourceType() { public ResourceType getResourceType() {
return this.resourceType; return this.resourceType;
} }
} }

View File

@ -19,38 +19,38 @@ package com.cloud.exception;
/** /**
* @author chiradeep * @author chiradeep
* *
*/ */
public class ResourceInUseException extends ManagementServerException { public class ResourceInUseException extends ManagementServerException {
private static final long serialVersionUID = 1383416910411639324L;
private String resourceType;
private String resourceName;
public ResourceInUseException(String message) { private static final long serialVersionUID = 1383416910411639324L;
super(message); private String resourceType;
} private String resourceName;
public ResourceInUseException(String message, String resourceType,
String resourceName) {
super(message);
this.resourceType = resourceType;
this.resourceName = resourceName;
}
public void setResourceType(String resourceType) { public ResourceInUseException(String message) {
this.resourceType = resourceType; super(message);
} }
public String getResourceType() {
return this.resourceType;
}
public void setResourceName(String resourceName) { public ResourceInUseException(String message, String resourceType,
this.resourceName = resourceName; String resourceName) {
} super(message);
this.resourceType = resourceType;
this.resourceName = resourceName;
}
public String getResourceName() { public void setResourceType(String resourceType) {
return resourceName; 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; import com.cloud.utils.exception.CloudRuntimeException;
public class UnsupportedServiceException extends CloudRuntimeException{ public class UnsupportedServiceException extends CloudRuntimeException {
public UnsupportedServiceException(String message) { public UnsupportedServiceException(String message) {
super(message); super(message);
} }

View File

@ -22,7 +22,7 @@ import com.cloud.utils.SerialVersionUID;
public class VirtualMachineMigrationException extends Exception { public class VirtualMachineMigrationException extends Exception {
private static final long serialVersionUID = SerialVersionUID.VirtualMachineMigrationException; private static final long serialVersionUID = SerialVersionUID.VirtualMachineMigrationException;
public VirtualMachineMigrationException(String message) { public VirtualMachineMigrationException(String message) {
super(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. * IpAddress represents the public ip address to be allocated in the CloudStack.
* *
* When it is not allocated, it should have * When it is not allocated, it should have
* - State = Free * - State = Free
* - Allocated = null * - Allocated = null
* - AccountId = null * - AccountId = null
* - DomainId = null * - DomainId = null
* *
* When it is allocated, it should have * When it is allocated, it should have
* - State = Allocated * - State = Allocated
* - AccountId = account owner. * - AccountId = account owner.
* - DomainId = domain of the account owner. * - DomainId = domain of the account owner.
* - Allocated = time it was allocated. * - Allocated = time it was allocated.
*/ */
public interface IpAddress extends ControlledEntity{ public interface IpAddress extends ControlledEntity {
enum State { enum State {
Allocating, // The IP Address is being propagated to other network elements and is not ready for use yet. 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. Allocated, // The IP address is in used.
Releasing, // The IP address is being released for other network elements and is not ready for allocation. 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. Free // The IP address is ready to be allocated.
} }
long getDataCenterId(); long getDataCenterId();
Ip getAddress(); Ip getAddress();
Date getAllocatedTime(); Date getAllocatedTime();
boolean isSourceNat(); boolean isSourceNat();
long getVlanId(); long getVlanId();
boolean isOneToOneNat(); boolean isOneToOneNat();
State getState(); State getState();
boolean readyToUse(); boolean readyToUse();
Long getAssociatedWithNetworkId(); Long getAssociatedWithNetworkId();
Long getAssociatedWithVmId(); Long getAssociatedWithVmId();
public Long getPhysicalNetworkId(); public Long getPhysicalNetworkId();
/** /**
* @return database id. * @return database id.
*/ */
long getId(); long getId();
void setState(IpAddress.State state); 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.Mode;
import com.cloud.network.Networks.TrafficType; import com.cloud.network.Networks.TrafficType;
public class NetworkProfile implements Network { public class NetworkProfile implements Network {
private long id; private long id;
private long dataCenterId; private long dataCenterId;
@ -167,7 +166,7 @@ public class NetworkProfile implements Network {
public String getDisplayText() { public String getDisplayText() {
return displayText; return displayText;
} }
@Override @Override
public String getReservationId() { public String getReservationId() {
return reservationId; return reservationId;
@ -182,9 +181,9 @@ public class NetworkProfile implements Network {
public long getDomainId() { public long getDomainId() {
return domainId; return domainId;
} }
@Override @Override
public Network.GuestType getGuestType(){ public Network.GuestType getGuestType() {
return guestType; return guestType;
} }
@ -199,11 +198,11 @@ public class NetworkProfile implements Network {
} }
@Override @Override
public ACLType getAclType() { public ACLType getAclType() {
return aclType; return aclType;
} }
@Override @Override
public boolean isSpecifiedCidr() { public boolean isSpecifiedCidr() {
return specifiedCidr; return specifiedCidr;
} }
@ -212,16 +211,16 @@ public class NetworkProfile implements Network {
this.specifiedCidr = specifiedCidr; this.specifiedCidr = specifiedCidr;
} }
@Override @Override
public boolean isRestartRequired() { public boolean isRestartRequired() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean getSpecifyIpRanges() { public boolean getSpecifyIpRanges() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
} }

View File

@ -84,7 +84,7 @@ public interface NetworkService {
Integer getNetworkRate(long networkId, Long vmId); Integer getNetworkRate(long networkId, Long vmId);
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType); Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId); 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); 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 getPhysicalNetworkServiceProvider(Long providerId);
PhysicalNetworkServiceProvider getCreatedPhysicalNetworkServiceProvider(Long providerId); PhysicalNetworkServiceProvider getCreatedPhysicalNetworkServiceProvider(Long providerId);
long findPhysicalNetworkId(long zoneId, String tag); long findPhysicalNetworkId(long zoneId, String tag);
PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkId, String trafficType, String xenLabel, String kvmLabel, String vmwareLabel, String simulatorLabel, String vlan); 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); List<? extends PhysicalNetworkTrafficType> listTrafficTypes(Long physicalNetworkId);
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType); PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Network getExclusiveGuestNetwork(long zoneId); Network getExclusiveGuestNetwork(long zoneId);
List<Pair<TrafficType, String>> listTrafficTypeImplementor(ListTrafficTypeImplementorsCmd cmd); 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. * Network includes all of the enums used within networking.
* *
*/ */
public class Networks { public class Networks {
public enum RouterPrivateIpStrategy { public enum RouterPrivateIpStrategy {
None, None,
DcGlobal, //global to data center DcGlobal, // global to data center
HostLocal; HostLocal;
public static String DummyPrivateIp = "169.254.1.1"; public static String DummyPrivateIp = "169.254.1.1";
} }
/** /**
* Different ways to assign ip address to this network. * Different ways to assign ip address to this network.
*/ */
@ -45,7 +45,7 @@ public class Networks {
Dhcp, Dhcp,
ExternalDhcp; ExternalDhcp;
}; };
public enum AddressFormat { public enum AddressFormat {
Ip4, Ip4,
Ip6, Ip6,
@ -53,7 +53,7 @@ public class Networks {
} }
/** /**
* Different types of broadcast domains. * Different types of broadcast domains.
*/ */
public enum BroadcastDomainType { public enum BroadcastDomainType {
Native(null, null), Native(null, null),
@ -63,29 +63,29 @@ public class Networks {
Vnet("vnet", Long.class), Vnet("vnet", Long.class),
Storage("storage", Integer.class), Storage("storage", Integer.class),
UnDecided(null, null); UnDecided(null, null);
private String scheme; private String scheme;
private Class<?> type; private Class<?> type;
private BroadcastDomainType(String scheme, Class<?> type) { private BroadcastDomainType(String scheme, Class<?> type) {
this.scheme = scheme; this.scheme = scheme;
this.type = type; 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() { public String scheme() {
return scheme; return scheme;
} }
/** /**
* @return type of the value in the broadcast uri. Null indicates that this type does not have broadcast tags. * @return type of the value in the broadcast uri. Null indicates that this type does not have broadcast tags.
*/ */
public Class<?> type() { public Class<?> type() {
return type; return type;
} }
public <T> URI toUri(T value) { public <T> URI toUri(T value) {
try { try {
return new URI(scheme + "://" + value); 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 { public enum TrafficType {
None, None,
Public, Public,
Guest, Guest,
Storage, Storage,
Management, Management,
Control, Control,
Vpn; Vpn;
public static boolean isSystemNetwork(TrafficType trafficType) { public static boolean isSystemNetwork(TrafficType trafficType) {
if(Storage.equals(trafficType) if (Storage.equals(trafficType)
|| Management.equals(trafficType) || Management.equals(trafficType)
|| Control.equals(trafficType)){ || Control.equals(trafficType)) {
return true; return true;
} }
return false; return false;
} }
public static TrafficType getTrafficType(String type) { public static TrafficType getTrafficType(String type) {
if ("Public".equals(type)) { if ("Public".equals(type)) {
return Public; return Public;
} else if ("Guest".equals(type)) { } else if ("Guest".equals(type)) {
return Guest; return Guest;
} else if ("Storage".equals(type)) { } else if ("Storage".equals(type)) {
return Storage; return Storage;
} else if ("Management".equals(type)) { } else if ("Management".equals(type)) {
return Management; return Management;
} else if ("Control".equals(type)) { } else if ("Control".equals(type)) {
return Control; return Control;
} else if ("Vpn".equals(type)) { } else if ("Vpn".equals(type)) {
return Vpn; return Vpn;
} else { } else {
return None; return None;
} }
} }
}; };
public enum IsolationType { public enum IsolationType {
None(null, null), None(null, null),
Ec2("ec2", String.class), Ec2("ec2", String.class),
@ -142,43 +142,44 @@ public class Networks {
Vswitch("vs", String.class), Vswitch("vs", String.class),
Undecided(null, null), Undecided(null, null),
Vnet("vnet", Long.class); Vnet("vnet", Long.class);
private final String scheme; private final String scheme;
private final Class<?> type; private final Class<?> type;
private IsolationType(String scheme, Class<?> type) { private IsolationType(String scheme, Class<?> type) {
this.scheme = scheme; this.scheme = scheme;
this.type = type; this.type = type;
} }
public String scheme() { public String scheme() {
return scheme; return scheme;
} }
public Class<?> type() { public Class<?> type() {
return type; return type;
} }
public <T> URI toUri(T value) { public <T> URI toUri(T value) {
try { 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()); return new URI(scheme + "://" + value.toString());
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
throw new CloudRuntimeException("Unable to convert to isolation type URI: " + value); throw new CloudRuntimeException("Unable to convert to isolation type URI: " + value);
} }
} }
} }
public enum BroadcastScheme { public enum BroadcastScheme {
Vlan("vlan"), Vlan("vlan"),
VSwitch("vswitch"); VSwitch("vswitch");
private String scheme; private String scheme;
private BroadcastScheme(String scheme) { private BroadcastScheme(String scheme) {
this.scheme = scheme; this.scheme = scheme;
} }
@Override @Override
public String toString() { public String toString() {
return scheme; 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 * This defines the specifics of a physical network present in a data center
* *
*/ */
public interface PhysicalNetwork { public interface PhysicalNetwork {
@ -33,30 +33,30 @@ public interface PhysicalNetwork {
Disabled, Disabled,
Enabled; Enabled;
} }
public enum IsolationMethod { public enum IsolationMethod {
VLAN, VLAN,
L3, L3,
GRE; GRE;
} }
public enum BroadcastDomainRange { public enum BroadcastDomainRange {
POD, POD,
ZONE; ZONE;
} }
long getId(); long getId();
BroadcastDomainRange getBroadcastDomainRange(); BroadcastDomainRange getBroadcastDomainRange();
//TrafficType getTrafficType(); // TrafficType getTrafficType();
long getDataCenterId(); long getDataCenterId();
State getState(); State getState();
List<String> getTags(); List<String> getTags();
List<String> getIsolationMethods(); List<String> getIsolationMethods();
Long getDomainId(); Long getDomainId();
@ -67,6 +67,6 @@ public interface PhysicalNetwork {
String getUuid(); String getUuid();
String getName(); String getName();
} }

View File

@ -25,11 +25,9 @@ import java.util.List;
import com.cloud.network.Network.Service; import com.cloud.network.Network.Service;
/** /**
* This defines the specifics of a physical network service provider * This defines the specifics of a physical network service provider
* *
*/ */
public interface PhysicalNetworkServiceProvider { public interface PhysicalNetworkServiceProvider {
@ -38,13 +36,13 @@ public interface PhysicalNetworkServiceProvider {
Enabled, Enabled,
Shutdown; Shutdown;
} }
long getId(); long getId();
State getState(); State getState();
long getPhysicalNetworkId(); long getPhysicalNetworkId();
String getProviderName(); String getProviderName();
long getDestinationPhysicalNetworkId(); long getDestinationPhysicalNetworkId();

View File

@ -17,23 +17,22 @@
*/ */
package com.cloud.network; package com.cloud.network;
/** /**
* PhysicalNetworkNames provides the labels to identify per traffic type * PhysicalNetworkNames provides the labels to identify per traffic type
* the physical networks available to the host . * the physical networks available to the host .
*/ */
public class PhysicalNetworkSetupInfo { public class PhysicalNetworkSetupInfo {
//physical network ID as seen by Mgmt server // physical network ID as seen by Mgmt server
Long physicalNetworkId; Long physicalNetworkId;
String privateNetworkName; String privateNetworkName;
String publicNetworkName; String publicNetworkName;
String guestNetworkName; String guestNetworkName;
String storageNetworkName; 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; String mgmtVlan;
public PhysicalNetworkSetupInfo(){ public PhysicalNetworkSetupInfo() {
} }
public String getPrivateNetworkName() { public String getPrivateNetworkName() {
@ -51,7 +50,7 @@ public class PhysicalNetworkSetupInfo {
public String getStorageNetworkName() { public String getStorageNetworkName() {
return storageNetworkName; return storageNetworkName;
} }
public void setPrivateNetworkName(String privateNetworkName) { public void setPrivateNetworkName(String privateNetworkName) {
this.privateNetworkName = privateNetworkName; this.privateNetworkName = privateNetworkName;
} }
@ -66,8 +65,8 @@ public class PhysicalNetworkSetupInfo {
public void setStorageNetworkName(String storageNetworkName) { public void setStorageNetworkName(String storageNetworkName) {
this.storageNetworkName = storageNetworkName; this.storageNetworkName = storageNetworkName;
} }
public Long getPhysicalNetworkId() { public Long getPhysicalNetworkId() {
return physicalNetworkId; return physicalNetworkId;
} }
@ -84,5 +83,4 @@ public class PhysicalNetworkSetupInfo {
this.mgmtVlan = mgmtVlan; this.mgmtVlan = mgmtVlan;
} }
} }

View File

@ -23,26 +23,24 @@ package com.cloud.network;
import com.cloud.network.Networks.TrafficType; import com.cloud.network.Networks.TrafficType;
/** /**
* This defines the specifics of a physical network traffic type * This defines the specifics of a physical network traffic type
* *
*/ */
public interface PhysicalNetworkTrafficType { public interface PhysicalNetworkTrafficType {
long getId(); long getId();
long getPhysicalNetworkId(); long getPhysicalNetworkId();
TrafficType getTrafficType(); TrafficType getTrafficType();
String getXenNetworkLabel(); String getXenNetworkLabel();
String getKvmNetworkLabel(); String getKvmNetworkLabel();
String getVmwareNetworkLabel(); String getVmwareNetworkLabel();
String getSimulatorNetworkLabel(); String getSimulatorNetworkLabel();
String getUuid(); String getUuid();

View File

@ -10,11 +10,11 @@ import com.cloud.api.commands.listStorageNetworkIpRangeCmd;
import com.cloud.dc.StorageNetworkIpRange; import com.cloud.dc.StorageNetworkIpRange;
public interface StorageNetworkService { 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); List<StorageNetworkIpRange> listIpRange(listStorageNetworkIpRangeCmd cmd);
StorageNetworkIpRange updateIpRange(UpdateStorageNetworkIpRangeCmd 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.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter;
import com.cloud.utils.component.PluggableService;
public interface VirtualNetworkApplianceService { public interface VirtualNetworkApplianceService {
/** /**
* Starts domain router * Starts domain router
* @param cmd the command specifying router's id *
* @param cmd
* the command specifying router's id
* @return DomainRouter object * @return DomainRouter object
*/ */
VirtualRouter startRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException; VirtualRouter startRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
/** /**
* Reboots domain router * Reboots domain router
* @param cmd the command specifying router's id *
* @param cmd
* the command specifying router's id
* @return router if successful * @return router if successful
*/ */
VirtualRouter rebootRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException; VirtualRouter rebootRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
VirtualRouter upgradeRouter(UpgradeRouterCmd cmd); VirtualRouter upgradeRouter(UpgradeRouterCmd cmd);
/** /**
* Stops domain router * 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 * @return router if successful, null otherwise
* @throws ResourceUnavailableException * @throws ResourceUnavailableException
* @throws ConcurrentOperationException * @throws ConcurrentOperationException
*/ */
VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUnavailableException, ConcurrentOperationException; VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUnavailableException, ConcurrentOperationException;

View File

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

View File

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

View File

@ -10,18 +10,22 @@ import com.cloud.user.Account;
public interface FirewallService { public interface FirewallService {
FirewallRule createFirewallRule(FirewallRule rule) throws NetworkRuleConflictException; FirewallRule createFirewallRule(FirewallRule rule) throws NetworkRuleConflictException;
List<? extends FirewallRule> listFirewallRules(ListFirewallRulesCmd cmd); List<? extends FirewallRule> listFirewallRules(ListFirewallRulesCmd cmd);
/** /**
* Revokes a firewall rule * Revokes a firewall rule
* @param ruleId the id of the rule to revoke. *
* @param ruleId
* the id of the rule to revoke.
* @return * @return
*/ */
boolean revokeFirewallRule(long ruleId, boolean apply); boolean revokeFirewallRule(long ruleId, boolean apply);
boolean applyFirewallRules(long ipId, Account caller) throws ResourceUnavailableException; boolean applyFirewallRules(long ipId, Account caller) throws ResourceUnavailableException;
FirewallRule getFirewallRule(long ruleId); FirewallRule getFirewallRule(long ruleId);
boolean revokeRelatedFirewallRule(long ruleId, boolean apply); boolean revokeRelatedFirewallRule(long ruleId, boolean apply);
} }

View File

@ -18,57 +18,66 @@
package com.cloud.network.lb; package com.cloud.network.lb;
import java.util.List; import java.util.List;
import com.cloud.api.commands.CreateLBStickinessPolicyCmd; import com.cloud.api.commands.CreateLBStickinessPolicyCmd;
import com.cloud.api.commands.CreateLoadBalancerRuleCmd; import com.cloud.api.commands.CreateLoadBalancerRuleCmd;
import com.cloud.api.commands.ListLBStickinessPoliciesCmd; import com.cloud.api.commands.ListLBStickinessPoliciesCmd;
import com.cloud.api.commands.ListLoadBalancerRuleInstancesCmd; import com.cloud.api.commands.ListLoadBalancerRuleInstancesCmd;
import com.cloud.api.commands.ListLoadBalancerRulesCmd; import com.cloud.api.commands.ListLoadBalancerRulesCmd;
import com.cloud.api.commands.UpdateLoadBalancerRuleCmd; import com.cloud.api.commands.UpdateLoadBalancerRuleCmd;
import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.rules.StickinessPolicy;
import com.cloud.network.rules.LoadBalancer; import com.cloud.network.rules.LoadBalancer;
import com.cloud.network.rules.StickinessPolicy;
import com.cloud.uservm.UserVm; import com.cloud.uservm.UserVm;
public interface LoadBalancingRulesService { public interface LoadBalancingRulesService {
/** /**
* Create a load balancer rule from the given ipAddress/port to the given private port * 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 * @return the newly created LoadBalancerVO if successful, null otherwise
* @throws InsufficientAddressCapacityException * @throws InsufficientAddressCapacityException
*/ */
LoadBalancer createLoadBalancerRule(CreateLoadBalancerRuleCmd lb, boolean openFirewall) throws NetworkRuleConflictException, InsufficientAddressCapacityException; LoadBalancer createLoadBalancerRule(CreateLoadBalancerRuleCmd lb, boolean openFirewall) throws NetworkRuleConflictException, InsufficientAddressCapacityException;
LoadBalancer updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd); LoadBalancer updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd);
boolean deleteLoadBalancerRule(long lbRuleId, boolean apply); 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. * Create a stickiness policy to a load balancer from the given stickiness method name and parameters in
* @param cmd the command specifying the stickiness method name, params (name,value pairs), policy name and description. * (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 * @return the newly created stickiness policy if successfull, null otherwise
* @thows NetworkRuleConflictException * @thows NetworkRuleConflictException
*/ */
public StickinessPolicy createLBStickinessPolicy(CreateLBStickinessPolicyCmd cmd) throws NetworkRuleConflictException; public StickinessPolicy createLBStickinessPolicy(CreateLBStickinessPolicyCmd cmd) throws NetworkRuleConflictException;
public boolean applyLBStickinessPolicy(CreateLBStickinessPolicyCmd cmd) throws ResourceUnavailableException; public boolean applyLBStickinessPolicy(CreateLBStickinessPolicyCmd cmd) throws ResourceUnavailableException;
boolean deleteLBStickinessPolicy(long stickinessPolicyId); boolean deleteLBStickinessPolicy(long stickinessPolicyId);
/** /**
* Assign a virtual machine, or list of virtual machines, to a load balancer. * Assign a virtual machine, or list of virtual machines, to a load balancer.
*/ */
boolean assignToLoadBalancer(long lbRuleId, List<Long> vmIds); boolean assignToLoadBalancer(long lbRuleId, List<Long> vmIds);
boolean removeFromLoadBalancer(long lbRuleId, List<Long> vmIds); boolean removeFromLoadBalancer(long lbRuleId, List<Long> vmIds);
boolean applyLoadBalancerConfig(long lbRuleId) throws ResourceUnavailableException; 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 * @param cmd
* @return list of vm instances that have been or can be applied to a load balancer * @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 * 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 * by id, name, public ip, and vm instance id
* @return list of load balancers that match the criteria * @return list of load balancers that match the criteria
*/ */
List<? extends LoadBalancer> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd); List<? extends LoadBalancer> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd);
/** /**
* List stickiness policies based on the given criteria * 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. * @return list of stickiness policies that match the criteria.
*/ */
List<? extends StickinessPolicy> searchForLBStickinessPolicies(ListLBStickinessPoliciesCmd cmd); List<? extends StickinessPolicy> searchForLBStickinessPolicies(ListLBStickinessPoliciesCmd cmd);
List<LoadBalancingRule> listByNetworkId(long networkId); List<LoadBalancingRule> listByNetworkId(long networkId);
LoadBalancer findById(long LoadBalancer); LoadBalancer findById(long LoadBalancer);
} }

View File

@ -22,62 +22,62 @@ import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
public class OvsCreateGreTunnelAnswer extends Answer { public class OvsCreateGreTunnelAnswer extends Answer {
String hostIp; String hostIp;
String remoteIp; String remoteIp;
String bridge; String bridge;
String key; String key;
long from; long from;
long to; long to;
int port; int port;
public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details) { public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details) {
super(cmd, success, details); super(cmd, success, details);
} }
public OvsCreateGreTunnelAnswer(Command cmd, boolean success, public OvsCreateGreTunnelAnswer(Command cmd, boolean success,
String details, String hostIp, String bridge) { String details, String hostIp, String bridge) {
super(cmd, success, details); super(cmd, success, details);
OvsCreateGreTunnelCommand c = (OvsCreateGreTunnelCommand)cmd; OvsCreateGreTunnelCommand c = (OvsCreateGreTunnelCommand) cmd;
this.hostIp = hostIp; this.hostIp = hostIp;
this.bridge = bridge; this.bridge = bridge;
this.remoteIp = c.getRemoteIp(); this.remoteIp = c.getRemoteIp();
this.key = c.getKey(); this.key = c.getKey();
this.port = -1; this.port = -1;
this.from = c.getFrom(); this.from = c.getFrom();
this.to = c.getTo(); this.to = c.getTo();
} }
public OvsCreateGreTunnelAnswer(Command cmd, boolean success, public OvsCreateGreTunnelAnswer(Command cmd, boolean success,
String details, String hostIp, String bridge, int port) { String details, String hostIp, String bridge, int port) {
this(cmd, success, details, hostIp, bridge); this(cmd, success, details, hostIp, bridge);
this.port = port; this.port = port;
} }
public String getHostIp() { public String getHostIp() {
return hostIp; return hostIp;
} }
public String getRemoteIp() { public String getRemoteIp() {
return remoteIp; return remoteIp;
} }
public String getBridge() { public String getBridge() {
return bridge; return bridge;
} }
public String getKey() { public String getKey() {
return key; return key;
} }
public long getFrom() { public long getFrom() {
return from; return from;
} }
public long getTo() { public long getTo() {
return to; return to;
} }
public int getPort() { public int getPort() {
return port; return port;
} }
} }

View File

@ -21,36 +21,36 @@ package com.cloud.network.ovs;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
public class OvsCreateGreTunnelCommand extends Command { public class OvsCreateGreTunnelCommand extends Command {
String remoteIp; String remoteIp;
String key; String key;
long from; long from;
long to; long to;
@Override
public boolean executeInSequence() {
return true;
}
public OvsCreateGreTunnelCommand(String remoteIp, String key, long from, long to) { @Override
this.remoteIp = remoteIp; public boolean executeInSequence() {
this.key = key; return true;
this.from = from; }
this.to = to;
} public OvsCreateGreTunnelCommand(String remoteIp, String key, long from, long to) {
this.remoteIp = remoteIp;
public String getRemoteIp() { this.key = key;
return remoteIp; this.from = from;
} this.to = to;
}
public String getKey() {
return key; public String getRemoteIp() {
} return remoteIp;
}
public long getFrom() {
return from; public String getKey() {
} return key;
}
public long getTo() {
return to; public long getFrom() {
} return from;
}
public long getTo() {
return to;
}
} }

View File

@ -16,56 +16,56 @@
* *
*/ */
package com.cloud.network.ovs; package com.cloud.network.ovs;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
public class OvsCreateTunnelCommand extends Command { public class OvsCreateTunnelCommand extends Command {
String key; String key;
String remoteIp; String remoteIp;
Long from; Long from;
Long to; Long to;
long account; long account;
//for debug info // for debug info
String fromIp; String fromIp;
@Override @Override
public boolean executeInSequence() { public boolean executeInSequence() {
return true; return true;
} }
public OvsCreateTunnelCommand(String remoteIp, String key, Long from, Long to, long account, String fromIp) { public OvsCreateTunnelCommand(String remoteIp, String key, Long from, Long to, long account, String fromIp) {
this.remoteIp = remoteIp; this.remoteIp = remoteIp;
this.key = key; this.key = key;
this.from = from; this.from = from;
this.to = to; this.to = to;
this.account = account; this.account = account;
this.fromIp = fromIp; this.fromIp = fromIp;
} }
public String getKey() { public String getKey() {
return key; return key;
} }
public String getRemoteIp() { public String getRemoteIp() {
return remoteIp; return remoteIp;
} }
public Long getFrom() { public Long getFrom() {
return from; return from;
} }
public Long getTo() { public Long getTo() {
return to; return to;
} }
public long getAccount() { public long getAccount() {
return account; return account;
} }
public String getFromIp() { public String getFromIp() {
return fromIp; return fromIp;
} }
} }

View File

@ -21,18 +21,18 @@ package com.cloud.network.ovs;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
public class OvsDeleteFlowCommand extends Command { public class OvsDeleteFlowCommand extends Command {
String vmName; String vmName;
@Override
public boolean executeInSequence() {
return true;
}
public String getVmName() { @Override
return vmName; public boolean executeInSequence() {
} return true;
}
public OvsDeleteFlowCommand(String vmName) {
this.vmName = vmName; 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; import com.cloud.agent.api.Command;
public class OvsSetTagAndFlowAnswer extends Answer { public class OvsSetTagAndFlowAnswer extends Answer {
Long vmId; Long vmId;
Long seqno; Long seqno;
public OvsSetTagAndFlowAnswer(Command cmd, boolean success, String details) { public OvsSetTagAndFlowAnswer(Command cmd, boolean success, String details) {
super(cmd, success, details); super(cmd, success, details);
OvsSetTagAndFlowCommand c = (OvsSetTagAndFlowCommand)cmd; OvsSetTagAndFlowCommand c = (OvsSetTagAndFlowCommand) cmd;
this.vmId = c.getVmId(); this.vmId = c.getVmId();
this.seqno = Long.parseLong(c.getSeqNo()); this.seqno = Long.parseLong(c.getSeqNo());
} }
public Long getVmId() { public Long getVmId() {
return vmId; return vmId;
} }
public Long getSeqNo() { public Long getSeqNo() {
return seqno; return seqno;
} }
} }

View File

@ -21,42 +21,42 @@ package com.cloud.network.ovs;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
public class OvsSetTagAndFlowCommand extends Command { public class OvsSetTagAndFlowCommand extends Command {
String vlans; String vlans;
String vmName; String vmName;
String seqno; String seqno;
String tag; String tag;
Long vmId; Long vmId;
@Override @Override
public boolean executeInSequence() { public boolean executeInSequence() {
return true; return true;
} }
public String getSeqNo() { public String getSeqNo() {
return seqno; return seqno;
} }
public String getVlans() { public String getVlans() {
return vlans; return vlans;
} }
public String getVmName() { public String getVmName() {
return vmName; return vmName;
} }
public Long getVmId() { public Long getVmId() {
return vmId; return vmId;
} }
public String getTag() { public String getTag() {
return tag; return tag;
} }
public OvsSetTagAndFlowCommand(String vmName, String tag, String vlans, String seqno, Long vmId) { public OvsSetTagAndFlowCommand(String vmName, String tag, String vlans, String seqno, Long vmId) {
this.vmName = vmName; this.vmName = vmName;
this.tag = tag; this.tag = tag;
this.vlans = vlans; this.vlans = vlans;
this.seqno = seqno; this.seqno = seqno;
this.vmId = vmId; this.vmId = vmId;
} }
} }

View File

@ -26,50 +26,61 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account; import com.cloud.user.Account;
public interface RulesService { 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 * Creates a port forwarding rule between two ip addresses or between
* an ip address and a virtual machine. * 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 rule
* @param openFirewall TODO * 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. * @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; PortForwardingRule createPortForwardingRule(PortForwardingRule rule, Long vmId, boolean openFirewall) throws NetworkRuleConflictException;
/** /**
* Revokes a port forwarding rule * Revokes a port forwarding rule
* @param ruleId the id of the rule to revoke. *
* @param caller * @param ruleId
* the id of the rule to revoke.
* @param caller
* @return * @return
*/ */
boolean revokePortForwardingRule(long ruleId, boolean apply); boolean revokePortForwardingRule(long ruleId, boolean apply);
/** /**
* List port forwarding rules assigned to an ip address * 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 * @return list of port forwarding rules on the given address, empty list if no rules exist
*/ */
public List<? extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd cmd); public List<? extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd cmd);
boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException; boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
boolean enableStaticNat(long ipAddressId, long vmId) throws NetworkRuleConflictException, ResourceUnavailableException; boolean enableStaticNat(long ipAddressId, long vmId) throws NetworkRuleConflictException, ResourceUnavailableException;
PortForwardingRule getPortForwardigRule(long ruleId); PortForwardingRule getPortForwardigRule(long ruleId);
FirewallRule getFirewallRule(long ruleId); FirewallRule getFirewallRule(long ruleId);
StaticNatRule createStaticNatRule(StaticNatRule rule, boolean openFirewall) throws NetworkRuleConflictException; StaticNatRule createStaticNatRule(StaticNatRule rule, boolean openFirewall) throws NetworkRuleConflictException;
boolean revokeStaticNatRule(long ruleId, boolean apply); boolean revokeStaticNatRule(long ruleId, boolean apply);
boolean applyStaticNatRules(long ipAdddressId, Account caller) throws ResourceUnavailableException; boolean applyStaticNatRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
StaticNatRule buildStaticNatRule(FirewallRule rule); StaticNatRule buildStaticNatRule(FirewallRule rule);
List<String> getSourceCidrs(long ruleId); 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; import com.cloud.acl.ControlledEntity;
public interface StaticNatRule extends ControlledEntity, FirewallRule{ public interface StaticNatRule extends ControlledEntity, FirewallRule {
long getId(); long getId();
String getXid(); String getXid();
String getProtocol(); String getProtocol();
Integer getSourcePortStart(); Integer getSourcePortStart();
Integer getSourcePortEnd(); Integer getSourcePortEnd();
Purpose getPurpose(); Purpose getPurpose();
State getState(); State getState();
long getAccountId(); long getAccountId();
long getDomainId(); long getDomainId();
long getNetworkId(); long getNetworkId();
long getSourceIpAddressId(); long getSourceIpAddressId();
String getDestIpAddress(); String getDestIpAddress();

View File

@ -21,9 +21,8 @@ import java.util.List;
import com.cloud.utils.Pair; import com.cloud.utils.Pair;
/** /**
* Definition for a StickinessPolicy * Definition for a StickinessPolicy
*/ */
public interface StickinessPolicy { public interface StickinessPolicy {
@ -38,8 +37,8 @@ public interface StickinessPolicy {
public String getMethodName(); public String getMethodName();
public boolean isRevoke(); public boolean isRevoke();
public List<Pair<String, String>> getParams(); /* get params in Map <string,String> format */ public List<Pair<String, String>> getParams(); /* get params in Map <string,String> format */
public String getUuid(); public String getUuid();
} }

View File

@ -19,35 +19,34 @@ package com.cloud.offering;
import java.util.Date; import java.util.Date;
/** /**
* Represents a disk offering that specifies what the end user needs in * Represents a disk offering that specifies what the end user needs in
* the disk offering. * the disk offering.
* *
*/ */
public interface DiskOffering { public interface DiskOffering {
long getId(); long getId();
String getUniqueName(); String getUniqueName();
boolean getUseLocalStorage(); boolean getUseLocalStorage();
Long getDomainId(); Long getDomainId();
String getName(); String getName();
boolean getSystemUse(); boolean getSystemUse();
String getDisplayText(); String getDisplayText();
public String getTags(); public String getTags();
public String[] getTagsArray(); public String[] getTagsArray();
Date getCreated(); Date getCreated();
long getDiskSize(); long getDiskSize();
boolean isCustomized(); boolean isCustomized();
void setDiskSize(long diskSize); void setDiskSize(long diskSize);

View File

@ -22,29 +22,29 @@ import com.cloud.network.Networks.TrafficType;
/** /**
* Describes network offering * Describes network offering
* *
*/ */
public interface NetworkOffering { public interface NetworkOffering {
public enum Availability { public enum Availability {
Required, Required,
Optional Optional
} }
public enum State { public enum State {
Disabled, Disabled,
Enabled Enabled
} }
public final static String SystemPublicNetwork = "System-Public-Network"; public final static String SystemPublicNetwork = "System-Public-Network";
public final static String SystemControlNetwork = "System-Control-Network"; public final static String SystemControlNetwork = "System-Control-Network";
public final static String SystemManagementNetwork = "System-Management-Network"; public final static String SystemManagementNetwork = "System-Management-Network";
public final static String SystemStorageNetwork = "System-Storage-Network"; public final static String SystemStorageNetwork = "System-Storage-Network";
public final static String DefaultSharedNetworkOfferingWithSGService = "DefaultSharedNetworkOfferingWithSGService"; public final static String DefaultSharedNetworkOfferingWithSGService = "DefaultSharedNetworkOfferingWithSGService";
public final static String DefaultIsolatedNetworkOfferingWithSourceNatService = "DefaultIsolatedNetworkOfferingWithSourceNatService"; public final static String DefaultIsolatedNetworkOfferingWithSourceNatService = "DefaultIsolatedNetworkOfferingWithSourceNatService";
public final static String DefaultSharedNetworkOffering = "DefaultSharedNetworkOffering"; public final static String DefaultSharedNetworkOffering = "DefaultSharedNetworkOffering";
public final static String DefaultIsolatedNetworkOffering= "DefaultIsolatedNetworkOffering"; public final static String DefaultIsolatedNetworkOffering = "DefaultIsolatedNetworkOffering";
public final static String DefaultSharedEIPandELBNetworkOffering = "DefaultSharedNetscalerEIPandELBNetworkOffering"; public final static String DefaultSharedEIPandELBNetworkOffering = "DefaultSharedNetscalerEIPandELBNetworkOffering";
long getId(); long getId();
@ -53,32 +53,32 @@ public interface NetworkOffering {
* @return name for the network offering. * @return name for the network offering.
*/ */
String getName(); String getName();
/** /**
* @return text to display to the end user. * @return text to display to the end user.
*/ */
String getDisplayText(); String getDisplayText();
/** /**
* @return the rate in megabits per sec to which a VM's network interface is throttled to * @return the rate in megabits per sec to which a VM's network interface is throttled to
*/ */
Integer getRateMbps(); Integer getRateMbps();
/** /**
* @return the rate megabits per sec to which a VM's multicast&broadcast traffic is throttled to * @return the rate megabits per sec to which a VM's multicast&broadcast traffic is throttled to
*/ */
Integer getMulticastRateMbps(); Integer getMulticastRateMbps();
TrafficType getTrafficType(); TrafficType getTrafficType();
boolean getSpecifyVlan(); boolean getSpecifyVlan();
String getTags(); String getTags();
boolean isDefault(); boolean isDefault();
boolean isSystemOnly(); boolean isSystemOnly();
Availability getAvailability(); Availability getAvailability();
String getUniqueName(); String getUniqueName();
@ -86,22 +86,23 @@ public interface NetworkOffering {
void setState(State state); void setState(State state);
State getState(); State getState();
GuestType getGuestType(); GuestType getGuestType();
Long getServiceOfferingId(); Long getServiceOfferingId();
boolean getDedicatedLB(); boolean getDedicatedLB();
boolean getSharedSourceNat(); boolean getSharedSourceNat();
boolean getRedundantRouter(); boolean getRedundantRouter();
boolean isConserveMode(); boolean isConserveMode();
boolean getElasticIp(); boolean getElasticIp();
boolean getElasticLb(); boolean getElasticLb();
boolean getSpecifyIpRanges();
boolean getSpecifyIpRanges();
} }

View File

@ -18,31 +18,34 @@
package com.cloud.offering; 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. * 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: * There are three types of offerings:
* - Service Offering - package of computing power and the root disk. * - Service Offering - package of computing power and the root disk.
* - Disk Offering - package of disk performance and size specification. * - Disk Offering - package of disk performance and size specification.
* - Network Offering - package of services available on a network. * - Network Offering - package of services available on a network.
* *
*/ */
public interface OfferingManager { public interface OfferingManager {
/** /**
* Creates a service offering. * Creates a service offering.
*
* @return ServiceOffering * @return ServiceOffering
*/ */
ServiceOffering createServiceOffering(); ServiceOffering createServiceOffering();
/** /**
* Creates a disk offering. * Creates a disk offering.
*
* @return DiskOffering * @return DiskOffering
*/ */
DiskOffering createDiskOffering(); DiskOffering createDiskOffering();
/** /**
* Creates a network offering. * Creates a network offering.
*
* @return NetworkOffering * @return NetworkOffering
*/ */
NetworkOffering createNetworkOffering(); NetworkOffering createNetworkOffering();

View File

@ -20,7 +20,7 @@ package com.cloud.offering;
import java.util.Date; 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. * offered.
*/ */
public interface ServiceOffering { public interface ServiceOffering {
@ -28,36 +28,35 @@ public interface ServiceOffering {
local, local,
shared shared
} }
long getId(); long getId();
String getDisplayText(); String getDisplayText();
Date getCreated(); Date getCreated();
String getTags(); String getTags();
/** /**
* @return user readable description * @return user readable description
*/ */
String getName(); String getName();
/** /**
* @return is this a system service offering * @return is this a system service offering
*/ */
boolean getSystemUse(); boolean getSystemUse();
/** /**
* @return # of cpu. * @return # of cpu.
*/ */
int getCpu(); int getCpu();
/** /**
* @return speed in mhz * @return speed in mhz
*/ */
int getSpeed(); int getSpeed();
/** /**
* @return ram size in megabytes * @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? * @return Does this service plan offer VM to use CPU resources beyond the service offering limits?
*/ */
boolean getLimitCpuUse(); boolean getLimitCpuUse();
/** /**
* @return the rate in megabits per sec to which a VM's network interface is throttled to * @return the rate in megabits per sec to which a VM's network interface is throttled to
*/ */
Integer getRateMbps(); Integer getRateMbps();
/** /**
* @return the rate megabits per sec to which a VM's multicast&broadcast traffic is throttled to * @return the rate megabits per sec to which a VM's multicast&broadcast traffic is throttled to
*/ */
Integer getMulticastRateMbps(); Integer getMulticastRateMbps();
/** /**
* @return whether or not the service offering requires local storage * @return whether or not the service offering requires local storage
*/ */
boolean getUseLocalStorage(); boolean getUseLocalStorage();
Long getDomainId(); Long getDomainId();
/** /**
* @return tag that should be present on the host needed, optional parameter * @return tag that should be present on the host needed, optional parameter
*/ */
String getHostTag(); String getHostTag();
boolean getDefaultUse(); boolean getDefaultUse();
String getSystemVmType(); String getSystemVmType();
} }

View File

@ -26,18 +26,23 @@ import com.cloud.org.Managed.ManagedState;
public interface Cluster extends Grouping { public interface Cluster extends Grouping {
public static enum ClusterType { public static enum ClusterType {
CloudManaged, CloudManaged,
ExternalManaged; ExternalManaged;
}; };
long getId(); long getId();
String getName(); String getName();
long getDataCenterId(); long getDataCenterId();
long getPodId(); long getPodId();
HypervisorType getHypervisorType(); HypervisorType getHypervisorType();
ClusterType getClusterType(); ClusterType getClusterType();
AllocationState getAllocationState(); AllocationState getAllocationState();
ManagedState getManagedState(); ManagedState getManagedState();
} }

View File

@ -23,8 +23,13 @@ import com.cloud.api.Identity;
import com.cloud.domain.PartOf; import com.cloud.domain.PartOf;
public interface Project extends PartOf, Identity { public interface Project extends PartOf, Identity {
public enum State {Active, Disabled, Suspended} public enum State {
public enum ListProjectResourcesCriteria {ListProjectResourcesOnly, SkipProjectResources} Active, Disabled, Suspended
}
public enum ListProjectResourcesCriteria {
ListProjectResourcesOnly, SkipProjectResources
}
String getDisplayText(); String getDisplayText();
@ -37,7 +42,7 @@ public interface Project extends PartOf, Identity {
Date getRemoved(); Date getRemoved();
String getName(); String getName();
long getProjectAccountId(); long getProjectAccountId();
State getState(); State getState();

View File

@ -1,14 +1,15 @@
package com.cloud.projects; package com.cloud.projects;
public interface ProjectAccount { public interface ProjectAccount {
public enum Role {Admin, Regular}; public enum Role {
Admin, Regular
};
long getAccountId(); long getAccountId();
long getProjectId(); long getProjectId();
Role getAccountRole(); Role getAccountRole();
long getProjectAccountId(); long getProjectAccountId();
} }

View File

@ -4,8 +4,10 @@ import java.util.Date;
import com.cloud.acl.ControlledEntity; import com.cloud.acl.ControlledEntity;
public interface ProjectInvitation extends ControlledEntity{ public interface ProjectInvitation extends ControlledEntity {
public enum State {Pending, Completed, Expired, Declined} public enum State {
Pending, Completed, Expired, Declined
}
long getId(); long getId();

View File

@ -8,65 +8,71 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.projects.ProjectAccount.Role; import com.cloud.projects.ProjectAccount.Role;
import com.cloud.user.Account; import com.cloud.user.Account;
public interface ProjectService { public interface ProjectService {
/** /**
* Creates a new project * Creates a new project
* *
* @param name - project name * @param name
* @param displayText - project display text * - project name
* @param accountName - account name of the project owner * @param displayText
* @param domainId - domainid of the project owner * - 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 * @return the project if created successfully, null otherwise
* @throws ResourceAllocationException * @throws ResourceAllocationException
*/ */
Project createProject(String name, String displayText, String accountName, Long domainId) throws ResourceAllocationException; Project createProject(String name, String displayText, String accountName, Long domainId) throws ResourceAllocationException;
/** /**
* Deletes a project * Deletes a project
* *
* @param id - project id * @param id
* - project id
* @return true if the project was deleted successfully, false otherwise * @return true if the project was deleted successfully, false otherwise
*/ */
boolean deleteProject(long id); boolean deleteProject(long id);
/** /**
* Gets a project by id * Gets a project by id
* *
* @param id - project id * @param id
* - project id
* @return project object * @return project object
*/ */
Project getProject(long id); 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); 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); ProjectAccount assignAccountToProject(Project project, long accountId, Role accountRole);
Account getProjectOwner(long projectId); Account getProjectOwner(long projectId);
boolean unassignAccountFromProject(long projectId, long accountId); boolean unassignAccountFromProject(long projectId, long accountId);
Project findByProjectAccountId(long projectAccountId); Project findByProjectAccountId(long projectAccountId);
Project findByNameAndDomainId(String name, long domainId); Project findByNameAndDomainId(String name, long domainId);
Project updateProject(long id, String displayText, String newOwnerName) throws ResourceAllocationException; Project updateProject(long id, String displayText, String newOwnerName) throws ResourceAllocationException;
boolean addAccountToProject(long projectId, String accountName, String email); boolean addAccountToProject(long projectId, String accountName, String email);
boolean deleteAccountFromProject(long projectId, String accountName); boolean deleteAccountFromProject(long projectId, String accountName);
List<? extends ProjectAccount> listProjectAccounts(long projectId, String accountName, String role, Long startIndex, Long pageSizeVal); 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); boolean updateInvitation(long projectId, String accountName, String token, boolean accept);
Project activateProject(long projectId); Project activateProject(long projectId);
Project suspendProject(long projectId) throws ConcurrentOperationException, ResourceUnavailableException; Project suspendProject(long projectId) throws ConcurrentOperationException, ResourceUnavailableException;
Project enableProject(long projectId); Project enableProject(long projectId);
boolean deleteProjectInvitation(long invitationId); boolean deleteProjectInvitation(long invitationId);
} }

View File

@ -3,18 +3,17 @@ package com.cloud.resource;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.fsm.StateMachine; import com.cloud.utils.fsm.StateMachine;
public enum ResourceState { public enum ResourceState {
Creating, Creating,
Enabled, Enabled,
Disabled, Disabled,
PrepareForMaintenance, PrepareForMaintenance,
ErrorInMaintenance, ErrorInMaintenance,
Maintenance, Maintenance,
Error; Error;
public enum Event { public enum Event {
InternalCreated("Resource is created"), InternalCreated("Resource is created"),
Enable("Admin enables"), Enable("Admin enables"),
@ -26,54 +25,55 @@ public enum ResourceState {
UnableToMigrate("Management server migrates VM failed"), UnableToMigrate("Management server migrates VM failed"),
Error("An internal error happened"), Error("An internal error happened"),
DeleteHost("Admin delete a host"), DeleteHost("Admin delete a host"),
/* /*
* Below events don't cause resource state to change, they are merely * Below events don't cause resource state to change, they are merely
* for ClusterManager propagating event from one mgmt server to another * for ClusterManager propagating event from one mgmt server to another
*/ */
Unmanaged("Umanage a cluster"); Unmanaged("Umanage a cluster");
private final String comment; private final String comment;
private Event(String comment) { private Event(String comment) {
this.comment = comment; this.comment = comment;
} }
public String getDescription() { public String getDescription() {
return this.comment; return this.comment;
} }
public static Event toEvent(String e) { public static Event toEvent(String e) {
if (Enable.toString().equals(e)) { if (Enable.toString().equals(e)) {
return Enable; return Enable;
} else if (Disable.toString().equals(e)) { } else if (Disable.toString().equals(e)) {
return Disable; return Disable;
} }
return null; return null;
} }
} }
public ResourceState getNextState(Event a) { public ResourceState getNextState(Event a) {
return s_fsm.getNextState(this, a); return s_fsm.getNextState(this, a);
} }
public ResourceState[] getFromStates(Event a) { public ResourceState[] getFromStates(Event a) {
List<ResourceState> from = s_fsm.getFromStates(this, a); List<ResourceState> from = s_fsm.getFromStates(this, a);
return from.toArray(new ResourceState[from.size()]); return from.toArray(new ResourceState[from.size()]);
} }
public Set<Event> getPossibleEvents() { public Set<Event> getPossibleEvents() {
return s_fsm.getPossibleEvents(this); return s_fsm.getPossibleEvents(this);
} }
public static String[] toString(ResourceState... states) { public static String[] toString(ResourceState... states) {
String[] strs = new String[states.length]; 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(); strs[i] = states[i].toString();
} }
return strs; return strs;
} }
protected static final StateMachine<ResourceState, Event> s_fsm = new StateMachine<ResourceState, Event>(); protected static final StateMachine<ResourceState, Event> s_fsm = new StateMachine<ResourceState, Event>();
static { static {
s_fsm.addTransition(null, Event.InternalCreated, ResourceState.Enabled); 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.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface Param { public @interface Param {
String name() default ""; String name() default "";
String propName() default "";
String description() default ""; String propName() default "";
// 2 parameters below are used by cloudstack api String description() default "";
Class<?> responseObject() default Object.class;
boolean includeInApiDoc() default true; // 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"; 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 * 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. * 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); 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 * @param cmd
* @return List of Hosts * @return List of Hosts
@ -158,7 +160,8 @@ public interface ManagementService {
VirtualMachineTemplate updateTemplate(UpdateTemplateCmd cmd); 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" * "endDate"
* *
* @param c * @param c
@ -167,7 +170,8 @@ public interface ManagementService {
List<? extends Event> searchForEvents(ListEventsCmd c); 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" * "podId", "hostId"
* *
* @param cmd * @param cmd
@ -175,9 +179,9 @@ public interface ManagementService {
*/ */
List<? extends VirtualRouter> searchForRouters(ListRoutersCmd cmd); 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 * @param cmd
* the command that wraps the search criteria * the command that wraps the search criteria
@ -236,7 +240,8 @@ public interface ManagementService {
* List ISOs that match the specified criteria. * List ISOs that match the specified criteria.
* *
* @param cmd * @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. * parameters.
* @return list of ISOs * @return list of ISOs
*/ */
@ -246,7 +251,8 @@ public interface ManagementService {
* List templates that match the specified criteria. * List templates that match the specified criteria.
* *
* @param cmd * @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. * parameters.
* @return list of ISOs * @return list of ISOs
*/ */
@ -300,7 +306,8 @@ public interface ManagementService {
* Extracts the volume to a particular location. * Extracts the volume to a particular location.
* *
* @param cmd * @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) * id (the id of the volume)
* @throws URISyntaxException * @throws URISyntaxException
* @throws InternalErrorException * @throws InternalErrorException
@ -311,7 +318,9 @@ public interface ManagementService {
/** /**
* return an array of available hypervisors * return an array of available hypervisors
* @param zoneId TODO *
* @param zoneId
* TODO
* *
* @return an array of available hypervisors in the cloud * @return an array of available hypervisors in the cloud
*/ */
@ -381,7 +390,8 @@ public interface ManagementService {
* *
* @param cmd * @param cmd
* The api command class. * 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); SSHKeyPair createSSHKeyPair(CreateSSHKeyPairCmd cmd);
@ -406,12 +416,15 @@ public interface ManagementService {
Type findSystemVMTypeById(long instanceId); 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. * 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 * 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); 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 { public interface GuestOS {
long getId(); long getId();
String getName();
String getDisplayName(); String getName();
long getCategoryId();
String getDisplayName();
long getCategoryId();
} }

View File

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

View File

@ -16,14 +16,14 @@
* *
*/ */
package com.cloud.storage; package com.cloud.storage;
import java.util.Date; import java.util.Date;
import com.cloud.acl.ControlledEntity; import com.cloud.acl.ControlledEntity;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
public interface Snapshot extends ControlledEntity{ public interface Snapshot extends ControlledEntity {
public enum Type { public enum Type {
MANUAL, MANUAL,
RECURRING, RECURRING,
@ -33,52 +33,62 @@ public interface Snapshot extends ControlledEntity{
WEEKLY, WEEKLY,
MONTHLY; MONTHLY;
private int max = 8; private int max = 8;
public void setMax(int max) { public void setMax(int max) {
this.max = max; this.max = max;
} }
public int getMax() { public int getMax() {
return max; return max;
} }
public String toString() { public String toString() {
return this.name(); return this.name();
} }
public boolean equals(String snapshotType) { public boolean equals(String snapshotType) {
return this.toString().equalsIgnoreCase(snapshotType); return this.toString().equalsIgnoreCase(snapshotType);
} }
} }
public enum Status { public enum Status {
Creating, Creating,
CreatedOnPrimary, CreatedOnPrimary,
BackingUp, BackingUp,
BackedUp, BackedUp,
Error; Error;
public String toString() { public String toString() {
return this.name(); return this.name();
} }
public boolean equals(String status) { public boolean equals(String status) {
return this.toString().equalsIgnoreCase(status); return this.toString().equalsIgnoreCase(status);
} }
} }
public static final long MANUAL_POLICY_ID = 0L; public static final long MANUAL_POLICY_ID = 0L;
Long getId(); Long getId();
long getAccountId();
long getVolumeId(); long getAccountId();
String getPath();
String getName(); long getVolumeId();
Date getCreated();
Type getType(); String getPath();
String getName();
Date getCreated();
Type getType();
Status getStatus(); Status getStatus();
HypervisorType getHypervisorType(); HypervisorType getHypervisorType();
boolean isRecursive(); boolean isRecursive();
short getsnapshotType(); short getsnapshotType();
} }

View File

@ -28,46 +28,46 @@ public class Storage {
ISO(false, false, false), ISO(false, false, false),
OVA(true, true, true, "ova"), OVA(true, true, true, "ova"),
BAREMETAL(false, false, false); BAREMETAL(false, false, false);
private final boolean thinProvisioned; private final boolean thinProvisioned;
private final boolean supportSparse; private final boolean supportSparse;
private final boolean supportSnapshot; private final boolean supportSnapshot;
private final String fileExtension; private final String fileExtension;
private ImageFormat(boolean thinProvisioned, boolean supportSparse, boolean supportSnapshot) { private ImageFormat(boolean thinProvisioned, boolean supportSparse, boolean supportSnapshot) {
this.thinProvisioned = thinProvisioned; this.thinProvisioned = thinProvisioned;
this.supportSparse = supportSparse; this.supportSparse = supportSparse;
this.supportSnapshot = supportSnapshot; this.supportSnapshot = supportSnapshot;
fileExtension = null; fileExtension = null;
} }
private ImageFormat(boolean thinProvisioned, boolean supportSparse, boolean supportSnapshot, String fileExtension) { private ImageFormat(boolean thinProvisioned, boolean supportSparse, boolean supportSnapshot, String fileExtension) {
this.thinProvisioned = thinProvisioned; this.thinProvisioned = thinProvisioned;
this.supportSparse = supportSparse; this.supportSparse = supportSparse;
this.supportSnapshot = supportSnapshot; this.supportSnapshot = supportSnapshot;
this.fileExtension = fileExtension; this.fileExtension = fileExtension;
} }
public boolean isThinProvisioned() { public boolean isThinProvisioned() {
return thinProvisioned; return thinProvisioned;
} }
public boolean supportsSparse() { public boolean supportsSparse() {
return supportSparse; return supportSparse;
} }
public boolean supportSnapshot() { public boolean supportSnapshot() {
return supportSnapshot; return supportSnapshot;
} }
public String getFileExtension() { public String getFileExtension() {
if(fileExtension == null) if (fileExtension == null)
return toString().toLowerCase(); return toString().toLowerCase();
return fileExtension; return fileExtension;
} }
} }
public static enum FileSystem { public static enum FileSystem {
Unknown, Unknown,
ext3, ext3,
@ -82,48 +82,51 @@ public class Storage {
hfs, hfs,
hfsp hfsp
} }
public static enum TemplateType { public static enum TemplateType {
SYSTEM, /*routing, system vm template*/ SYSTEM, /* routing, system vm template */
BUILTIN, /*buildin template*/ BUILTIN, /* buildin template */
PERHOST, /* every host has this template, don't need to install it in secondary storage */ PERHOST, /* every host has this template, don't need to install it in secondary storage */
USER /* User supplied template/iso */ USER /* User supplied template/iso */
} }
public static enum StoragePoolType { public static enum StoragePoolType {
Filesystem(false), //local directory Filesystem(false), // local directory
NetworkFilesystem(true), //NFS or CIFS NetworkFilesystem(true), // NFS or CIFS
IscsiLUN(true), //shared LUN, with a clusterfs overlay IscsiLUN(true), // shared LUN, with a clusterfs overlay
Iscsi(true), //for e.g., ZFS Comstar Iscsi(true), // for e.g., ZFS Comstar
ISO(false), // for iso image ISO(false), // for iso image
LVM(false), // XenServer local LVM SR LVM(false), // XenServer local LVM SR
CLVM(true), CLVM(true),
SharedMountPoint(true), SharedMountPoint(true),
VMFS(true), // VMware VMFS storage VMFS(true), // VMware VMFS storage
PreSetup(true), // for XenServer, Storage Pool is set up by customers. PreSetup(true), // for XenServer, Storage Pool is set up by customers.
EXT(false), // XenServer local EXT SR EXT(false), // XenServer local EXT SR
OCFS2(true); OCFS2(true);
boolean shared; boolean shared;
StoragePoolType(boolean shared) { StoragePoolType(boolean shared) {
this.shared = shared; this.shared = shared;
} }
public boolean isShared() { public boolean isShared() {
return shared; return shared;
} }
} }
public static List<StoragePoolType> getNonSharedStoragePoolTypes(){
List<StoragePoolType> nonSharedStoragePoolTypes = new ArrayList<StoragePoolType>(); public static List<StoragePoolType> getNonSharedStoragePoolTypes() {
for(StoragePoolType storagePoolType : StoragePoolType.values()){ List<StoragePoolType> nonSharedStoragePoolTypes = new ArrayList<StoragePoolType>();
if (!storagePoolType.isShared()){ for (StoragePoolType storagePoolType : StoragePoolType.values()) {
nonSharedStoragePoolTypes.add(storagePoolType); if (!storagePoolType.isShared()) {
} nonSharedStoragePoolTypes.add(storagePoolType);
} }
return nonSharedStoragePoolTypes; }
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; import com.cloud.utils.component.Adapter;
/** /**
* StorageGuru understands about how to implement different * StorageGuru understands about how to implement different
* types of storage pools. * types of storage pools.
*/ */
public interface StorageGuru extends Adapter { public interface StorageGuru extends Adapter {
void createVolume(); void createVolume();
void prepareVolume(); void prepareVolume();
void destroyVolume(); void destroyVolume();
} }

View File

@ -19,37 +19,36 @@ package com.cloud.storage;
import java.util.Date; import java.util.Date;
import com.cloud.host.Status;
import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Storage.StoragePoolType;
/** /**
* @author chiradeep * @author chiradeep
* *
*/ */
public interface StoragePool { public interface StoragePool {
/** /**
* @return id of the pool. * @return id of the pool.
*/ */
long getId(); long getId();
/** /**
* @return name of the pool. * @return name of the pool.
*/ */
String getName(); String getName();
/*** /***
* *
* @return unique identifier * @return unique identifier
*/ */
String getUuid(); String getUuid();
/** /**
* @return the type of pool. * @return the type of pool.
*/ */
StoragePoolType getPoolType(); StoragePoolType getPoolType();
/** /**
* @return the date the pool first registered * @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. * @return the last time the state of this pool was modified.
*/ */
Date getUpdateTime(); Date getUpdateTime();
/** /**
* @return availability zone. * @return availability zone.
*/ */
long getDataCenterId(); long getDataCenterId();
/** /**
* @return capacity of storage poolin bytes * @return capacity of storage poolin bytes
*/ */
long getCapacityBytes(); long getCapacityBytes();
/** /**
* @return available storage in bytes * @return available storage in bytes
*/ */
long getAvailableBytes(); long getAvailableBytes();
Long getClusterId(); Long getClusterId();
/** /**
* @return the fqdn or ip address of the storage host * @return the fqdn or ip address of the storage host
*/ */
String getHostAddress(); String getHostAddress();
/** /**
* @return the filesystem path of the pool on the storage host (server) * @return the filesystem path of the pool on the storage host (server)
*/ */
String getPath(); String getPath();
/** /**
* @return the storage pool represents a shared storage resource * @return the storage pool represents a shared storage resource
*/ */
boolean isShared(); boolean isShared();
/** /**
* @return the storage pool represents a local storage resource * @return the storage pool represents a local storage resource
*/ */
@ -103,9 +99,9 @@ public interface StoragePool {
/** /**
* @return the storage pool status * @return the storage pool status
*/ */
StoragePoolStatus getStatus(); StoragePoolStatus getStatus();
int getPort(); int getPort();
Long getPodId(); Long getPodId();
} }

View File

@ -38,7 +38,8 @@ public interface StorageService {
* Create StoragePool based on uri * Create StoragePool based on uri
* *
* @param cmd * @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 * @return
* @throws ResourceInUseException * @throws ResourceInUseException
* @throws IllegalArgumentException * @throws IllegalArgumentException
@ -52,7 +53,8 @@ public interface StorageService {
* Creates the database object for a volume based on the given criteria * Creates the database object for a volume based on the given criteria
* *
* @param cmd * @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 * @return the volume object
* @throws PermissionDeniedException * @throws PermissionDeniedException
*/ */
@ -62,7 +64,8 @@ public interface StorageService {
* Creates the volume based on the given criteria * Creates the volume based on the given criteria
* *
* @param cmd * @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 * @return the volume object
*/ */
Volume createVolume(CreateVolumeCmd cmd); Volume createVolume(CreateVolumeCmd cmd);
@ -106,8 +109,8 @@ public interface StorageService {
public StoragePool getStoragePool(long id); 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 interface Swift {
public long getId(); public long getId();
public String getUrl(); public String getUrl();
public String getAccount(); public String getAccount();
public String getUserName(); public String getUserName();
public String getKey(); public String getKey();
public SwiftTO toSwiftTO(); public SwiftTO toSwiftTO();
} }

View File

@ -22,10 +22,18 @@ import java.util.Date;
public interface Upload { 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 Status {
public static enum Type {VOLUME, TEMPLATE, ISO} 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 Mode {FTP_UPLOAD, HTTP_DOWNLOAD} }
public static enum Type {
VOLUME, TEMPLATE, ISO
}
public static enum Mode {
FTP_UPLOAD, HTTP_DOWNLOAD
}
long getHostId(); long getHostId();
long getId(); long getId();
@ -57,5 +65,5 @@ public interface Upload {
String getInstallPath(); String getInstallPath();
void setInstallPath(String installPath); void setInstallPath(String installPath);
} }

View File

@ -21,47 +21,49 @@ import java.util.Date;
/** /**
* @author chiradeep * @author chiradeep
* *
*/ */
public interface VMTemplateStorageResourceAssoc { 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();; String getJobId();;
long getTemplateSize(); long getTemplateSize();
} }

View File

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

View File

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

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