Skip to content

Commit 2404d34

Browse files
Koushik DasAlex Huang
authored andcommitted
CS-14277
Support for local data disk. Currently enable/disable config is at zone level, in subsequent checkins it can be made more granular. Following changes are made: - Create disk offering API now takes an extra parameter to denote storage type (local or shared). This is similar to storage type in service offering. - Create/delete of data volume on local storage - Attach/detach for local data volumes. Re-attach is allowed as long as vm host and data volume storage pool host is same. - Migration of VM instance is not supported if it uses local root or data volumes. - Migrate is not supported for local volumes. - Zone level config to enable/disable local storage usage for service and disk offerings. - Local storage gets discovered when a host is added/reconnected if zone level config is enabled. When disabled existing local storages are not removed but any new local storage is not added. - Deploy VM command validates service and disk offerings based on local storage config. - Upgrade uses the global config 'use.local.storage' to set the zone level config for local storage. (cherry picked from commit 62710aed37606168012a0ed255a876c8e7954010)
1 parent be00326 commit 2404d34

29 files changed

Lines changed: 286 additions & 124 deletions

api/src/com/cloud/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ public class ApiConstants {
294294
public static final String DHCP_RANGE = "dhcprange";
295295
public static final String UUID = "uuid";
296296
public static final String SECURITY_GROUP_EANBLED = "securitygroupenabled";
297+
public static final String LOCAL_STORAGE_ENABLED = "localstorageenabled";
297298
public static final String GUEST_IP_TYPE = "guestiptype";
298299
public static final String XEN_NETWORK_LABEL = "xennetworklabel";
299300
public static final String KVM_NETWORK_LABEL = "kvmnetworklabel";

api/src/com/cloud/api/commands/CreateDiskOfferingCmd.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.cloud.api.ServerApiException;
2727
import com.cloud.api.response.DiskOfferingResponse;
2828
import com.cloud.offering.DiskOffering;
29+
import com.cloud.offering.ServiceOffering;
2930
import com.cloud.user.Account;
3031

3132
@Implementation(description="Creates a disk offering.", responseObject=DiskOfferingResponse.class)
@@ -56,7 +57,10 @@ public class CreateDiskOfferingCmd extends BaseCmd {
5657
@IdentityMapper(entityTableName="domain")
5758
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the containing domain, null for public offerings")
5859
private Long domainId;
59-
60+
61+
@Parameter(name=ApiConstants.STORAGE_TYPE, type=CommandType.STRING, description="the storage type of the disk offering. Values are local and shared.")
62+
private String storageType = ServiceOffering.StorageType.shared.toString();
63+
6064
/////////////////////////////////////////////////////
6165
/////////////////// Accessors ///////////////////////
6266
/////////////////////////////////////////////////////
@@ -84,6 +88,11 @@ public Boolean isCustomized(){
8488
public Long getDomainId(){
8589
return domainId;
8690
}
91+
92+
public String getStorageType() {
93+
return storageType;
94+
}
95+
8796
/////////////////////////////////////////////////////
8897
/////////////// API Implementation///////////////////
8998
/////////////////////////////////////////////////////

api/src/com/cloud/api/commands/CreateZoneCmd.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ public class CreateZoneCmd extends BaseCmd {
7373
@Parameter(name=ApiConstants.SECURITY_GROUP_EANBLED, type=CommandType.BOOLEAN, description="true if network is security group enabled, false otherwise")
7474
private Boolean securitygroupenabled;
7575

76+
@Parameter(name=ApiConstants.LOCAL_STORAGE_ENABLED, type=CommandType.BOOLEAN, description="true if local storage offering enabled, false otherwise")
77+
private Boolean localStorageEnabled;
78+
7679
/////////////////////////////////////////////////////
7780
/////////////////// Accessors ///////////////////////
7881
/////////////////////////////////////////////////////
@@ -123,8 +126,14 @@ public Boolean getSecuritygroupenabled() {
123126
}
124127
return securitygroupenabled;
125128
}
126-
127-
129+
130+
public Boolean getLocalStorageEnabled() {
131+
if (localStorageEnabled == null) {
132+
return false;
133+
}
134+
return localStorageEnabled;
135+
}
136+
128137
/////////////////////////////////////////////////////
129138
/////////////// API Implementation///////////////////
130139
@Override

api/src/com/cloud/api/commands/DeployVMCmd.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,24 @@ public void create() throws ResourceAllocationException{
374374
if (template == null) {
375375
throw new InvalidParameterValueException("Unable to use template " + templateId);
376376
}
377-
377+
378+
DiskOffering diskOffering = null;
378379
if (diskOfferingId != null) {
379-
DiskOffering diskOffering = _configService.getDiskOffering(diskOfferingId);
380+
diskOffering = _configService.getDiskOffering(diskOfferingId);
380381
if (diskOffering == null) {
381382
throw new InvalidParameterValueException("Unable to find disk offering " + diskOfferingId);
382383
}
383384
}
384385

386+
if (!zone.isLocalStorageEnabled()) {
387+
if (serviceOffering.getUseLocalStorage()) {
388+
throw new InvalidParameterValueException("Zone is not configured to use local storage but service offering " + serviceOffering.getName() + " uses it");
389+
}
390+
if (diskOffering != null && diskOffering.getUseLocalStorage()) {
391+
throw new InvalidParameterValueException("Zone is not configured to use local storage but disk offering " + diskOffering.getName() + " uses it");
392+
}
393+
}
394+
385395
UserVm vm = null;
386396
if (getHypervisor() == HypervisorType.BareMetal) {
387397
vm = _bareMetalVmService.createVirtualMachine(this);

api/src/com/cloud/api/commands/UpdateZoneCmd.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ public class UpdateZoneCmd extends BaseCmd {
8181

8282
@Parameter(name=ApiConstants.DNS_SEARCH_ORDER, type=CommandType.LIST, collectionType = CommandType.STRING, description="the dns search order list")
8383
private List<String> dnsSearchOrder;
84-
84+
85+
@Parameter(name=ApiConstants.LOCAL_STORAGE_ENABLED, type=CommandType.BOOLEAN, description="true if local storage offering enabled, false otherwise")
86+
private Boolean localStorageEnabled;
87+
8588
/////////////////////////////////////////////////////
8689
/////////////////// Accessors ///////////////////////
8790
/////////////////////////////////////////////////////
@@ -137,6 +140,11 @@ public String getDomain() {
137140
public List<String> getDnsSearchOrder() {
138141
return dnsSearchOrder;
139142
}
143+
144+
public Boolean getLocalStorageEnabled() {
145+
return localStorageEnabled;
146+
}
147+
140148
/////////////////////////////////////////////////////
141149
/////////////// API Implementation///////////////////
142150
/////////////////////////////////////////////////////

api/src/com/cloud/api/response/DiskOfferingResponse.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public class DiskOfferingResponse extends BaseResponse {
5151
@SerializedName(ApiConstants.TAGS) @Param(description="the tags for the disk offering")
5252
private String tags;
5353

54+
@SerializedName("storagetype") @Param(description="the storage type for this disk offering")
55+
private String storageType;
56+
5457
public Long getId() {
5558
return id.getValue();
5659
}
@@ -123,4 +126,11 @@ public void setCustomized(Boolean customized) {
123126
this.customized = customized;
124127
}
125128

129+
public String getStorageType() {
130+
return storageType;
131+
}
132+
133+
public void setStorageType(String storageType) {
134+
this.storageType = storageType;
135+
}
126136
}

api/src/com/cloud/api/response/ZoneResponse.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public class ZoneResponse extends BaseResponse {
8686
@SerializedName("capacity") @Param(description="the capacity of the Zone", responseObject = CapacityResponse.class)
8787
private List<CapacityResponse> capacitites;
8888

89+
@SerializedName(ApiConstants.LOCAL_STORAGE_ENABLED) @Param(description="true if local storage offering enabled, false otherwise")
90+
private boolean localStorageEnabled;
91+
8992
public void setId(Long id) {
9093
this.id.setValue(id);
9194
}
@@ -165,4 +168,8 @@ public void setCapacitites(List<CapacityResponse> capacitites) {
165168
public void setDomainName(String domainName) {
166169
this.domainName = domainName;
167170
}
171+
172+
public void setLocalStorageEnabled(boolean localStorageEnabled) {
173+
this.localStorageEnabled = localStorageEnabled;
174+
}
168175
}

api/src/com/cloud/dc/DataCenter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ public enum NetworkType {
7575

7676
String getZoneToken();
7777

78+
boolean isLocalStorageEnabled();
7879
}

client/WEB-INF/classes/resources/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,7 @@ label.linklocal.ip=Link Local IP Adddress
11241124
label.load.balancer=Load Balancer
11251125
label.loading=Loading
11261126
label.local=Local
1127+
label.local.storage.enabled=Local Storage Enabled
11271128
label.login=Login
11281129
label.logout=Logout
11291130
label.lun=LUN

console-proxy/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
</execution>
139139
</executions>
140140
</plugin>
141-
<plugin>
141+
<!--plugin>
142142
<groupId>org.codehaus.mojo</groupId>
143143
<artifactId>exec-maven-plugin</artifactId>
144144
<version>1.2.1</version>
@@ -163,7 +163,7 @@
163163
<argument>authorized_keys</argument>
164164
</arguments>
165165
</configuration>
166-
</plugin>
166+
</plugin-->
167167
</plugins>
168168
</build>
169169
</project>

0 commit comments

Comments
 (0)