You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2018/03/02 11:07:58 UTC
[cloudstack] branch master updated: [CLOUDSTACK-10257]Create
template/volume does not allow to specify HVM requirement (#2437)
This is an automated email from the ASF dual-hosted git repository.
rafael 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 2037dc9 [CLOUDSTACK-10257]Create template/volume does not allow to specify HVM requirement (#2437)
2037dc9 is described below
commit 2037dc9eb3979cbefc0a1c7f8b927c8d8b53ac26
Author: Rafael Weingärtner <ra...@gmail.com>
AuthorDate: Fri Mar 2 08:07:53 2018 -0300
[CLOUDSTACK-10257]Create template/volume does not allow to specify HVM requirement (#2437)
---
ui/scripts/sharedFunctions.js | 183 ++++++++++++++++++++++++++++
ui/scripts/storage.js | 269 +-----------------------------------------
2 files changed, 186 insertions(+), 266 deletions(-)
diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js
index 606fed4..923ab76 100644
--- a/ui/scripts/sharedFunctions.js
+++ b/ui/scripts/sharedFunctions.js
@@ -2622,3 +2622,186 @@ $.validator.addMethod("allzonesonly", function(value, element){
},
"All Zones cannot be combined with any other zone");
+
+cloudStack.createTemplateMethod = function (isSnapshot){
+ return {
+ label: 'label.create.template',
+ messages: {
+ confirm: function(args) {
+ return 'message.create.template';
+ },
+ notification: function(args) {
+ return 'label.create.template';
+ }
+ },
+ createForm: {
+ title: 'label.create.template',
+ preFilter: cloudStack.preFilter.createTemplate,
+ desc: '',
+ preFilter: function(args) {
+ if (args.context.volumes[0].hypervisor == "XenServer") {
+ if (isAdmin()) {
+ args.$form.find('.form-item[rel=xenserverToolsVersion61plus]').css('display', 'inline-block');
+ }
+ }
+ },
+ fields: {
+ name: {
+ label: 'label.name',
+ validation: {
+ required: true
+ }
+ },
+ displayText: {
+ label: 'label.description',
+ validation: {
+ required: true
+ }
+ },
+ xenserverToolsVersion61plus: {
+ label: 'label.xenserver.tools.version.61.plus',
+ isBoolean: true,
+ isChecked: function (args) {
+ var b = false;
+ var vmObj;
+ $.ajax({
+ url: createURL("listVirtualMachines"),
+ data: {
+ id: args.context.volumes[0].virtualmachineid
+ },
+ async: false,
+ success: function(json) {
+ vmObj = json.listvirtualmachinesresponse.virtualmachine[0];
+ }
+ });
+ if (vmObj == undefined) { //e.g. VM has failed over
+ if (isAdmin()) {
+ $.ajax({
+ url: createURL('listConfigurations'),
+ data: {
+ name: 'xenserver.pvdriver.version'
+ },
+ async: false,
+ success: function (json) {
+ if (json.listconfigurationsresponse.configuration != null && json.listconfigurationsresponse.configuration[0].value == 'xenserver61') {
+ b = true;
+ }
+ }
+ });
+ }
+ } else {
+ if ('details' in vmObj && 'hypervisortoolsversion' in vmObj.details) {
+ if (vmObj.details.hypervisortoolsversion == 'xenserver61')
+ b = true;
+ else
+ b = false;
+ }
+ }
+ return b;
+ },
+ isHidden: true
+ },
+ osTypeId: {
+ label: 'label.os.type',
+ select: function(args) {
+ $.ajax({
+ url: createURL("listOsTypes"),
+ dataType: "json",
+ async: true,
+ success: function(json) {
+ var ostypes = json.listostypesresponse.ostype;
+ var items = [];
+ $(ostypes).each(function() {
+ items.push({
+ id: this.id,
+ description: this.description
+ });
+ });
+ args.response.success({
+ data: items
+ });
+ }
+ });
+ }
+ },
+ isPublic: {
+ label: 'label.public',
+ isBoolean: true
+ },
+ isPasswordEnabled: {
+ label: 'label.password.enabled',
+ isBoolean: true
+ },
+ isFeatured: {
+ label: 'label.featured',
+ isBoolean: true
+ },
+ isdynamicallyscalable: {
+ label: 'label.dynamically.scalable',
+ isBoolean: true
+ },
+ requireshvm: {
+ label: 'label.hvm',
+ docID: 'helpRegisterTemplateHvm',
+ isBoolean: true,
+ isHidden: false,
+ isChecked: false
+ }
+ }
+ },
+ action: function(args) {
+ var data = {
+ name: args.data.name,
+ displayText: args.data.displayText,
+ osTypeId: args.data.osTypeId,
+ isPublic: (args.data.isPublic == "on"),
+ passwordEnabled: (args.data.isPasswordEnabled == "on"),
+ isdynamicallyscalable: (args.data.isdynamicallyscalable == "on"),
+ requireshvm: (args.data.requireshvm == "on")
+ };
+
+ if(isSnapshot){
+ data.snapshotid = args.context.snapshots[0].id;
+ } else{
+ data.volumeId = args.context.volumes[0].id;
+ }
+ if (args.$form.find('.form-item[rel=isFeatured]').css("display") != "none") {
+ $.extend(data, {
+ isfeatured: (args.data.isFeatured == "on")
+ });
+ }
+
+ //XenServer only (starts here)
+ if (args.$form.find('.form-item[rel=xenserverToolsVersion61plus]').length > 0) {
+ if (args.$form.find('.form-item[rel=xenserverToolsVersion61plus]').css("display") != "none") {
+ $.extend(data, {
+ 'details[0].hypervisortoolsversion': (args.data.xenserverToolsVersion61plus == "on") ? "xenserver61" : "xenserver56"
+ });
+ }
+ }
+ //XenServer only (ends here)
+
+ $.ajax({
+ url: createURL('createTemplate'),
+ data: data,
+ success: function(json) {
+ var jid = json.createtemplateresponse.jobid;
+ args.response.success({
+ _custom: {
+ jobId: jid,
+ getUpdatedItem: function(json) {
+ return {}; //no properties in this volume needs to be updated
+ },
+ getActionFilter: function() {
+ return volumeActionfilter;
+ }
+ }
+ });
+ }
+ });
+ },
+ notification: {
+ poll: pollAsyncJobResult
+ }
+ };
+};
\ No newline at end of file
diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js
index e9b6138..47c4dfc 100644
--- a/ui/scripts/storage.js
+++ b/ui/scripts/storage.js
@@ -1302,175 +1302,8 @@
}
},
- createTemplate: {
- label: 'label.create.template',
- messages: {
- confirm: function(args) {
- return 'message.create.template';
- },
- notification: function(args) {
- return 'label.create.template';
- }
- },
- createForm: {
- title: 'label.create.template',
- preFilter: cloudStack.preFilter.createTemplate,
- desc: '',
- preFilter: function(args) {
- if (args.context.volumes[0].hypervisor == "XenServer") {
- args.$form.find('.form-item[rel=xenserverToolsVersion61plus]').css('display', 'inline-block');
-
- }
- },
- fields: {
- name: {
- label: 'label.name',
- validation: {
- required: true
- }
- },
- displayText: {
- label: 'label.description',
- validation: {
- required: true
- }
- },
- xenserverToolsVersion61plus: {
- label: 'label.xenserver.tools.version.61.plus',
- isBoolean: true,
- isChecked: function (args) {
- var b = false;
- var vmObj;
- $.ajax({
- url: createURL("listVirtualMachines"),
- data: {
- id: args.context.volumes[0].virtualmachineid
- },
- async: false,
- success: function(json) {
- vmObj = json.listvirtualmachinesresponse.virtualmachine[0];
- }
- });
- if (vmObj == undefined) { //e.g. VM has failed over
- if (isAdmin()) {
- $.ajax({
- url: createURL('listConfigurations'),
- data: {
- name: 'xenserver.pvdriver.version'
- },
- async: false,
- success: function (json) {
- if (json.listconfigurationsresponse.configuration != null && json.listconfigurationsresponse.configuration[0].value == 'xenserver61') {
- b = true;
- }
- }
- });
- }
- } else {
- if ('details' in vmObj && 'hypervisortoolsversion' in vmObj.details) {
- if (vmObj.details.hypervisortoolsversion == 'xenserver61')
- b = true;
- else
- b = false;
- }
- }
- return b;
- },
- isHidden: true
- },
- osTypeId: {
- label: 'label.os.type',
- select: function(args) {
- $.ajax({
- url: createURL("listOsTypes"),
- dataType: "json",
- async: true,
- success: function(json) {
- var ostypes = json.listostypesresponse.ostype;
- var items = [];
- $(ostypes).each(function() {
- items.push({
- id: this.id,
- description: this.description
- });
- });
- args.response.success({
- data: items
- });
- }
- });
- }
- },
- isPublic: {
- label: 'label.public',
- isBoolean: true
- },
- isPasswordEnabled: {
- label: 'label.password.enabled',
- isBoolean: true
- },
- isFeatured: {
- label: 'label.featured',
- isBoolean: true
- },
- isdynamicallyscalable: {
- label: 'label.dynamically.scalable',
- isBoolean: true
- }
- }
- },
- action: function(args) {
- var data = {
- volumeId: args.context.volumes[0].id,
- name: args.data.name,
- displayText: args.data.displayText,
- osTypeId: args.data.osTypeId,
- isPublic: (args.data.isPublic == "on"),
- passwordEnabled: (args.data.isPasswordEnabled == "on"),
- isdynamicallyscalable: (args.data.isdynamicallyscalable == "on")
-
- };
-
- if (args.$form.find('.form-item[rel=isFeatured]').css("display") != "none") {
- $.extend(data, {
- isfeatured: (args.data.isFeatured == "on")
- });
- }
-
- //XenServer only (starts here)
- if (args.$form.find('.form-item[rel=xenserverToolsVersion61plus]').length > 0) {
- if (args.$form.find('.form-item[rel=xenserverToolsVersion61plus]').css("display") != "none") {
- $.extend(data, {
- 'details[0].hypervisortoolsversion': (args.data.xenserverToolsVersion61plus == "on") ? "xenserver61" : "xenserver56"
- });
- }
- }
- //XenServer only (ends here)
-
- $.ajax({
- url: createURL('createTemplate'),
- data: data,
- success: function(json) {
- var jid = json.createtemplateresponse.jobid;
- args.response.success({
- _custom: {
- jobId: jid,
- getUpdatedItem: function(json) {
- return {}; //no properties in this volume needs to be updated
- },
- getActionFilter: function() {
- return volumeActionfilter;
- }
- }
- });
- }
- });
- },
- notification: {
- poll: pollAsyncJobResult
- }
- },
-
+ createTemplate: cloudStack.createTemplateMethod(false),
+
migrateToAnotherStorage: {
label: 'label.migrate.volume.to.primary.storage',
messages: {
@@ -2102,103 +1935,7 @@
detailView: {
name: 'Snapshot detail',
actions: {
- createTemplate: {
- label: 'label.create.template',
- messages: {
- confirm: function(args) {
- return 'message.create.template';
- },
- notification: function(args) {
- return 'label.create.template';
- }
- },
- createForm: {
- title: 'label.create.template',
- desc: '',
- fields: {
- name: {
- label: 'label.name',
- validation: {
- required: true
- }
- },
- displayText: {
- label: 'label.description',
- validation: {
- required: true
- }
- },
- osTypeId: {
- label: 'label.os.type',
- select: function(args) {
- $.ajax({
- url: createURL("listOsTypes"),
- dataType: "json",
- async: true,
- success: function(json) {
- var ostypes = json.listostypesresponse.ostype;
- var items = [];
- $(ostypes).each(function() {
- items.push({
- id: this.id,
- description: this.description
- });
- });
- args.response.success({
- data: items
- });
- }
- });
- }
- },
- isPublic: {
- label: 'label.public',
- isBoolean: true
- },
- isPasswordEnabled: {
- label: 'label.password.enabled',
- isBoolean: true
- },
- isdynamicallyscalable: {
- label: 'label.dynamically.scalable',
- isBoolean: true
- }
- }
- },
- action: function(args) {
- var data = {
- snapshotid: args.context.snapshots[0].id,
- name: args.data.name,
- displayText: args.data.displayText,
- osTypeId: args.data.osTypeId,
- isPublic: (args.data.isPublic == "on"),
- passwordEnabled: (args.data.isPasswordEnabled == "on"),
- isdynamicallyscalable: (args.data.isdynamicallyscalable == "on")
- };
-
- $.ajax({
- url: createURL('createTemplate'),
- data: data,
- success: function(json) {
- var jid = json.createtemplateresponse.jobid;
- args.response.success({
- _custom: {
- jobId: jid,
- getUpdatedItem: function(json) {
- return {}; //nothing in this snapshot needs to be updated
- },
- getActionFilter: function() {
- return snapshotActionfilter;
- }
- }
- });
- }
- });
- },
- notification: {
- poll: pollAsyncJobResult
- }
- },
+ createTemplate: cloudStack.createTemplateMethod(true),
createVolume: {
label: 'label.action.create.volume',
--
To stop receiving notification emails like this one, please contact
rafael@apache.org.