Пример #1
0
    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:
            raise ServiceFailed("nis", _("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:
                    raise ServiceFailed("nis", _("NIS failed to restart."))
            if started is False:
                try:
                    started = notifier().start("nis")
                    log.debug("Try to start: %s", started)
                except:
                    raise ServiceFailed("nis", _("NIS failed to start."))
            if started is False:
                self.instance.ad_enable = False
                super(NISForm, self).save()
                raise ServiceFailed("nis", _("NIS failed to reload."))
        else:
            if started is True:
                started = notifier().stop("nis")
Пример #2
0
    def save(self):
        enable = self.cleaned_data.get("ldap_enable")

        started = notifier().started("ldap")
        obj = super(LDAPForm, self).save()
        self.cifs.cifs_srv_netbiosname = self.cleaned_data.get(
            "ldap_netbiosname_a")
        self.cifs.cifs_srv_netbiosname_b = self.cleaned_data.get(
            "ldap_netbiosname_b")
        self.cifs.cifs_srv_netbiosalias = self.cleaned_data.get(
            "ldap_netbiosalias")
        self.cifs.save()

        if enable:
            if started is True:
                started = notifier().restart("ldap", timeout=90)
            if started is False:
                started = notifier().start("ldap", timeout=90)
            if started is False:
                self.instance.ldap_enable = False
                super(LDAPForm, self).save()
                raise ServiceFailed("ldap", _("LDAP failed to reload."))
        else:
            if started is True:
                started = notifier().stop("ldap")

        return obj
Пример #3
0
    def save(self):
        enable = self.cleaned_data.get("ad_enable")
        if self.__original_changed():
            notifier()._clear_activedirectory_config()

        started = notifier().started("activedirectory")
        obj = super(ActiveDirectoryForm, self).save()
        self.cifs.cifs_srv_netbiosname = self.cleaned_data.get(
            "ad_netbiosname_a")
        self.cifs.cifs_srv_netbiosname_b = self.cleaned_data.get(
            "ad_netbiosname_b")
        self.cifs.cifs_srv_netbiosalias = self.cleaned_data.get(
            "ad_netbiosalias")
        self.cifs.save()

        if enable:
            if started is True:
                started = notifier().restart("activedirectory")
            if started is False:
                started = notifier().start("activedirectory")
            if started is False:
                self.instance.ad_enable = False
                super(ActiveDirectoryForm, self).save()
                raise ServiceFailed(
                    "activedirectory",
                    _("Active Directory failed to reload."),
                )
        else:
            if started is True:
                started = notifier().stop("activedirectory")
        return obj
Пример #4
0
    def __save(self, *args, **kwargs):
        data = self.middleware_prepare()

        if self.instance.id:
            self._middleware_action = "update"

            if self.is_singletone:
                args = (data, ) + args
            else:
                args = (self.instance.id, data) + args
        else:
            self._middleware_action = "create"

            args = (data, ) + args

        if self.middleware_job and self.middleware_job_wait:
            kwargs['job'] = True

        with client as c:
            try:
                return c.call(
                    f"{self.middleware_plugin}.{self._middleware_action}",
                    *args, **kwargs)
            except ClientException as e:
                if e.errno == ClientException.ESERVICESTARTFAILURE:
                    raise ServiceFailed(e.extra[0], e.error)
                else:
                    raise
Пример #5
0
 def save(self):
     super(iSCSITargetToExtentForm, self).save()
     started = notifier().reload("iscsitarget")
     if started is False and models.services.objects.get(
             srv_service='iscsitarget').srv_enable:
         raise ServiceFailed("iscsitarget",
                             _("The iSCSI service failed to reload."))
Пример #6
0
    def save(self):
        enable = self.cleaned_data.get("nt4_enable")
        started = notifier().started("nt4")
        if enable:
            if started is True:
                started = notifier().restart("nt4")
            if started is False:
                started = notifier().start("nt4")
            if started is False:
                self.instance.ad_enable = False
                super(NT4Form, self).save()
                raise ServiceFailed("nt4", _("NT4 failed to reload."))
        else:
            if started == True:
                started = notifier().stop("nt4")

        super(NT4Form, self).save()
Пример #7
0
    def save(self):
        enable = self.cleaned_data.get("ldap_enable")

        started = notifier().started("ldap")
        obj = super(LDAPForm, self).save()

        if enable:
            if started is True:
                started = notifier().restart("ldap")
            if started is False:
                started = notifier().start("ldap")
            if started is False:
                self.instance.ldap_enable = False
                super(LDAPForm, self).save()
                raise ServiceFailed("ldap", _("LDAP failed to reload."))
        else:
            if started is True:
                started = notifier().stop("ldap")

        return obj
Пример #8
0
    def save(self):
        enable = self.cleaned_data.get("ad_enable")
        if self.__original_changed():
            notifier()._clear_activedirectory_config()

        started = notifier().started("activedirectory")
        super(ActiveDirectoryForm, self).save()

        if enable:
            if started is True:
                started = notifier().restart("activedirectory")
            if started is False:
                started = notifier().start("activedirectory")
            if started is False:
                self.instance.ad_enable = False
                super(ActiveDirectoryForm, self).save()
                raise ServiceFailed("activedirectory",
                                    _("Active Directory failed to reload."))
        else:
            if started == True:
                started = notifier().stop("activedirectory")
Пример #9
0
    def save(self):
        enable = self.cleaned_data.get("ad_enable")
        if self.__original_changed():
            notifier()._clear_activedirectory_config()

        started = notifier().started("activedirectory")
        obj = super(ActiveDirectoryForm, self).save()

        try:
            utils.get_idmap_object(obj.ds_type, obj.id, obj.ad_idmap_backend)
        except ObjectDoesNotExist:
            log.debug(
                'IDMAP backend {} entry does not exist, creating one.'.format(
                    obj.ad_idmap_backend))
            utils.get_idmap(obj.ds_type, obj.id, obj.ad_idmap_backend)

        self.cifs.cifs_srv_netbiosname = self.cleaned_data.get(
            "ad_netbiosname_a")
        self.cifs.cifs_srv_netbiosname_b = self.cleaned_data.get(
            "ad_netbiosname_b")
        self.cifs.cifs_srv_netbiosalias = self.cleaned_data.get(
            "ad_netbiosalias")
        self.cifs.save()

        if enable:
            if started is True:
                started = notifier().restart("activedirectory")
            if started is False:
                started = notifier().start("activedirectory")
            if started is False:
                self.instance.ad_enable = False
                super(ActiveDirectoryForm, self).save()
                raise ServiceFailed(
                    "activedirectory",
                    _("Active Directory failed to reload."),
                )
        else:
            if started is True:
                started = notifier().stop("activedirectory")
        return obj
Пример #10
0
    def save(self):
        enable = self.cleaned_data.get("ad_enable")
        enable_monitoring = self.cleaned_data.get("ad_enable_monitor")
        monit_frequency = self.cleaned_data.get("ad_monitor_frequency")
        monit_retry = self.cleaned_data.get("ad_recover_retry")
        fqdn = self.cleaned_data.get("ad_domainname")
        if self.__original_changed():
            notifier().clear_activedirectory_config()

        started = notifier().started("activedirectory")
        obj = super(ActiveDirectoryForm, self).save()

        try:
            utils.get_idmap_object(obj.ds_type, obj.id, obj.ad_idmap_backend)
        except ObjectDoesNotExist:
            log.debug(
                'IDMAP backend {} entry does not exist, creating one.'.format(
                    obj.ad_idmap_backend))
            utils.get_idmap(obj.ds_type, obj.id, obj.ad_idmap_backend)

        self.cifs.cifs_srv_netbiosname = self.cleaned_data.get(
            "ad_netbiosname_a")
        self.cifs.cifs_srv_netbiosname_b = self.cleaned_data.get(
            "ad_netbiosname_b")
        self.cifs.cifs_srv_netbiosalias = self.cleaned_data.get(
            "ad_netbiosalias")
        self.cifs.save()

        if enable:
            if started is True:
                started = notifier().restart("activedirectory", timeout=90)
            if started is False:
                started = notifier().start("activedirectory", timeout=90)
            if started is False:
                self.instance.ad_enable = False
                super(ActiveDirectoryForm, self).save()
                raise ServiceFailed(
                    "activedirectory",
                    _("Active Directory failed to reload."),
                )
        else:
            if started is True:
                started = notifier().stop("activedirectory", timeout=60)

        with client as c:
            if enable_monitoring and enable:
                log.debug(
                    "[ServiceMonitoring] Add %s service, frequency: %d, retry: %d"
                    % ('activedirectory', monit_frequency, monit_retry))
                c.call('service.enable_test_service_connection',
                       monit_frequency, monit_retry, fqdn, 3268,
                       'activedirectory')
            else:
                log.debug(
                    "[ServiceMonitoring] Remove %s service, frequency: %d, retry: %d"
                    % ('activedirectory', monit_frequency, monit_retry))
                c.call('service.disable_test_service_connection',
                       monit_frequency, monit_retry, fqdn, 3268,
                       'activedirectory')

        return obj