Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
6233ebd
File share : db schema
abh1sar Jun 1, 2024
bbbbb69
File Share : FileShare interface with fsm and constants
abh1sar Jun 1, 2024
af3d873
File share : crud apis, vo and dao skeleton.
abh1sar Jun 1, 2024
dc916f8
File Share : ServiceImpl class and framework-plugin structure
abh1sar Jun 1, 2024
948ee45
File Share : Skeleton code for SimulatorFileShareProvider and Storage…
abh1sar Jun 2, 2024
d6aac5c
File Share : Dao spring context, added created and removed to VO
abh1sar Jun 4, 2024
5bff62e
File Share : minor changes to FileShareDao
abh1sar Jun 4, 2024
43ccf1e
File Share : Added lifecycle class, file share provider map etc
abh1sar Jun 5, 2024
96375f3
File Share : added emtpy constructor to FileShareVO
abh1sar Jun 5, 2024
0f52310
File Share : Added schema, vo and dao for storagefsvm table plus othe…
abh1sar Jun 8, 2024
3a692b9
File Share : Api, response and service layer changes for create, list…
abh1sar Jun 21, 2024
e21c457
Merge remote-tracking branch 'upstream/main' into fsp_synced
abh1sar Jun 21, 2024
a156214
File Share : minor fix to gen_toc
abh1sar Jun 21, 2024
4bd8283
File Share : api, service layer implementations
abh1sar Jun 23, 2024
ebbc1e8
File Share : minor - import remove in StorageFsVMFileShareLifeCycle
abh1sar Jun 23, 2024
6d85670
UI, fileshare response, update api
abh1sar Jun 29, 2024
f3fd82c
Merge remote-tracking branch 'upstream/main' into fsp
abh1sar Jun 29, 2024
204aaa1
fix StorageFsVmFileShareLifeCycle impl
abh1sar Jun 29, 2024
fcb39c2
State and event changes
abh1sar Jun 29, 2024
997d914
ui/locales for fileshare
abh1sar Jun 29, 2024
8791690
Merge branch 'main' into filesharepoc
abh1sar Jun 29, 2024
0c10548
event for initialize and deploy
abh1sar Jun 29, 2024
a99cafb
UI custom disk offering
abh1sar Jul 1, 2024
1bd9219
Merge branch 'main' into filesharepoc
abh1sar Jul 1, 2024
bb00408
UI: Instance and Volume tab. offerings in details pane
abh1sar Jul 1, 2024
fc486d4
size in createFileShareCmd can be null if diskoffering is not custom
abh1sar Jul 2, 2024
f205961
New disk offering flag for fileshares
abh1sar Jul 5, 2024
53c3a47
db change to support new disk offering flag for file share
abh1sar Jul 5, 2024
7f02195
Remove VM type StorageFsVm and related VO/Dao. Remove Simulator provider
abh1sar Jul 5, 2024
df8268d
Fixed nics in fileshare response + some ui changes + new user vm type…
abh1sar Jul 9, 2024
ef0a9fb
Merge remote-tracking branch 'upstream/main' into fsp
abh1sar Jul 9, 2024
87f8001
Added storage_fileshare_view table,vo,dao. updated fileshareresponse …
abh1sar Jul 10, 2024
38aec51
Merge branch 'main' into filesharepoc
abh1sar Jul 10, 2024
9ebf866
systemvm changes
abh1sar Jul 15, 2024
50f9148
add storagefsvm type to cmdline args
abh1sar Jul 15, 2024
feedf98
fsvm cloud init
abh1sar Jul 15, 2024
f50c4f9
Createfileshare ui to get networks andoffering for specific account a…
abh1sar Jul 15, 2024
24b33a1
Merge branch 'main' into filesharepoc
abh1sar Jul 15, 2024
4c7a1c6
fix pre-commit failures
abh1sar Jul 15, 2024
0ea68a7
remove simulator from pom.xml. provider and lifecycle
abh1sar Jul 15, 2024
be5defe
Disable attach.detach volume. Xfs install and resize
abh1sar Jul 16, 2024
2c07fe8
remove size column in storage_fileshare and get it from the volume
abh1sar Jul 16, 2024
7d156ff
get disk offering from volume. change diskoffering for file share
abh1sar Jul 16, 2024
253e230
Don't show file share diskoffering by default
abh1sar Jul 16, 2024
fdaf3bb
Restart file share with cleanup + misc changes
abh1sar Jul 20, 2024
ee20973
attachVoltoVM for fileshare restart
abh1sar Jul 21, 2024
92d07dc
minor change in deleteFileShare
abh1sar Jul 21, 2024
b434266
create default fsvm disk offering
abh1sar Jul 21, 2024
336e016
filesystem and hypervisor specific fsvm init
abh1sar Jul 21, 2024
78476d9
show volume stats in file share view
abh1sar Jul 21, 2024
08b3fa0
Merge remote-tracking branch 'upstream/main' into fsp
abh1sar Jul 22, 2024
f72beb5
Added minimum cpu,ram limit to service offerings
abh1sar Jul 22, 2024
97cdbc6
add serviceoffering to update fileshare
abh1sar Jul 22, 2024
9f5bce3
fileshare start,stop, change offering apis
abh1sar Jul 23, 2024
8544c34
UI for fileshare resize,start,stop,changeoffering
abh1sar Jul 23, 2024
6efc1f6
Don't try to format the disk on restart with cleanup
abh1sar Jul 23, 2024
91f9d02
file share instance tab improvement
abh1sar Jul 24, 2024
29602d0
Expunge logic
abh1sar Jul 24, 2024
8d13e17
Recover and Expunge api + ui
abh1sar Jul 24, 2024
c988752
fs format changes
abh1sar Jul 24, 2024
5d2e2a6
Ui improvements for Fileshare tabs
abh1sar Jul 26, 2024
4391eb5
minor ui fixes
abh1sar Jul 26, 2024
15fc2eb
Project,domain,account basic handling
abh1sar Jul 28, 2024
d380e66
Remove file share specific disk offering
abh1sar Jul 28, 2024
249e660
Project owned fileshare fixes
abh1sar Jul 29, 2024
c9726a0
uservm type in uservmresponse + add storagefsvm config to capability
abh1sar Jul 29, 2024
72c7d18
remove file share resize api and ui
abh1sar Jul 29, 2024
f873149
fix in global setting to disable file share feature
abh1sar Jul 29, 2024
e892ff7
API checks and ui fix for changeSrviceoffering
abh1sar Jul 29, 2024
0e4a74a
Added checks to service apis
abh1sar Jul 30, 2024
a2f5df6
UI improvements re groupaction and filter
abh1sar Jul 30, 2024
41b34b3
disawllow vm operations on storagefsvm
abh1sar Jul 30, 2024
62fd111
fix pre-commit failure
abh1sar Jul 30, 2024
2d9210c
Merge remote-tracking branch 'upstream/main' into fsp
abh1sar Jul 30, 2024
8c52ef8
Improvements for the service layer
abh1sar Aug 2, 2024
04844d8
fix pre-commit failure
abh1sar Aug 2, 2024
0e4990b
fix pre-commit failure
abh1sar Aug 2, 2024
9f72120
Misc backend minor changes
abh1sar Aug 2, 2024
fa628cb
Minor misc ui improvements
abh1sar Aug 2, 2024
5b0c829
Added ui/api support for chosing fs format
abh1sar Aug 2, 2024
74ffafb
export share to all networks
abh1sar Aug 2, 2024
2ce6663
Fixed storagefsvm naming
abh1sar Aug 4, 2024
a5c291e
Improvement to the Access tab
abh1sar Aug 4, 2024
a2f8333
Added dochelp to ui + minor changes
abh1sar Aug 5, 2024
a2bd0fd
Changes to storagefsvm.sh
abh1sar Aug 5, 2024
94369c8
UT for service and lifecycle classes + minor fixes
abh1sar Aug 7, 2024
d947b41
Merge remote-tracking branch 'upstream/main' into fsp
abh1sar Aug 7, 2024
f76ea14
fix pre-commit failures
abh1sar Aug 7, 2024
36a72d4
increase timeout for scan lock
abh1sar Aug 7, 2024
2efbfb2
Fixed UT failures
abh1sar Aug 7, 2024
506094a
Added fileShareJoinDao UT and minor fixes
abh1sar Aug 7, 2024
563a7f4
Addressed 1st set of comments by Wei
abh1sar Aug 7, 2024
03d2193
Merge remote-tracking branch 'upstream/main' into fsp
abh1sar Aug 7, 2024
a974741
fix precommit failure
abh1sar Aug 7, 2024
99e6733
Addressed first set of comments from Abhishek
abh1sar Aug 8, 2024
9ff34b8
passing hypervisor type to userdata
abh1sar Aug 8, 2024
bcc6927
Iterate through hypervisors until a vm deployment is successful
abh1sar Aug 11, 2024
5101a7b
Merge remote-tracking branch 'upstream/main' into fs
abh1sar Aug 11, 2024
06f5b25
merged try-catch block for create and start vm
abh1sar Aug 12, 2024
9e41a2e
Integration test for file share
abh1sar Aug 13, 2024
2cd8400
Added more unit tests
abh1sar Aug 13, 2024
f4dd8e3
Merge remote-tracking branch 'upstream/main' into fs
abh1sar Aug 13, 2024
499bc74
Fixed ut failure due to GlobalLock
abh1sar Aug 13, 2024
9c6351c
fixed pre-commit failure
abh1sar Aug 13, 2024
2da161d
Fixed resize udev rules
abh1sar Aug 14, 2024
806cd6a
Merge branch 'main' into filesharepoc
abh1sar Aug 14, 2024
eb0d5b9
dropdown for format and remove provider in create form
abh1sar Aug 20, 2024
1c0aae9
Fix for zone being displayed twice in the create form
abh1sar Aug 20, 2024
c7c0de3
Expunge fileshares in Error state automatically
abh1sar Aug 21, 2024
0aefdfd
Fix expunge and force select option not working with Group Destroy
abh1sar Aug 21, 2024
dd7bd92
Merge remote-tracking branch 'upstream/main' into fs
abh1sar Aug 21, 2024
4b773b6
Added fileshare resize to integration test
abh1sar Aug 21, 2024
f45d7fc
Merge branch 'filesharepoc' of https://github.com/abh1sar/cloudstack …
abh1sar Aug 21, 2024
eeb17cd
Rename format to filesystem
abh1sar Aug 21, 2024
e121755
minor changes to createfileshare form
abh1sar Aug 21, 2024
5443011
run dhclient for interfaces added before cloud-init + no_root-squash
abh1sar Aug 26, 2024
5bfdc8b
Restart with cleanup and changeServiceOffering with preserve ip
abh1sar Aug 26, 2024
0683400
Rename File Share to Shared FileSystem
abh1sar Aug 28, 2024
bf44f56
Don't allow duplicate shared fs name for the same account
abh1sar Aug 28, 2024
065dbef
Merge remote-tracking branch 'upstream/main' into fs
abh1sar Aug 28, 2024
5d1f417
remove sharedfsdaoimpletest and added eof line to init.sh
abh1sar Aug 28, 2024
0c6a29a
Added domain path to shared fs view
abh1sar Aug 28, 2024
db168a5
changed export path to /export and shared network related checks
abh1sar Aug 28, 2024
3804e8e
Fix SharefFSServiceImpleTest failure
abh1sar Aug 28, 2024
12068dc
disallow duplicate shared fs name for account-domain
abh1sar Aug 28, 2024
c500b05
Merge remote-tracking branch 'upstream/main' into fs
abh1sar Aug 29, 2024
c78cd80
Filter shared filesystems by network
abh1sar Aug 29, 2024
722ab10
fix addnictovm failure in smokes
abh1sar Aug 30, 2024
379d8c5
resize udev trigger doesn't work if vm is stopped
abh1sar Aug 30, 2024
74a036e
fix pre-commit failure
abh1sar Aug 30, 2024
3a02beb
xfs_growfs should work on the mount point, not on the device
abh1sar Sep 1, 2024
a568a8d
Merge remote-tracking branch 'upstream/main' into fsp
abh1sar Sep 2, 2024
45e0ffe
rename storagefsvm to sharedfsvm. ssh related changes in sharedfsvm.sh
abh1sar Sep 2, 2024
cab8504
Change storagefsvm -> sharedfsvm in init.sh
abh1sar Sep 3, 2024
61a9db9
fix integration test failure for vmware and xen
abh1sar Sep 3, 2024
9541620
Update systemvm/debian/opt/cloud/bin/setup/cloud-early-config
weizhouapache Sep 3, 2024
c11a523
Addressed comments by Wei
abh1sar Sep 3, 2024
905ebf9
Fix integration test for xenserver
abh1sar Sep 3, 2024
7c5cd19
Merge branch 'filesharepoc' of https://github.com/abh1sar/cloudstack …
abh1sar Sep 3, 2024
7139be4
fix sharedfs create on shared project network
abh1sar Sep 3, 2024
8f64d60
remove resetsshkeypair support for sharedfsvm
abh1sar Sep 3, 2024
a82b732
Merge remote-tracking branch 'upstream/main' into fs
abh1sar Sep 4, 2024
5665cab
Run the resize filesystem script via add udev rule if resize is done …
abh1sar Sep 4, 2024
f8c26d2
Fix resize.service for ext4
abh1sar Sep 4, 2024
cf8f85f
systemvm optimization + minor changes in ui and test
abh1sar Sep 5, 2024
1cf6c90
Merge remote-tracking branch 'upstream/main' into fs
abh1sar Sep 5, 2024
c5214ac
Merge remote-tracking branch 'upstream/main' into fs
abh1sar Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions api/src/main/java/com/cloud/event/EventTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.cloudstack.config.Configuration;
import org.apache.cloudstack.ha.HAConfig;
import org.apache.cloudstack.quota.QuotaTariff;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.object.Bucket;
import org.apache.cloudstack.storage.object.ObjectStore;
import org.apache.cloudstack.usage.Usage;
Expand Down Expand Up @@ -744,6 +745,18 @@ public class EventTypes {
public static final String EVENT_QUOTA_TARIFF_DELETE = "QUOTA.TARIFF.DELETE";
public static final String EVENT_QUOTA_TARIFF_UPDATE = "QUOTA.TARIFF.UPDATE";

// SharedFS
public static final String EVENT_SHAREDFS_CREATE = "SHAREDFS.CREATE";
public static final String EVENT_SHAREDFS_START = "SHAREDFS.START";
public static final String EVENT_SHAREDFS_UPDATE = "SHAREDFS.UPDATE";
public static final String EVENT_SHAREDFS_CHANGE_SERVICE_OFFERING = "SHAREDFS.CHANGE.SERVICE.OFFERING";
public static final String EVENT_SHAREDFS_CHANGE_DISK_OFFERING = "SHAREDFS.CHANGE.DISK.OFFERING";
public static final String EVENT_SHAREDFS_STOP = "SHAREDFS.STOP";
public static final String EVENT_SHAREDFS_RESTART = "SHAREDFS.RESTART";
public static final String EVENT_SHAREDFS_DESTROY = "SHAREDFS.DESTROY";
public static final String EVENT_SHAREDFS_EXPUNGE = "SHAREDFS.EXPUNGE";
public static final String EVENT_SHAREDFS_RECOVER = "SHAREDFS.RECOVER";

static {

// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
Expand Down Expand Up @@ -1203,6 +1216,18 @@ public class EventTypes {
entityEventDetails.put(EVENT_QUOTA_TARIFF_CREATE, QuotaTariff.class);
entityEventDetails.put(EVENT_QUOTA_TARIFF_DELETE, QuotaTariff.class);
entityEventDetails.put(EVENT_QUOTA_TARIFF_UPDATE, QuotaTariff.class);

// SharedFS
entityEventDetails.put(EVENT_SHAREDFS_CREATE, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_START, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_STOP, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_UPDATE, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_CHANGE_SERVICE_OFFERING, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_CHANGE_DISK_OFFERING, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_RESTART, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_DESTROY, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_EXPUNGE, SharedFS.class);
entityEventDetails.put(EVENT_SHAREDFS_RECOVER, SharedFS.class);
}

public static boolean isNetworkEvent(String eventType) {
Expand Down
4 changes: 4 additions & 0 deletions api/src/main/java/com/cloud/storage/VolumeApiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ public interface VolumeApiService {

boolean deleteVolume(long volumeId, Account caller);

Volume changeDiskOfferingForVolumeInternal(Long volumeId, Long newDiskOfferingId, Long newSize, Long newMinIops, Long newMaxIops, boolean autoMigrateVolume, boolean shrinkOk) throws ResourceAllocationException;

Volume attachVolumeToVM(AttachVolumeCmd command);

Volume attachVolumeToVM(Long vmId, Long volumeId, Long deviceId, Boolean allowAttachForSharedFS);

Volume detachVolumeViaDestroyVM(long vmId, long volumeId);

Volume detachVolumeFromVM(DetachVolumeCmd cmd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public enum ApiCommandResourceType {
Bucket(org.apache.cloudstack.storage.object.Bucket.class),
QuotaTariff(org.apache.cloudstack.quota.QuotaTariff.class),
KubernetesCluster(null),
KubernetesSupportedVersion(null);
KubernetesSupportedVersion(null),
SharedFS(org.apache.cloudstack.storage.sharedfs.SharedFS.class);

private final Class<?> clazz;

Expand Down
6 changes: 6 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public class ApiConstants {
public static final String EXTERNAL_UUID = "externaluuid";
public static final String FENCE = "fence";
public static final String FETCH_LATEST = "fetchlatest";
public static final String FILESYSTEM = "filesystem";
public static final String FIRSTNAME = "firstname";
public static final String FORCED = "forced";
public static final String FORCED_DESTROY_LOCAL_STORAGE = "forcedestroylocalstorage";
Expand Down Expand Up @@ -432,6 +433,7 @@ public class ApiConstants {
public static final String SIGNATURE_VERSION = "signatureversion";
public static final String SINCE = "since";
public static final String SIZE = "size";
public static final String SIZEGB = "sizegb";
public static final String SNAPSHOT = "snapshot";
public static final String SNAPSHOT_ID = "snapshotid";
public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
Expand Down Expand Up @@ -504,6 +506,7 @@ public class ApiConstants {
public static final String VIRTUAL_MACHINE_ID_IP = "vmidipmap";
public static final String VIRTUAL_MACHINE_COUNT = "virtualmachinecount";
public static final String VIRTUAL_MACHINE_TYPE = "virtualmachinetype";
public static final String VIRTUAL_MACHINE_STATE = "vmstate";
public static final String VIRTUAL_MACHINES = "virtualmachines";
public static final String USAGE_ID = "usageid";
public static final String USAGE_TYPE = "usagetype";
Expand Down Expand Up @@ -1143,6 +1146,9 @@ public class ApiConstants {

public static final String NFS_MOUNT_OPTIONS = "nfsmountopts";

public static final String SHAREDFSVM_MIN_CPU_COUNT = "sharedfsvmmincpucount";
public static final String SHAREDFSVM_MIN_RAM_SIZE = "sharedfsvmminramsize";

public static final String PARAMETER_DESCRIPTION_ACTIVATION_RULE = "Quota tariff's activation rule. It can receive a JS script that results in either " +
"a boolean or a numeric value: if it results in a boolean value, the tariff value will be applied according to the result; if it results in a numeric value, the " +
"numeric value will be applied; if the result is neither a boolean nor a numeric value, the tariff will not be applied. If the rule is not informed, the tariff " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.apache.cloudstack.api.response.DomainRouterResponse;
import org.apache.cloudstack.api.response.EventResponse;
import org.apache.cloudstack.api.response.ExtractResponse;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.api.response.FirewallResponse;
import org.apache.cloudstack.api.response.FirewallRuleResponse;
import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
Expand Down Expand Up @@ -151,6 +152,7 @@
import org.apache.cloudstack.region.PortableIpRange;
import org.apache.cloudstack.region.Region;
import org.apache.cloudstack.secstorage.heuristics.Heuristic;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.object.ObjectStore;
import org.apache.cloudstack.usage.Usage;

Expand Down Expand Up @@ -551,4 +553,6 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine
ObjectStoreResponse createObjectStoreResponse(ObjectStore os);

BucketResponse createBucketResponse(Bucket bucket);

SharedFSResponse createSharedFSResponse(ResponseView view, SharedFS sharedFS);
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public void execute() {
response.setInstancesStatsUserOnly((Boolean) capabilities.get(ApiConstants.INSTANCES_STATS_USER_ONLY));
response.setInstancesDisksStatsRetentionEnabled((Boolean) capabilities.get(ApiConstants.INSTANCES_DISKS_STATS_RETENTION_ENABLED));
response.setInstancesDisksStatsRetentionTime((Integer) capabilities.get(ApiConstants.INSTANCES_DISKS_STATS_RETENTION_TIME));
response.setSharedFsVmMinCpuCount((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_CPU_COUNT));
response.setSharedFsVmMinRamSize((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_RAM_SIZE));
response.setObjectName("capability");
response.setResponseName(getCommandName());
this.setResponseObject(response);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.user.storage.sharedfs;

import javax.inject.Inject;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.UserCmd;
import org.apache.cloudstack.api.response.DiskOfferingResponse;
import org.apache.cloudstack.api.response.SharedFSResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.sharedfs.SharedFS;
import org.apache.cloudstack.storage.sharedfs.SharedFSService;

import com.cloud.event.EventTypes;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.user.Account;

@APICommand(name = "changeSharedFileSystemDiskOffering",
responseObject= SharedFSResponse.class,
description = "Change Disk offering of a Shared FileSystem",
responseView = ResponseObject.ResponseView.Restricted,
entityType = SharedFS.class,
requestHasSensitiveInfo = false,
since = "4.20.0",
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
public class ChangeSharedFSDiskOfferingCmd extends BaseAsyncCmd implements UserCmd {

@Inject
SharedFSService sharedFSService;

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID,
type = CommandType.UUID,
required = true,
entityType = SharedFSResponse.class,
description = "the ID of the shared filesystem")
private Long id;

@Parameter(name = ApiConstants.DISK_OFFERING_ID,
type = CommandType.UUID,
entityType = DiskOfferingResponse.class,
description = "the disk offering to use for the underlying storage")
private Long diskOfferingId;

@Parameter(name = ApiConstants.SIZE,
type = CommandType.LONG,
description = "the size of the shared filesystem in GiB")
private Long size;

@Parameter(name = ApiConstants.MIN_IOPS,
type = CommandType.LONG,
description = "min iops")
private Long minIops;

@Parameter(name = ApiConstants.MAX_IOPS,
type = CommandType.LONG,
description = "max iops")
private Long maxIops;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getId() {
return id;
}

public Long getSize() {
return size;
}

public Long getDiskOfferingId() {
return diskOfferingId;
}

public Long getMinIops() {
return minIops;
}

public Long getMaxIops() {
return maxIops;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public String getEventType() {
return EventTypes.EVENT_SHAREDFS_CHANGE_DISK_OFFERING;
}

@Override
public String getEventDescription() {
return "Changing disk offering for the Shared FileSystem " + id;
}

@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}

@Override
public void execute() throws ResourceAllocationException {
SharedFS sharedFS = sharedFSService.changeSharedFSDiskOffering(this);
if (sharedFS != null) {
ResponseObject.ResponseView respView = getResponseView();
Account caller = CallContext.current().getCallingAccount();
if (_accountService.isRootAdmin(caller.getId())) {
respView = ResponseObject.ResponseView.Full;
}
SharedFSResponse response = _responseGenerator.createSharedFSResponse(respView, sharedFS);
response.setObjectName(SharedFS.class.getSimpleName().toLowerCase());
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to change disk offering for the Shared FileSystem");
}
}
}
Loading