cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ro...@apache.org
Subject [cloudstack] branch master updated: server: fix for vm snapshot search (#3208) (#3257)
Date Mon, 08 Apr 2019 08:48:07 GMT
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.git


The following commit(s) were added to refs/heads/master by this push:
     new 9b14e17  server: fix for vm snapshot search (#3208) (#3257)
9b14e17 is described below

commit 9b14e17a5848afb230d89ab7505493ac6206beaa
Author: Abhishek Kumar <abhishek.mrt22@gmail.com>
AuthorDate: Mon Apr 8 14:18:00 2019 +0530

    server: fix for vm snapshot search (#3208) (#3257)
    
    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.
    
    Fixes #3208
    
    Using db column instead of VO variable name was causing issue with SQL select statement.
    This PR fixes the problem by using VO variable for adding conditional.
    Additionally in UI listAll parameter was being sent twice in the listVMSnapshot API call.
It is fixed with this PR.
    
    Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
---
 .../cloud/vm/snapshot/VMSnapshotManagerImpl.java   |   2 +-
 ui/scripts/storage.js                              | 535 ++++++++++-----------
 2 files changed, 266 insertions(+), 271 deletions(-)

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 bd42fac..e2cae06 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 class VMSnapshotManagerImpl extends MutualExclusiveIdsManagerBase
impleme
         if (keyword != null) {
             SearchCriteria<VMSnapshotVO> 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);
         }
diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js
index 06fe41e..9fda923 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,243 +2258,245 @@
                         }
                     },
 
-		    dataProvider: function(args) {
-                        var data = {};
-                        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&listAll=true'),
-                            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
+                }
             }
         }
     };


Mime
View raw message