From f8e75cea2b5aea46a4715b9c9edd2f5cb72b63ea Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 3 Apr 2019 12:56:33 +0530 Subject: [PATCH 1/3] server: fix for VM snapshot search criteria (#3208) Using db column instead of VO variable name was causing issue with SQL select statement. This change fixes the problem by using VO variable for adding conditional. Signed-off-by: Abhishek Kumar --- .../main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java index bd42faca6583..e2cae0651ebb 100644 --- a/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java @@ -265,7 +265,7 @@ public Pair, Integer> listVMSnapshots(ListVMSnapshotC if (keyword != null) { SearchCriteria ssc = _vmSnapshotDao.createSearchCriteria(); ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); - ssc.addOr("display_name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); + ssc.addOr("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%"); sc.addAnd("name", SearchCriteria.Op.SC, ssc); } From 85919310b6d371d946caacb72b4e43c8869cfe01 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 3 Apr 2019 13:00:17 +0530 Subject: [PATCH 2/3] ui: fixes multiple listAll param in listVMSnapshot API call (#3208) Signed-off-by: Abhishek Kumar --- ui/scripts/storage.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 06fe41e2f712..04f69c3378b7 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -2266,7 +2266,9 @@ }, dataProvider: function(args) { - var data = {}; + var data = { + listAll: true + }; listViewDataProvider(args, data); if (args.context != null) { @@ -2277,7 +2279,7 @@ } } $.ajax({ - url: createURL('listVMSnapshot&listAll=true'), + url: createURL('listVMSnapshot'), data: data, dataType: "json", async: true, From 1fb86defdc5fe0e2de9830374aeebb3e83982c74 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 3 Apr 2019 13:44:38 +0530 Subject: [PATCH 3/3] refactorings: fixed tabs Signed-off-by: Abhishek Kumar --- ui/scripts/storage.js | 537 +++++++++++++++++++++--------------------- 1 file changed, 265 insertions(+), 272 deletions(-) diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 04f69c3378b7..9fda923fe47d 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -26,7 +26,6 @@ select: function(args) { var mapStoragePoolsByUuid = new Map(); var volumeId = args.context.volumes[0].id; - var volumeBeingMigrated = undefined; $.ajax({ url: createURL("listVolumes&id=" + volumeId), @@ -36,7 +35,6 @@ volumeBeingMigrated = json.listvolumesresponse.volume[0]; } }); - var currentStoragePool = undefined; $.ajax({ url: createURL("listStoragePools&id=" + volumeBeingMigrated.storageid), @@ -81,7 +79,6 @@ $('select[name=storagePool]').change(function(){ var uuidOfStoragePoolSelected = $(this).val(); var storagePoolSelected = mapStoragePoolsByUuid.get(uuidOfStoragePoolSelected); - if(currentStoragePool.scope === storagePoolSelected.scope){ $('div[rel=newDiskOffering],div[rel=useNewDiskOffering]').hide(); }else{ @@ -110,7 +107,6 @@ } }; $('div[rel=useNewDiskOffering] input[type=checkbox]').click(functionHideShowNewDiskOfferint); - $('select[name=storagePool]').change(); functionHideShowNewDiskOfferint(); } @@ -152,7 +148,6 @@ var functionMigrateVolume = function(args) { var volumeBeingMigrated = args.context.volumes[0]; var isLiveMigrate = volumeBeingMigrated.vmstate == 'Running'; - var migrateVolumeUrl = "migrateVolume&livemigrate="+ isLiveMigrate +"&storageid=" + args.data.storagePool + "&volumeid=" + volumeBeingMigrated.id; if($('div[rel=useNewDiskOffering] input[name=useNewDiskOffering]:checkbox').is(':checked')){ migrateVolumeUrl = migrateVolumeUrl + '&newdiskofferingid=' + $('div[rel=newDiskOffering] select').val(); @@ -924,8 +919,8 @@ label: 'label.name' }, asyncBackup: { - label: 'label.async.backup', - isBoolean: true + label: 'label.async.backup', + isBoolean: true } } }, @@ -1388,7 +1383,6 @@ }, createTemplate: cloudStack.createTemplateMethod(false), - migrateToAnotherStorage: { label: 'label.migrate.volume.to.primary.storage', messages: { @@ -1475,7 +1469,6 @@ args.response.success({ data: items }); - args.$select.change(function() { if(args.context.volumes[0].type == "ROOT") { selectedDiskOfferingObj = null; @@ -1688,10 +1681,10 @@ } }, clusterid: { - label: 'label.cluster' + label: 'label.cluster' }, clustername: { - label: 'label.cluster.name' + label: 'label.cluster.name' }, physicalsize: { label: 'label.disk.physicalsize', @@ -2166,36 +2159,36 @@ */ vmsnapshots: { type: 'select', - title: 'label.vmsnapshot', - listView: { - id: 'vmsnapshots', - isMaximized: true, - fields: { - displayname: { - label: 'label.name' - }, - state: { - label: 'label.state', - indicator: { - 'Ready': 'on', - 'Error': 'off' - } - }, - type: { - label: 'label.vmsnapshot.type' - }, - current: { - label: 'label.vmsnapshot.current', - converter: cloudStack.converters.toBooleanText - }, - parentName: { - label: 'label.vmsnapshot.parentname' - }, - created: { - label: 'label.date', - converter: cloudStack.converters.toLocalDate - } - }, + title: 'label.vmsnapshot', + listView: { + id: 'vmsnapshots', + isMaximized: true, + fields: { + displayname: { + label: 'label.name' + }, + state: { + label: 'label.state', + indicator: { + 'Ready': 'on', + 'Error': 'off' + } + }, + type: { + label: 'label.vmsnapshot.type' + }, + current: { + label: 'label.vmsnapshot.current', + converter: cloudStack.converters.toBooleanText + }, + parentName: { + label: 'label.vmsnapshot.parentname' + }, + created: { + label: 'label.date', + converter: cloudStack.converters.toLocalDate + } + }, advSearchFields: { name: { @@ -2265,245 +2258,245 @@ } }, - dataProvider: function(args) { - var data = { - listAll: true - }; - listViewDataProvider(args, data); + dataProvider: function(args) { + var data = { + listAll: true + }; + listViewDataProvider(args, data); - if (args.context != null) { - if ("instances" in args.context) { - $.extend(data, { - virtualMachineId: args.context.instances[0].id + if (args.context != null) { + if ("instances" in args.context) { + $.extend(data, { + virtualMachineId: args.context.instances[0].id + }); + } + } + $.ajax({ + url: createURL('listVMSnapshot'), + data: data, + dataType: "json", + async: true, + success: function(json) { + var jsonObj; + jsonObj = json.listvmsnapshotresponse.vmSnapshot; + args.response.success({ + actionFilter: vmSnapshotActionfilter, + data: jsonObj }); - } - } - $.ajax({ - url: createURL('listVMSnapshot'), - data: data, - dataType: "json", - async: true, - success: function(json) { - var jsonObj; - jsonObj = json.listvmsnapshotresponse.vmSnapshot; - args.response.success({ - actionFilter: vmSnapshotActionfilter, - data: jsonObj - }); - } - }); - }, - //dataProvider end - detailView: { - tabs: { - details: { - title: 'label.details', - fields: { - id: { - label: 'label.id' - }, - name: { - label: 'label.name' - }, - displayname: { - label: 'label.display.name' - }, - type: { - label: 'label.vmsnapshot.type' - }, - description: { - label: 'label.description' - }, - state: { - label: 'label.state', - indicator: { - 'Ready': 'on', - 'Error': 'off' - } - }, - current: { - label: 'label.vmsnapshot.current', - converter: cloudStack.converters.toBooleanText - }, - parentName: { - label: 'label.vmsnapshot.parentname' - }, - domain: { - label: 'label.domain' + } + }); + }, + //dataProvider end + detailView: { + tabs: { + details: { + title: 'label.details', + fields: { + id: { + label: 'label.id' }, - account: { - label: 'label.account' + name: { + label: 'label.name' }, - virtualmachineid: { - label: 'label.vm.id' - }, - created: { - label: 'label.date', - converter: cloudStack.converters.toLocalDate - } - }, - dataProvider: function(args) { - $.ajax({ - url: createURL("listVMSnapshot&listAll=true&vmsnapshotid=" + args.context.vmsnapshots[0].id), - dataType: "json", - async: true, - success: function(json) { - var jsonObj; - jsonObj = json.listvmsnapshotresponse.vmSnapshot[0]; - args.response.success({ - actionFilter: vmSnapshotActionfilter, - data: jsonObj - }); - } - }); - }, - tags: cloudStack.api.tags({ - resourceType: 'VMSnapshot', - contextId: 'vmsnapshots' - }) - } - }, - actions: { - //delete a snapshot - remove: { - label: 'label.action.vmsnapshot.delete', - messages: { - confirm: function(args) { - return 'message.action.vmsnapshot.delete'; - }, - notification: function(args) { - return 'label.action.vmsnapshot.delete'; - } - }, - action: function(args) { - $.ajax({ - url: createURL("deleteVMSnapshot&vmsnapshotid=" + args.context.vmsnapshots[0].id), - dataType: "json", - async: true, - success: function(json) { - var jid = json.deletevmsnapshotresponse.jobid; - args.response.success({ - _custom: { - jobId: jid - } - }); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, - revertToVMSnapshot: { - label: 'label.action.vmsnapshot.revert', - messages: { - confirm: function(args) { - return 'label.action.vmsnapshot.revert'; - }, - notification: function(args) { - return 'message.action.vmsnapshot.revert'; - } - }, - action: function(args) { - $.ajax({ - url: createURL("revertToVMSnapshot&vmsnapshotid=" + args.context.vmsnapshots[0].id), - dataType: "json", - async: true, - success: function(json) { - var jid = json.reverttovmsnapshotresponse.jobid; - args.response.success({ - _custom: { - jobId: jid - } - }); - } - }); - - }, - notification: { - poll: pollAsyncJobResult - } - }, - takeSnapshot: { - label: 'Create Snapshot From VM Snapshot', - messages: { - confirm: function(args) { - return 'Please confirm that you want to create a volume snapshot from the vm snapshot.'; - }, - notification: function(args) { - return 'Volume snapshot is created from vm snapshot'; - } - }, - createForm: { - title: 'label.action.take.snapshot', - desc: 'message.action.take.snapshot', - fields: { - name: { - label: 'label.name', - }, - volume: { - label: 'label.volume', - validation: { - required: true + displayname: { + label: 'label.display.name' + }, + type: { + label: 'label.vmsnapshot.type' + }, + description: { + label: 'label.description' + }, + state: { + label: 'label.state', + indicator: { + 'Ready': 'on', + 'Error': 'off' + } + }, + current: { + label: 'label.vmsnapshot.current', + converter: cloudStack.converters.toBooleanText + }, + parentName: { + label: 'label.vmsnapshot.parentname' + }, + domain: { + label: 'label.domain' }, - select: function(args) { - $.ajax({ - url: createURL("listVolumes&virtualMachineId=" + args.context.vmsnapshots[0].virtualmachineid), - dataType: "json", - async: true, - success: function(json) { - var volumes = json.listvolumesresponse.volume; - var items = []; - $(volumes).each(function() { - items.push({ - id: this.id, - description: this.name - }); - }); - args.response.success({ - data: items - }); + account: { + label: 'label.account' + }, + virtualmachineid: { + label: 'label.vm.id' + }, + created: { + label: 'label.date', + converter: cloudStack.converters.toLocalDate + } + }, + dataProvider: function(args) { + $.ajax({ + url: createURL("listVMSnapshot&listAll=true&vmsnapshotid=" + args.context.vmsnapshots[0].id), + dataType: "json", + async: true, + success: function(json) { + var jsonObj; + jsonObj = json.listvmsnapshotresponse.vmSnapshot[0]; + args.response.success({ + actionFilter: vmSnapshotActionfilter, + data: jsonObj + }); + } + }); + }, + tags: cloudStack.api.tags({ + resourceType: 'VMSnapshot', + contextId: 'vmsnapshots' + }) + } + }, + actions: { + //delete a snapshot + remove: { + label: 'label.action.vmsnapshot.delete', + messages: { + confirm: function(args) { + return 'message.action.vmsnapshot.delete'; + }, + notification: function(args) { + return 'label.action.vmsnapshot.delete'; + } + }, + action: function(args) { + $.ajax({ + url: createURL("deleteVMSnapshot&vmsnapshotid=" + args.context.vmsnapshots[0].id), + dataType: "json", + async: true, + success: function(json) { + var jid = json.deletevmsnapshotresponse.jobid; + args.response.success({ + _custom: { + jobId: jid + } + }); + } + }); + }, + notification: { + poll: pollAsyncJobResult + } + }, + revertToVMSnapshot: { + label: 'label.action.vmsnapshot.revert', + messages: { + confirm: function(args) { + return 'label.action.vmsnapshot.revert'; + }, + notification: function(args) { + return 'message.action.vmsnapshot.revert'; + } + }, + action: function(args) { + $.ajax({ + url: createURL("revertToVMSnapshot&vmsnapshotid=" + args.context.vmsnapshots[0].id), + dataType: "json", + async: true, + success: function(json) { + var jid = json.reverttovmsnapshotresponse.jobid; + args.response.success({ + _custom: { + jobId: jid + } + }); + } + }); + }, + notification: { + poll: pollAsyncJobResult + } + }, + takeSnapshot: { + label: 'Create Snapshot From VM Snapshot', + messages: { + confirm: function(args) { + return 'Please confirm that you want to create a volume snapshot from the vm snapshot.'; + }, + notification: function(args) { + return 'Volume snapshot is created from vm snapshot'; + } + }, + createForm: { + title: 'label.action.take.snapshot', + desc: 'message.action.take.snapshot', + fields: { + name: { + label: 'label.name', + }, + volume: { + label: 'label.volume', + validation: { + required: true + }, + select: function(args) { + $.ajax({ + url: createURL("listVolumes&virtualMachineId=" + args.context.vmsnapshots[0].virtualmachineid), + dataType: "json", + async: true, + success: function(json) { + var volumes = json.listvolumesresponse.volume; + var items = []; + $(volumes).each(function() { + items.push({ + id: this.id, + description: this.name + }); + }); + args.response.success({ + data: items + }); + + } + }); } - }); - } + } + } + }, + action: function(args) { + var data = { + volumeid: args.data.volume, + vmsnapshotid: args.context.vmsnapshots[0].id + }; + if (args.data.name != null && args.data.name.length > 0) { + $.extend(data, { + name: args.data.name + }); + } + $.ajax({ + url: createURL("createSnapshotFromVMSnapshot"), + data: data, + dataType: "json", + async: true, + success: function(json) { + var jid = json.createsnapshotfromvmsnapshotresponse.jobid; + args.response.success({ + _custom: { + jobId: jid + } + }); } - } - }, - action: function(args) { - var data = { - volumeid: args.data.volume, - vmsnapshotid: args.context.vmsnapshots[0].id - }; - if (args.data.name != null && args.data.name.length > 0) { - $.extend(data, { - name: args.data.name - }); - } - $.ajax({ - url: createURL("createSnapshotFromVMSnapshot"), - data: data, - dataType: "json", - async: true, - success: function(json) { - var jid = json.createsnapshotfromvmsnapshotresponse.jobid; - args.response.success({ - _custom: { - jobId: jid - } - }); - } - }); - - }, - notification: { - poll: pollAsyncJobResult - } - } - } - } - //detailview end - } + }); + + }, + notification: { + poll: pollAsyncJobResult + } + } + } + } + //detailview end + } } } };