def do_reload(signum=None, frame=None): qs = GlobalConfiguration.objects.order_by('-id') if not qs.exists(): gc = GlobalConfiguration.objects.create() else: gc = qs[0] configure_http_proxy(gc.gc_httpproxy)
def save(self): # TODO: new IP address should be added in a side-by-side manner # or the interface wouldn't appear once IP was changed. retval = super(GlobalConfigurationForm, self).save() whattoreload = ["hostname"] if (self.instance._orig_gc_domain != self.cleaned_data.get('gc_domain') or self.instance._orig_gc_nameserver1 != self.cleaned_data.get('gc_nameserver1') or self.instance._orig_gc_nameserver2 != self.cleaned_data.get('gc_nameserver2') or self.instance._orig_gc_nameserver3 != self.cleaned_data.get('gc_nameserver3')): # Note notifier's _reload_resolvconf has reloading hostname folded in it whattoreload.append("resolvconf") if (self.instance._orig_gc_ipv4gateway != self.cleaned_data.get('gc_ipv4gateway') or self.instance._orig_gc_ipv6gateway != self.cleaned_data.get('gc_ipv6gateway')): # this supersedes all since it has hostname and resolvconf reloads folded in it whattoreload.append("networkgeneral") with client as c: c.call('routes.sync') if hasattr(notifier, 'failover_licensed') and notifier().failover_licensed() and \ self.instance._orig_gc_hostname_virtual != self.cleaned_data.get('gc_hostname_virtual'): from freenasUI.services.models import services, NFS svcobj = services.objects.get(srv_service='nfs') nfsobj = NFS.objects.all()[0] if (svcobj and svcobj.srv_enable) and ( nfsobj and (nfsobj.nfs_srv_v4 and nfsobj.nfs_srv_v4_krb)): notifier().restart("ix-nfsd") whattoreload.append("mountd") for what in whattoreload: notifier().reload(what) http_proxy = self.cleaned_data.get('gc_httpproxy') configure_http_proxy(http_proxy) if self.instance._orig_gc_httpproxy != http_proxy: # Notify the middleware http_proxy has changed with client as c: c.call('core.event_send', 'network.config', 'CHANGED', {'data': { 'httpproxy': http_proxy }}) try: alertd_pidfile = '/var/run/alertd.pid' if os.path.exists(alertd_pidfile): with open(alertd_pidfile, 'r') as f: pid = int(f.read()) os.kill(pid, signal.SIGHUP) except (FileNotFoundError, OSError, ValueError): log.warn('Failed to kick alertd', exc_info=True) return retval
def save(self): # TODO: new IP address should be added in a side-by-side manner # or the interface wouldn't appear once IP was changed. retval = super(GlobalConfigurationForm, self).save() whattoreload = "hostname" if (self.instance._orig_gc_domain != self.cleaned_data.get('gc_domain') or self.instance._orig_gc_nameserver1 != self.cleaned_data.get('gc_nameserver1') or self.instance._orig_gc_nameserver2 != self.cleaned_data.get('gc_nameserver2') or self.instance._orig_gc_nameserver3 != self.cleaned_data.get('gc_nameserver3')): # Note notifier's _reload_resolvconf has reloading hostname folded in it whattoreload = "resolvconf" if (self.instance._orig_gc_ipv4gateway != self.cleaned_data.get('gc_ipv4gateway') or self.instance._orig_gc_ipv6gateway != self.cleaned_data.get('gc_ipv6gateway')): # this supersedes all since it has hostname and resolvconf reloads folded in it whattoreload = "networkgeneral" with client as c: c.call('routes.sync') notifier().reload(whattoreload) http_proxy = self.cleaned_data.get('gc_httpproxy') configure_http_proxy(http_proxy) if self.instance._orig_gc_httpproxy != http_proxy: # Notify the middleware http_proxy has changed with client as c: c.call('core.event_send', 'network.config', 'CHANGED', {'data': { 'httpproxy': http_proxy }}) try: alertd_pidfile = '/var/run/alertd.pid' if os.path.exists(alertd_pidfile): with open(alertd_pidfile, 'r') as f: pid = int(f.read()) os.kill(pid, signal.SIGHUP) except (FileNotFoundError, OSError, ValueError): log.warn('Failed to kick alertd', exc_info=True) return retval
def save(self): # TODO: new IP address should be added in a side-by-side manner # or the interface wouldn't appear once IP was changed. retval = super(GlobalConfigurationForm, self).save() whattoreload = "hostname" if ( self.instance._orig_gc_domain != self.cleaned_data.get('gc_domain') or self.instance._orig_gc_nameserver1 != self.cleaned_data.get('gc_nameserver1') or self.instance._orig_gc_nameserver2 != self.cleaned_data.get('gc_nameserver2') or self.instance._orig_gc_nameserver3 != self.cleaned_data.get('gc_nameserver3') ): # Note notifier's _reload_resolvconf has reloading hostname folded in it whattoreload = "resolvconf" if ( self.instance._orig_gc_ipv4gateway != self.cleaned_data.get('gc_ipv4gateway') or self.instance._orig_gc_ipv6gateway != self.cleaned_data.get('gc_ipv6gateway') ): # this supersedes all since it has hostname and resolvconf reloads folded in it whattoreload = "networkgeneral" with client as c: c.call('routes.sync') notifier().reload(whattoreload) http_proxy = self.cleaned_data.get('gc_httpproxy') configure_http_proxy(http_proxy) if self.instance._orig_gc_httpproxy != http_proxy: # Notify the middleware http_proxy has changed with client as c: c.call('core.event_send', 'network.config', 'CHANGED', {'data': {'httpproxy': http_proxy}}) try: alertd_pidfile = '/var/run/alertd.pid' if os.path.exists(alertd_pidfile): with open(alertd_pidfile, 'r') as f: pid = int(f.read()) os.kill(pid, signal.SIGHUP) except (FileNotFoundError, OSError, ValueError): log.warn('Failed to kick alertd', exc_info=True) return retval
def done(self, request, events): http_proxy = self.cleaned_data.get('gc_httpproxy') configure_http_proxy(http_proxy)