28 from django
import forms
29 from django.utils.translation
import ugettext_lazy
as _
31 from wi.utils
import parsing
32 from wi.utils.forms
import attrs_dict, BetterForm
41 rest_data = kwargs.pop(
'rest_data')
42 super(MountNodeForm, self).
__init__(*args, **kwargs)
43 self.fields[
'node_id'] = forms.ChoiceField(choices=parsing.parse_node_names(rest_data),
59 fieldsets = ((
'libvirt', {
'fields': (
'address',),
'legend': _(
'Libvirt configuration')}),
60 (
'resources', {
'fields': (
'hdd_total',
'cpu_total',
'memory_total'),
'legend': _(
'Node capacity')}),)
66 super(NodeForm, self).
__init__(*args, **kwargs)
67 self.fields[
'address'] = forms.CharField(widget=forms.TextInput(attrs=dict(attrs_dict, maxlength=45)),
68 label=_(
'Node address'),
69 help_text=_(
'Node address - IP or DNS name'))
70 self.fields[
'hdd_total'] = forms.IntegerField(min_value=1,
71 label=_(
'HDD Total [MB]'),
72 help_text=_(
' - total amount of storage for virtual machine images'))
73 self.fields[
'cpu_total'] = forms.IntegerField(min_value=1,
75 help_text=_(
' - total amount of CPU\'s for libvirt'))
76 self.fields[
'memory_total'] = forms.IntegerField(min_value=1,
77 label=_(
'Memory Total [MB]'),
78 help_text=_(
' - total amount of RAM'))
92 fieldsets = ((
'libvirt', {
'fields': (
'address',
'comment'),
'legend': _(
'Libvirt configuration')}),
93 (
'resources', {
'fields': (
'hdd_total',
'cpu_total',
'memory_total'),
'legend': _(
'Node capacity')}),)
99 super(EditNodeForm, self).
__init__(*args, **kwargs)
100 self.fields[
'comment'] = forms.CharField(required=
False,
101 widget=forms.Textarea(attrs=dict(attrs_dict,