mirror of https://github.com/apache/cloudstack.git
remove getDomainId and write the workaround code
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
e3da9ec645
commit
d04c6ea276
|
|
@ -104,8 +104,6 @@ public interface ServiceOffering extends DiskOffering, InfrastructureEntity, Int
|
||||||
@Override
|
@Override
|
||||||
boolean isUseLocalStorage();
|
boolean isUseLocalStorage();
|
||||||
|
|
||||||
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
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
// under the License.
|
// under the License.
|
||||||
package org.apache.cloudstack.api.command.admin.offering;
|
package org.apache.cloudstack.api.command.admin.offering;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
import org.apache.cloudstack.api.APICommand;
|
||||||
|
|
@ -62,24 +61,17 @@ public class CreateDiskOfferingCmd extends BaseCmd {
|
||||||
private Boolean customized;
|
private Boolean customized;
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.DOMAIN_ID,
|
@Parameter(name = ApiConstants.DOMAIN_ID,
|
||||||
type = CommandType.UUID,
|
|
||||||
entityType = DomainResponse.class,
|
|
||||||
description = "the ID of the containing domain, null for public offerings")
|
|
||||||
private Long domainId;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.DOMAIN_ID_LIST,
|
|
||||||
type = CommandType.LIST,
|
type = CommandType.LIST,
|
||||||
collectionType = CommandType.UUID,
|
collectionType = CommandType.UUID,
|
||||||
entityType = DomainResponse.class,
|
entityType = DomainResponse.class,
|
||||||
description = "the ID of the domains offering is associated with, null for all domain offerings",
|
description = "the ID of the containing domain(s), null for public offerings")
|
||||||
since = "4.13")
|
|
||||||
private List<Long> domainIds;
|
private List<Long> domainIds;
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.ZONE_ID_LIST,
|
@Parameter(name = ApiConstants.ZONE_ID,
|
||||||
type = CommandType.LIST,
|
type = CommandType.LIST,
|
||||||
collectionType = CommandType.UUID,
|
collectionType = CommandType.UUID,
|
||||||
entityType = ZoneResponse.class,
|
entityType = ZoneResponse.class,
|
||||||
description = "the ID of the zones offering is associated with, null for all zone offerings",
|
description = "the ID of the containing zone(s), null for public offerings",
|
||||||
since = "4.13")
|
since = "4.13")
|
||||||
private List<Long> zoneIds;
|
private List<Long> zoneIds;
|
||||||
|
|
||||||
|
|
@ -186,12 +178,6 @@ public class CreateDiskOfferingCmd extends BaseCmd {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Long> getDomainIds() {
|
public List<Long> getDomainIds() {
|
||||||
if (domainIds == null) {
|
|
||||||
domainIds = new ArrayList<>();
|
|
||||||
}
|
|
||||||
if (domainId != null) {
|
|
||||||
domainIds.add(domainId);
|
|
||||||
}
|
|
||||||
return domainIds;
|
return domainIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.admin.offering;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
import org.apache.cloudstack.api.APICommand;
|
||||||
|
|
@ -83,10 +84,11 @@ public class CreateServiceOfferingCmd extends BaseCmd {
|
||||||
private String tags;
|
private String tags;
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.DOMAIN_ID,
|
@Parameter(name = ApiConstants.DOMAIN_ID,
|
||||||
type = CommandType.UUID,
|
type = CommandType.LIST,
|
||||||
entityType = DomainResponse.class,
|
collectionType = CommandType.UUID,
|
||||||
description = "the ID of the containing domain, null for public offerings")
|
entityType = DomainResponse.class,
|
||||||
private Long domainId;
|
description = "the ID of the containing domain(s), null for public offerings")
|
||||||
|
private List<Long> domainIds;
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.HOST_TAGS, type = CommandType.STRING, description = "the host tag for this service offering.")
|
@Parameter(name = ApiConstants.HOST_TAGS, type = CommandType.STRING, description = "the host tag for this service offering.")
|
||||||
private String hostTag;
|
private String hostTag;
|
||||||
|
|
@ -249,8 +251,8 @@ public class CreateServiceOfferingCmd extends BaseCmd {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getDomainId() {
|
public List<Long> getDomainId() {
|
||||||
return domainId;
|
return domainIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHostTag() {
|
public String getHostTag() {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public interface DomainDao extends GenericDao<DomainVO, Long> {
|
||||||
|
|
||||||
public DomainVO findDomainByPath(String domainPath);
|
public DomainVO findDomainByPath(String domainPath);
|
||||||
|
|
||||||
public boolean isChildDomain(Long parentId, Long childId);
|
boolean isChildDomain(Long parentId, Long childId);
|
||||||
|
|
||||||
DomainVO findImmediateChildForParent(Long parentId);
|
DomainVO findImmediateChildForParent(Long parentId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, boolean limitCpuUse,
|
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, boolean limitCpuUse,
|
||||||
boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, Long domainId) {
|
boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType) {
|
||||||
super(name, displayText, provisioningType, false, tags, recreatable, useLocalStorage, systemUse, true);
|
super(name, displayText, provisioningType, false, tags, recreatable, useLocalStorage, systemUse, true);
|
||||||
this.cpu = cpu;
|
this.cpu = cpu;
|
||||||
this.ramSize = ramSize;
|
this.ramSize = ramSize;
|
||||||
|
|
@ -120,8 +120,8 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA,
|
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA,
|
||||||
boolean limitResourceUse, boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse,
|
boolean limitResourceUse, boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse,
|
||||||
VirtualMachine.Type vmType, Long domainId, String hostTag) {
|
VirtualMachine.Type vmType, String hostTag) {
|
||||||
this(name,
|
this(name,
|
||||||
cpu,
|
cpu,
|
||||||
ramSize,
|
ramSize,
|
||||||
|
|
@ -137,14 +137,14 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
||||||
recreatable,
|
recreatable,
|
||||||
tags,
|
tags,
|
||||||
systemUse,
|
systemUse,
|
||||||
vmType,
|
vmType
|
||||||
domainId);
|
);
|
||||||
this.hostTag = hostTag;
|
this.hostTag = hostTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA,
|
public ServiceOfferingVO(String name, Integer cpu, Integer ramSize, Integer speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA,
|
||||||
boolean limitResourceUse, boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse,
|
boolean limitResourceUse, boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse,
|
||||||
VirtualMachine.Type vmType, Long domainId, String hostTag, String deploymentPlanner) {
|
VirtualMachine.Type vmType, String hostTag, String deploymentPlanner) {
|
||||||
this(name,
|
this(name,
|
||||||
cpu,
|
cpu,
|
||||||
ramSize,
|
ramSize,
|
||||||
|
|
@ -161,8 +161,7 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
||||||
tags,
|
tags,
|
||||||
systemUse,
|
systemUse,
|
||||||
vmType,
|
vmType,
|
||||||
domainId,
|
hostTag);
|
||||||
hostTag);
|
|
||||||
this.deploymentPlanner = deploymentPlanner;
|
this.deploymentPlanner = deploymentPlanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,12 +191,6 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
||||||
vmType = offering.getSystemVmType();
|
vmType = offering.getSystemVmType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getDomainId() {
|
|
||||||
// TODO: get rid of me
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOfferHA() {
|
public boolean isOfferHA() {
|
||||||
return offerHA;
|
return offerHA;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,15 @@ public interface ResourceDetailsDao<R extends ResourceDetail> extends GenericDao
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public R findDetail(long resourceId, String name);
|
R findDetail(long resourceId, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find details by resourceId and key
|
||||||
|
* @param resourceId
|
||||||
|
* @param key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<R> findDetails(long resourceId, String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find details by key,value pair
|
* Find details by key,value pair
|
||||||
|
|
@ -39,7 +47,7 @@ public interface ResourceDetailsDao<R extends ResourceDetail> extends GenericDao
|
||||||
* @param display
|
* @param display
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<R> findDetails(String key, String value, Boolean display);
|
List<R> findDetails(String key, String value, Boolean display);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all details for the resource specified
|
* Removes all details for the resource specified
|
||||||
|
|
@ -47,12 +55,21 @@ public interface ResourceDetailsDao<R extends ResourceDetail> extends GenericDao
|
||||||
*/
|
*/
|
||||||
public void removeDetails(long resourceId);
|
public void removeDetails(long resourceId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes detail having resourceId and key specified (unique combination)
|
* Removes detail having resourceId and key specified (unique combination)
|
||||||
* @param resourceId
|
* @param resourceId
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public void removeDetail(long resourceId, String key);
|
void removeDetail(long resourceId, String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes detail having resourceId and key, value specified (unique combination)
|
||||||
|
* @param resourceId
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void removeDetail(long resourceId, String key, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all details for the resourceId
|
* Lists all details for the resourceId
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,13 @@ public abstract class ResourceDetailsDaoBase<R extends ResourceDetail> extends G
|
||||||
return findOneBy(sc);
|
return findOneBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<R> findDetails(long resourceId, String key) {
|
||||||
|
SearchCriteria<R> sc = AllFieldsSearch.create();
|
||||||
|
sc.setParameters("resourceId", resourceId);
|
||||||
|
sc.setParameters("name", key);
|
||||||
|
return listBy(sc);
|
||||||
|
}
|
||||||
|
|
||||||
public List<R> findDetails(String name, String value, Boolean display) {
|
public List<R> findDetails(String name, String value, Boolean display) {
|
||||||
SearchCriteria<R> sc = AllFieldsSearch.create();
|
SearchCriteria<R> sc = AllFieldsSearch.create();
|
||||||
|
|
||||||
|
|
@ -107,6 +114,16 @@ public abstract class ResourceDetailsDaoBase<R extends ResourceDetail> extends G
|
||||||
remove(sc);
|
remove(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeDetail(long resourceId, String key, String value) {
|
||||||
|
if (key != null) {
|
||||||
|
SearchCriteria<R> sc = AllFieldsSearch.create();
|
||||||
|
sc.setParameters("resourceId", resourceId);
|
||||||
|
sc.setParameters("name", key);
|
||||||
|
sc.setParameters("value", value);
|
||||||
|
remove(sc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeDetail(long resourceId, String key) {
|
public void removeDetail(long resourceId, String key) {
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
SearchCriteria<R> sc = AllFieldsSearch.create();
|
SearchCriteria<R> sc = AllFieldsSearch.create();
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ ALTER TABLE `cloud`.`disk_offering` DROP COLUMN `domain_id`;
|
||||||
-- Disk offering with multi-domains and multi-zones
|
-- Disk offering with multi-domains and multi-zones
|
||||||
DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
|
DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
|
||||||
CREATE VIEW `cloud`.`disk_offering_view` AS
|
CREATE VIEW `cloud`.`disk_offering_view` AS
|
||||||
select
|
SELECT
|
||||||
`disk_offering`.`id` AS `id`,
|
`disk_offering`.`id` AS `id`,
|
||||||
`disk_offering`.`uuid` AS `uuid`,
|
`disk_offering`.`uuid` AS `uuid`,
|
||||||
`disk_offering`.`name` AS `name`,
|
`disk_offering`.`name` AS `name`,
|
||||||
|
|
@ -60,25 +60,27 @@ CREATE VIEW `cloud`.`disk_offering_view` AS
|
||||||
`disk_offering`.`type` AS `type`,
|
`disk_offering`.`type` AS `type`,
|
||||||
`disk_offering`.`display_offering` AS `display_offering`,
|
`disk_offering`.`display_offering` AS `display_offering`,
|
||||||
`disk_offering`.`state` AS `state`,
|
`disk_offering`.`state` AS `state`,
|
||||||
GROUP_CONCAT(domain.id) AS domain_id,
|
GROUP_CONCAT(DISTINCT(domain.id)) AS domain_id,
|
||||||
GROUP_CONCAT(domain.uuid) AS domain_uuid,
|
GROUP_CONCAT(DISTINCT(domain.uuid)) AS domain_uuid,
|
||||||
GROUP_CONCAT(domain.name) AS domain_name,
|
GROUP_CONCAT(DISTINCT(domain.name)) AS domain_name,
|
||||||
GROUP_CONCAT(domain.path) AS domain_path,
|
GROUP_CONCAT(DISTINCT(domain.path)) AS domain_path,
|
||||||
GROUP_CONCAT(zone.id) AS zone_id,
|
GROUP_CONCAT(DISTINCT(zone.id)) AS zone_id,
|
||||||
GROUP_CONCAT(zone.uuid) AS zone_uuid,
|
GROUP_CONCAT(DISTINCT(zone.uuid)) AS zone_uuid,
|
||||||
GROUP_CONCAT(zone.name) AS zone_name
|
GROUP_CONCAT(DISTINCT(zone.name)) AS zone_name
|
||||||
from
|
FROM
|
||||||
`cloud`.`disk_offering`
|
`cloud`.`disk_offering`
|
||||||
left join
|
LEFT JOIN
|
||||||
`cloud`.`disk_offering_details` AS `domain_details` ON `domain_details`.`offering_id` = `disk_offering`.`id` AND `domain_details`.`name`='domainid'
|
`cloud`.`disk_offering_details` AS `domain_details` ON `domain_details`.`offering_id` = `disk_offering`.`id` AND `domain_details`.`name`='domainid'
|
||||||
left join
|
LEFT JOIN
|
||||||
`cloud`.`domain` AS `domain` ON `domain`.`id` = `domain_details`.`value`
|
`cloud`.`domain` AS `domain` ON FIND_IN_SET(`domain`.`id`, `domain_details`.`value`)
|
||||||
left join
|
LEFT JOIN
|
||||||
`cloud`.`disk_offering_details` AS `zone_details` ON `zone_details`.`offering_id` = `disk_offering`.`id` AND `zone_details`.`name`='zoneid'
|
`cloud`.`disk_offering_details` AS `zone_details` ON `zone_details`.`offering_id` = `disk_offering`.`id` AND `zone_details`.`name`='zoneid'
|
||||||
left join
|
LEFT JOIN
|
||||||
`cloud`.`data_center` AS `zone` ON `zone`.`id` = `zone_details`.`value`
|
`cloud`.`data_center` AS `zone` ON FIND_IN_SET(`zone`.`id`, `zone_details`.`value`)
|
||||||
where
|
WHERE
|
||||||
disk_offering.state='ACTIVE' GROUP BY id;
|
`disk_offering`.`state`='ACTIVE'
|
||||||
|
GROUP BY
|
||||||
|
`disk_offering`.`id`;
|
||||||
|
|
||||||
-- Service offering with multi-domains and multi-zones
|
-- Service offering with multi-domains and multi-zones
|
||||||
DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
|
DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
|
||||||
|
|
|
||||||
|
|
@ -28,15 +28,15 @@ import java.util.Map;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
import net.sf.cglib.proxy.Factory;
|
|
||||||
import net.sf.cglib.proxy.MethodInterceptor;
|
|
||||||
import net.sf.cglib.proxy.MethodProxy;
|
|
||||||
|
|
||||||
import com.cloud.utils.db.SearchCriteria.Func;
|
import com.cloud.utils.db.SearchCriteria.Func;
|
||||||
import com.cloud.utils.db.SearchCriteria.Op;
|
import com.cloud.utils.db.SearchCriteria.Op;
|
||||||
import com.cloud.utils.db.SearchCriteria.SelectType;
|
import com.cloud.utils.db.SearchCriteria.SelectType;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
|
import net.sf.cglib.proxy.Factory;
|
||||||
|
import net.sf.cglib.proxy.MethodInterceptor;
|
||||||
|
import net.sf.cglib.proxy.MethodProxy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SearchBase contains the methods that are used to build up search
|
* SearchBase contains the methods that are used to build up search
|
||||||
* queries. While this class is public it's not really meant for public
|
* queries. While this class is public it's not really meant for public
|
||||||
|
|
@ -410,6 +410,10 @@ public abstract class SearchBase<J extends SearchBase<?, T, K>, T, K> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (op == Op.FIND_IN_SET) {
|
||||||
|
sql.append(" FIND_IN_SET(?, ");
|
||||||
|
}
|
||||||
|
|
||||||
sql.append(attr.table).append(".").append(attr.columnName).append(op.toString());
|
sql.append(attr.table).append(".").append(attr.columnName).append(op.toString());
|
||||||
if (op == Op.IN && params.length == 1) {
|
if (op == Op.IN && params.length == 1) {
|
||||||
sql.delete(sql.length() - op.toString().length(), sql.length());
|
sql.delete(sql.length() - op.toString().length(), sql.length());
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ public class SearchCriteria<K> {
|
||||||
" NOT BETWEEN ? AND ? ",
|
" NOT BETWEEN ? AND ? ",
|
||||||
2), IN(" IN () ", -1), NOTIN(" NOT IN () ", -1), LIKE(" LIKE ? ", 1), NLIKE(" NOT LIKE ? ", 1), NIN(" NOT IN () ", -1), NULL(" IS NULL ", 0), NNULL(
|
2), IN(" IN () ", -1), NOTIN(" NOT IN () ", -1), LIKE(" LIKE ? ", 1), NLIKE(" NOT LIKE ? ", 1), NIN(" NOT IN () ", -1), NULL(" IS NULL ", 0), NNULL(
|
||||||
" IS NOT NULL ",
|
" IS NOT NULL ",
|
||||||
0), SC(" () ", 1), TEXT(" () ", 1), RP("", 0), AND(" AND ", 0), OR(" OR ", 0), NOT(" NOT ", 0);
|
0), SC(" () ", 1), TEXT(" () ", 1), RP("", 0), AND(" AND ", 0), OR(" OR ", 0), NOT(" NOT ", 0), FIND_IN_SET(" ) ", 1);
|
||||||
|
|
||||||
private final String op;
|
private final String op;
|
||||||
int params;
|
int params;
|
||||||
|
|
@ -57,7 +57,7 @@ public class SearchCriteria<K> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Func {
|
public enum Func {
|
||||||
NATIVE("@", 1), MAX("MAX(@)", 1), MIN("MIN(@)", 1), FIRST("FIRST(@)", 1), LAST("LAST(@)", 1), SUM("SUM(@)", 1), COUNT("COUNT(@)", 1), DISTINCT("DISTINCT(@)", 1), FIND_IN_SET("FIND_IN_SET(@, @)", 2);
|
NATIVE("@", 1), MAX("MAX(@)", 1), MIN("MIN(@)", 1), FIRST("FIRST(@)", 1), LAST("LAST(@)", 1), SUM("SUM(@)", 1), COUNT("COUNT(@)", 1), DISTINCT("DISTINCT(@)", 1);
|
||||||
|
|
||||||
private String func;
|
private String func;
|
||||||
private int count;
|
private int count;
|
||||||
|
|
|
||||||
|
|
@ -284,10 +284,4 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
||||||
public void setDynamicFlag(boolean isdynamic) {
|
public void setDynamicFlag(boolean isdynamic) {
|
||||||
isDynamic = isdynamic;
|
isDynamic = isdynamic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getDomainId() {
|
|
||||||
// TODO: get rid of me
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.acl;
|
package com.cloud.acl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -41,6 +42,8 @@ import com.cloud.offering.DiskOffering;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.projects.ProjectManager;
|
import com.cloud.projects.ProjectManager;
|
||||||
import com.cloud.projects.dao.ProjectAccountDao;
|
import com.cloud.projects.dao.ProjectAccountDao;
|
||||||
|
import com.cloud.service.ServiceOfferingDetailsVO;
|
||||||
|
import com.cloud.service.dao.ServiceOfferingDetailsDao;
|
||||||
import com.cloud.storage.LaunchPermissionVO;
|
import com.cloud.storage.LaunchPermissionVO;
|
||||||
import com.cloud.storage.dao.LaunchPermissionDao;
|
import com.cloud.storage.dao.LaunchPermissionDao;
|
||||||
import com.cloud.template.VirtualMachineTemplate;
|
import com.cloud.template.VirtualMachineTemplate;
|
||||||
|
|
@ -72,6 +75,8 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
|
||||||
AccountService _accountService;
|
AccountService _accountService;
|
||||||
@Inject
|
@Inject
|
||||||
DiskOfferingDetailsDao diskOfferingDetailsDao;
|
DiskOfferingDetailsDao diskOfferingDetailsDao;
|
||||||
|
@Inject
|
||||||
|
ServiceOfferingDetailsDao serviceOfferingDetailsDao;
|
||||||
|
|
||||||
protected DomainChecker() {
|
protected DomainChecker() {
|
||||||
super();
|
super();
|
||||||
|
|
@ -222,7 +227,11 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkAccess(Account account, ServiceOffering so) throws PermissionDeniedException {
|
public boolean checkAccess(Account account, ServiceOffering so) throws PermissionDeniedException {
|
||||||
if (account == null || so.getDomainId() == null) {//public offering
|
final List<Long> soDomainIds = new ArrayList<>();
|
||||||
|
for (final ServiceOfferingDetailsVO detail: serviceOfferingDetailsDao.findDetails(so.getId(), ApiConstants.DOMAIN_ID)) {
|
||||||
|
soDomainIds.add(Long.valueOf(detail.getValue()));
|
||||||
|
}
|
||||||
|
if (account == null || soDomainIds.isEmpty()) { //public offering
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
//admin has all permissions
|
//admin has all permissions
|
||||||
|
|
@ -235,13 +244,13 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
|
||||||
|| account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN
|
|| account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN
|
||||||
|| _accountService.isDomainAdmin(account.getId())
|
|| _accountService.isDomainAdmin(account.getId())
|
||||||
|| account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
|| account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||||
if (account.getDomainId() == so.getDomainId()) {
|
if (soDomainIds.contains(account.getDomainId())) {
|
||||||
return true; //service offering and account at exact node
|
return true; //service offering and account at exact node
|
||||||
} else {
|
} else {
|
||||||
Domain domainRecord = _domainDao.findById(account.getDomainId());
|
Domain domainRecord = _domainDao.findById(account.getDomainId());
|
||||||
if (domainRecord != null) {
|
if (domainRecord != null) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (domainRecord.getId() == so.getDomainId()) {
|
if (soDomainIds.contains(domainRecord.getId())) {
|
||||||
//found as a child
|
//found as a child
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,13 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DiskOfferingJoinVO> findByDomainId(long domainId) {
|
public List<DiskOfferingJoinVO> findByDomainId(long domainId) {
|
||||||
SearchBuilder<DiskOfferingJoinVO> DiskOfferingsByDomainIdSearch = createSearchBuilder();
|
SearchBuilder<DiskOfferingJoinVO> sb = createSearchBuilder();
|
||||||
DiskOfferingsByDomainIdSearch.and("domainId", DiskOfferingsByDomainIdSearch.entity().getDomainId(), SearchCriteria.Op.NNULL);
|
sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.FIND_IN_SET);
|
||||||
DiskOfferingsByDomainIdSearch.select("domainId", SearchCriteria.Func.FIND_IN_SET, DiskOfferingsByDomainIdSearch.entity().getDomainId(), String.valueOf(domainId));
|
sb.done();
|
||||||
DiskOfferingsByDomainIdSearch.done();
|
|
||||||
|
|
||||||
return listBy(DiskOfferingsByDomainIdSearch.create());
|
SearchCriteria<DiskOfferingJoinVO> sc = sb.create();
|
||||||
|
sc.setParameters("domainId", String.valueOf(domainId));
|
||||||
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,13 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ServiceOfferingJoinVO> findByDomainId(long domainId) {
|
public List<ServiceOfferingJoinVO> findByDomainId(long domainId) {
|
||||||
SearchBuilder<ServiceOfferingJoinVO> ServiceOfferingsByDomainIdSearch = createSearchBuilder();
|
SearchBuilder<ServiceOfferingJoinVO> sb = createSearchBuilder();
|
||||||
ServiceOfferingsByDomainIdSearch.select("domainId", SearchCriteria.Func.FIND_IN_SET, ServiceOfferingsByDomainIdSearch.entity().getDomainId(), String.valueOf(domainId));
|
sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.FIND_IN_SET);
|
||||||
ServiceOfferingsByDomainIdSearch.done();
|
sb.done();
|
||||||
|
|
||||||
return listBy(ServiceOfferingsByDomainIdSearch.create());
|
SearchCriteria<ServiceOfferingJoinVO> sc = sb.create();
|
||||||
|
sc.setParameters("domainId", String.valueOf(domainId));
|
||||||
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -2289,8 +2289,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if valid domain
|
// check if valid domain
|
||||||
if (cmd.getDomainId() != null && _domainDao.findById(cmd.getDomainId()) == null) {
|
if (cmd.getDomainId() != null && !cmd.getDomainId().isEmpty()) {
|
||||||
throw new InvalidParameterValueException("Please specify a valid domain id");
|
for (final Long domainId: cmd.getDomainId()) {
|
||||||
|
if (_domainDao.findById(domainId) == null) {
|
||||||
|
throw new InvalidParameterValueException("Please specify a valid domain id");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Boolean offerHA = cmd.isOfferHa();
|
final Boolean offerHA = cmd.isOfferHa();
|
||||||
|
|
@ -2378,7 +2382,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||||
|
|
||||||
protected ServiceOfferingVO createServiceOffering(final long userId, final boolean isSystem, final VirtualMachine.Type vmType,
|
protected ServiceOfferingVO createServiceOffering(final long userId, final boolean isSystem, final VirtualMachine.Type vmType,
|
||||||
final String name, final Integer cpu, final Integer ramSize, final Integer speed, final String displayText, final String provisioningType, final boolean localStorageRequired,
|
final String name, final Integer cpu, final Integer ramSize, final Integer speed, final String displayText, final String provisioningType, final boolean localStorageRequired,
|
||||||
final boolean offerHA, final boolean limitResourceUse, final boolean volatileVm, String tags, final Long domainId, final String hostTag,
|
final boolean offerHA, final boolean limitResourceUse, final boolean volatileVm, String tags, final List<Long> domainIds, final String hostTag,
|
||||||
final Integer networkRate, final String deploymentPlanner, final Map<String, String> details, final Boolean isCustomizedIops, Long minIops, Long maxIops,
|
final Integer networkRate, final String deploymentPlanner, final Map<String, String> details, final Boolean isCustomizedIops, Long minIops, Long maxIops,
|
||||||
Long bytesReadRate, Long bytesReadRateMax, Long bytesReadRateMaxLength,
|
Long bytesReadRate, Long bytesReadRateMax, Long bytesReadRateMaxLength,
|
||||||
Long bytesWriteRate, Long bytesWriteRateMax, Long bytesWriteRateMaxLength,
|
Long bytesWriteRate, Long bytesWriteRateMax, Long bytesWriteRateMaxLength,
|
||||||
|
|
@ -2393,14 +2397,16 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||||
}
|
}
|
||||||
final Account account = _accountDao.findById(user.getAccountId());
|
final Account account = _accountDao.findById(user.getAccountId());
|
||||||
if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
|
if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
|
||||||
if (domainId == null) {
|
if (domainIds == null || domainIds.isEmpty()) {
|
||||||
throw new InvalidParameterValueException("Unable to create public service offering by id " + userId + " because it is domain-admin");
|
throw new InvalidParameterValueException("Unable to create public service offering by id " + userId + " because it is domain-admin");
|
||||||
}
|
}
|
||||||
if (tags != null || hostTag != null) {
|
if (tags != null || hostTag != null) {
|
||||||
throw new InvalidParameterValueException("Unable to create service offering with storage tags or host tags by id " + userId + " because it is domain-admin");
|
throw new InvalidParameterValueException("Unable to create service offering with storage tags or host tags by id " + userId + " because it is domain-admin");
|
||||||
}
|
}
|
||||||
if (! _domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
for (Long domainId: domainIds) {
|
||||||
throw new InvalidParameterValueException("Unable to create service offering by another domain admin with id " + userId);
|
if (! _domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||||
|
throw new InvalidParameterValueException("Unable to create service offering by another domain admin with id " + userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
} else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
||||||
throw new InvalidParameterValueException("Unable to create service offering by id " + userId + " because it is not root-admin or domain-admin");
|
throw new InvalidParameterValueException("Unable to create service offering by id " + userId + " because it is not root-admin or domain-admin");
|
||||||
|
|
@ -2412,7 +2418,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||||
|
|
||||||
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, null, offerHA,
|
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, null, offerHA,
|
||||||
limitResourceUse, volatileVm, displayText, typedProvisioningType, localStorageRequired, false, tags, isSystem, vmType,
|
limitResourceUse, volatileVm, displayText, typedProvisioningType, localStorageRequired, false, tags, isSystem, vmType,
|
||||||
domainId, hostTag, deploymentPlanner);
|
hostTag, deploymentPlanner);
|
||||||
|
|
||||||
if (Boolean.TRUE.equals(isCustomizedIops) || isCustomizedIops == null) {
|
if (Boolean.TRUE.equals(isCustomizedIops) || isCustomizedIops == null) {
|
||||||
minIops = null;
|
minIops = null;
|
||||||
|
|
@ -2484,7 +2490,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||||
|
|
||||||
offering.setHypervisorSnapshotReserve(hypervisorSnapshotReserve);
|
offering.setHypervisorSnapshotReserve(hypervisorSnapshotReserve);
|
||||||
|
|
||||||
List<ServiceOfferingDetailsVO> detailsVO = null;
|
List<ServiceOfferingDetailsVO> detailsVO = new ArrayList<ServiceOfferingDetailsVO>();
|
||||||
if (details != null) {
|
if (details != null) {
|
||||||
// To have correct input, either both gpu card name and VGPU type should be passed or nothing should be passed.
|
// To have correct input, either both gpu card name and VGPU type should be passed or nothing should be passed.
|
||||||
// Use XOR condition to verify that.
|
// Use XOR condition to verify that.
|
||||||
|
|
@ -2493,7 +2499,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||||
if ((entry1 || entry2) && !(entry1 && entry2)) {
|
if ((entry1 || entry2) && !(entry1 && entry2)) {
|
||||||
throw new InvalidParameterValueException("Please specify the pciDevice and vgpuType correctly.");
|
throw new InvalidParameterValueException("Please specify the pciDevice and vgpuType correctly.");
|
||||||
}
|
}
|
||||||
detailsVO = new ArrayList<ServiceOfferingDetailsVO>();
|
|
||||||
for (final Entry<String, String> detailEntry : details.entrySet()) {
|
for (final Entry<String, String> detailEntry : details.entrySet()) {
|
||||||
if (detailEntry.getKey().equals(GPU.Keys.pciDevice.toString())) {
|
if (detailEntry.getKey().equals(GPU.Keys.pciDevice.toString())) {
|
||||||
if (detailEntry.getValue() == null) {
|
if (detailEntry.getValue() == null) {
|
||||||
|
|
@ -2510,9 +2515,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((offering = _serviceOfferingDao.persist(offering)) != null) {
|
if ((offering = _serviceOfferingDao.persist(offering)) != null) {
|
||||||
if (detailsVO != null && !detailsVO.isEmpty()) {
|
if (domainIds != null && !domainIds.isEmpty()) {
|
||||||
for (int index = 0; index < detailsVO.size(); index++) {
|
for (Long domainId: domainIds) {
|
||||||
detailsVO.get(index).setResourceId(offering.getId());
|
detailsVO.add(new ServiceOfferingDetailsVO(offering.getId(), ApiConstants.DOMAIN_ID, String.valueOf(domainId), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!detailsVO.isEmpty()) {
|
||||||
|
for (ServiceOfferingDetailsVO detail: detailsVO) {
|
||||||
|
detail.setResourceId(offering.getId());
|
||||||
}
|
}
|
||||||
_serviceOfferingDetailsDao.saveDetails(detailsVO);
|
_serviceOfferingDetailsDao.saveDetails(detailsVO);
|
||||||
}
|
}
|
||||||
|
|
@ -2549,11 +2559,15 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||||
}
|
}
|
||||||
final Account account = _accountDao.findById(user.getAccountId());
|
final Account account = _accountDao.findById(user.getAccountId());
|
||||||
if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
|
if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
|
||||||
if (offeringHandle.getDomainId() == null) {
|
final List<ServiceOfferingDetailsVO> details = _serviceOfferingDetailsDao.findDetails(offeringHandle.getId(), ApiConstants.DOMAIN_ID);
|
||||||
|
if (details.isEmpty()) {
|
||||||
throw new InvalidParameterValueException("Unable to update public service offering by id " + userId + " because it is domain-admin");
|
throw new InvalidParameterValueException("Unable to update public service offering by id " + userId + " because it is domain-admin");
|
||||||
}
|
}
|
||||||
if (! _domainDao.isChildDomain(account.getDomainId(), offeringHandle.getDomainId() )) {
|
for (final ServiceOfferingDetailsVO detail : details) {
|
||||||
throw new InvalidParameterValueException("Unable to update service offering by another domain admin with id " + userId);
|
final Long domainId = Long.valueOf(detail.getValue(), 0);
|
||||||
|
if (!_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||||
|
throw new InvalidParameterValueException("Unable to update service offering by another domain admin with id " + userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
} else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
||||||
throw new InvalidParameterValueException("Unable to update service offering by id " + userId + " because it is not root-admin or domain-admin");
|
throw new InvalidParameterValueException("Unable to update service offering by id " + userId + " because it is not root-admin or domain-admin");
|
||||||
|
|
@ -2997,11 +3011,15 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||||
}
|
}
|
||||||
final Account account = _accountDao.findById(user.getAccountId());
|
final Account account = _accountDao.findById(user.getAccountId());
|
||||||
if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
|
if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
|
||||||
if (offering.getDomainId() == null) {
|
final List<ServiceOfferingDetailsVO> details = _serviceOfferingDetailsDao.findDetails(offering.getId(), ApiConstants.DOMAIN_ID);
|
||||||
|
if (details.isEmpty()) {
|
||||||
throw new InvalidParameterValueException("Unable to delete public service offering by id " + userId + " because it is domain-admin");
|
throw new InvalidParameterValueException("Unable to delete public service offering by id " + userId + " because it is domain-admin");
|
||||||
}
|
}
|
||||||
if (! _domainDao.isChildDomain(account.getDomainId(), offering.getDomainId() )) {
|
for (final ServiceOfferingDetailsVO detail : details) {
|
||||||
throw new InvalidParameterValueException("Unable to delete service offering by another domain admin with id " + userId);
|
final Long domainId = Long.valueOf(detail.getValue(), 0);
|
||||||
|
if (!_domainDao.isChildDomain(account.getDomainId(), domainId)) {
|
||||||
|
throw new InvalidParameterValueException("Unable to delete service offering by another domain admin with id " + userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
} else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
||||||
throw new InvalidParameterValueException("Unable to delete service offering by id " + userId + " because it is not root-admin or domain-admin");
|
throw new InvalidParameterValueException("Unable to delete service offering by id " + userId + " because it is not root-admin or domain-admin");
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,9 @@ import com.cloud.network.dao.NetworkDomainDao;
|
||||||
import com.cloud.projects.ProjectManager;
|
import com.cloud.projects.ProjectManager;
|
||||||
import com.cloud.projects.ProjectVO;
|
import com.cloud.projects.ProjectVO;
|
||||||
import com.cloud.projects.dao.ProjectDao;
|
import com.cloud.projects.dao.ProjectDao;
|
||||||
|
import com.cloud.service.dao.ServiceOfferingDao;
|
||||||
import com.cloud.service.dao.ServiceOfferingDetailsDao;
|
import com.cloud.service.dao.ServiceOfferingDetailsDao;
|
||||||
|
import com.cloud.storage.dao.DiskOfferingDao;
|
||||||
import com.cloud.user.dao.AccountDao;
|
import com.cloud.user.dao.AccountDao;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.ManagerBase;
|
import com.cloud.utils.component.ManagerBase;
|
||||||
|
|
@ -97,10 +99,14 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom
|
||||||
@Inject
|
@Inject
|
||||||
private DiskOfferingJoinDao diskOfferingJoinDao;
|
private DiskOfferingJoinDao diskOfferingJoinDao;
|
||||||
@Inject
|
@Inject
|
||||||
|
private DiskOfferingDao diskOfferingDao;
|
||||||
|
@Inject
|
||||||
private DiskOfferingDetailsDao diskOfferingDetailsDao;
|
private DiskOfferingDetailsDao diskOfferingDetailsDao;
|
||||||
@Inject
|
@Inject
|
||||||
private ServiceOfferingJoinDao serviceOfferingJoinDao;
|
private ServiceOfferingJoinDao serviceOfferingJoinDao;
|
||||||
@Inject
|
@Inject
|
||||||
|
private ServiceOfferingDao serviceOfferingDao;
|
||||||
|
@Inject
|
||||||
private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
|
private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
|
||||||
@Inject
|
@Inject
|
||||||
private ProjectDao _projectDao;
|
private ProjectDao _projectDao;
|
||||||
|
|
@ -446,22 +452,23 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String domainIdString = String.valueOf(domainId);
|
||||||
List<Long> diskOfferingsDetailsToRemove = new ArrayList<>();
|
List<Long> diskOfferingsDetailsToRemove = new ArrayList<>();
|
||||||
List<Long> serviceOfferingsDetailsToRemove = new ArrayList<>();
|
List<Long> serviceOfferingsDetailsToRemove = new ArrayList<>();
|
||||||
|
|
||||||
// delete the service and disk offerings associated with this domain
|
// delete the service and disk offerings associated with this domain
|
||||||
List<DiskOfferingJoinVO> diskOfferingsForThisDomain = diskOfferingJoinDao.findByDomainId(domainId);
|
List<DiskOfferingJoinVO> diskOfferingsForThisDomain = diskOfferingJoinDao.findByDomainId(domainId);
|
||||||
for (DiskOfferingJoinVO diskOffering : diskOfferingsForThisDomain) {
|
for (DiskOfferingJoinVO diskOffering : diskOfferingsForThisDomain) {
|
||||||
if (String.valueOf(domainId).equals(diskOffering.getDomainId())) {
|
if (domainIdString.equals(diskOffering.getDomainId())) {
|
||||||
diskOfferingJoinDao.remove(diskOffering.getId());
|
diskOfferingDao.remove(diskOffering.getId());
|
||||||
} else {
|
} else {
|
||||||
diskOfferingsDetailsToRemove.add(diskOffering.getId());
|
diskOfferingsDetailsToRemove.add(diskOffering.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<ServiceOfferingJoinVO> serviceOfferingsForThisDomain = serviceOfferingJoinDao.findByDomainId(domainId);
|
List<ServiceOfferingJoinVO> serviceOfferingsForThisDomain = serviceOfferingJoinDao.findByDomainId(domainId);
|
||||||
for (ServiceOfferingJoinVO serviceOffering : serviceOfferingsForThisDomain) {
|
for (ServiceOfferingJoinVO serviceOffering : serviceOfferingsForThisDomain) {
|
||||||
if (String.valueOf(domainId).equals(serviceOffering.getDomainId())) {
|
if (domainIdString.equals(serviceOffering.getDomainId())) {
|
||||||
serviceOfferingJoinDao.remove(serviceOffering.getId());
|
serviceOfferingDao.remove(serviceOffering.getId());
|
||||||
} else {
|
} else {
|
||||||
serviceOfferingsDetailsToRemove.add(serviceOffering.getId());
|
serviceOfferingsDetailsToRemove.add(serviceOffering.getId());
|
||||||
}
|
}
|
||||||
|
|
@ -469,10 +476,10 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom
|
||||||
|
|
||||||
// Remove domain IDs for offerings which may be multi-domain
|
// Remove domain IDs for offerings which may be multi-domain
|
||||||
for (final Long diskOfferingId : diskOfferingsDetailsToRemove) {
|
for (final Long diskOfferingId : diskOfferingsDetailsToRemove) {
|
||||||
diskOfferingDetailsDao.removeDetail(diskOfferingId, ApiConstants.DOMAIN_ID);
|
diskOfferingDetailsDao.removeDetail(diskOfferingId, ApiConstants.DOMAIN_ID, domainIdString);
|
||||||
}
|
}
|
||||||
for (final Long serviceOfferingId : serviceOfferingsDetailsToRemove) {
|
for (final Long serviceOfferingId : serviceOfferingsDetailsToRemove) {
|
||||||
serviceOfferingDetailsDao.removeDetail(serviceOfferingId, ApiConstants.DOMAIN_ID);
|
serviceOfferingDetailsDao.removeDetail(serviceOfferingId, ApiConstants.DOMAIN_ID, domainIdString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,6 @@ public class DeploymentPlanningManagerImplTest {
|
||||||
@Mock
|
@Mock
|
||||||
Host host;
|
Host host;
|
||||||
|
|
||||||
private static long domainId = 5L;
|
|
||||||
private static long dataCenterId = 1L;
|
private static long dataCenterId = 1L;
|
||||||
private static long hostId = 1l;
|
private static long hostId = 1l;
|
||||||
|
|
||||||
|
|
@ -186,8 +185,8 @@ public class DeploymentPlanningManagerImplTest {
|
||||||
public void dataCenterAvoidTest() throws InsufficientServerCapacityException, AffinityConflictException {
|
public void dataCenterAvoidTest() throws InsufficientServerCapacityException, AffinityConflictException {
|
||||||
ServiceOfferingVO svcOffering =
|
ServiceOfferingVO svcOffering =
|
||||||
new ServiceOfferingVO("testOffering", 1, 512, 500, 1, 1, false, false, false, "test dpm",
|
new ServiceOfferingVO("testOffering", 1, 512, 500, 1, 1, false, false, false, "test dpm",
|
||||||
ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.User, domainId,
|
ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.User,
|
||||||
null, "FirstFitPlanner");
|
null, "FirstFitPlanner");
|
||||||
Mockito.when(vmProfile.getServiceOffering()).thenReturn(svcOffering);
|
Mockito.when(vmProfile.getServiceOffering()).thenReturn(svcOffering);
|
||||||
|
|
||||||
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
||||||
|
|
@ -201,8 +200,8 @@ public class DeploymentPlanningManagerImplTest {
|
||||||
public void plannerCannotHandleTest() throws InsufficientServerCapacityException, AffinityConflictException {
|
public void plannerCannotHandleTest() throws InsufficientServerCapacityException, AffinityConflictException {
|
||||||
ServiceOfferingVO svcOffering =
|
ServiceOfferingVO svcOffering =
|
||||||
new ServiceOfferingVO("testOffering", 1, 512, 500, 1, 1, false, false, false, "test dpm",
|
new ServiceOfferingVO("testOffering", 1, 512, 500, 1, 1, false, false, false, "test dpm",
|
||||||
ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.User, domainId,
|
ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.User,
|
||||||
null, "UserDispersingPlanner");
|
null, "UserDispersingPlanner");
|
||||||
Mockito.when(vmProfile.getServiceOffering()).thenReturn(svcOffering);
|
Mockito.when(vmProfile.getServiceOffering()).thenReturn(svcOffering);
|
||||||
|
|
||||||
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
||||||
|
|
@ -217,8 +216,8 @@ public class DeploymentPlanningManagerImplTest {
|
||||||
public void emptyClusterListTest() throws InsufficientServerCapacityException, AffinityConflictException {
|
public void emptyClusterListTest() throws InsufficientServerCapacityException, AffinityConflictException {
|
||||||
ServiceOfferingVO svcOffering =
|
ServiceOfferingVO svcOffering =
|
||||||
new ServiceOfferingVO("testOffering", 1, 512, 500, 1, 1, false, false, false, "test dpm",
|
new ServiceOfferingVO("testOffering", 1, 512, 500, 1, 1, false, false, false, "test dpm",
|
||||||
ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.User, domainId,
|
ProvisioningType.THIN, false, false, null, false, VirtualMachine.Type.User,
|
||||||
null, "FirstFitPlanner");
|
null, "FirstFitPlanner");
|
||||||
Mockito.when(vmProfile.getServiceOffering()).thenReturn(svcOffering);
|
Mockito.when(vmProfile.getServiceOffering()).thenReturn(svcOffering);
|
||||||
|
|
||||||
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
DataCenterDeployment plan = new DataCenterDeployment(dataCenterId);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue