Skip to content

Commit

Permalink
Merge pull request #1431 from freenas/FIX-34522-11.1STABLE
Browse files Browse the repository at this point in the history
Functionality to reset SED Password added
  • Loading branch information
sonicaj committed Jun 25, 2018
2 parents 2e54a29 + 3aa7a2d commit 7fa193c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
23 changes: 19 additions & 4 deletions gui/storage/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,13 @@ class DiskFormPartial(ModelForm):
required=False,
)

disk_reset_password = forms.BooleanField(
label='Reset Password',
required=False,
initial=False,
help_text=_('Click this box to reset SED password'),
)

class Meta:
model = models.Disk
widgets = {
Expand All @@ -1104,6 +1111,11 @@ def __init__(self, *args, **kwargs):
'dijitDisabled dijitTextBoxDisabled '
'dijitValidationTextBoxDisabled')

self.fields['disk_reset_password'].widget.attrs['onChange'] = (
'toggleGeneric("id_disk_reset_password", ["id_disk_passwd",'
' "id_disk_passwd2"], false);'
)

def clean_disk_name(self):
return self.instance.disk_name

Expand All @@ -1115,10 +1127,13 @@ def clean_disk_passwd2(self):
return password2

def clean(self):
cdata = self.cleaned_data
if not cdata.get("disk_passwd"):
cdata['disk_passwd'] = self.instance.disk_passwd
return cdata
cdata = self.cleaned_data
reset_password = cdata.get('disk_reset_password', False)
if reset_password:
cdata['disk_passwd'] = ''
elif not cdata.get("disk_passwd"):
cdata['disk_passwd'] = self.instance.disk_passwd
return cdata

def save(self, *args, **kwargs):
obj = super(DiskFormPartial, self).save(*args, **kwargs)
Expand Down
27 changes: 22 additions & 5 deletions gui/system/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,14 @@ def save(self):


class AdvancedForm(ModelForm):

adv_reset_sed_password = forms.BooleanField(
label='Reset SED Password',
required=False,
initial=False,
help_text=_('Click this box to reset global SED password'),
)

class Meta:
fields = '__all__'
model = models.Advanced
Expand Down Expand Up @@ -1212,11 +1220,20 @@ def __init__(self, *args, **kwargs):
self.instance._original_adv_graphite = self.instance.adv_graphite
self.instance._original_adv_fqdn_syslog = self.instance.adv_fqdn_syslog

def clean_adv_sed_passwd(self):
passwd = self.cleaned_data.get('adv_sed_passwd')
if not passwd:
return self.instance.adv_sed_passwd
return passwd
self.fields['adv_reset_sed_password'].widget.attrs['onChange'] = (
'toggleGeneric("id_adv_reset_sed_password", ["id_adv_sed_passwd"], false);'
)

def clean(self):
cdata = self.cleaned_data
reset_password = cdata.get('adv_reset_sed_password', False)
passwd = cdata.get('adv_sed_passwd')
if reset_password:
cdata['adv_sed_passwd'] = ''
elif not passwd:
cdata['adv_sed_passwd'] = self.instance.adv_sed_passwd

return cdata

def save(self):
super(AdvancedForm, self).save()
Expand Down

0 comments on commit 7fa193c

Please sign in to comment.