def core(request): try: domaincontroller = models.DomainController.objects.order_by("-id")[0] except IndexError: domaincontroller = models.DomainController.objects.create() domaincontroller.onclick_enable = 'enable' ds_status = get_directoryservice_status() for key in ds_status: if ds_status[key] == True and key != 'dc_enable': domaincontroller.onclick_enable = 'disable' break try: afp = models.AFP.objects.order_by("-id")[0] except IndexError: afp = models.AFP.objects.create() try: cifs = models.CIFS.objects.order_by("-id")[0] except IndexError: cifs = models.CIFS.objects.create() try: dynamicdns = models.DynamicDNS.objects.order_by("-id")[0] except IndexError: dynamicdns = models.DynamicDNS.objects.create() try: lldp = models.LLDP.objects.order_by("-id")[0] except IndexError: lldp = models.LLDP.objects.create() try: nfs = models.NFS.objects.order_by("-id")[0] except IndexError: nfs = models.NFS.objects.create() try: ftp = models.FTP.objects.order_by("-id")[0] except IndexError: ftp = models.FTP.objects.create() try: tftp = models.TFTP.objects.order_by("-id")[0] except IndexError: tftp = models.TFTP.objects.create() try: rsyncd = models.Rsyncd.objects.order_by("-id")[0] except IndexError: rsyncd = models.Rsyncd.objects.create() try: smart = models.SMART.objects.order_by("-id")[0] except IndexError: smart = models.SMART.objects.create() try: snmp = models.SNMP.objects.order_by("-id")[0] except IndexError: snmp = models.SNMP.objects.create() try: ssh = models.SSH.objects.order_by("-id")[0] except IndexError: ssh = models.SSH.objects.create() try: ups = models.UPS.objects.order_by("-id")[0] except IndexError: ups = models.UPS.objects.create() try: webdav = models.WebDAV.objects.order_by("-id")[0] except IndexError: webdav = models.WebDAV.objects.create() srv = models.services.objects.all() return render(request, 'services/core.html', { 'srv': srv, 'cifs': cifs, 'afp': afp, 'lldp': lldp, 'nfs': nfs, 'rsyncd': rsyncd, 'dynamicdns': dynamicdns, 'snmp': snmp, 'ups': ups, 'ftp': ftp, 'tftp': tftp, 'smart': smart, 'ssh': ssh, 'domaincontroller': domaincontroller, 'webdav': webdav })
def core(request): disabled = {} for key, val in get_directoryservice_status().items(): if val is True and key != 'dc_enable': disabled['domaincontroller'] = { 'reason': _('A directory service is already enabled.'), } break try: afp = models.AFP.objects.order_by("-id")[0] except IndexError: afp = models.AFP.objects.create() try: cifs = models.CIFS.objects.order_by("-id")[0] except IndexError: cifs = models.CIFS.objects.create() try: domaincontroller = models.DomainController.objects.order_by("-id")[0] except IndexError: domaincontroller = models.DomainController.objects.create() try: dynamicdns = models.DynamicDNS.objects.order_by("-id")[0] except IndexError: dynamicdns = models.DynamicDNS.objects.create() try: lldp = models.LLDP.objects.order_by("-id")[0] except IndexError: lldp = models.LLDP.objects.create() try: nfs = models.NFS.objects.order_by("-id")[0] except IndexError: nfs = models.NFS.objects.create() try: ftp = models.FTP.objects.order_by("-id")[0] except IndexError: ftp = models.FTP.objects.create() try: tftp = models.TFTP.objects.order_by("-id")[0] except IndexError: tftp = models.TFTP.objects.create() try: rsyncd = models.Rsyncd.objects.order_by("-id")[0] except IndexError: rsyncd = models.Rsyncd.objects.create() try: s3 = models.S3.objects.order_by("-id")[0] except IndexError: s3 = models.S3.objects.create() try: smart = models.SMART.objects.order_by("-id")[0] except IndexError: smart = models.SMART.objects.create() try: snmp = models.SNMP.objects.order_by("-id")[0] except IndexError: snmp = models.SNMP.objects.create() try: ssh = models.SSH.objects.order_by("-id")[0] except IndexError: ssh = models.SSH.objects.create() try: ups = models.UPS.objects.order_by("-id")[0] except IndexError: ups = models.UPS.objects.create() try: webdav = models.WebDAV.objects.order_by("-id")[0] except IndexError: webdav = models.WebDAV.objects.create() return render( request, 'services/core.html', { 'urls': json.dumps({ 'cifs': reverse('services_cifs'), 'afp': afp.get_edit_url(), 'lldp': lldp.get_edit_url(), 'nfs': nfs.get_edit_url(), 'rsync': rsyncd.get_edit_url(), 'dynamicdns': dynamicdns.get_edit_url(), 's3': reverse('services_s3'), 'snmp': snmp.get_edit_url(), 'ups': ups.get_edit_url(), 'ftp': ftp.get_edit_url(), 'tftp': tftp.get_edit_url(), 'ssh': ssh.get_edit_url(), 'smartd': smart.get_edit_url(), 'webdav': webdav.get_edit_url(), 'domaincontroller': domaincontroller.get_edit_url(), 'netdata': reverse('services_netdata'), }), 'disabled': json.dumps(disabled), })
def core(request): disabled = {} for key, val in get_directoryservice_status().items(): if val is True and key != 'dc_enable': disabled['domaincontroller'] = { 'reason': _('A directory service is already enabled.'), } break try: afp = models.AFP.objects.order_by("-id")[0] except IndexError: afp = models.AFP.objects.create() try: cifs = models.CIFS.objects.order_by("-id")[0] except IndexError: cifs = models.CIFS.objects.create() try: domaincontroller = models.DomainController.objects.order_by("-id")[0] except IndexError: domaincontroller = models.DomainController.objects.create() try: dynamicdns = models.DynamicDNS.objects.order_by("-id")[0] except IndexError: dynamicdns = models.DynamicDNS.objects.create() try: lldp = models.LLDP.objects.order_by("-id")[0] except IndexError: lldp = models.LLDP.objects.create() try: nfs = models.NFS.objects.order_by("-id")[0] except IndexError: nfs = models.NFS.objects.create() try: ftp = models.FTP.objects.order_by("-id")[0] except IndexError: ftp = models.FTP.objects.create() try: tftp = models.TFTP.objects.order_by("-id")[0] except IndexError: tftp = models.TFTP.objects.create() try: rsyncd = models.Rsyncd.objects.order_by("-id")[0] except IndexError: rsyncd = models.Rsyncd.objects.create() try: s3 = models.S3.objects.order_by("-id")[0] except IndexError: s3 = models.S3.objects.create() try: smart = models.SMART.objects.order_by("-id")[0] except IndexError: smart = models.SMART.objects.create() try: snmp = models.SNMP.objects.order_by("-id")[0] except IndexError: snmp = models.SNMP.objects.create() try: ssh = models.SSH.objects.order_by("-id")[0] except IndexError: ssh = models.SSH.objects.create() try: ups = models.UPS.objects.order_by("-id")[0] except IndexError: ups = models.UPS.objects.create() try: webdav = models.WebDAV.objects.order_by("-id")[0] except IndexError: webdav = models.WebDAV.objects.create() return render(request, 'services/core.html', { 'urls': json.dumps({ 'cifs': reverse('services_cifs'), 'afp': afp.get_edit_url(), 'lldp': lldp.get_edit_url(), 'nfs': nfs.get_edit_url(), 'rsync': rsyncd.get_edit_url(), 'dynamicdns': dynamicdns.get_edit_url(), 's3': reverse('services_s3'), 'snmp': snmp.get_edit_url(), 'ups': ups.get_edit_url(), 'ftp': ftp.get_edit_url(), 'tftp': tftp.get_edit_url(), 'ssh': ssh.get_edit_url(), 'smartd': smart.get_edit_url(), 'webdav': webdav.get_edit_url(), 'domaincontroller': domaincontroller.get_edit_url(), 'netdata': reverse('services_netdata'), }), 'disabled': json.dumps(disabled), })
def core(request): try: domaincontroller = models.DomainController.objects.order_by("-id")[0] except IndexError: domaincontroller = models.DomainController.objects.create() domaincontroller.onclick_enable = "enable" ds_status = get_directoryservice_status() for key in ds_status: if ds_status[key] is True and key != "dc_enable": domaincontroller.onclick_enable = "disable" break try: afp = models.AFP.objects.order_by("-id")[0] except IndexError: afp = models.AFP.objects.create() try: cifs = models.CIFS.objects.order_by("-id")[0] except IndexError: cifs = models.CIFS.objects.create() try: dynamicdns = models.DynamicDNS.objects.order_by("-id")[0] except IndexError: dynamicdns = models.DynamicDNS.objects.create() try: lldp = models.LLDP.objects.order_by("-id")[0] except IndexError: lldp = models.LLDP.objects.create() try: nfs = models.NFS.objects.order_by("-id")[0] except IndexError: nfs = models.NFS.objects.create() try: ftp = models.FTP.objects.order_by("-id")[0] except IndexError: ftp = models.FTP.objects.create() try: tftp = models.TFTP.objects.order_by("-id")[0] except IndexError: tftp = models.TFTP.objects.create() try: rsyncd = models.Rsyncd.objects.order_by("-id")[0] except IndexError: rsyncd = models.Rsyncd.objects.create() try: smart = models.SMART.objects.order_by("-id")[0] except IndexError: smart = models.SMART.objects.create() try: snmp = models.SNMP.objects.order_by("-id")[0] except IndexError: snmp = models.SNMP.objects.create() try: ssh = models.SSH.objects.order_by("-id")[0] except IndexError: ssh = models.SSH.objects.create() try: ups = models.UPS.objects.order_by("-id")[0] except IndexError: ups = models.UPS.objects.create() try: webdav = models.WebDAV.objects.order_by("-id")[0] except IndexError: webdav = models.WebDAV.objects.create() srv = models.services.objects.all() return render( request, "services/core.html", { "srv": srv, "cifs": cifs, "afp": afp, "lldp": lldp, "nfs": nfs, "rsyncd": rsyncd, "dynamicdns": dynamicdns, "snmp": snmp, "ups": ups, "ftp": ftp, "tftp": tftp, "smart": smart, "ssh": ssh, "domaincontroller": domaincontroller, "webdav": webdav, }, )