Skip to content

Commit

Permalink
Initial NIS middleware plugin (#2772)
Browse files Browse the repository at this point in the history
* Initial NIS middleware plugin
  • Loading branch information
anodos325 committed Mar 20, 2019
1 parent 1aef779 commit bd8f7c3
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 226 deletions.
43 changes: 11 additions & 32 deletions gui/directoryservice/forms.py
Expand Up @@ -51,6 +51,7 @@
from freenasUI.directoryservice import models, utils
from freenasUI.middleware.client import client
from freenasUI.middleware.exceptions import MiddlewareError
from freenasUI.middleware.form import MiddlewareModelForm
from freenasUI.middleware.notifier import notifier
from freenasUI.services.models import CIFS, ServiceMonitor

Expand Down Expand Up @@ -712,7 +713,13 @@ def save(self):
return obj


class NISForm(ModelForm):
class NISForm(MiddlewareModelForm, ModelForm):

middleware_attr_prefix = 'nis_'
middleware_attr_schema = 'nis'
middleware_plugin = 'nis'
is_singletone = True

class Meta:
fields = '__all__'
model = models.NIS
Expand All @@ -723,37 +730,9 @@ def __init__(self, *args, **kwargs):
"nis_mutex_toggle();"
)

def save(self):
enable = self.cleaned_data.get("nis_enable")

# XXX: We need to have a method to test server connection.
try:
started = notifier().started("nis")
except Exception:
raise MiddlewareError(_("Failed to check NIS status."))
finally:
super(NISForm, self).save()

if enable:
if started is True:
try:
started = notifier().restart("nis")
log.debug("Try to restart: %s", started)
except Exception:
raise MiddlewareError(_("NIS failed to restart."))
if started is False:
try:
started = notifier().start("nis")
log.debug("Try to start: %s", started)
except Exception:
raise MiddlewareError(_("NIS failed to start."))
if started is False:
self.instance.ad_enable = False
super(NISForm, self).save()
raise MiddlewareError(_("NIS failed to reload."))
else:
if started is True:
started = notifier().stop("nis")
def middleware_clean(self, data):
data['servers'] = data['servers'].split(',')
return data


class LDAPForm(ModelForm):
Expand Down
97 changes: 0 additions & 97 deletions src/freenas/etc/directoryservice/NIS/ctl

This file was deleted.

76 changes: 0 additions & 76 deletions src/freenas/etc/directoryservice/rc.NIS

This file was deleted.

0 comments on commit bd8f7c3

Please sign in to comment.