Skip to content

Commit 5afff61

Browse files
authored
create template from snapshot regression (partly reverted) (#3767)
1 parent c75c228 commit 5afff61

2 files changed

Lines changed: 103 additions & 1 deletion

File tree

ui/scripts/sharedFunctions.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,6 +2841,7 @@ cloudStack.createTemplateMethod = function (isSnapshot){
28412841
isChecked: false
28422842
}
28432843
}
2844+
28442845
},
28452846
action: function(args) {
28462847
var data = {
@@ -2898,6 +2899,107 @@ cloudStack.createTemplateMethod = function (isSnapshot){
28982899
}
28992900
};
29002901
};
2902+
cloudStack.createTemplateFromSnapshotMethod = function (){
2903+
return {
2904+
label: 'label.create.template',
2905+
messages: {
2906+
confirm: function(args) {
2907+
return 'message.create.template';
2908+
},
2909+
notification: function(args) {
2910+
return 'label.create.template';
2911+
}
2912+
},
2913+
createForm: {
2914+
title: 'label.create.template',
2915+
desc: '',
2916+
2917+
2918+
fields: {
2919+
name: {
2920+
label: 'label.name',
2921+
validation: {
2922+
required: true
2923+
}
2924+
},
2925+
displayText: {
2926+
label: 'label.description',
2927+
validation: {
2928+
required: true
2929+
}
2930+
},
2931+
osTypeId: {
2932+
label: 'label.os.type',
2933+
select: function(args) {
2934+
$.ajax({
2935+
url: createURL("listOsTypes"),
2936+
dataType: "json",
2937+
async: true,
2938+
success: function(json) {
2939+
var ostypes = json.listostypesresponse.ostype;
2940+
var items = [];
2941+
$(ostypes).each(function() {
2942+
items.push({
2943+
id: this.id,
2944+
description: this.description
2945+
});
2946+
});
2947+
args.response.success({
2948+
data: items
2949+
});
2950+
}
2951+
});
2952+
}
2953+
},
2954+
isPublic: {
2955+
label: 'label.public',
2956+
isBoolean: true
2957+
},
2958+
isPasswordEnabled: {
2959+
label: 'label.password.enabled',
2960+
isBoolean: true
2961+
},
2962+
isdynamicallyscalable: {
2963+
label: 'label.dynamically.scalable',
2964+
isBoolean: true
2965+
}
2966+
}
2967+
},
2968+
action: function(args) {
2969+
var data = {
2970+
snapshotid: args.context.snapshots[0].id,
2971+
name: args.data.name,
2972+
displayText: args.data.displayText,
2973+
osTypeId: args.data.osTypeId,
2974+
isPublic: (args.data.isPublic == "on"),
2975+
passwordEnabled: (args.data.isPasswordEnabled == "on"),
2976+
isdynamicallyscalable: (args.data.isdynamicallyscalable == "on")
2977+
};
2978+
2979+
$.ajax({
2980+
url: createURL('createTemplate'),
2981+
data: data,
2982+
success: function(json) {
2983+
var jid = json.createtemplateresponse.jobid;
2984+
args.response.success({
2985+
_custom: {
2986+
jobId: jid,
2987+
getUpdatedItem: function(json) {
2988+
return {}; //nothing in this snapshot needs to be updated
2989+
},
2990+
getActionFilter: function() {
2991+
return snapshotActionfilter;
2992+
}
2993+
}
2994+
});
2995+
}
2996+
});
2997+
},
2998+
notification: {
2999+
poll: pollAsyncJobResult
3000+
}
3001+
};
3002+
};
29013003

29023004
cloudStack.addParameterToCommandUrlParameterArrayIfValueIsNotEmpty = function(array, parameterName, value){
29033005
if (value != null && value.length > 0) {

ui/scripts/storage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,7 @@
19601960
detailView: {
19611961
name: 'Snapshot detail',
19621962
actions: {
1963-
createTemplate: cloudStack.createTemplateMethod(true),
1963+
createTemplate: cloudStack.createTemplateFromSnapshotMethod(),
19641964

19651965
createVolume: {
19661966
label: 'label.action.create.volume',

0 commit comments

Comments
 (0)