diff --git a/tuskar_ui/infrastructure/nodes/forms.py b/tuskar_ui/infrastructure/nodes/forms.py index 59359007b..cb3197d3f 100644 --- a/tuskar_ui/infrastructure/nodes/forms.py +++ b/tuskar_ui/infrastructure/nodes/forms.py @@ -53,16 +53,23 @@ def get_driver_info_dict(data): def create_node(request, data): + cpu_arch = data.get('cpu_arch') + cpus = data.get('cpus') + memory_mb = data.get('memory_mb') + local_gb = data.get('local_gb') + kwargs = get_driver_info_dict(data) kwargs.update( - cpu_arch=data.get('cpu_arch'), - cpus=data.get('cpus'), - memory_mb=data.get('memory_mb'), - local_gb=data.get('local_gb'), + cpu_arch=cpu_arch, + cpus=cpus, + memory_mb=memory_mb, + local_gb=local_gb, mac_addresses=data['mac_addresses'].split(), ) node = api.node.Node.create(request, **kwargs) - if data.get('do_autodiscovery', False): + + # If not all the parameters have been filled in, run the autodiscovery + if not all([cpu_arch, cpus, memory_mb, local_gb]): api.node.Node.set_maintenance(request, node.uuid, True) api.node.Node.discover(request, [node.uuid]) @@ -139,13 +146,9 @@ class NodeForm(django.forms.Form): 'rows': 2, }), ) - do_autodiscovery = django.forms.BooleanField( - label=_("Discover missing attributes"), - required=False, - ) mac_addresses = tuskar_ui.forms.MultiMACField( label=_("NIC MAC Addresses"), - required=False, + required=True, widget=django.forms.Textarea(attrs={ 'placeholder': _('unspecified'), 'rows': '2', @@ -216,25 +219,14 @@ class NodeForm(django.forms.Form): def clean(self): cleaned_data = super(NodeForm, self).clean() driver = cleaned_data['driver'] + if driver == 'pxe_ipmitool': self._require_field('ipmi_address', cleaned_data) elif driver == 'pxe_ssh': self._require_field('ssh_address', cleaned_data) self._require_field('ssh_username', cleaned_data) self._require_field('ssh_key_contents', cleaned_data) - if not cleaned_data.get('do_autodiscovery', False): - for field_name in [ - 'mac_addresses', - 'cpu_arch', - 'cpus', - 'memory_mb', - 'local_gb', - ]: - if not cleaned_data.get(field_name): - self._errors[field_name] = self.error_class([( - u"This field is required " - u"when autodiscovery is disabled." - )]) + return cleaned_data @@ -263,7 +255,6 @@ class UploadNodeForm(forms.SelfHandlingForm): ssh_key_contents=row[3], mac_addresses=row[4], driver=driver, - do_autodiscovery=True, ) elif driver == 'pxe_ipmitool': node = dict( @@ -271,7 +262,6 @@ class UploadNodeForm(forms.SelfHandlingForm): ipmi_username=row[2], ipmi_password=row[3], driver=driver, - do_autodiscovery=True, ) data.append(node) return data diff --git a/tuskar_ui/infrastructure/static/infrastructure/scss/_formsets.scss b/tuskar_ui/infrastructure/static/infrastructure/scss/_formsets.scss index e692cbb16..c2a84e92e 100644 --- a/tuskar_ui/infrastructure/static/infrastructure/scss/_formsets.scss +++ b/tuskar_ui/infrastructure/static/infrastructure/scss/_formsets.scss @@ -23,3 +23,7 @@ color: #428bca; } } + +.param-section { + padding-bottom: 15px; +} diff --git a/tuskar_ui/infrastructure/templates/infrastructure/nodes/_nodes_formset_form.html b/tuskar_ui/infrastructure/templates/infrastructure/nodes/_nodes_formset_form.html index 01b12632c..270b41367 100644 --- a/tuskar_ui/infrastructure/templates/infrastructure/nodes/_nodes_formset_form.html +++ b/tuskar_ui/infrastructure/templates/infrastructure/nodes/_nodes_formset_form.html @@ -5,31 +5,27 @@ id="tab-{{ form.prefix }}">
{% include 'horizon/common/_form_errors.html' with form=form %} -
-

{% trans "Node Detail" %}

+

{% trans "Node Detail" %}

+
+
{% trans "Power Management" %}
+ {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.driver required=True %} + {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ipmi_address required=True %} + {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ipmi_username %} + {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ipmi_password %} + {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ssh_address required=True %} + {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ssh_username required=True %} + {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ssh_key_contents required=True %}
-
{% trans "Power Management" %}
- {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.driver required=True %} - {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ipmi_address required=True %} - {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ipmi_username %} - {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ipmi_password %} - {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ssh_address required=True %} - {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ssh_username required=True %} - {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.ssh_key_contents required=True %} -
-
- -
-
{% trans "Networking" %}
+
+
{% trans "Networking" %}
{% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.mac_addresses required=True %} -
{% trans "Hardware" %}
- {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.cpu_arch required=True %} - {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.cpus extra_text=_('units') required=True %} - {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.memory_mb extra_text=_('MB') required=True %} - {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.local_gb extra_text=_('GB') required=True %} +
+
+
{% trans "Hardware" %}
+ {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.cpu_arch %} + {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.cpus extra_text=_('units') %} + {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.memory_mb extra_text=_('MB') %} + {% include 'infrastructure/nodes/_nodes_formset_field.html' with field=form.local_gb extra_text=_('GB') %}
@@ -44,11 +40,5 @@ var $nav_link = $('a[href="#' + $form.attr('id') + '"]'); $nav_link.html($(this).val() || undefined_name); }); - - $form.find('input[name$="-do_autodiscovery"]').change(function () { - var $this = $(this); - $this.closest('.panel').find( - '.form-group .row').toggleClass('required', !($this.attr('checked'))); - }); });