remove domain id usage

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2019-04-02 15:41:37 +05:30 committed by Abhishek Kumar
parent 9c117f2781
commit 7721126076
12 changed files with 70 additions and 142 deletions

View File

@ -59,8 +59,6 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId
boolean isUseLocalStorage();
Long getDomainId();
String getName();
boolean isSystemUse();

View File

@ -104,7 +104,6 @@ public interface ServiceOffering extends DiskOffering, InfrastructureEntity, Int
@Override
boolean isUseLocalStorage();
@Override
Long getDomainId();
/**

View File

@ -17,8 +17,6 @@
package org.apache.cloudstack.api.response;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
@ -35,13 +33,21 @@ public class DiskOfferingResponse extends BaseResponse {
private String id;
@SerializedName(ApiConstants.DOMAIN_ID)
@Param(description = "the domain ID this disk offering belongs to. Ignore this information as it is not currently applicable.")
@Param(description = "the domain ID(s) this disk offering belongs to. Ignore this information as it is not currently applicable.")
private String domainId;
@SerializedName(ApiConstants.DOMAIN)
@Param(description = "the domain name this disk offering belongs to. Ignore this information as it is not currently applicable.")
@Param(description = "the domain name(s) this disk offering belongs to. Ignore this information as it is not currently applicable.")
private String domain;
@SerializedName(ApiConstants.ZONE_ID)
@Param(description = "the zone ID(s) this disk offering belongs to. Ignore this information as it is not currently applicable.", since = "4.13.0")
private String zoneId;
@SerializedName(ApiConstants.ZONE)
@Param(description = "the zone name(s) this disk offering belongs to. Ignore this information as it is not currently applicable.", since = "4.13.0")
private String zone;
@SerializedName(ApiConstants.NAME)
@Param(description = "the name of the disk offering")
private String name;
@ -145,10 +151,6 @@ public class DiskOfferingResponse extends BaseResponse {
@Param(description = "whether to display the offering to the end user or not.")
private Boolean displayOffering;
@SerializedName(ApiConstants.DETAILS)
@Param(description = "the details of the disk offering", since = "4.13.0")
private Map<String, Object> details = new HashMap<>();
public Boolean getDisplayOffering() {
return displayOffering;
}
@ -182,6 +184,22 @@ public class DiskOfferingResponse extends BaseResponse {
this.domain = domain;
}
public String getZoneId() {
return zoneId;
}
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public String getZone() {
return zone;
}
public void setZone(String zone) {
this.zone = zone;
}
public String getName() {
return name;
}
@ -333,16 +351,4 @@ public class DiskOfferingResponse extends BaseResponse {
public void setIopsWriteRateMaxLength(Long iopsWriteRateMaxLength) {
this.iopsWriteRateMaxLength = iopsWriteRateMaxLength;
}
public Map<String, Object> getDetails() {
return details;
}
public void putDetail(String key, Object value) {
this.details.put(key, value);
}
public void setDetails(Map<String, Object> details) {
this.details = details;
}
}

View File

@ -35,6 +35,9 @@ import com.cloud.vm.VirtualMachine;
@DiscriminatorValue(value = "Service")
@PrimaryKeyJoinColumn(name = "id")
public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering {
@Column(name = "domain_id")
Long domainId;
@Column(name = "cpu")
private Integer cpu;
@ -106,7 +109,8 @@ 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,
boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, Long domainId) {
super(name, displayText, provisioningType, false, tags, recreatable, useLocalStorage, systemUse, true, domainId);
super(name, displayText, provisioningType, false, tags, recreatable, useLocalStorage, systemUse, true);
this.domainId = domainId;
this.cpu = cpu;
this.ramSize = ramSize;
this.speed = speed;
@ -177,9 +181,9 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
offering.isSystemUse(),
true,
offering.isCustomizedIops()== null ? false:offering.isCustomizedIops(),
offering.getDomainId(),
offering.getMinIops(),
offering.getMaxIops());
domainId = offering.getDomainId();
cpu = offering.getCpu();
ramSize = offering.getRamSize();
speed = offering.getSpeed();
@ -192,6 +196,11 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
vmType = offering.getSystemVmType();
}
@Override
public Long getDomainId() {
return domainId;
}
@Override
public boolean isOfferHA() {
return offerHA;

View File

@ -50,10 +50,6 @@ public class DiskOfferingVO implements DiskOffering {
@Column(name = "id")
long id;
// TODO: remove me
@Column(name = "domain_id")
Long domainId = null;
@Column(name = "unique_name")
private String uniqueName;
@ -164,9 +160,8 @@ public class DiskOfferingVO implements DiskOffering {
uuid = UUID.randomUUID().toString();
}
public DiskOfferingVO(Long domainId, String name, String displayText, Storage.ProvisioningType provisioningType, long diskSize, String tags, boolean isCustomized, Boolean isCustomizedIops,
public DiskOfferingVO(String name, String displayText, Storage.ProvisioningType provisioningType, long diskSize, String tags, boolean isCustomized, Boolean isCustomizedIops,
Long minIops, Long maxIops, DiskCacheMode cacheMode) {
this.domainId = domainId;
this.name = name;
this.displayText = displayText;
this.provisioningType = provisioningType;
@ -201,28 +196,8 @@ public class DiskOfferingVO implements DiskOffering {
state = State.Active;
}
public DiskOfferingVO(Long domainId, String name, String displayText, Storage.ProvisioningType provisioningType, long diskSize, String tags, boolean isCustomized, Boolean isCustomizedIops,
Long minIops, Long maxIops) {
this.domainId = domainId;
this.name = name;
this.displayText = displayText;
this.provisioningType = provisioningType;
this.diskSize = diskSize;
this.tags = tags;
recreatable = false;
type = Type.Disk;
useLocalStorage = false;
customized = isCustomized;
uuid = UUID.randomUUID().toString();
customizedIops = isCustomizedIops;
this.minIops = minIops;
this.maxIops = maxIops;
state = State.Active;
}
public DiskOfferingVO(String name, String displayText, Storage.ProvisioningType provisioningType, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage, boolean systemUse,
boolean customized) {
domainId = null;
type = Type.Service;
this.name = name;
this.displayText = displayText;
@ -236,26 +211,8 @@ public class DiskOfferingVO implements DiskOffering {
state = State.Active;
}
// domain specific offerings constructor (null domainId implies public
// offering)
public DiskOfferingVO(String name, String displayText, Storage.ProvisioningType provisioningType, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage, boolean systemUse,
boolean customized, Long domainId) {
type = Type.Service;
this.name = name;
this.displayText = displayText;
this.provisioningType = provisioningType;
this.tags = tags;
this.recreatable = recreatable;
this.useLocalStorage = useLocalStorage;
this.systemUse = systemUse;
this.customized = customized;
this.domainId = domainId;
uuid = UUID.randomUUID().toString();
state = State.Active;
}
public DiskOfferingVO(long id, String name, String displayText, Storage.ProvisioningType provisioningType, boolean mirrored, String tags, boolean recreatable, boolean useLocalStorage,
boolean systemUse, boolean customized, boolean customizedIops, Long domainId, Long minIops, Long maxIops) {
boolean systemUse, boolean customized, boolean customizedIops, Long minIops, Long maxIops) {
this.id = id;
type = Type.Service;
this.name = name;
@ -267,7 +224,6 @@ public class DiskOfferingVO implements DiskOffering {
this.systemUse = systemUse;
this.customized = customized;
this.customizedIops = customizedIops;
this.domainId = domainId;
uuid = UUID.randomUUID().toString();
state = State.Active;
this.minIops = minIops;
@ -347,11 +303,6 @@ public class DiskOfferingVO implements DiskOffering {
return useLocalStorage;
}
@Override
public Long getDomainId() {
return domainId;
}
@Override
public Type getType() {
return type;
@ -362,10 +313,6 @@ public class DiskOfferingVO implements DiskOffering {
return recreatable;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
@Override
public String getName() {
return name;

View File

@ -36,6 +36,9 @@ import com.cloud.vm.VirtualMachine;
@DiscriminatorValue(value = "Service")
@PrimaryKeyJoinColumn(name = "id")
public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering {
@Column(name = "domain_id")
Long domainId;
@Column(name = "cpu")
private Integer cpu;
@ -103,7 +106,8 @@ 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,
boolean volatileVm, String displayText, ProvisioningType provisioningType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse,
VirtualMachine.Type vmType, Long domainId) {
super(name, displayText, provisioningType, false, tags, recreatable, useLocalStorage, systemUse, true, domainId);
super(name, displayText, provisioningType, false, tags, recreatable, useLocalStorage, systemUse, true);
this.domainId = domainId;
this.cpu = cpu;
this.ramSize = ramSize;
this.speed = speed;
@ -133,8 +137,9 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
public ServiceOfferingVO(ServiceOfferingVO offering) {
super(offering.getId(), offering.getName(), offering.getDisplayText(), offering.getProvisioningType(), false, offering.getTags(), offering.isRecreatable(),
offering.isUseLocalStorage(), offering.isSystemUse(), true, offering.isCustomizedIops() == null ? false : offering.isCustomizedIops(), offering.getDomainId(),
offering.isUseLocalStorage(), offering.isSystemUse(), true, offering.isCustomizedIops() == null ? false : offering.isCustomizedIops(),
offering.getMinIops(), offering.getMaxIops());
domainId = offering.getDomainId();
cpu = offering.getCpu();
ramSize = offering.getRamSize();
speed = offering.getSpeed();
@ -226,6 +231,11 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
return multicastRateMbps;
}
@Override
public Long getDomainId() {
return domainId;
}
public void setHostTag(String hostTag) {
this.hostTag = hostTag;
}

View File

@ -1915,7 +1915,7 @@ public class ApiDBUtils {
public static DiskOfferingResponse newDiskOfferingResponse(DiskOfferingJoinVO offering) {
DiskOfferingResponse diskOfferingResponse = s_diskOfferingJoinDao.newDiskOfferingResponse(offering);
if (diskOfferingResponse != null) {
Map<String, String> details = s_diskOfferingDetailsDao.listDetailsKeyPairs(offering.getId(), true);
Map<String, String> details = s_diskOfferingDetailsDao.listDetailsKeyPairs(offering.getId());
if (MapUtils.isNotEmpty(details)) {
// Domains
String[] domainIds = details.getOrDefault(ApiConstants.DOMAIN_ID_LIST, "").split(",");
@ -1923,14 +1923,16 @@ public class ApiDBUtils {
for (DomainVO domain : s_domainDao.list(domainIds)) {
domains.put(domain.getName(), domain.getUuid());
}
diskOfferingResponse.putDetail(ApiConstants.DOMAIN, domains);
diskOfferingResponse.setDomain(String.join(", ", domains.keySet()));
diskOfferingResponse.setDomainId(String.join(", ", domains.values()));
// Zones
String[] zoneIds = details.getOrDefault(ApiConstants.ZONE_ID_LIST, "").split(",");
final Map<String, String> zones = new HashMap<>();
for (DataCenterVO zone : s_zoneDao.list(zoneIds)) {
zones.put(zone.getName(), zone.getUuid());
}
diskOfferingResponse.putDetail(ApiConstants.ZONE, zones);
diskOfferingResponse.setZone(String.join(", ", zones.keySet()));
diskOfferingResponse.setZoneId(String.join(", ", zones.values()));
}
}
return diskOfferingResponse;

View File

@ -63,8 +63,6 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
diskOfferingResponse.setMinIops(offering.getMinIops());
diskOfferingResponse.setMaxIops(offering.getMaxIops());
diskOfferingResponse.setDomain(offering.getDomainName());
diskOfferingResponse.setDomainId(offering.getDomainUuid());
diskOfferingResponse.setDisplayOffering(offering.isDisplayOffering());
diskOfferingResponse.setTags(offering.getTags());

View File

@ -23,11 +23,11 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.storage.Storage;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.offering.DiskOffering.Type;
import com.cloud.storage.Storage;
import com.cloud.utils.db.GenericDao;
@Entity
@ -128,18 +128,6 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity,
@Column(name = GenericDao.REMOVED_COLUMN)
private Date removed;
@Column(name = "domain_id")
private long domainId;
@Column(name = "domain_uuid")
private String domainUuid;
@Column(name = "domain_name")
private String domainName = null;
@Column(name = "domain_path")
private String domainPath = null;
@Column(name = "display_offering")
boolean displayOffering;
@ -224,22 +212,6 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity,
return removed;
}
public long getDomainId() {
return domainId;
}
public String getDomainUuid() {
return domainUuid;
}
public String getDomainName() {
return domainName;
}
public String getDomainPath() {
return domainPath;
}
public int getSortKey() {
return sortKey;
}

View File

@ -225,11 +225,11 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
createServiceOffering(User.UID_SYSTEM, "Small Instance", 1, 512, 500, "Small Instance", ProvisioningType.THIN, false, false, null);
createServiceOffering(User.UID_SYSTEM, "Medium Instance", 1, 1024, 1000, "Medium Instance", ProvisioningType.THIN, false, false, null);
// Save default disk offerings
createdefaultDiskOffering(null, "Small", "Small Disk, 5 GB", ProvisioningType.THIN, 5, null, false, false);
createdefaultDiskOffering(null, "Medium", "Medium Disk, 20 GB", ProvisioningType.THIN, 20, null, false, false);
createdefaultDiskOffering(null, "Large", "Large Disk, 100 GB", ProvisioningType.THIN, 100, null, false, false);
createdefaultDiskOffering(null, "Large", "Large Disk, 100 GB", ProvisioningType.THIN, 100, null, false, false);
createdefaultDiskOffering(null, "Custom", "Custom Disk", ProvisioningType.THIN, 0, null, true, false);
createDefaultDiskOffering("Small", "Small Disk, 5 GB", ProvisioningType.THIN, 5, null, false, false);
createDefaultDiskOffering("Medium", "Medium Disk, 20 GB", ProvisioningType.THIN, 20, null, false, false);
createDefaultDiskOffering("Large", "Large Disk, 100 GB", ProvisioningType.THIN, 100, null, false, false);
createDefaultDiskOffering("Large", "Large Disk, 100 GB", ProvisioningType.THIN, 100, null, false, false);
createDefaultDiskOffering("Custom", "Custom Disk", ProvisioningType.THIN, 0, null, true, false);
// Save the mount parent to the configuration table
String mountParent = getMountParent();
@ -920,13 +920,13 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
return pod;
}
private DiskOfferingVO createdefaultDiskOffering(Long domainId, String name, String description, ProvisioningType provisioningType,
int numGibibytes, String tags, boolean isCustomized, boolean isSystemUse) {
private DiskOfferingVO createDefaultDiskOffering(String name, String description, ProvisioningType provisioningType,
int numGibibytes, String tags, boolean isCustomized, boolean isSystemUse) {
long diskSize = numGibibytes;
diskSize = diskSize * 1024 * 1024 * 1024;
tags = cleanupTags(tags);
DiskOfferingVO newDiskOffering = new DiskOfferingVO(domainId, name, description, provisioningType, diskSize, tags, isCustomized, null, null, null);
DiskOfferingVO newDiskOffering = new DiskOfferingVO(name, description, provisioningType, diskSize, tags, isCustomized, null, null, null);
newDiskOffering.setUniqueName("Cloud.Com-" + name);
// leaving the above reference to cloud.com in as it is an identifyer and has no real world relevance
newDiskOffering.setSystemUse(isSystemUse);

View File

@ -983,7 +983,6 @@ public class DatabaseConfig {
@DB
protected void saveDiskOffering() {
long id = Long.parseLong(_currentObjectParams.get("id"));
long domainId = Long.parseLong(_currentObjectParams.get("domainId"));
String name = _currentObjectParams.get("name");
String displayText = _currentObjectParams.get("displayText");
ProvisioningType provisioningType = ProvisioningType.valueOf(_currentObjectParams.get("provisioningtype"));
@ -1006,7 +1005,7 @@ public class DatabaseConfig {
newTags.delete(newTags.length() - 1, newTags.length());
tags = newTags.toString();
}
DiskOfferingVO diskOffering = new DiskOfferingVO(domainId, name, displayText, provisioningType, diskSpace, tags, false, null, null, null);
DiskOfferingVO diskOffering = new DiskOfferingVO(name, displayText, provisioningType, diskSpace, tags, false, null, null, null);
diskOffering.setUseLocalStorage(local);
Long bytesReadRate = Long.parseLong(_currentObjectParams.get("bytesReadRate"));

View File

@ -2438,11 +2438,11 @@
tags: {
label: 'label.storage.tags'
},
domains: {
label: 'label.domains'
domain: {
label: 'label.domain'
},
zones: {
label: 'label.zones'
zone: {
label: 'label.zone'
},
storagetype: {
label: 'label.storage.type'
@ -2461,18 +2461,6 @@
data: data
};
var diskOffering = cloudStack.listDiskOfferings(listDiskOfferingsOptions)[0];
if (diskOffering.details) {
if (diskOffering.details.domain) {
$.extend(diskOffering, {
domains: Object.keys(diskOffering.details.domain).join(', ')
});
}
if (diskOffering.details.zone) {
$.extend(diskOffering, {
zones: Object.keys(diskOffering.details.zone).join(', ')
});
}
}
args.response.success({
actionFilter: diskOfferingActionfilter,
data: diskOffering