From 2bc239fa76895ef18e4dbb04d18888b6d2d07ca1 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Thu, 20 Aug 2020 10:44:24 +0200 Subject: [PATCH] storage: Allow creating snapshot from VM snapshot (#587) In old UI we support creating snapshot from VM snapshot by selecting one of the volume belonging to VM. Allow the same in new UI Co-authored-by: Rakesh Venkatesh Signed-off-by: Rohit Yadav --- ui/src/config/section/storage.js | 13 +- ui/src/locales/en.json | 5 + .../storage/CreateSnapshotFromVMSnapshot.vue | 151 ++++++++++++++++++ 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 ui/src/views/storage/CreateSnapshotFromVMSnapshot.vue diff --git a/ui/src/config/section/storage.js b/ui/src/config/section/storage.js index a18401be8e9..2e7c205aefa 100644 --- a/ui/src/config/section/storage.js +++ b/ui/src/config/section/storage.js @@ -256,6 +256,7 @@ export default { columns: () => { var fields = ['name', 'state', 'volumename', 'intervaltype', 'created'] if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) { + fields.push('domain') fields.push('account') } return fields @@ -315,7 +316,7 @@ export default { permission: ['listVMSnapshot'], resourceType: 'VMSnapshot', columns: () => { - var fields = ['displayname', 'state', 'name', 'type', 'current', 'parentName', 'created'] + const fields = ['displayname', 'state', 'name', 'type', 'current', 'parentName', 'created'] if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) { fields.push('domain') fields.push('account') @@ -325,6 +326,16 @@ export default { details: ['name', 'id', 'displayname', 'description', 'type', 'current', 'parentName', 'virtualmachineid', 'account', 'domain', 'created'], searchFilters: ['name', 'domainid', 'account', 'tags'], actions: [ + { + api: 'createSnapshotFromVMSnapshot', + icon: 'camera', + label: 'label.action.create.snapshot.from.vmsnapshot', + message: 'message.action.create.snapshot.from.vmsnapshot', + dataView: true, + popup: true, + show: (record) => { return (record.state === 'Ready' && record.hypervisor === 'KVM') }, + component: () => import('@/views/storage/CreateSnapshotFromVMSnapshot.vue') + }, { api: 'revertToVMSnapshot', icon: 'sync', diff --git a/ui/src/locales/en.json b/ui/src/locales/en.json index 63cbba7b6b5..2566cab1eb3 100644 --- a/ui/src/locales/en.json +++ b/ui/src/locales/en.json @@ -83,6 +83,7 @@ "label.action.create.template.from.vm": "Create Template from VM", "label.action.create.template.from.volume": "Create Template from Volume", "label.action.create.template.processing": "Creating Template....", +"label.action.create.snapshot.from.vmsnapshot": "Create Snapshot from VM Snapshot", "label.action.create.vm": "Create VM", "label.action.create.vm.processing": "Creating VM....", "label.action.create.volume": "Create Volume", @@ -2341,6 +2342,7 @@ "message.action.cancel.maintenance.mode": "Please confirm that you want to cancel this maintenance.", "message.action.change.service.warning.for.instance": "Your instance must be stopped before attempting to change its current service offering.", "message.action.change.service.warning.for.router": "Your router must be stopped before attempting to change its current service offering.", +"message.action.create.snapshot.from.vmsnapshot": "Please confirm that you want to create snapshot from VM Snapshot", "message.action.delete.backup.offering": "Please confirm that you want to delete this backup offering?", "message.action.delete.cluster": "Please confirm that you want to delete this cluster.", "message.action.delete.disk.offering": "Please confirm that you want to delete this disk offering.", @@ -2595,6 +2597,8 @@ "message.create.internallb.failed": "Failed to create Internal LB", "message.create.internallb.processing": "Creation of Internal LB is in progress", "message.create.service.offering": "Service offering created", +"message.create.snapshot.from.vmsnapshot.failed": "Failed to create Snapshot from VM Snapshot", +"message.create.snapshot.from.vmsnapshot.progress": "Snapshot Creation in progress", "message.create.template": "Are you sure you want to create template?", "message.create.template.vm": "Create VM from template ", "message.create.template.volume": "Please specify the following information before creating a template of your disk volume: . Creation of the template can range from several minutes to longer depending on the size of the volume.", @@ -3064,6 +3068,7 @@ "message.success.create.keypair": "Successfully created SSH key pair", "message.success.create.kubernetes.cluter": "Successfully created Kubernetes cluster", "message.success.create.l2.network": "Successfully created L2 network", +"message.success.create.snapshot.from.vmsnapshot": "Successfully created Snapshot from VM snapshot", "message.success.create.volume": "Successfully created volume", "message.success.delete": "Delete success", "message.success.delete.acl.rule": "Successfully removed ACL rule", diff --git a/ui/src/views/storage/CreateSnapshotFromVMSnapshot.vue b/ui/src/views/storage/CreateSnapshotFromVMSnapshot.vue new file mode 100644 index 00000000000..6e3be3cfd12 --- /dev/null +++ b/ui/src/views/storage/CreateSnapshotFromVMSnapshot.vue @@ -0,0 +1,151 @@ +// 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. + + + + + +