You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2020/05/05 10:58:14 UTC
[cloudstack-primate] branch master updated: storage: fix volume
actions (#231)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-primate.git
The following commit(s) were added to refs/heads/master by this push:
new a0d4532 storage: fix volume actions (#231)
a0d4532 is described below
commit a0d45326e9c406cd5a355bbf0c3050bd348a8d06
Author: Abhishek Kumar <ab...@gmail.com>
AuthorDate: Tue May 5 16:28:06 2020 +0530
storage: fix volume actions (#231)
Fixes #225
Signed-off-by: Abhishek Kumar <ab...@gmail.com>
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Co-authored-by: Rohit Yadav <ro...@shapeblue.com>
---
src/config/section/storage.js | 44 +++++++++++++++++++++++++++++++++++--------
src/views/AutogenView.vue | 18 ++++++++++++------
2 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/src/config/section/storage.js b/src/config/section/storage.js
index 0e2466e..dcbaf11 100644
--- a/src/config/section/storage.js
+++ b/src/config/section/storage.js
@@ -41,7 +41,8 @@ export default {
listView: true,
popup: true,
component: () => import('@/views/storage/CreateVolume.vue')
- }, {
+ },
+ {
api: 'getUploadParamsForVolume',
icon: 'cloud-upload',
label: 'Upload Local Volume',
@@ -67,14 +68,14 @@ export default {
label: 'Attach Volume',
args: ['virtualmachineid'],
dataView: true,
- show: (record) => { return !('virtualmachineid' in record) }
+ show: (record) => { return record.type !== 'ROOT' && record.state !== 'Destroy' && !('virtualmachineid' in record) }
},
{
api: 'detachVolume',
icon: 'link',
label: 'Detach Volume',
dataView: true,
- show: (record) => { return 'virtualmachineid' in record && record.virtualmachineid }
+ show: (record) => { return record.type !== 'ROOT' && 'virtualmachineid' in record && record.virtualmachineid }
},
{
api: 'createSnapshot',
@@ -108,6 +109,7 @@ export default {
label: 'Resize Volume',
dataView: true,
popup: true,
+ show: (record) => { return record.state !== 'Destroy' },
component: () => import('@/views/storage/ResizeVolume.vue')
},
{
@@ -116,7 +118,7 @@ export default {
label: 'Migrate Volume',
args: ['volumeid', 'storageid', 'livemigrate'],
dataView: true,
- show: (record) => { return record && record.state === 'Ready' },
+ show: (record, store) => { return record && record.state === 'Ready' && ['Admin', 'DomainAdmin'].includes(store.userInfo.roletype) },
popup: true,
component: () => import('@/views/storage/MigrateVolume.vue'),
mapping: {
@@ -133,7 +135,7 @@ export default {
icon: 'cloud-download',
label: 'Download Volume',
dataView: true,
- show: (record) => { return record && record.state === 'Ready' },
+ show: (record) => { return record && record.state === 'Ready' && (record.vmstate === 'Stopped' || record.virtualmachineid == null) && record.state !== 'Destroy' },
args: ['zoneid', 'mode'],
mapping: {
zoneid: {
@@ -150,7 +152,7 @@ export default {
icon: 'picture',
label: 'Create Template from Volume',
dataView: true,
- show: (record) => { return record.type === 'ROOT' },
+ show: (record) => { return (record.type === 'ROOT' && record.vmstate === 'Stopped') || (record.type !== 'ROOT' && !('virtualmachineid' in record) && !['Allocated', 'Uploaded', 'Destroy'].includes(record.state)) },
args: ['volumeid', 'name', 'displaytext', 'ostypeid', 'ispublic', 'isfeatured', 'isdynamicallyscalable', 'requireshvm', 'passwordenabled', 'sshkeyenabled'],
mapping: {
volumeid: {
@@ -159,11 +161,36 @@ export default {
}
},
{
+ api: 'recoverVolume',
+ icon: 'medicine-box',
+ label: 'Recover Volume',
+ dataView: true,
+ show: (record, store) => {
+ return (['Admin', 'DomainAdmin'].includes(store.userInfo.roletype) || store.features.allowuserexpungerecovervolume) && record.state === 'Destroy'
+ }
+ },
+ {
api: 'deleteVolume',
icon: 'delete',
label: 'Delete Volume',
dataView: true,
- groupAction: true
+ groupAction: true,
+ show: (record, store) => {
+ return ['Expunging', 'Expunged', 'UploadError'].includes(record.state) ||
+ ((['Admin', 'DomainAdmin'].includes(store.userInfo.roletype) || store.features.allowuserexpungerecovervolume) && record.state === 'Destroy')
+ }
+ },
+ {
+ api: 'destroyVolume',
+ icon: 'delete',
+ label: 'Destroy Volume',
+ dataView: true,
+ args: (record, store) => {
+ return (!['Admin', 'DomainAdmin'].includes(store.userInfo.roletype) && !store.features.allowuserexpungerecovervolumestore) ? [] : ['expunge']
+ },
+ show: (record, store) => {
+ return (!['Creating'].includes(record.state) && record.type !== 'ROOT' && !('virtualmachineid' in record) && record.state !== 'Destroy')
+ }
}
]
},
@@ -206,7 +233,8 @@ export default {
api: 'revertSnapshot',
icon: 'sync',
label: 'Revert Snapshot',
- dataView: true
+ dataView: true,
+ show: (record) => { return record.revertable }
},
{
api: 'deleteSnapshot',
diff --git a/src/views/AutogenView.vue b/src/views/AutogenView.vue
index 452540d..1db2b17 100644
--- a/src/views/AutogenView.vue
+++ b/src/views/AutogenView.vue
@@ -556,12 +556,18 @@ export default {
return 0
})
this.currentAction.paramFields = []
- if (action.args && action.args.length > 0) {
- this.currentAction.paramFields = action.args.map(function (arg) {
- return paramFields.filter(function (param) {
- return param.name.toLowerCase() === arg.toLowerCase()
- })[0]
- })
+ if ('args' in action) {
+ var args = action.args
+ if (typeof action.args === 'function') {
+ args = action.args(action.resource, this.$store.getters)
+ }
+ if (args.length > 0) {
+ this.currentAction.paramFields = args.map(function (arg) {
+ return paramFields.filter(function (param) {
+ return param.name.toLowerCase() === arg.toLowerCase()
+ })[0]
+ })
+ }
}
this.showAction = true