diff --git a/include/Datastore.h b/include/Datastore.h index 58a6124ccb..5be4db3a4e 100644 --- a/include/Datastore.h +++ b/include/Datastore.h @@ -248,6 +248,18 @@ public: */ int enable(bool enable, string& error_str); + /** + * Return a set with compatible system ds for an image ds + */ + void get_compatible_system_ds(set &compatible_sys_ds) + { + string compatible_sys_ds_str; + + get_template_attribute("COMPATIBLE_SYS_DS", compatible_sys_ds_str); + + one_util::split_unique(compatible_sys_ds_str, ',', compatible_sys_ds); + } + private: // ------------------------------------------------------------------------- diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index a5313ddf97..c99f0e3679 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1010,7 +1010,12 @@ public: * @param error_str Returns the error reason, if any * @return 0 on success */ - int automatic_requirements(set& cluster_ids, string& error_str); + int automatic_requirements(set& cluster_ids, string& error_str) + { + std::set datastore_ids; + + return automatic_requirements(cluster_ids, datastore_ids, error_str); + } /** * Checks if the resize parameters are valid @@ -2004,6 +2009,16 @@ private: */ int get_vmgroup(string& error); + /** + * Adds automatic placement requirements: Datastore and Cluster + * @param cluster_ids set of viable clusters for this VM + * @param ds_ids set of viable datastores for this VM + * @param error_str Returns the error reason, if any + * @return 0 on success + */ + int automatic_requirements(set& cluster_ids, set& ds_ids, + string& error_str); + // ------------------------------------------------------------------------ // Public cloud templates related functions // ------------------------------------------------------------------------ diff --git a/src/sunstone/public/app/tabs/datastores-tab/form-panels/create.js b/src/sunstone/public/app/tabs/datastores-tab/form-panels/create.js index db03b4115a..b4f911de9f 100644 --- a/src/sunstone/public/app/tabs/datastores-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/datastores-tab/form-panels/create.js @@ -208,6 +208,16 @@ define(function(require) { _selectCustom(dialog); break; } + + $("input[name='ds_type']", dialog).change(function() { + var value = $(this).val(); + if ( value === "IMAGE_DS" ){ + $(".only_img_ds", dialog).show(); + } else { + $(".only_img_ds", dialog).hide(); + } + }); + $(".only_img_ds", dialog).show(); }); $('#presets', dialog).change(); @@ -248,6 +258,7 @@ define(function(require) { var iscsi_user = $('#iscsi_user', dialog).val(); var iscsi_usage = $('#iscsi_usage', dialog).val(); var vcenter_cluster = $('#vcenter_cluster', dialog).val(); + var compatible_sys_ds = $('#compatible_sys_ds', dialog).val(); var ds_obj = { "datastore" : { @@ -333,6 +344,9 @@ define(function(require) { if (vcenter_cluster) ds_obj.datastore.vcenter_cluster = vcenter_cluster; + if (compatible_sys_ds) + ds_obj.datastore.compatible_sys_ds = compatible_sys_ds; + Sunstone.runAction("Datastore.create", ds_obj); return false; } diff --git a/src/sunstone/public/app/tabs/datastores-tab/form-panels/create/wizard.hbs b/src/sunstone/public/app/tabs/datastores-tab/form-panels/create/wizard.hbs index c14c59c686..f06fafc7aa 100644 --- a/src/sunstone/public/app/tabs/datastores-tab/form-panels/create/wizard.hbs +++ b/src/sunstone/public/app/tabs/datastores-tab/form-panels/create/wizard.hbs @@ -250,6 +250,12 @@ +
+ + +