You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2014/01/17 23:40:45 UTC
[43/50] [abbrv] Merge branch 'master' into rbac.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
index 6ea1181,5e087fd..ecd97c7
--- a/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/AccountJoinDaoImpl.java
@@@ -75,14 -70,14 +75,14 @@@ public class AccountJoinDaoImpl extend
accountResponse.setBytesReceived(account.getBytesReceived());
accountResponse.setBytesSent(account.getBytesSent());
- boolean accountIsAdmin = (account.getType() == Account.ACCOUNT_TYPE_ADMIN);
- setResourceLimits(account, accountIsAdmin, accountResponse);
+ boolean fullView = (view == ResponseView.Full);
+ setResourceLimits(account, fullView, accountResponse);
-
+
//get resource limits for projects
- long projectLimit = ApiDBUtils.findCorrectResourceLimit(account.getProjectLimit(), account.getType(), ResourceType.project);
- String projectLimitDisplay = (accountIsAdmin || projectLimit == -1) ? "Unlimited" : String.valueOf(projectLimit);
+ long projectLimit = ApiDBUtils.findCorrectResourceLimit(account.getProjectLimit(), account.getId(), ResourceType.project);
+ String projectLimitDisplay = (fullView || projectLimit == -1) ? "Unlimited" : String.valueOf(projectLimit);
long projectTotal = (account.getProjectTotal() == null) ? 0 : account.getProjectTotal();
- String projectAvail = (accountIsAdmin || projectLimit == -1) ? "Unlimited" : String.valueOf(projectLimit - projectTotal);
+ String projectAvail = (fullView || projectLimit == -1) ? "Unlimited" : String.valueOf(projectLimit - projectTotal);
accountResponse.setProjectLimit(projectLimitDisplay);
accountResponse.setProjectTotal(projectTotal);
accountResponse.setProjectAvailable(projectAvail);
@@@ -101,21 -96,17 +101,20 @@@
// set details
accountResponse.setDetails(ApiDBUtils.getAccountDetails(account.getId()));
accountResponse.setObjectName("account");
-
+
+ // add all the acl groups for an account
+ accountResponse.setGroups(_acctMgr.listAclGroupsByAccount(account.getId()));
+
return accountResponse;
}
-
@Override
- public void setResourceLimits(AccountJoinVO account, boolean accountIsAdmin, ResourceLimitAndCountResponse response) {
+ public void setResourceLimits(AccountJoinVO account, boolean fullView, ResourceLimitAndCountResponse response) {
// Get resource limits and counts
- long vmLimit = ApiDBUtils.findCorrectResourceLimit(account.getVmLimit(), account.getType(), ResourceType.user_vm);
- String vmLimitDisplay = (accountIsAdmin || vmLimit == -1) ? "Unlimited" : String.valueOf(vmLimit);
+ long vmLimit = ApiDBUtils.findCorrectResourceLimit(account.getVmLimit(), account.getId(), ResourceType.user_vm);
+ String vmLimitDisplay = (fullView || vmLimit == -1) ? "Unlimited" : String.valueOf(vmLimit);
long vmTotal = (account.getVmTotal() == null) ? 0 : account.getVmTotal();
- String vmAvail = (accountIsAdmin || vmLimit == -1) ? "Unlimited" : String.valueOf(vmLimit - vmTotal);
+ String vmAvail = (fullView || vmLimit == -1) ? "Unlimited" : String.valueOf(vmLimit - vmTotal);
response.setVmLimit(vmLimitDisplay);
response.setVmTotal(vmTotal);
response.setVmAvailable(vmAvail);
@@@ -204,21 -195,23 +203,23 @@@
response.setMemoryTotal(memoryTotal);
response.setMemoryAvailable(memoryAvail);
- //get resource limits for primary storage space and convert it from Bytes to GiB
- long primaryStorageLimit = ApiDBUtils.findCorrectResourceLimit(account.getPrimaryStorageLimit(), account.getType(), ResourceType.primary_storage);
- String primaryStorageLimitDisplay = (accountIsAdmin || primaryStorageLimit == -1) ? "Unlimited" : String.valueOf(primaryStorageLimit / ResourceType.bytesToGiB);
+ //get resource limits for primary storage space and convert it from Bytes to GiB
+ long primaryStorageLimit = ApiDBUtils.findCorrectResourceLimit(account.getPrimaryStorageLimit(), account.getId(), ResourceType.primary_storage);
+ String primaryStorageLimitDisplay = (fullView || primaryStorageLimit == -1) ? "Unlimited" : String.valueOf(primaryStorageLimit / ResourceType.bytesToGiB);
long primaryStorageTotal = (account.getPrimaryStorageTotal() == null) ? 0 : (account.getPrimaryStorageTotal() / ResourceType.bytesToGiB);
- String primaryStorageAvail =
- (accountIsAdmin || primaryStorageLimit == -1) ? "Unlimited" : String.valueOf((primaryStorageLimit / ResourceType.bytesToGiB) - primaryStorageTotal);
+ String primaryStorageAvail = (fullView || primaryStorageLimit == -1) ? "Unlimited" : String.valueOf((primaryStorageLimit / ResourceType.bytesToGiB) - primaryStorageTotal);
++
response.setPrimaryStorageLimit(primaryStorageLimitDisplay);
response.setPrimaryStorageTotal(primaryStorageTotal);
response.setPrimaryStorageAvailable(primaryStorageAvail);
//get resource limits for secondary storage space and convert it from Bytes to GiB
- long secondaryStorageLimit = ApiDBUtils.findCorrectResourceLimit(account.getSecondaryStorageLimit(), account.getType(), ResourceType.secondary_storage);
- String secondaryStorageLimitDisplay =
- (accountIsAdmin || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf(secondaryStorageLimit / ResourceType.bytesToGiB);
+ long secondaryStorageLimit = ApiDBUtils.findCorrectResourceLimit(account.getSecondaryStorageLimit(), account.getId(), ResourceType.secondary_storage);
+ String secondaryStorageLimitDisplay = (fullView || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf(secondaryStorageLimit / ResourceType.bytesToGiB);
long secondaryStorageTotal = (account.getSecondaryStorageTotal() == null) ? 0 : (account.getSecondaryStorageTotal() / ResourceType.bytesToGiB);
- String secondaryStorageAvail =
- (accountIsAdmin || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf((secondaryStorageLimit / ResourceType.bytesToGiB) - secondaryStorageTotal);
+ String secondaryStorageAvail = (fullView || secondaryStorageLimit == -1) ? "Unlimited" : String.valueOf((secondaryStorageLimit / ResourceType.bytesToGiB)
+ - secondaryStorageTotal);
++
response.setSecondaryStorageLimit(secondaryStorageLimitDisplay);
response.setSecondaryStorageTotal(secondaryStorageTotal);
response.setSecondaryStorageAvailable(secondaryStorageAvail);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
index 4bfad78,e3331d9..5f176b8
--- a/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java
@@@ -46,10 -43,7 +46,9 @@@ import com.cloud.utils.db.SearchCriteri
public class DataCenterJoinDaoImpl extends GenericDaoBase<DataCenterJoinVO, Long> implements DataCenterJoinDao {
public static final Logger s_logger = Logger.getLogger(DataCenterJoinDaoImpl.class);
-
private SearchBuilder<DataCenterJoinVO> dofIdSearch;
+ @Inject
+ public AccountManager _accountMgr;
protected DataCenterJoinDaoImpl() {
@@@ -57,13 -51,11 +56,11 @@@
dofIdSearch.and("id", dofIdSearch.entity().getId(), SearchCriteria.Op.EQ);
dofIdSearch.done();
- this._count = "select count(distinct id) from data_center_view WHERE ";
+ _count = "select count(distinct id) from data_center_view WHERE ";
}
-
-
@Override
- public ZoneResponse newDataCenterResponse(DataCenterJoinVO dataCenter, Boolean showCapacities) {
+ public ZoneResponse newDataCenterResponse(ResponseView view, DataCenterJoinVO dataCenter, Boolean showCapacities) {
Account account = CallContext.current().getCallingAccount();
ZoneResponse zoneResponse = new ZoneResponse();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
index 2f536d4,f8838d8..9594c01
--- a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java
@@@ -64,10 -63,9 +66,9 @@@ public class DomainRouterJoinDaoImpl ex
vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
vrIdSearch.done();
-- this._count = "select count(distinct id) from domain_router_view WHERE ";
++ _count = "select count(distinct id) from domain_router_view WHERE ";
}
-
@Override
public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, Account caller) {
DomainRouterResponse routerResponse = new DomainRouterResponse();
@@@ -79,9 -77,16 +80,17 @@@
routerResponse.setState(router.getState());
routerResponse.setIsRedundantRouter(router.isRedundantRouter());
routerResponse.setRedundantState(router.getRedundantState().toString());
+ if (router.getTemplateVersion() != null) {
+ String routerVersion = Version.trimRouterVersion(router.getTemplateVersion());
+ routerResponse.setVersion(routerVersion);
+ routerResponse.setRequiresUpgrade((Version.compare(routerVersion, VirtualNetworkApplianceService.MinVRVersion) < 0));
+ } else {
+ routerResponse.setVersion("UNKNOWN");
+ routerResponse.setRequiresUpgrade(true);
+ }
- if (caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_ADMIN) {
+ if (caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN
+ || _accountMgr.isRootAdmin(caller.getId())) {
if (router.getHostId() != null) {
routerResponse.setHostId(router.getHostUuid());
routerResponse.setHostName(router.getHostName());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/dao/TemplateJoinDao.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/TemplateJoinDao.java
index afd399c,cb1b130..298be4d
--- a/server/src/com/cloud/api/query/dao/TemplateJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/TemplateJoinDao.java
@@@ -23,7 -25,7 +23,10 @@@ import org.apache.cloudstack.api.respon
import com.cloud.api.query.vo.TemplateJoinVO;
import com.cloud.template.VirtualMachineTemplate;
++import com.cloud.utils.Pair;
++import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GenericDao;
++import com.cloud.utils.db.SearchCriteria;
public interface TemplateJoinDao extends GenericDao<TemplateJoinVO, Long> {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
index 8840da2,fedc13d..92f5110
--- a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
@@@ -44,7 -44,8 +44,9 @@@ import com.cloud.storage.VMTemplateHost
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.user.Account;
+import com.cloud.user.AccountService;
+ import com.cloud.utils.Pair;
+ import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
@@@ -97,25 -95,33 +98,24 @@@ public class TemplateJoinDaoImpl extend
_count = "select count(distinct temp_zone_pair) from template_view WHERE ";
}
- private String getTemplateStatus(TemplateJoinVO template) {
- boolean isAdmin = false;
- Account caller = CallContext.current().getCallingAccount();
- if ((caller == null) || BaseCmd.isAdmin(caller.getType())) {
- isAdmin = true;
- }
-
- // If the user is an Admin, add the template download status
+ private String getTemplateStatus(TemplateJoinVO template) {
String templateStatus = null;
- if (isAdmin || caller.getId() == template.getAccountId()) {
- // add download status
- if (template.getDownloadState() != Status.DOWNLOADED) {
- templateStatus = "Processing";
- if (template.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
- if (template.getDownloadPercent() == 100) {
- templateStatus = "Installing Template";
- } else {
- templateStatus = template.getDownloadPercent() + "% Downloaded";
- }
+ if (template.getDownloadState() != Status.DOWNLOADED) {
+ templateStatus = "Processing";
+ if (template.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
+ if (template.getDownloadPercent() == 100) {
+ templateStatus = "Installing Template";
} else {
- templateStatus = template.getErrorString();
+ templateStatus = template.getDownloadPercent() + "% Downloaded";
}
- } else if (template.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED) {
- templateStatus = "Download Complete";
} else {
- templateStatus = "Successfully Installed";
+ templateStatus = template.getErrorString();
}
+ } else if (template.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED) {
+ templateStatus = "Download Complete";
+ } else {
+ templateStatus = "Successfully Installed";
}
return templateStatus;
}
@@@ -159,16 -163,13 +157,15 @@@
templateResponse.setDomainId(template.getDomainUuid());
templateResponse.setDomainName(template.getDomainName());
-
// If the user is an Admin, add the template download status
- String templateStatus = getTemplateStatus(template);
- if (templateStatus != null) {
- templateResponse.setStatus(templateStatus);
+ if (view == ResponseView.Full) {
+ String templateStatus = getTemplateStatus(template);
+ if (templateStatus != null) {
+ templateResponse.setStatus(templateStatus);
+ }
}
- if ( template.getDataCenterId() > 0 ){
+ if (template.getDataCenterId() > 0) {
templateResponse.setZoneId(template.getDataCenterUuid());
templateResponse.setZoneName(template.getDataCenterName());
}
@@@ -249,16 -248,13 +244,13 @@@
return response;
}
-
-
-
@Override
- public TemplateResponse setTemplateResponse(TemplateResponse templateResponse, TemplateJoinVO template) {
+ public TemplateResponse setTemplateResponse(ResponseView view, TemplateResponse templateResponse, TemplateJoinVO template) {
// update details map
- if (template.getDetailName() != null){
+ if (template.getDetailName() != null) {
Map<String, String> details = templateResponse.getDetails();
- if ( details == null ){
+ if (details == null) {
details = new HashMap<String, String>();
}
details.put(template.getDetailName(), template.getDetailValue());
@@@ -311,10 -305,9 +301,9 @@@
isoResponse.setDomainId(iso.getDomainUuid());
isoResponse.setDomainName(iso.getDomainName());
-
Account caller = CallContext.current().getCallingAccount();
boolean isAdmin = false;
- if ((caller == null) || BaseCmd.isAdmin(caller.getType())) {
+ if ((caller == null) || _accountService.isAdmin(caller.getType())) {
isAdmin = true;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
index 76966e6,07449a2..92d6d54
--- a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
@@@ -60,9 -58,10 +61,12 @@@ public class UserVmJoinDaoImpl extends
public static final Logger s_logger = Logger.getLogger(UserVmJoinDaoImpl.class);
@Inject
- private ConfigurationDao _configDao;
+ private ConfigurationDao _configDao;
+ @Inject
+ public AccountManager _accountMgr;
+ @Inject
+ private UserVmDetailsDao _userVmDetailsDao;
+
private final SearchBuilder<UserVmJoinVO> VmDetailSearch;
private final SearchBuilder<UserVmJoinVO> activeVmByIsoSearch;
@@@ -91,12 -89,11 +94,11 @@@
return listBy(sc);
}
-
@Override
- public UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
+ public UserVmResponse newUserVmResponse(ResponseView view, String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
UserVmResponse userVmResponse = new UserVmResponse();
- if (userVm.getHypervisorType() != null){
+ if (userVm.getHypervisorType() != null) {
userVmResponse.setHypervisor(userVm.getHypervisorType().toString());
}
userVmResponse.setId(userVm.getUuid());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
index dfcf028,3604883..9512a60
--- a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
@@@ -70,14 -65,11 +69,11 @@@ public class VolumeJoinDaoImpl extends
volIdSearch.and("id", volIdSearch.entity().getId(), SearchCriteria.Op.EQ);
volIdSearch.done();
- this._count = "select count(distinct id) from volume_view WHERE ";
+ _count = "select count(distinct id) from volume_view WHERE ";
}
-
-
-
@Override
- public VolumeResponse newVolumeResponse(VolumeJoinVO volume) {
+ public VolumeResponse newVolumeResponse(ResponseView view, VolumeJoinVO volume) {
Account caller = CallContext.current().getCallingAccount();
VolumeResponse volResponse = new VolumeResponse();
@@@ -118,11 -110,8 +114,8 @@@
volResponse.setSize(volume.getVolumeStoreSize());
volResponse.setCreated(volume.getCreatedOnStore());
- // if (_accountMgr.isRootAdmin(caller.getId())
- // || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)
- if (view == ResponseView.Full) {
- volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getFormat()).toString());
- }
- if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)
++ if (view == ResponseView.Full)
+ volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(), volume.getFormat()).toString());
if (volume.getDownloadState() != Status.DOWNLOADED) {
String volumeStatus = "Processing";
if (volume.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
@@@ -149,8 -138,7 +142,7 @@@
}
}
- // if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN){
- if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN) {
+ if (view == ResponseView.Full) {
volResponse.setPath(volume.getPath());
}
@@@ -179,14 -166,17 +170,17 @@@
volResponse.setBytesWriteRate(volume.getBytesReadRate());
volResponse.setIopsReadRate(volume.getIopsWriteRate());
volResponse.setIopsWriteRate(volume.getIopsWriteRate());
-
+
}
-
+
// return hypervisor and storage pool info for ROOT and Resource domain only
- // if (_accountMgr.isRootAdmin(caller.getId()) || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
- if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
+ if (view == ResponseView.Full) {
- if (volume.getState() != Volume.State.UploadOp && volume.getHypervisorType() != null) {
- volResponse.setHypervisor(volume.getHypervisorType().toString());
+ if (volume.getState() != Volume.State.UploadOp) {
+ if (volume.getHypervisorType() != null) {
+ volResponse.setHypervisor(volume.getHypervisorType().toString());
+ } else {
+ volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(), volume.getFormat()).toString());
+ }
}
Long poolId = volume.getPoolId();
String poolName = (poolId == null) ? "none" : volume.getPoolName();
@@@ -230,10 -220,8 +224,8 @@@
return volResponse;
}
-
-
@Override
- public VolumeResponse setVolumeResponse(VolumeResponse volData, VolumeJoinVO vol) {
+ public VolumeResponse setVolumeResponse(ResponseView view, VolumeResponse volData, VolumeJoinVO vol) {
long tag_id = vol.getTagId();
if (tag_id > 0) {
ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/AffinityGroupJoinVO.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/vo/AffinityGroupJoinVO.java
index 0e731a3,047d1b3..d556c5c
--- a/server/src/com/cloud/api/query/vo/AffinityGroupJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/AffinityGroupJoinVO.java
@@@ -193,10 -192,4 +193,9 @@@ public class AffinityGroupJoinVO extend
return aclType;
}
+ @Override
+ public AclEntityType getEntityType() {
+ return AclEntityType.AffinityGroup;
+ }
+
}
-
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/AsyncJobJoinVO.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/vo/AsyncJobJoinVO.java
index b1cd5e3,e225310..d657bd4
--- a/server/src/com/cloud/api/query/vo/AsyncJobJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/AsyncJobJoinVO.java
@@@ -31,75 -32,75 +31,74 @@@ import org.apache.cloudstack.api.ApiCom
import com.cloud.utils.db.GenericDao;
@Entity
-@Table(name = "async_job_view")
-public class AsyncJobJoinVO extends BaseViewVO implements InternalIdentity, Identity {
-
+@Table(name="async_job_view")
+public class AsyncJobJoinVO extends BaseViewVO implements ControlledViewEntity { //InternalIdentity, Identity {
-
@Id
- @Column(name="id")
+ @Column(name = "id")
private long id;
- @Column(name="uuid")
+ @Column(name = "uuid")
private String uuid;
- @Column(name="account_id")
+ @Column(name = "account_id")
private long accountId;
- @Column(name="account_uuid")
+ @Column(name = "account_uuid")
private String accountUuid;
- @Column(name="account_name")
+ @Column(name = "account_name")
private String accountName = null;
- @Column(name="account_type")
+ @Column(name = "account_type")
private short accountType;
- @Column(name="domain_id")
+ @Column(name = "domain_id")
private long domainId;
- @Column(name="domain_uuid")
+ @Column(name = "domain_uuid")
private String domainUuid;
- @Column(name="domain_name")
+ @Column(name = "domain_name")
private String domainName = null;
- @Column(name="domain_path")
+ @Column(name = "domain_path")
private String domainPath = null;
- @Column(name="user_id")
+ @Column(name = "user_id")
private long userId;
- @Column(name="user_uuid")
+ @Column(name = "user_uuid")
private String userUuid;
- @Column(name="job_cmd")
+ @Column(name = "job_cmd")
private String cmd;
- @Column(name="job_status")
+ @Column(name = "job_status")
private int status;
- @Column(name="job_process_status")
+ @Column(name = "job_process_status")
private int processStatus;
- @Column(name="job_result_code")
+ @Column(name = "job_result_code")
private int resultCode;
- @Column(name="job_result", length=65535)
+ @Column(name = "job_result", length = 65535)
private String result;
- @Column(name=GenericDao.CREATED_COLUMN)
+ @Column(name = GenericDao.CREATED_COLUMN)
private Date created;
- @Column(name=GenericDao.REMOVED_COLUMN)
+ @Column(name = GenericDao.REMOVED_COLUMN)
private Date removed;
- @Enumerated(value=EnumType.STRING)
- @Column(name="instance_type", length=64)
+ @Enumerated(value = EnumType.STRING)
+ @Column(name = "instance_type", length = 64)
private ApiCommandJobType instanceType;
- @Column(name="instance_id", length=64)
+ @Column(name = "instance_id", length = 64)
private Long instanceId;
- @Column(name="instance_uuid")
+ @Column(name = "instance_uuid")
private String instanceUuid;
public AsyncJobJoinVO() {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/EventJoinVO.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/InstanceGroupJoinVO.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/ProjectInvitationJoinVO.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/ResourceTagJoinVO.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/SecurityGroupJoinVO.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/vo/TemplateJoinVO.java
index 34cbb7a,c096279..e395b18
--- a/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
@@@ -35,6 -35,6 +35,7 @@@ import com.cloud.server.ResourceTag.Res
import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
++import com.cloud.template.VirtualMachineTemplate.State;
import com.cloud.utils.db.GenericDao;
@Entity
@@@ -534,8 -538,5 +539,12 @@@ public class TemplateJoinVO extends Bas
return tempZonePair;
}
- public State getTemplateState() { return templateState; }
++ public State getTemplateState() {
++ return templateState;
++ }
++
+ @Override
+ public AclEntityType getEntityType() {
+ return AclEntityType.VirtualMachineTemplate;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/response/ApiResponseSerializer.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/response/ApiResponseSerializer.java
index 9631850,d8b728a..97836f7
--- a/server/src/com/cloud/api/response/ApiResponseSerializer.java
+++ b/server/src/com/cloud/api/response/ApiResponseSerializer.java
@@@ -99,8 -97,8 +99,8 @@@ public class ApiResponseSerializer
sb.append(", ").append(jsonStr);
}
sb.append(" ] }");
- } else {
+ } else {
- if (!nonZeroCount){
+ if (!nonZeroCount) {
sb.append("{");
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/api/response/SecurityGroupResultObject.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/response/SecurityGroupResultObject.java
index 9ed8fe8,9697495..e618da5
--- a/server/src/com/cloud/api/response/SecurityGroupResultObject.java
+++ b/server/src/com/cloud/api/response/SecurityGroupResultObject.java
@@@ -21,8 -21,9 +21,10 @@@ import java.util.HashMap
import java.util.List;
import java.util.Map;
+import org.apache.cloudstack.acl.AclEntityType;
import org.apache.cloudstack.acl.ControlledEntity;
+ import org.apache.cloudstack.api.InternalIdentity;
+
import com.cloud.api.ApiDBUtils;
import com.cloud.network.security.SecurityGroup;
import com.cloud.network.security.SecurityGroupRules;
@@@ -62,9 -63,10 +64,10 @@@ public class SecurityGroupResultObject
this.domainId = domainId;
this.accountId = accountId;
this.accountName = accountName;
-- this.securityGroupRules = ingressRules;
++ securityGroupRules = ingressRules;
}
+ @Override
public long getId() {
return id;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/929fbaba/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index b7ffbfc,9d148fa..ac991d2
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@@ -35,6 -36,6 +36,8 @@@ import javax.ejb.Local
import javax.inject.Inject;
import javax.naming.ConfigurationException;
++import org.apache.log4j.Logger;
++
import org.apache.cloudstack.acl.SecurityChecker;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupService;
@@@ -79,10 -81,9 +83,8 @@@ import org.apache.cloudstack.region.Reg
import org.apache.cloudstack.region.RegionVO;
import org.apache.cloudstack.region.dao.RegionDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
- import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
--import org.apache.log4j.Logger;
import com.cloud.alert.AlertManager;
import com.cloud.api.ApiDBUtils;
@@@ -619,14 -597,21 +598,21 @@@ public class ConfigurationManagerImpl e
Long clusterId = cmd.getClusterId();
Long storagepoolId = cmd.getStoragepoolId();
Long accountId = cmd.getAccountId();
- CallContext.current().setEventDetails(
- " Name: " + name + " New Value: "
- + (((name.toLowerCase()).contains("password")) ? "*****" : (((value == null) ? "" : value))));
+ CallContext.current().setEventDetails(" Name: " + name + " New Value: " + (((name.toLowerCase()).contains("password")) ? "*****" : (((value == null) ? "" : value))));
// check if config value exists
ConfigurationVO config = _configDao.findByName(name);
+ String catergory = null;
+
+ // FIX ME - All configuration parameters are not moved from config.java to configKey
if (config == null) {
+ if (_configDepot.get(name) == null) {
+ s_logger.warn("Probably the component manager where configuration variable " + name + " is defined needs to implement Configurable interface");
- throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist");
- }
+ throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist");
+ }
+ catergory = _configDepot.get(name).category();
+ } else {
+ catergory = config.getCategory();
+ }
if (value == null) {
return _configDao.findByName(name);
@@@ -996,45 -968,43 +969,43 @@@
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
- // Delete private ip addresses for the pod if there are any
+ // Delete private ip addresses for the pod if there are any
- List<DataCenterIpAddressVO> privateIps = _privateIpAddressDao.listByPodIdDcId(Long.valueOf(podId),
- pod.getDataCenterId());
+ List<DataCenterIpAddressVO> privateIps = _privateIpAddressDao.listByPodIdDcId(Long.valueOf(podId), pod.getDataCenterId());
- if (!privateIps.isEmpty()) {
- if (!(_privateIpAddressDao.deleteIpAddressByPod(podId))) {
- throw new CloudRuntimeException("Failed to cleanup private ip addresses for pod " + podId);
- }
- }
+ if (!privateIps.isEmpty()) {
+ if (!(_privateIpAddressDao.deleteIpAddressByPod(podId))) {
+ throw new CloudRuntimeException("Failed to cleanup private ip addresses for pod " + podId);
+ }
+ }
- // Delete link local ip addresses for the pod
+ // Delete link local ip addresses for the pod
- List<DataCenterLinkLocalIpAddressVO> localIps = _LinkLocalIpAllocDao.listByPodIdDcId(podId,
- pod.getDataCenterId());
+ List<DataCenterLinkLocalIpAddressVO> localIps = _linkLocalIpAllocDao.listByPodIdDcId(podId, pod.getDataCenterId());
- if (!localIps.isEmpty()) {
+ if (!localIps.isEmpty()) {
- if (!(_LinkLocalIpAllocDao.deleteIpAddressByPod(podId))) {
+ if (!(_linkLocalIpAllocDao.deleteIpAddressByPod(podId))) {
- throw new CloudRuntimeException("Failed to cleanup private ip addresses for pod " + podId);
- }
- }
+ throw new CloudRuntimeException("Failed to cleanup private ip addresses for pod " + podId);
+ }
+ }
- // Delete vlans associated with the pod
- List<? extends Vlan> vlans = _networkModel.listPodVlans(podId);
- if (vlans != null && !vlans.isEmpty()) {
- for (Vlan vlan : vlans) {
- _vlanDao.remove(vlan.getId());
- }
- }
+ // Delete vlans associated with the pod
+ List<? extends Vlan> vlans = _networkModel.listPodVlans(podId);
+ if (vlans != null && !vlans.isEmpty()) {
+ for (Vlan vlan : vlans) {
+ _vlanDao.remove(vlan.getId());
+ }
+ }
- // Delete corresponding capacity records
- _capacityDao.removeBy(null, null, podId, null, null);
+ // Delete corresponding capacity records
+ _capacityDao.removeBy(null, null, podId, null, null);
- // Delete the pod
- if (!(_podDao.remove(podId))) {
- throw new CloudRuntimeException("Failed to delete pod " + podId);
- }
+ // Delete the pod
+ if (!(_podDao.remove(podId))) {
+ throw new CloudRuntimeException("Failed to delete pod " + podId);
+ }
- // remove from dedicated resources
- DedicatedResourceVO dr = _dedicatedDao.findByPodId(podId);
- if (dr != null) {
- _dedicatedDao.remove(dr.getId());
- }
+ // remove from dedicated resources
+ DedicatedResourceVO dr = _dedicatedDao.findByPodId(podId);
+ if (dr != null) {
+ _dedicatedDao.remove(dr.getId());
+ }
}
});
@@@ -1535,25 -1494,24 +1496,24 @@@
boolean success = _zoneDao.remove(zoneId);
- if (success) {
- // delete all capacity records for the zone
- _capacityDao.removeBy(null, zoneId, null, null, null);
- // remove from dedicated resources
- DedicatedResourceVO dr = _dedicatedDao.findByZoneId(zoneId);
- if (dr != null) {
- _dedicatedDao.remove(dr.getId());
- // find the group associated and check if there are any more
- // resources under that group
+ if (success) {
+ // delete all capacity records for the zone
+ _capacityDao.removeBy(null, zoneId, null, null, null);
+ // remove from dedicated resources
+ DedicatedResourceVO dr = _dedicatedDao.findByZoneId(zoneId);
+ if (dr != null) {
+ _dedicatedDao.remove(dr.getId());
+ // find the group associated and check if there are any more
+ // resources under that group
- List<DedicatedResourceVO> resourcesInGroup = _dedicatedDao.listByAffinityGroupId(dr
- .getAffinityGroupId());
+ List<DedicatedResourceVO> resourcesInGroup = _dedicatedDao.listByAffinityGroupId(dr.getAffinityGroupId());
- if (resourcesInGroup.isEmpty()) {
- // delete the group
- _affinityGroupService.deleteAffinityGroup(dr.getAffinityGroupId(), null, null, null);
- }
- }
+ if (resourcesInGroup.isEmpty()) {
+ // delete the group
+ _affinityGroupService.deleteAffinityGroup(dr.getAffinityGroupId(), null, null, null);
}
+ }
+ }
- return success;
+ return success;
}
});
}
@@@ -1676,10 -1634,9 +1636,9 @@@
}
boolean checkForDuplicates = !zoneName.equals(oldZoneName);
- checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates, null,
- allocationStateStr, ip6Dns1, ip6Dns2);// not allowing updating
+ checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates, null, allocationStateStr, ip6Dns1, ip6Dns2);// not allowing updating
- // domain associated with
- // a zone, once created
+ // domain associated with
+ // a zone, once created
zone.setName(zoneName);
zone.setDns1(dns1);
@@@ -1704,81 -1661,78 +1663,78 @@@
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
- Map<String, String> updatedDetails = new HashMap<String, String>();
- _zoneDao.loadDetails(zone);
- if (zone.getDetails() != null) {
- updatedDetails.putAll(zone.getDetails());
- }
- updatedDetails.putAll(newDetails);
- zone.setDetails(updatedDetails);
-
- if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
- Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
-
- if (allocationState == Grouping.AllocationState.Enabled) {
- // check if zone has necessary trafficTypes before enabling
- try {
- PhysicalNetwork mgmtPhyNetwork;
- // zone should have a physical network with management
- // traffiType
+ Map<String, String> updatedDetails = new HashMap<String, String>();
+ _zoneDao.loadDetails(zone);
+ if (zone.getDetails() != null) {
+ updatedDetails.putAll(zone.getDetails());
+ }
+ updatedDetails.putAll(newDetails);
+ zone.setDetails(updatedDetails);
+
+ if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
+ Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
+
+ if (allocationState == Grouping.AllocationState.Enabled) {
+ // check if zone has necessary trafficTypes before enabling
+ try {
+ PhysicalNetwork mgmtPhyNetwork;
+ // zone should have a physical network with management
+ // traffiType
- mgmtPhyNetwork = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId,
- TrafficType.Management);
+ mgmtPhyNetwork = _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Management);
- if (NetworkType.Advanced == zone.getNetworkType() && !zone.isSecurityGroupEnabled()) {
- // advanced zone without SG should have a physical
- // network with public Thpe
- _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public);
- }
-
- try {
- _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Storage);
- } catch (InvalidParameterValueException noStorage) {
+ if (NetworkType.Advanced == zone.getNetworkType() && !zone.isSecurityGroupEnabled()) {
+ // advanced zone without SG should have a physical
+ // network with public Thpe
+ _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Public);
+ }
+
+ try {
+ _networkModel.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Storage);
+ } catch (InvalidParameterValueException noStorage) {
- PhysicalNetworkTrafficTypeVO mgmtTraffic = _trafficTypeDao.findBy(mgmtPhyNetwork.getId(),
- TrafficType.Management);
- _networkSvc.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(),
- TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(),
- mgmtTraffic.getKvmNetworkLabel(), mgmtTraffic.getVmwareNetworkLabel(),
- mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan());
- s_logger.info("No storage traffic type was specified by admin, create default storage traffic on physical network "
- + mgmtPhyNetwork.getId() + " with same configure of management traffic type");
+ PhysicalNetworkTrafficTypeVO mgmtTraffic = _trafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Management);
+ _networkSvc.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(), TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(),
+ mgmtTraffic.getKvmNetworkLabel(), mgmtTraffic.getVmwareNetworkLabel(), mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan(),
+ mgmtTraffic.getHypervNetworkLabel());
+ s_logger.info("No storage traffic type was specified by admin, create default storage traffic on physical network " + mgmtPhyNetwork.getId()
+ + " with same configure of management traffic type");
- }
- } catch (InvalidParameterValueException ex) {
- throw new InvalidParameterValueException("Cannot enable this Zone since: " + ex.getMessage());
- }
}
- _capacityDao.updateCapacityState(zone.getId(), null, null, null, allocationStateStr);
- zone.setAllocationState(allocationState);
+ } catch (InvalidParameterValueException ex) {
+ throw new InvalidParameterValueException("Cannot enable this Zone since: " + ex.getMessage());
}
+ }
+ _capacityDao.updateCapacityState(zone.getId(), null, null, null, allocationStateStr);
+ zone.setAllocationState(allocationState);
+ }
- if (dhcpProvider != null) {
- zone.setDhcpProvider(dhcpProvider);
- }
+ if (dhcpProvider != null) {
+ zone.setDhcpProvider(dhcpProvider);
+ }
-
+
- // update a private zone to public; not vice versa
- if (isPublic != null && isPublic) {
- zone.setDomainId(null);
- zone.setDomain(null);
-
- // release the dedication for this zone
- DedicatedResourceVO resource = _dedicatedDao.findByZoneId(zoneId);
- Long resourceId = null;
- if (resource != null) {
- resourceId = resource.getId();
- if (!_dedicatedDao.remove(resourceId)) {
- throw new CloudRuntimeException("Failed to delete dedicated Zone Resource " + resourceId);
- }
- // find the group associated and check if there are any more
- // resources under that group
- List<DedicatedResourceVO> resourcesInGroup = _dedicatedDao.listByAffinityGroupId(resource.getAffinityGroupId());
- if (resourcesInGroup.isEmpty()) {
- // delete the group
- _affinityGroupService.deleteAffinityGroup(resource.getAffinityGroupId(), null, null, null);
- }
- }
- }
+ // update a private zone to public; not vice versa
+ if (isPublic != null && isPublic) {
+ zone.setDomainId(null);
+ zone.setDomain(null);
- if (!_zoneDao.update(zoneId, zone)) {
- throw new CloudRuntimeException("Failed to edit zone. Please contact Cloud Support.");
+ // release the dedication for this zone
+ DedicatedResourceVO resource = _dedicatedDao.findByZoneId(zoneId);
+ Long resourceId = null;
+ if (resource != null) {
+ resourceId = resource.getId();
+ if (!_dedicatedDao.remove(resourceId)) {
+ throw new CloudRuntimeException("Failed to delete dedicated Zone Resource " + resourceId);
}
+ // find the group associated and check if there are any more
+ // resources under that group
+ List<DedicatedResourceVO> resourcesInGroup = _dedicatedDao.listByAffinityGroupId(resource.getAffinityGroupId());
+ if (resourcesInGroup.isEmpty()) {
+ // delete the group
+ _affinityGroupService.deleteAffinityGroup(resource.getAffinityGroupId(), null, null, null);
+ }
+ }
+ }
+
+ if (!_zoneDao.update(zoneId, zone)) {
+ throw new CloudRuntimeException("Failed to edit zone. Please contact Cloud Support.");
+ }
}
});
@@@ -1814,38 -1766,35 +1768,35 @@@
byte[] bytes = (zoneName + System.currentTimeMillis()).getBytes();
String zoneToken = UUID.nameUUIDFromBytes(bytes).toString();
- // Create the new zone in the database
+ // Create the new zone in the database
- final DataCenterVO zoneFinal = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, guestCidr,
- domain, domainId, zoneType, zoneToken, networkDomain, isSecurityGroupEnabled,
- isLocalStorageEnabled,
- ip6Dns1, ip6Dns2);
+ final DataCenterVO zoneFinal = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, guestCidr, domain, domainId, zoneType, zoneToken, networkDomain,
+ isSecurityGroupEnabled, isLocalStorageEnabled, ip6Dns1, ip6Dns2);
- if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
- Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
+ if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
+ Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
zoneFinal.setAllocationState(allocationState);
- } else {
- // Zone will be disabled since 3.0. Admin should enable it after
- // physical network and providers setup.
+ } else {
+ // Zone will be disabled since 3.0. Admin should enable it after
+ // physical network and providers setup.
zoneFinal.setAllocationState(Grouping.AllocationState.Disabled);
- }
+ }
return Transaction.execute(new TransactionCallback<DataCenterVO>() {
@Override
public DataCenterVO doInTransaction(TransactionStatus status) {
DataCenterVO zone = _zoneDao.persist(zoneFinal);
- if (domainId != null) {
- // zone is explicitly dedicated to this domain
- // create affinity group associated and dedicate the zone.
- AffinityGroup group = createDedicatedAffinityGroup(null, domainId, null);
+ if (domainId != null) {
+ // zone is explicitly dedicated to this domain
+ // create affinity group associated and dedicate the zone.
+ AffinityGroup group = createDedicatedAffinityGroup(null, domainId, null);
- DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(zone.getId(), null, null, null,
- domainId, null, group.getId());
+ DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(zone.getId(), null, null, null, domainId, null, group.getId());
- _dedicatedDao.persist(dedicatedResource);
- }
+ _dedicatedDao.persist(dedicatedResource);
+ }
- // Create default system networks
- createDefaultSystemNetworks(zone.getId());
+ // Create default system networks
+ createDefaultSystemNetworks(zone.getId());
- return zone;
- }
+ return zone;
+ }
});
}
@@@ -2684,26 -2604,28 +2607,28 @@@
String newVlanNetmask = newVlanNetmaskFinal;
String newVlanGateway = newVlanGatewayFinal;
- if ((sameSubnet == null || sameSubnet.first() == false) && (network.getTrafficType()== TrafficType.Guest) && (network.getGuestType() == GuestType.Shared) && (_vlanDao.listVlansByNetworkId(networkId) != null)) {
- Map<Capability, String> dhcpCapabilities = _networkSvc.getNetworkOfferingServiceCapabilities(_networkOfferingDao.findById(network.getNetworkOfferingId()), Service.Dhcp);
+ if ((sameSubnet == null || sameSubnet.first() == false) && (network.getTrafficType() == TrafficType.Guest) && (network.getGuestType() == GuestType.Shared)
+ && (_vlanDao.listVlansByNetworkId(networkId) != null)) {
+ Map<Capability, String> dhcpCapabilities = _networkSvc.getNetworkOfferingServiceCapabilities(_networkOfferingDao.findById(network.getNetworkOfferingId()),
+ Service.Dhcp);
- String supportsMultipleSubnets = dhcpCapabilities.get(Capability.DhcpAccrossMultipleSubnets);
- if (supportsMultipleSubnets == null || !Boolean.valueOf(supportsMultipleSubnets)) {
- throw new InvalidParameterValueException("The Dhcp serivice provider for this network dose not support the dhcp across multiple subnets");
- }
- s_logger.info("adding a new subnet to the network " + network.getId());
- } else if (sameSubnet != null) {
- // if it is same subnet the user might not send the vlan and the
- // netmask details. so we are
- // figuring out while validation and setting them here.
- newVlanGateway = sameSubnet.second().first();
- newVlanNetmask = sameSubnet.second().second();
- }
+ String supportsMultipleSubnets = dhcpCapabilities.get(Capability.DhcpAccrossMultipleSubnets);
+ if (supportsMultipleSubnets == null || !Boolean.valueOf(supportsMultipleSubnets)) {
+ throw new InvalidParameterValueException("The Dhcp serivice provider for this network dose not support the dhcp across multiple subnets");
+ }
+ s_logger.info("adding a new subnet to the network " + network.getId());
+ } else if (sameSubnet != null) {
+ // if it is same subnet the user might not send the vlan and the
+ // netmask details. so we are
+ // figuring out while validation and setting them here.
+ newVlanGateway = sameSubnet.second().first();
+ newVlanNetmask = sameSubnet.second().second();
+ }
- Vlan vlan = createVlanAndPublicIpRange(zoneId, networkId, physicalNetworkId, forVirtualNetwork, podId, startIP,
- endIP, newVlanGateway, newVlanNetmask, vlanId, vlanOwner, startIPv6, endIPv6, ip6Gateway, ip6Cidr);
+ Vlan vlan = createVlanAndPublicIpRange(zoneId, networkId, physicalNetworkId, forVirtualNetwork, podId, startIP, endIP, newVlanGateway, newVlanNetmask, vlanId,
+ vlanOwner, startIPv6, endIPv6, ip6Gateway, ip6Cidr);
- // create an entry in the nic_secondary table. This will be the new
- // gateway that will be configured on the corresponding routervm.
- return vlan;
- }
+ // create an entry in the nic_secondary table. This will be the new
+ // gateway that will be configured on the corresponding routervm.
+ return vlan;
+ }
});
}
@@@ -3052,42 -2954,40 +2957,40 @@@
return Transaction.execute(new TransactionCallback<VlanVO>() {
@Override
public VlanVO doInTransaction(TransactionStatus status) {
- VlanVO vlan = new VlanVO(vlanType, vlanId, vlanGateway, vlanNetmask, zone.getId(), ipRange, networkId,
- physicalNetworkId, vlanIp6Gateway, vlanIp6Cidr, ipv6Range);
+ VlanVO vlan = new VlanVO(vlanType, vlanId, vlanGateway, vlanNetmask, zone.getId(), ipRange, networkId, physicalNetworkId, vlanIp6Gateway, vlanIp6Cidr, ipv6Range);
- s_logger.debug("Saving vlan range " + vlan);
- vlan = _vlanDao.persist(vlan);
+ s_logger.debug("Saving vlan range " + vlan);
+ vlan = _vlanDao.persist(vlan);
- // IPv6 use a used ip map, is different from ipv4, no need to save
- // public ip range
- if (ipv4) {
- if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId(), networkId, physicalNetworkId)) {
- throw new CloudRuntimeException("Failed to save IPv4 range. Please contact Cloud Support.");
- }
- }
+ // IPv6 use a used ip map, is different from ipv4, no need to save
+ // public ip range
+ if (ipv4) {
+ if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId(), networkId, physicalNetworkId)) {
+ throw new CloudRuntimeException("Failed to save IPv4 range. Please contact Cloud Support.");
+ }
+ }
- if (vlanOwner != null) {
- // This VLAN is account-specific, so create an AccountVlanMapVO
- // entry
- AccountVlanMapVO accountVlanMapVO = new AccountVlanMapVO(vlanOwner.getId(), vlan.getId());
- _accountVlanMapDao.persist(accountVlanMapVO);
+ if (vlanOwner != null) {
+ // This VLAN is account-specific, so create an AccountVlanMapVO
+ // entry
+ AccountVlanMapVO accountVlanMapVO = new AccountVlanMapVO(vlanOwner.getId(), vlan.getId());
+ _accountVlanMapDao.persist(accountVlanMapVO);
- // generate usage event for dedication of every ip address in the
- // range
- List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlan.getId());
- for (IPAddressVO ip : ips) {
+ // generate usage event for dedication of every ip address in the
+ // range
+ List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlan.getId());
+ for (IPAddressVO ip : ips) {
- UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_ASSIGN, vlanOwner.getId(), ip
- .getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(), vlan
- .getVlanType().toString(), ip.getSystem(), ip.getClass().getName(), ip.getUuid());
+ UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_ASSIGN, vlanOwner.getId(), ip.getDataCenterId(), ip.getId(), ip.getAddress().toString(),
+ ip.isSourceNat(), vlan.getVlanType().toString(), ip.getSystem(), ip.getClass().getName(), ip.getUuid());
- }
- // increment resource count for dedicated public ip's
- _resourceLimitMgr.incrementResourceCount(vlanOwner.getId(), ResourceType.public_ip, new Long(ips.size()));
- } else if (podId != null) {
- // This VLAN is pod-wide, so create a PodVlanMapVO entry
- PodVlanMapVO podVlanMapVO = new PodVlanMapVO(podId, vlan.getId());
- _podVlanMapDao.persist(podVlanMapVO);
- }
- return vlan;
}
+ // increment resource count for dedicated public ip's
+ _resourceLimitMgr.incrementResourceCount(vlanOwner.getId(), ResourceType.public_ip, new Long(ips.size()));
+ } else if (podId != null) {
+ // This VLAN is pod-wide, so create a PodVlanMapVO entry
+ PodVlanMapVO podVlanMapVO = new PodVlanMapVO(podId, vlan.getId());
+ _podVlanMapDao.persist(podVlanMapVO);
+ }
+ return vlan;
+ }
});
}
@@@ -3125,23 -3025,14 +3028,14 @@@
}
for (IPAddressVO ip : ips) {
if (ip.isOneToOneNat()) {
- throw new InvalidParameterValueException(
- "Can't delete account specific vlan "
- + vlanDbId
- + " as ip "
- + ip
+ throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId + " as ip " + ip
- + " belonging to the range is used for static nat purposes. Cleanup the rules first");
+ + " belonging to the range is used for static nat purposes. Cleanup the rules first");
}
if (ip.isSourceNat()) {
- throw new InvalidParameterValueException(
- "Can't delete account specific vlan "
- + vlanDbId
- + " as ip "
- + ip
- + " belonging to the range is a source nat ip for the network id="
- + ip.getSourceNetworkId()
+ throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId + " as ip " + ip
+ + " belonging to the range is a source nat ip for the network id=" + ip.getSourceNetworkId()
- + ". IP range with the source nat ip address can be removed either as a part of Network, or account removal");
+ + ". IP range with the source nat ip address can be removed either as a part of Network, or account removal");
}
if (_firewallDao.countRulesByIpId(ip.getId()) > 0) {
@@@ -3371,9 -3244,8 +3247,8 @@@
List<String> problemIps = Transaction.execute(new TransactionCallback<List<String>>() {
@Override
public List<String> doInTransaction(TransactionStatus status) {
- IPRangeConfig config = new IPRangeConfig();
+ IPRangeConfig config = new IPRangeConfig();
- return config.savePublicIPRange(TransactionLegacy.currentTxn(), startIPLong, endIPLong, zoneId, vlanDbId,
- sourceNetworkid, physicalNetworkId);
+ return config.savePublicIPRange(TransactionLegacy.currentTxn(), startIPLong, endIPLong, zoneId, vlanDbId, sourceNetworkid, physicalNetworkId);
}
});
@@@ -3965,9 -3800,8 +3803,8 @@@
boolean perAccount = value.contains("peraccount");
boolean perZone = value.contains("perzone");
if ((perAccount && perZone) || (!perAccount && !perZone)) {
- throw new InvalidParameterValueException(
- "Either peraccount or perzone source NAT type can be specified for "
+ throw new InvalidParameterValueException("Either peraccount or perzone source NAT type can be specified for "
- + Capability.SupportedSourceNatTypes.getName());
+ + Capability.SupportedSourceNatTypes.getName());
}
} else if (capability == Capability.RedundantRouter) {
boolean enabled = value.contains("true");
@@@ -4005,12 -3835,12 +3838,12 @@@
+ " capabilitiy can be sepcified for static nat service");
}
}
- if ((! eipEnabled) && associatePublicIP) {
- throw new InvalidParameterValueException("Capability " + Capability.AssociatePublicIP.getName()
- + " can only be set when capability " + Capability.ElasticIp.getName() + " is true");
+ if ((!eipEnabled) && associatePublicIP) {
+ throw new InvalidParameterValueException("Capability " + Capability.AssociatePublicIP.getName() + " can only be set when capability "
+ + Capability.ElasticIp.getName() + " is true");
+ }
}
}
- }
@Override
@DB
@@@ -4178,44 -3994,41 +3997,41 @@@
public NetworkOfferingVO doInTransaction(TransactionStatus status) {
NetworkOfferingVO offering = offeringFinal;
- // 1) create network offering object
- s_logger.debug("Adding network offering " + offering);
- offering.setConcurrentConnections(maxconn);
+ // 1) create network offering object
+ s_logger.debug("Adding network offering " + offering);
+ offering.setConcurrentConnections(maxconn);
offering.setKeepAliveEnabled(enableKeepAlive);
- offering = _networkOfferingDao.persist(offering, details);
- // 2) populate services and providers
- if (serviceProviderMap != null) {
- for (Network.Service service : serviceProviderMap.keySet()) {
- Set<Provider> providers = serviceProviderMap.get(service);
- if (providers != null && !providers.isEmpty()) {
- boolean vpcOff = false;
- for (Network.Provider provider : providers) {
- if (provider == Provider.VPCVirtualRouter) {
- vpcOff = true;
- }
+ offering = _networkOfferingDao.persist(offering, details);
+ // 2) populate services and providers
+ if (serviceProviderMap != null) {
+ for (Network.Service service : serviceProviderMap.keySet()) {
+ Set<Provider> providers = serviceProviderMap.get(service);
+ if (providers != null && !providers.isEmpty()) {
+ boolean vpcOff = false;
+ for (Network.Provider provider : providers) {
+ if (provider == Provider.VPCVirtualRouter) {
+ vpcOff = true;
+ }
- NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(),
- service, provider);
+ NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(), service, provider);
- _ntwkOffServiceMapDao.persist(offService);
+ _ntwkOffServiceMapDao.persist(offService);
- s_logger.trace("Added service for the network offering: " + offService + " with provider "
- + provider.getName());
+ s_logger.trace("Added service for the network offering: " + offService + " with provider " + provider.getName());
- }
+ }
- if (vpcOff) {
- List<Service> supportedSvcs = new ArrayList<Service>();
- supportedSvcs.addAll(serviceProviderMap.keySet());
- _vpcMgr.validateNtwkOffForVpc(offering, supportedSvcs);
- }
- } else {
- NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(), service, null);
- _ntwkOffServiceMapDao.persist(offService);
- s_logger.trace("Added service for the network offering: " + offService + " with null provider");
- }
+ if (vpcOff) {
+ List<Service> supportedSvcs = new ArrayList<Service>();
+ supportedSvcs.addAll(serviceProviderMap.keySet());
+ _vpcMgr.validateNtwkOffForVpc(offering, supportedSvcs);
}
+ } else {
- NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(), service,
- null);
++ NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(), service, null);
+ _ntwkOffServiceMapDao.persist(offService);
+ s_logger.trace("Added service for the network offering: " + offService + " with null provider");
}
-
- return offering;
}
+ }
+
+ return offering;
+ }
});
}
@@@ -4613,9 -4410,9 +4413,9 @@@
offering.setAvailability(availability);
}
}
- if (_ntwkOffServiceMapDao.areServicesSupportedByNetworkOffering(offering.getId(), Service.Lb)){
+ if (_ntwkOffServiceMapDao.areServicesSupportedByNetworkOffering(offering.getId(), Service.Lb)) {
if (maxconn != null) {
- offering.setConcurrentConnections(maxconn);
+ offering.setConcurrentConnections(maxconn);
}
}
@@@ -4750,15 -4544,14 +4547,14 @@@
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
- for (AccountVlanMapVO map : maps) {
+ for (AccountVlanMapVO map : maps) {
- if (!releasePublicIpRange(map.getVlanDbId(), _accountMgr.getSystemUser().getId(),
- _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM))) {
+ if (!releasePublicIpRange(map.getVlanDbId(), _accountMgr.getSystemUser().getId(), _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM))) {
throw new CloudRuntimeException("Failed to release account specific virtual ip ranges for account id=" + accountId);
- }
- }
+ }
+ }
}
});
- } catch ( CloudRuntimeException e ) {
+ } catch (CloudRuntimeException e) {
s_logger.error(e);
return false;
}
@@@ -4895,23 -4684,22 +4687,22 @@@
@Override
public PortableIpRangeVO doInTransaction(TransactionStatus status) {
PortableIpRangeVO portableIpRange = new PortableIpRangeVO(regionId, vlanIdFinal, gateway, netmask, startIP, endIP);
- portableIpRange = _portableIpRangeDao.persist(portableIpRange);
+ portableIpRange = _portableIpRangeDao.persist(portableIpRange);
- long startIpLong = NetUtils.ip2Long(startIP);
- long endIpLong = NetUtils.ip2Long(endIP);
- while (startIpLong <= endIpLong) {
+ long startIpLong = NetUtils.ip2Long(startIP);
+ long endIpLong = NetUtils.ip2Long(endIP);
+ while (startIpLong <= endIpLong) {
- PortableIpVO portableIP = new PortableIpVO(regionId, portableIpRange.getId(), vlanIdFinal, gateway, netmask,
- NetUtils.long2Ip(startIpLong));
+ PortableIpVO portableIP = new PortableIpVO(regionId, portableIpRange.getId(), vlanIdFinal, gateway, netmask, NetUtils.long2Ip(startIpLong));
- _portableIpDao.persist(portableIP);
- startIpLong++;
- }
+ _portableIpDao.persist(portableIP);
+ startIpLong++;
+ }
- // implicitly enable portable IP service for the region
- region.setPortableipEnabled(true);
- _regionDao.update(region.getId(), region);
+ // implicitly enable portable IP service for the region
+ region.setPortableipEnabled(true);
+ _regionDao.update(region.getId(), region);
- return portableIpRange;
- }
+ return portableIpRange;
+ }
});
} finally {
portableIpLock.unlock();