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 e82f401 config: action args remapping framework
e82f401 is described below
commit e82f401d83a6d37c44d4310b35e4ec2b6d6e8278
Author: Rohit Yadav <[email protected]>
AuthorDate: Mon Nov 25 06:48:01 2019 +0530
config: action args remapping framework
This implements actions args remapping framework which allows developers
to specify how to provide/show args to the user/admin or how to override
based on the resource by means of (a) `value(record)` function, (b)
statically defined `api` name, (c) `options` array.
For example, in the config file:
```
args: ['id', 'virtualmachineid', 'mode'],
mapping: {
id: {
api: 'listIsos'
},
virtualmachineid: {
value: (record, params) => { return record.id }
},
mode: {
options: ['http', 'nfs', 'something else']
}
}
```
Signed-off-by: Rohit Yadav <[email protected]>
---
src/config/section/compute.js | 91 ++++++++++++++++++++-------
src/config/section/iam.js | 36 +++++------
src/config/section/image.js | 20 +++---
src/config/section/infra/clusters.js | 7 +--
src/config/section/infra/hosts.js | 9 +--
src/config/section/infra/pods.js | 7 +--
src/config/section/infra/primaryStorages.js | 6 +-
src/config/section/infra/routers.js | 10 +--
src/config/section/infra/secondaryStorages.js | 3 +-
src/config/section/infra/systemVms.js | 8 +--
src/config/section/infra/zones.js | 9 +--
src/config/section/network.js | 12 ++--
src/config/section/offering.js | 25 +++-----
src/config/section/project.js | 7 +--
src/config/section/storage.js | 87 ++++++++++++++++++-------
src/views/AutogenView.vue | 87 ++++++++++++++++++++-----
16 files changed, 260 insertions(+), 164 deletions(-)
diff --git a/src/config/section/compute.js b/src/config/section/compute.js
index aa3277b..b518400 100644
--- a/src/config/section/compute.js
+++ b/src/config/section/compute.js
@@ -90,7 +90,7 @@ export default {
docHelp:
'adminguide/virtual_machines.html#stopping-and-starting-vms',
dataView: true,
groupAction: true,
- args: ['id', 'forced'],
+ args: ['forced'],
show: (record) => { return ['Running'].includes(record.state) }
},
{
@@ -98,7 +98,6 @@ export default {
icon: 'reload',
label: 'label.action.reboot.instance',
dataView: true,
- args: ['id'],
show: (record) => { return ['Running'].includes(record.state) }
},
{
@@ -106,7 +105,12 @@ export default {
icon: 'sync',
label: 'label.reinstall.vm',
dataView: true,
- args: ['virtualmachineid', 'templateid']
+ args: ['virtualmachineid', 'templateid'],
+ mapping: {
+ virtualmachineid: {
+ value: (record) => { return record.id }
+ }
+ }
},
{
api: 'createVMSnapshot',
@@ -114,7 +118,12 @@ export default {
label: 'Create VM Snapshot',
dataView: true,
args: ['virtualmachineid', 'name', 'description', 'snapshotmemory',
'quiescevm'],
- show: (record) => { return ['Running'].includes(record.state) }
+ show: (record) => { return ['Running'].includes(record.state) },
+ mapping: {
+ virtualmachineid: {
+ value: (record, params) => { return record.id }
+ }
+ }
},
{
api: 'attachIso',
@@ -122,15 +131,28 @@ export default {
label: 'label.action.attach.iso',
dataView: true,
args: ['id', 'virtualmachineid'],
- show: (record) => { return !record.isoid }
+ show: (record) => { return !record.isoid },
+ mapping: {
+ id: {
+ api: 'listIsos'
+ },
+ virtualmachineid: {
+ value: (record, params) => { return record.id }
+ }
+ }
},
{
api: 'detachIso',
icon: 'link',
label: 'label.action.detach.iso',
dataView: true,
- args: ['id', 'virtualmachineid'],
- show: (record) => { return 'isoid' in record && record.isoid }
+ args: ['virtualmachineid'],
+ show: (record) => { return 'isoid' in record && record.isoid },
+ mapping: {
+ virtualmachineid: {
+ value: (record, params) => { return record.id }
+ }
+ }
},
{
api: 'migrateVirtualMachine',
@@ -158,7 +180,7 @@ export default {
icon: 'swap',
label: 'label.change.affinity',
dataView: true,
- args: ['id', 'serviceofferingid'],
+ args: ['affinitygroupids'],
show: (record) => { return ['Stopped'].includes(record.state) }
},
{
@@ -166,15 +188,15 @@ export default {
icon: 'arrows-alt',
label: 'Scale VM',
dataView: true,
- args: ['id', 'serviceofferingid', 'details'],
- show: (record) => { return record.state === 'Stopped' ||
record.hypervisor === 'VMWare' }
+ args: ['serviceofferingid', 'details'],
+ show: (record) => { return record.hypervisor !== 'KVM' }
},
{
api: 'changeServiceForVirtualMachine',
icon: 'sliders',
label: 'Change Service Offering',
dataView: true,
- args: ['id', 'serviceofferingid'],
+ args: ['serviceofferingid'],
show: (record) => { return ['Stopped'].includes(record.state) }
},
{
@@ -182,7 +204,6 @@ export default {
icon: 'key',
label: 'Reset Instance Password',
dataView: true,
- args: ['id'],
show: (record) => { return ['Stopped'].includes(record.state) }
},
{
@@ -190,20 +211,31 @@ export default {
icon: 'lock',
label: 'Reset SSH Key',
dataView: true,
- show: (record) => { return ['Stopped'].includes(record.state) }
+ args: ['keypair'],
+ show: (record) => { return ['Stopped'].includes(record.state) },
+ mapping: {
+ keypair: {
+ api: 'listSSHKeyPairs'
+ }
+ }
},
{
api: 'assignVirtualMachine',
icon: 'user-add',
label: 'Assign Instance to Another Account',
dataView: true,
- show: (record) => { return ['Stopped'].includes(record.state) }
+ show: (record) => { return ['Stopped'].includes(record.state) },
+ args: ['virtualmachineid', 'account', 'domainid'],
+ mapping: {
+ virtualmachineid: {
+ value: (record, params) => { return record.id }
+ }
+ }
},
{
api: 'recoverVirtualMachine',
icon: 'medicine-box',
label: 'label.recover.vm',
- args: ['id'],
dataView: true,
show: (record) => { return ['Destroyed'].includes(record.state) }
},
@@ -211,7 +243,6 @@ export default {
api: 'expungeVirtualMachine',
icon: 'delete',
label: 'label.action.expunge.instance',
- args: ['id'],
dataView: true,
show: (record) => { return ['Destroyed'].includes(record.state) }
},
@@ -219,7 +250,7 @@ export default {
api: 'destroyVirtualMachine',
icon: 'delete',
label: 'label.action.destroy.instance',
- args: ['id', 'expunge', 'volumeids'],
+ args: ['expunge', 'volumeids'],
dataView: true,
groupAction: true
}
@@ -266,8 +297,7 @@ export default {
api: 'deleteInstanceGroup',
icon: 'delete',
label: 'Delete Instance Group',
- dataView: true,
- args: ['id']
+ dataView: true
}
]
},
@@ -304,7 +334,18 @@ export default {
icon: 'delete',
label: 'Delete SSH key pair',
dataView: true,
- args: ['name', 'account', 'domainid']
+ args: ['name', 'account', 'domainid'],
+ mapping: {
+ name: {
+ value: (record, params) => { return record.name }
+ },
+ account: {
+ value: (record, params) => { return record.account }
+ },
+ domainid: {
+ value: (record, params) => { return record.domainid }
+ }
+ }
}
]
},
@@ -327,14 +368,18 @@ export default {
icon: 'plus',
label: 'New Affinity Group',
listView: true,
- args: ['name', 'description', 'type']
+ args: ['name', 'description', 'type'],
+ mapping: {
+ type: {
+ options: ['host anti-affinity', 'host affinity']
+ }
+ }
},
{
api: 'deleteAffinityGroup',
icon: 'delete',
label: 'Delete Affinity Group',
- dataView: true,
- args: ['id']
+ dataView: true
}
]
}
diff --git a/src/config/section/iam.js b/src/config/section/iam.js
index 2792080..aaca2bb 100644
--- a/src/config/section/iam.js
+++ b/src/config/section/iam.js
@@ -41,44 +41,40 @@ export default {
icon: 'edit',
label: 'label.edit',
dataView: true,
- args: ['id', 'username', 'email', 'firstname', 'lastname',
'timezone']
+ args: ['username', 'email', 'firstname', 'lastname', 'timezone']
},
{
api: 'updateUser',
icon: 'key',
label: 'Change Password',
dataView: true,
- args: ['id', 'currentpassword', 'password']
+ args: ['currentpassword', 'password']
},
{
api: 'registerUserKeys',
icon: 'file-protect',
label: 'Generate Keys',
- dataView: true,
- args: ['id']
+ dataView: true
},
{
api: 'enableUser',
icon: 'play-circle',
label: 'Enable User',
dataView: true,
- show: (record) => { return record.state === 'disabled' },
- args: ['id']
+ show: (record) => { return record.state === 'disabled' }
},
{
api: 'disableUser',
icon: 'pause-circle',
label: 'Disable User',
dataView: true,
- args: ['id'],
show: (record) => { return record.state === 'enabled' }
},
{
api: 'deleteUser',
icon: 'delete',
label: 'Delete user',
- dataView: true,
- args: ['id']
+ dataView: true
}
]
},
@@ -102,7 +98,7 @@ export default {
icon: 'edit',
label: 'label.update.account',
dataView: true,
- args: ['id', 'newname', 'domainid', 'roleid', 'networkdomain',
'details']
+ args: ['newname', 'domainid', 'roleid', 'networkdomain', 'details']
},
{
api: 'updateResourceCount',
@@ -117,7 +113,6 @@ export default {
label: 'Enable Account',
dataView: true,
show: (record) => { return record.state === 'disabled' ||
record.state === 'locked' },
- args: ['id'],
params: { lock: 'false' }
},
{
@@ -126,7 +121,6 @@ export default {
label: 'Disable Account',
dataView: true,
show: (record) => { return record.state === 'enabled' },
- args: ['id'],
params: { lock: 'false' }
},
{
@@ -135,7 +129,7 @@ export default {
label: 'Lock account',
dataView: true,
show: (record) => { return record.state === 'enabled' },
- args: ['id', 'lock']
+ args: ['lock']
},
{
api: 'deleteAccount',
@@ -175,14 +169,19 @@ export default {
icon: 'edit',
label: 'label.action.edit.domain',
dataView: true,
- args: ['id', 'name', 'networkdomain']
+ args: ['name', 'networkdomain']
},
{
api: 'updateResourceCount',
icon: 'sync',
label: 'label.action.update.resource.count',
dataView: true,
- args: ['domainid']
+ args: ['domainid'],
+ mapping: {
+ domainid: {
+ value: (record) => { return record.id }
+ }
+ }
},
{
api: 'deleteDomain',
@@ -190,7 +189,7 @@ export default {
label: 'label.delete.domain',
dataView: true,
show: (record) => { return record.level !== 0 },
- args: ['id', 'cleanup']
+ args: ['cleanup']
}
]
},
@@ -214,14 +213,13 @@ export default {
icon: 'edit',
label: 'Edit Role',
dataView: true,
- args: ['id', 'name', 'description', 'type']
+ args: ['name', 'description', 'type']
},
{
api: 'deleteRole',
icon: 'delete',
label: 'label.delete.role',
- dataView: true,
- args: ['id']
+ dataView: true
}
]
}
diff --git a/src/config/section/image.js b/src/config/section/image.js
index 04fec8b..3a614f8 100644
--- a/src/config/section/image.js
+++ b/src/config/section/image.js
@@ -65,34 +65,34 @@ export default {
icon: 'edit',
label: 'label.edit',
dataView: true,
- args: ['id', 'name', 'displaytext', 'passwordenabled',
'sshkeyenabled', 'ostypeid', 'isdynamicallyscalable', 'isrouting']
+ args: ['name', 'displaytext', 'passwordenabled', 'sshkeyenabled',
'ostypeid', 'isdynamicallyscalable', 'isrouting']
},
{
api: 'extractTemplate',
icon: 'cloud-download',
label: 'Download Template',
dataView: true,
- args: ['id', 'zoneid', 'mode']
+ args: ['zoneid', 'mode']
},
{
api: 'updateTemplatePermissions',
icon: 'reconciliation',
label: 'Update template permissions',
dataView: true,
- args: ['id', 'op', 'accounts', 'projectids']
+ args: ['op', 'accounts', 'projectids']
},
{
api: 'copyTemplate',
icon: 'copy',
label: 'Copy Template',
- args: ['id', 'sourcezoneid', 'destzoneids'],
+ args: ['sourcezoneid', 'destzoneids'],
dataView: true
},
{
api: 'deleteTemplate',
icon: 'delete',
label: 'Delete Template',
- args: ['id', 'zoneid'],
+ args: ['zoneid'],
dataView: true,
groupAction: true
}
@@ -133,34 +133,34 @@ export default {
icon: 'edit',
label: 'label.edit',
dataView: true,
- args: ['id', 'name', 'displaytext', 'bootable', 'ostypeid',
'isdynamicallyscalable', 'isrouting']
+ args: ['name', 'displaytext', 'bootable', 'ostypeid',
'isdynamicallyscalable', 'isrouting']
},
{
api: 'extractIso',
icon: 'cloud-download',
label: 'Download ISO',
dataView: true,
- args: ['id', 'zoneid', 'mode']
+ args: ['zoneid', 'mode']
},
{
api: 'updateIsoPermissions',
icon: 'reconciliation',
label: 'Update ISO Permissions',
dataView: true,
- args: ['id', 'op', 'accounts', 'projectids']
+ args: ['op', 'accounts', 'projectids']
},
{
api: 'copyIso',
icon: 'copy',
label: 'Copy ISO',
- args: ['id', 'sourcezoneid', 'destzoneids'],
+ args: ['sourcezoneid', 'destzoneids'],
dataView: true
},
{
api: 'deleteIso',
icon: 'delete',
label: 'Delete ISO',
- args: ['id', 'zoneid'],
+ args: ['zoneid'],
dataView: true,
groupAction: true
}
diff --git a/src/config/section/infra/clusters.js
b/src/config/section/infra/clusters.js
index 79ad842..ae9e8d7 100644
--- a/src/config/section/infra/clusters.js
+++ b/src/config/section/infra/clusters.js
@@ -40,7 +40,6 @@ export default {
icon: 'pause-circle',
label: 'label.action.enable.cluster',
dataView: true,
- args: ['id'],
defaultArgs: { allocationstate: 'Disabled' },
show: (record) => { return record.allocationstate === 'Enabled' }
},
@@ -49,7 +48,6 @@ export default {
icon: 'play-circle',
label: 'label.action.disable.cluster',
dataView: true,
- args: ['id'],
defaultArgs: { allocationstate: 'Enabled' },
show: (record) => { return record.allocationstate === 'Disabled' }
},
@@ -74,7 +72,6 @@ export default {
icon: 'plus-square',
label: 'Manage Cluster',
dataView: true,
- args: ['id'],
defaultArgs: { managedstate: 'Managed' },
show: (record) => { return record.clustertype === 'CloudManaged' &&
['PrepareUnmanaged', 'Unmanaged'].includes(record.state) }
},
@@ -83,7 +80,6 @@ export default {
icon: 'minus-square',
label: 'Unmanage Cluster',
dataView: true,
- args: ['id'],
defaultArgs: { managedstate: 'Unmanaged' },
show: (record) => { return record.clustertype === 'CloudManaged' &&
record.state === 'Enabled' }
},
@@ -135,8 +131,7 @@ export default {
api: 'deleteCluster',
icon: 'delete',
label: 'label.action.delete.cluster',
- dataView: true,
- args: ['id']
+ dataView: true
}
]
}
diff --git a/src/config/section/infra/hosts.js
b/src/config/section/infra/hosts.js
index 5c63177..64c1cbc 100644
--- a/src/config/section/infra/hosts.js
+++ b/src/config/section/infra/hosts.js
@@ -42,7 +42,7 @@ export default {
icon: 'edit',
label: 'label.edit',
dataView: true,
- args: ['id', 'hosttags', 'oscategoryid']
+ args: ['hosttags', 'oscategoryid']
},
{
api: 'provisionCertificate',
@@ -57,7 +57,6 @@ export default {
icon: 'forward',
label: 'label.action.force.reconnect',
dataView: true,
- args: ['id'],
show: (record) => { return ['Disconnected', 'Up'].includes(record.state)
}
},
{
@@ -65,7 +64,6 @@ export default {
icon: 'pause-circle',
label: 'Disable Host',
dataView: true,
- args: ['id'],
defaultArgs: { allocationstate: 'Disable' },
show: (record) => { return record.resourcestate === 'Enabled' }
},
@@ -74,7 +72,6 @@ export default {
icon: 'play-circle',
label: 'Enable Host',
dataView: true,
- args: ['id'],
defaultArgs: { allocationstate: 'Enable' },
show: (record) => { return record.resourcestate === 'Disabled' }
},
@@ -99,7 +96,6 @@ export default {
icon: 'plus-square',
label: 'label.action.enable.maintenance.mode',
dataView: true,
- args: ['id'],
show: (record) => { return record.resourcestate === 'Enabled' }
},
{
@@ -107,7 +103,6 @@ export default {
icon: 'minus-square',
label: 'label.action.cancel.maintenance.mode',
dataView: true,
- args: ['id'],
show: (record) => { return record.resourcestate === 'Maintenance' ||
record.resourcestate === 'ErrorInMaintenance' || record.resourcestate ===
'PrepareForMaintenance' }
},
{
@@ -195,7 +190,7 @@ export default {
icon: 'delete',
label: 'Remove Host',
dataView: true,
- args: ['id', 'forced'],
+ args: ['forced'],
show: (record) => { return ['Maintenance', 'Disabled', 'Down', 'Alert',
'Disconnected'].includes(record.resourcestate) }
}
]
diff --git a/src/config/section/infra/pods.js b/src/config/section/infra/pods.js
index 04aa26e..23b80e4 100644
--- a/src/config/section/infra/pods.js
+++ b/src/config/section/infra/pods.js
@@ -44,7 +44,7 @@ export default {
icon: 'edit',
label: 'label.edit',
dataView: true,
- args: ['id', 'name', 'netmask', 'gateway']
+ args: ['name', 'netmask', 'gateway']
},
{
api: 'dedicatePod',
@@ -67,7 +67,6 @@ export default {
icon: 'play-circle',
label: 'label.action.enable.pod',
dataView: true,
- args: ['id'],
show: (record) => { return record.allocationstate === 'Disabled' }
},
{
@@ -75,7 +74,6 @@ export default {
icon: 'pause-circle',
label: 'label.action.disable.pod',
dataView: true,
- args: ['id'],
show: (record) => { return record.allocationstate === 'Enabled' },
defaultArgs: { allocationstate: 'Disabled' }
},
@@ -83,8 +81,7 @@ export default {
api: 'deletePod',
icon: 'delete',
label: 'label.action.delete.pod',
- dataView: true,
- args: ['id']
+ dataView: true
}
]
}
diff --git a/src/config/section/infra/primaryStorages.js
b/src/config/section/infra/primaryStorages.js
index bab4a91..bff2521 100644
--- a/src/config/section/infra/primaryStorages.js
+++ b/src/config/section/infra/primaryStorages.js
@@ -40,14 +40,13 @@ export default {
icon: 'edit',
label: 'label.edit',
dataView: true,
- args: ['id', 'tags', 'capacitybytes', 'capacityiops']
+ args: ['tags', 'capacitybytes', 'capacityiops']
},
{
api: 'enableStorageMaintenance',
icon: 'plus-square',
label: 'label.action.enable.maintenance.mode',
dataView: true,
- args: ['id'],
show: (record) => { return ['Up', 'Connecting', 'Down',
'ErrorInMaintenance'].includes(record.state) }
},
{
@@ -55,7 +54,6 @@ export default {
icon: 'minus-square',
label: 'label.action.cancel.maintenance.mode',
dataView: true,
- args: ['id'],
show: (record) => { return ['Maintenance', 'PrepareForMaintenance',
'ErrorInMaintenance'].includes(record.state) }
},
{
@@ -63,7 +61,7 @@ export default {
icon: 'delete',
label: 'label.action.delete.primary.storage',
dataView: true,
- args: ['id', 'forced'],
+ args: ['forced'],
show: (record) => { return !(record.state === 'Down' || record.state ===
'Alert' || record.state === 'Maintenance' || record.state === 'Disconnected') }
}
]
diff --git a/src/config/section/infra/routers.js
b/src/config/section/infra/routers.js
index 07377d0..f3631bb 100644
--- a/src/config/section/infra/routers.js
+++ b/src/config/section/infra/routers.js
@@ -28,7 +28,6 @@ export default {
icon: 'caret-right',
label: 'label.action.start.router',
dataView: true,
- args: ['id'],
show: (record) => { return record.state === 'Stopped' }
},
{
@@ -36,7 +35,7 @@ export default {
icon: 'stop',
label: 'label.action.stop.router',
dataView: true,
- args: ['id', 'forced'],
+ args: ['forced'],
show: (record) => { return record.state === 'Running' }
},
{
@@ -44,7 +43,6 @@ export default {
icon: 'sync',
label: 'label.action.reboot.router',
dataView: true,
- args: ['id'],
hidden: (record) => { return record.state === 'Running' }
},
{
@@ -52,8 +50,8 @@ export default {
icon: 'arrows-alt',
label: 'label.change.service.offering',
dataView: true,
- args: ['id', 'serviceofferingid'],
- show: (record) => { return record.state === 'Stopped' ||
record.hypervisor === 'VMWare' }
+ args: ['serviceofferingid'],
+ show: (record) => { return record.hypervisor !== 'KVM' }
},
{
api: 'upgradeRouterTemplate',
@@ -61,7 +59,6 @@ export default {
label: 'label.upgrade.router.newer.template',
dataView: true,
groupAction: true,
- args: ['id'],
show: (record) => { return record.requiresupgrade }
},
{
@@ -85,7 +82,6 @@ export default {
icon: 'delete',
label: 'label.destroy.router',
dataView: true,
- args: ['id'],
show: (record) => { return ['Running', 'Error',
'Stopped'].includes(record.state) }
}
]
diff --git a/src/config/section/infra/secondaryStorages.js
b/src/config/section/infra/secondaryStorages.js
index 4b9861f..3b81411 100644
--- a/src/config/section/infra/secondaryStorages.js
+++ b/src/config/section/infra/secondaryStorages.js
@@ -34,8 +34,7 @@ export default {
api: 'deleteImageStore',
icon: 'delete',
label: 'label.action.delete.secondary.storage',
- dataView: true,
- args: ['id']
+ dataView: true
}
]
}
diff --git a/src/config/section/infra/systemVms.js
b/src/config/section/infra/systemVms.js
index 4aaaf0e..3c87da0 100644
--- a/src/config/section/infra/systemVms.js
+++ b/src/config/section/infra/systemVms.js
@@ -28,7 +28,6 @@ export default {
icon: 'caret-right',
label: 'label.action.start.systemvm',
dataView: true,
- args: ['id'],
show: (record) => { return record.state === 'Stopped' }
},
{
@@ -36,7 +35,6 @@ export default {
icon: 'stop',
label: 'label.action.stop.systemvm',
dataView: true,
- args: ['id'],
show: (record) => { return record.state === 'Running' }
},
{
@@ -44,7 +42,6 @@ export default {
icon: 'sync',
label: 'label.action.reboot.systemvm',
dataView: true,
- args: ['id'],
show: (record) => { return record.state === 'Running' }
},
{
@@ -52,8 +49,8 @@ export default {
icon: 'arrows-alt',
label: 'label.change.service.offering',
dataView: true,
- args: ['id', 'serviceofferingid'],
- show: (record) => { return record.hypervisor === 'VMWare' ||
record.state === 'Stopped' }
+ args: ['serviceofferingid'],
+ show: (record) => { return record.hypervisor !== 'KVM' }
},
{
api: 'migrateSystemVm',
@@ -76,7 +73,6 @@ export default {
icon: 'delete',
label: 'label.action.destroy.systemvm',
dataView: true,
- args: ['id'],
show: (record) => { return ['Running', 'Error',
'Stopped'].includes(record.state) }
}
]
diff --git a/src/config/section/infra/zones.js
b/src/config/section/infra/zones.js
index cf40392..4d8edb0 100644
--- a/src/config/section/infra/zones.js
+++ b/src/config/section/infra/zones.js
@@ -57,7 +57,7 @@ export default {
icon: 'edit',
label: 'Edit Zone',
dataView: true,
- args: ['id', 'name', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2',
'internaldns1', 'internaldns2', 'guestcidraddress', 'domain',
'localstorageenabled'],
+ args: ['name', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2', 'internaldns1',
'internaldns2', 'guestcidraddress', 'domain', 'localstorageenabled'],
show: (record) => { return record.networktype === 'Advanced' }
},
{
@@ -65,7 +65,7 @@ export default {
icon: 'edit',
label: 'Edit Zone',
dataView: true,
- args: ['id', 'name', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2',
'internaldns1', 'internaldns2', 'domain', 'localstorageenabled'],
+ args: ['name', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2', 'internaldns1',
'internaldns2', 'domain', 'localstorageenabled'],
show: (record) => { return record.networktype === 'Basic' }
},
{
@@ -73,7 +73,6 @@ export default {
icon: 'pause-circle',
label: 'label.action.disable.zone',
dataView: true,
- args: ['id'],
defaultArgs: { allocationstate: 'Disabled' },
show: (record) => { return record.allocationstate === 'Enabled' }
},
@@ -82,7 +81,6 @@ export default {
icon: 'play-circle',
label: 'label.action.enable.zone',
dataView: true,
- args: ['id'],
defaultArgs: { allocationstate: 'Enabled' },
show: (record) => { return record.allocationstate === 'Disabled' }
},
@@ -174,8 +172,7 @@ export default {
api: 'deleteZone',
icon: 'delete',
label: 'label.action.delete.zone',
- dataView: true,
- args: ['id']
+ dataView: true
}
]
}
diff --git a/src/config/section/network.js b/src/config/section/network.js
index dda00a0..874f394 100644
--- a/src/config/section/network.js
+++ b/src/config/section/network.js
@@ -58,20 +58,19 @@ export default {
icon: 'edit',
label: 'Update Network',
dataView: true,
- args: ['id', 'name', 'displaytext', 'guestvmcidr']
+ args: ['name', 'displaytext', 'guestvmcidr']
},
{
api: 'restartNetwork',
icon: 'sync',
label: 'Restart Network',
dataView: true,
- args: ['id', 'makeredundant', 'cleanup']
+ args: ['makeredundant', 'cleanup']
},
{
api: 'deleteNetwork',
icon: 'delete',
label: 'Delete Network',
- args: ['id'],
dataView: true
}
]
@@ -109,20 +108,19 @@ export default {
icon: 'edit',
label: 'Update VPC',
dataView: true,
- args: ['id', 'name', 'displaytext']
+ args: ['name', 'displaytext']
},
{
api: 'restartVPC',
icon: 'sync',
label: 'Restart VPC',
dataView: true,
- args: ['id', 'makeredundant', 'cleanup']
+ args: ['makeredundant', 'cleanup']
},
{
api: 'deleteVPC',
icon: 'delete',
label: 'Delete VPC',
- args: ['id'],
dataView: true
}
]
@@ -157,7 +155,6 @@ export default {
api: 'deleteSecurityGroup',
icon: 'delete',
label: 'Delete Security Group',
- args: ['id'],
dataView: true,
show: (record) => { return record.name !== 'default' }
}
@@ -223,7 +220,6 @@ export default {
api: 'disassociateIpAddress',
icon: 'delete',
label: 'Delete IP',
- args: ['id'],
dataView: true,
show: (record) => { return !record.issourcenat }
}
diff --git a/src/config/section/offering.js b/src/config/section/offering.js
index 5c17dc3..b629530 100644
--- a/src/config/section/offering.js
+++ b/src/config/section/offering.js
@@ -45,13 +45,12 @@ export default {
icon: 'edit',
label: 'Edit Offering',
dataView: true,
- args: ['id', 'name', 'displaytext']
+ args: ['name', 'displaytext']
}, {
api: 'deleteServiceOffering',
icon: 'delete',
label: 'Delete Offering',
- dataView: true,
- args: ['id']
+ dataView: true
}]
},
{
@@ -76,14 +75,13 @@ export default {
label: 'Edit Offering',
dataView: true,
params: { issystem: 'true' },
- args: ['id', 'name', 'displaytext']
+ args: ['name', 'displaytext']
}, {
api: 'deleteServiceOffering',
icon: 'delete',
label: 'Delete Offering',
dataView: true,
- params: { issystem: 'true' },
- args: ['id']
+ params: { issystem: 'true' }
}]
},
{
@@ -110,13 +108,12 @@ export default {
icon: 'edit',
label: 'Edit Offering',
dataView: true,
- args: ['id', 'name', 'displaytext']
+ args: ['name', 'displaytext']
}, {
api: 'deleteDiskOffering',
icon: 'delete',
label: 'Delete Offering',
- dataView: true,
- args: ['id']
+ dataView: true
}]
},
{
@@ -138,13 +135,12 @@ export default {
icon: 'edit',
label: 'Edit Offering',
dataView: true,
- args: ['id', 'name', 'displaytext', 'availability']
+ args: ['name', 'displaytext', 'availability']
}, {
api: 'deleteNetworkOffering',
icon: 'delete',
label: 'Delete Offering',
- dataView: true,
- args: ['id']
+ dataView: true
}]
},
{
@@ -172,13 +168,12 @@ export default {
icon: 'edit',
label: 'Edit Offering',
dataView: true,
- args: ['id', 'name', 'displaytext']
+ args: ['name', 'displaytext']
}, {
api: 'deleteVPCOffering',
icon: 'delete',
label: 'Delete Offering',
- dataView: true,
- args: ['id']
+ dataView: true
}]
}
]
diff --git a/src/config/section/project.js b/src/config/section/project.js
index e5155ff..1f2b033 100644
--- a/src/config/section/project.js
+++ b/src/config/section/project.js
@@ -36,14 +36,13 @@ export default {
icon: 'edit',
label: 'Edit Project',
dataView: true,
- args: ['id', 'displaytext']
+ args: ['displaytext']
},
{
api: 'activateProject',
icon: 'play-circle',
label: 'Activate Project',
dataView: true,
- args: ['id'],
show: (record) => { return record.state === 'Suspended' }
},
{
@@ -51,7 +50,6 @@ export default {
icon: 'pause-circle',
label: 'Suspend Project',
dataView: true,
- args: ['id'],
show: (record) => { return record.state !== 'Suspended' }
},
{
@@ -65,8 +63,7 @@ export default {
api: 'deleteProject',
icon: 'delete',
label: 'Delete Project',
- dataView: true,
- args: ['id']
+ dataView: true
}
]
}
diff --git a/src/config/section/storage.js b/src/config/section/storage.js
index dccb782..48e2298 100644
--- a/src/config/section/storage.js
+++ b/src/config/section/storage.js
@@ -60,7 +60,7 @@ export default {
api: 'attachVolume',
icon: 'paper-clip',
label: 'Attach Volume',
- args: ['id', 'virtualmachineid'],
+ args: ['virtualmachineid'],
dataView: true,
show: (record) => { return !('virtualmachineid' in record) }
},
@@ -68,7 +68,6 @@ export default {
api: 'detachVolume',
icon: 'link',
label: 'Detach Volume',
- args: ['id'],
dataView: true,
show: (record) => { return 'virtualmachineid' in record &&
record.virtualmachineid }
},
@@ -76,25 +75,37 @@ export default {
api: 'createSnapshot',
icon: 'camera',
label: 'Take Snapshot',
- args: ['volumeid', 'name', 'asyncbackup', 'tags'],
dataView: true,
- show: (record) => { return record.state === 'Ready' }
+ show: (record) => { return record.state === 'Ready' },
+ args: ['volumeid', 'name', 'asyncbackup', 'tags'],
+ mapping: {
+ volumeid: {
+ value: (record) => { return record.id }
+ }
+ }
},
{
api: 'createSnapshotPolicy',
icon: 'video-camera',
label: 'Recurring Snapshots',
- args: ['volumeid', 'schedule', 'timezone', 'intervaltype',
'maxsnaps'],
dataView: true,
- show: (record) => { return record.state === 'Ready' }
+ show: (record) => { return record.state === 'Ready' },
+ args: ['volumeid', 'intervaltype', 'schedule', 'maxsnaps',
'timezone'],
+ mapping: {
+ volumeid: {
+ value: (record) => { return record.id }
+ },
+ intervaltype: {
+ options: ['HOURLY', 'DAILY', 'WEEKLY', 'MONTHLY']
+ }
+ }
},
{
api: 'resizeVolume',
icon: 'fullscreen',
label: 'Resize Volume',
- type: 'main',
- args: ['id', 'virtualmachineid'],
- dataView: true
+ dataView: true,
+ args: ['size']
},
{
api: 'migrateVolume',
@@ -102,19 +113,30 @@ export default {
label: 'Migrate Volume',
args: ['volumeid', 'storageid', 'livemigrate'],
dataView: true,
- show: (record) => { return 'virtualmachineid' in record &&
record.virtualmachineid }
+ show: (record) => { return 'virtualmachineid' in record &&
record.virtualmachineid },
+ mapping: {
+ volumeid: {
+ value: (record) => { return record.id }
+ },
+ storageid: {
+ api: 'listStoragePools'
+ }
+ }
},
{
api: 'extractVolume',
icon: 'cloud-download',
label: 'Download Volume',
- args: ['id', 'zoneid', 'mode'],
- paramOptions: {
+ dataView: true,
+ args: ['zoneid', 'mode'],
+ mapping: {
+ zoneid: {
+ value: (record) => { return record.zoneid }
+ },
mode: {
- value: 'HTTP_DOWNLOAD'
+ value: (record) => { return 'HTTP_DOWNLOAD' }
}
- },
- dataView: true
+ }
},
{
api: 'createTemplate',
@@ -128,7 +150,6 @@ export default {
api: 'deleteVolume',
icon: 'delete',
label: 'Delete Volume',
- args: ['id'],
dataView: true,
groupAction: true
}
@@ -148,28 +169,36 @@ export default {
icon: 'plus',
label: 'Create volume',
dataView: true,
- args: ['snapshotid', 'name']
+ args: ['snapshotid', 'name'],
+ mapping: {
+ snapshotid: {
+ value: (record) => { return record.id }
+ }
+ }
},
{
api: 'createTemplate',
icon: 'picture',
label: 'Create volume',
dataView: true,
- args: ['snapshotid', 'name', 'displaytext', 'ostypeid', 'ispublic',
'isfeatured', 'isdynamicallyscalable', 'requireshvm', 'passwordenabled',
'sshkeyenabled']
+ args: ['snapshotid', 'name', 'displaytext', 'ostypeid', 'ispublic',
'isfeatured', 'isdynamicallyscalable', 'requireshvm', 'passwordenabled',
'sshkeyenabled'],
+ mapping: {
+ snapshotid: {
+ value: (record) => { return record.id }
+ }
+ }
},
{
api: 'revertSnapshot',
icon: 'sync',
label: 'Revert Snapshot',
- dataView: true,
- args: ['id']
+ dataView: true
},
{
api: 'deleteSnapshot',
icon: 'delete',
label: 'Delete Snapshot',
- dataView: true,
- args: ['id']
+ dataView: true
}
]
},
@@ -187,14 +216,24 @@ export default {
icon: 'sync',
label: 'Revert VM snapshot',
dataView: true,
- args: ['vmsnapshotid']
+ args: ['vmsnapshotid'],
+ mapping: {
+ vmsnapshotid: {
+ value: (record) => { return record.id }
+ }
+ }
},
{
api: 'deleteVMSnapshot',
icon: 'delete',
label: 'Delete VM Snapshot',
dataView: true,
- args: ['vmsnapshotid']
+ args: ['vmsnapshotid'],
+ mapping: {
+ vmsnapshotid: {
+ value: (record) => { return record.id }
+ }
+ }
}
]
}
diff --git a/src/views/AutogenView.vue b/src/views/AutogenView.vue
index 59bd819..8fd7a3f 100644
--- a/src/views/AutogenView.vue
+++ b/src/views/AutogenView.vue
@@ -120,13 +120,12 @@
@submit="handleSubmit"
layout="vertical" >
<a-form-item
- v-for="(field, fieldIndex) in currentAction.params"
+ v-for="(field, fieldIndex) in currentAction.paramFields"
:key="fieldIndex"
:label="$t(field.name)"
:v-bind="field.name"
- v-if="field.name !== 'id'"
+ v-if="!(currentAction.mapping && field.name in
currentAction.mapping && currentAction.mapping[field.name].value)"
>
-
<span v-if="field.type==='boolean'">
<a-switch
v-decorator="[field.name, {
@@ -135,7 +134,20 @@
:placeholder="field.description"
/>
</span>
- <span v-else-if="field.type==='uuid' || field.name==='account'">
+ <span v-else-if="currentAction.mapping && field.name in
currentAction.mapping && currentAction.mapping[field.name].options">
+ <a-select
+ :loading="field.loading"
+ v-decorator="[field.name, {
+ rules: [{ required: field.required, message: 'Please
select option' }]
+ }]"
+ :placeholder="field.description"
+ >
+ <a-select-option v-for="(opt, optIndex) in
currentAction.mapping[field.name].options" :key="optIndex">
+ {{ opt }}
+ </a-select-option>
+ </a-select>
+ </span>
+ <span v-else-if="field.type==='uuid' || field.name==='account'
|| field.name==='keypair'">
<a-select
:loading="field.loading"
v-decorator="[field.name, {
@@ -148,6 +160,20 @@
</a-select-option>
</a-select>
</span>
+ <span v-else-if="field.type==='list'">
+ <a-select
+ :loading="field.loading"
+ mode="multiple"
+ v-decorator="[field.name, {
+ rules: [{ required: field.required, message: 'Please
select option' }]
+ }]"
+ :placeholder="field.description"
+ >
+ <a-select-option v-for="(opt, optIndex) in field.opts"
:key="optIndex">
+ {{ opt.name && opt.type ? opt.name + ' (' + opt.type + ')'
: opt.name || opt.description }}
+ </a-select-option>
+ </a-select>
+ </span>
<span v-else-if="field.type==='long'">
<a-input-number
v-decorator="[field.name, {
@@ -413,8 +439,9 @@ export default {
return
}
this.currentAction = action
- var params = store.getters.apis[this.currentAction.api].params
- params.sort(function (a, b) {
+ this.currentAction.params =
store.getters.apis[this.currentAction.api].params
+ var paramFields = this.currentAction.params
+ paramFields.sort(function (a, b) {
if (a.name === 'name' && b.name !== 'name') { return -1 }
if (a.name !== 'name' && b.name === 'name') { return -1 }
if (a.name === 'id') { return -1 }
@@ -422,29 +449,34 @@ export default {
if (a.name > b.name) { return 1 }
return 0
})
+ this.currentAction.paramFields = []
if (action.args && action.args.length > 0) {
- this.currentAction.params = action.args.map(function (arg) {
- return params.filter(function (param) {
+ this.currentAction.paramFields = action.args.map(function (arg) {
+ return paramFields.filter(function (param) {
return param.name.toLowerCase() === arg.toLowerCase()
})[0]
})
- } else {
- this.currentAction.params = params
}
this.showAction = true
- for (const param of this.currentAction.params) {
- if (param.type === 'uuid' || param.name === 'account') {
+ for (const param of this.currentAction.paramFields) {
+ if (param.type === 'uuid' || param.type === 'list' || param.name ===
'account' || (this.currentAction.mapping && param.name in
this.currentAction.mapping)) {
this.listUuidOpts(param)
}
}
+ console.log(this.currentAction.paramFields)
this.currentAction.loading = false
},
listUuidOpts (param) {
+ if (this.currentAction.mapping && param.name in
this.currentAction.mapping && !this.currentAction.mapping[param.name].api) {
+ return
+ }
var paramName = param.name
- const possibleName = 'list' + paramName.replace('id', '').toLowerCase()
+ 's'
+ const possibleName = 'list' + paramName.replace('ids', '').replace('id',
'').toLowerCase() + 's'
var possibleApi
- if (paramName === 'id') {
+ if (this.currentAction.mapping && param.name in
this.currentAction.mapping && this.currentAction.mapping[param.name].api) {
+ possibleApi = this.currentAction.mapping[param.name].api
+ } else if (paramName === 'id') {
possibleApi = this.apiName
} else {
for (const api in store.getters.apis) {
@@ -462,6 +494,8 @@ export default {
var params = { listall: true }
if (possibleApi === 'listTemplates') {
params.templatefilter = 'executable'
+ } else if (possibleApi === 'listIsos') {
+ params.isofilter = 'executable'
}
api(possibleApi, params).then(json => {
param.loading = false
@@ -503,9 +537,13 @@ export default {
handleSubmit (e) {
e.preventDefault()
this.form.validateFields((err, values) => {
+ console.log(values)
if (!err) {
this.currentAction.loading = true
const params = {}
+ if ('id' in this.resource && this.currentAction.params.map(i => {
return i.name }).includes('id')) {
+ params.id = this.resource.id
+ }
for (const key in values) {
const input = values[key]
for (const param of this.currentAction.params) {
@@ -516,8 +554,14 @@ export default {
}
break
}
- if (param.type === 'uuid') {
+ if (this.currentAction.mapping && key in
this.currentAction.mapping && this.currentAction.mapping[key].options) {
+ params[key] = this.currentAction.mapping[key].options[input]
+ } else if (param.type === 'uuid') {
params[key] = param.opts[input].id
+ } else if (param.type === 'list') {
+ params[key] = input.map(e => { return param.opts[e].id
}).reduce((str, name) => { return str + ',' + name })
+ } else if (param.name === 'account' || param.name ===
'keypair') {
+ params[key] = param.opts[input].name
} else {
params[key] = input
}
@@ -532,9 +576,18 @@ export default {
}
}
- if ('id' in this.resource) {
- params.id = this.resource.id
+ console.log(this.currentAction)
+
+ if (this.currentAction.mapping) {
+ for (const key in this.currentAction.mapping) {
+ if (!this.currentAction.mapping[key].value) {
+ continue
+ }
+ var keyName = this.currentAction.mapping[key].rename ?
this.currentAction.mapping[key].rename : key
+ params[keyName] =
this.currentAction.mapping[key].value(this.resource, params)
+ }
}
+ console.log(params)
var hasJobId = false
api(this.currentAction.api, params).then(json => {