diff --git a/sahara_dashboard/api/sahara.py b/sahara_dashboard/api/sahara.py index 0c930649..2a3e5237 100644 --- a/sahara_dashboard/api/sahara.py +++ b/sahara_dashboard/api/sahara.py @@ -170,7 +170,9 @@ def nodegroup_template_create(request, name, plugin_name, hadoop_version, shares=None, is_public=None, is_protected=None, - volume_mount_prefix=None): + volume_mount_prefix=None, + boot_from_volume=None): + payload = dict( name=name, plugin_name=plugin_name, @@ -194,10 +196,13 @@ def nodegroup_template_create(request, name, plugin_name, hadoop_version, is_public=is_public, is_protected=is_protected, volume_mount_prefix=volume_mount_prefix) + if VERSIONS.active == '2': payload['plugin_version'] = hadoop_version + payload['boot_from_volume'] = boot_from_volume else: payload['hadoop_version'] = hadoop_version + return client(request).node_group_templates.create(**payload) @@ -237,7 +242,9 @@ def nodegroup_template_update(request, ngt_id, name, plugin_name, shares=None, is_protected=None, is_public=None, - image_id=None): + image_id=None, + boot_from_volume=None): + payload = dict( ng_template_id=ngt_id, name=name, @@ -261,10 +268,13 @@ def nodegroup_template_update(request, ngt_id, name, plugin_name, is_public=is_public, is_protected=is_protected, image_id=image_id) + if VERSIONS.active == '2': payload['plugin_version'] = hadoop_version + payload['boot_from_volume'] = boot_from_volume else: payload['hadoop_version'] = hadoop_version + return client(request).node_group_templates.update(**payload) diff --git a/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/tests.py b/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/tests.py index a78a0b4c..097ea50c 100644 --- a/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/tests.py +++ b/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/tests.py @@ -337,7 +337,8 @@ class DataProcessingNodeGroupTests(test.TestCase): shares=[], is_protected=False, is_public=False, - image_id=ngt.image_id) + image_id=ngt.image_id, + ) @test.create_mocks({api.sahara: ('nodegroup_template_get', 'plugin_get_version_details', diff --git a/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/workflows/create.py b/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/workflows/create.py index ecf1ec54..9de56b18 100644 --- a/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/workflows/create.py +++ b/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/workflows/create.py @@ -190,6 +190,15 @@ class GeneralConfigAction(workflows.Action): self.fields['is_protected'] = acl_utils.get_is_protected_form( _("node group template")) + if saharaclient.VERSIONS.active == '2': + self.fields['boot_from_volume'] = forms.BooleanField( + label=_("Boot From Volume"), + help_text=_("If selected, the node group instance will be " + "booted from volume"), + required=False, + widget=forms.CheckboxInput(), + initial=False) + self.fields["plugin_name"] = forms.CharField( widget=forms.HiddenInput(), initial=plugin @@ -547,6 +556,11 @@ class ConfigureNodegroupTemplate(workflow_helpers.ServiceParametersWorkflow, image_id = context["general_image"] or None + if saharaclient.VERSIONS.active == '2': + boot_from_volume = context["general_boot_from_volume"] + else: + boot_from_volume = None + ngt = saharaclient.nodegroup_template_create( request, name=context["general_nodegroup_name"], @@ -570,6 +584,7 @@ class ConfigureNodegroupTemplate(workflow_helpers.ServiceParametersWorkflow, shares=ngt_shares, is_public=context['general_is_public'], is_protected=context['general_is_protected'], + boot_from_volume=boot_from_volume, image_id=image_id) hlps = helpers.Helpers(request) diff --git a/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/workflows/edit.py b/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/workflows/edit.py index 1d91ccb9..cee76255 100644 --- a/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/workflows/edit.py +++ b/sahara_dashboard/content/data_processing/clusters/nodegroup_templates/workflows/edit.py @@ -79,7 +79,7 @@ class EditNodegroupTemplate(copy_flow.CopyNodegroupTemplate): image_id = context["general_image"] or None - saharaclient.nodegroup_template_update( + args_dict = dict( request=request, ngt_id=self.template_id, name=context["general_nodegroup_name"], @@ -104,6 +104,13 @@ class EditNodegroupTemplate(copy_flow.CopyNodegroupTemplate): is_public=context['general_is_public'], is_protected=context['general_is_protected'], image_id=image_id) + + if saharaclient.VERSIONS.active == '2': + args_dict['boot_from_volume'] = ( + context['general_boot_from_volume']) + + saharaclient.nodegroup_template_update(**args_dict) + return True except api_base.APIException as e: self.error_description = str(e.message) diff --git a/sahara_dashboard/content/data_processing/clusters/templates/nodegroup_templates/_details.html b/sahara_dashboard/content/data_processing/clusters/templates/nodegroup_templates/_details.html index 1e07745a..cb99b8e1 100644 --- a/sahara_dashboard/content/data_processing/clusters/templates/nodegroup_templates/_details.html +++ b/sahara_dashboard/content/data_processing/clusters/templates/nodegroup_templates/_details.html @@ -59,6 +59,11 @@
{{ template.auto_security_group }}
+
+
{% trans "Boot from Volume" %}
+
{{ template.boot_from_volume }}
+
+
{% trans "Security Groups" %}