def set_dhcp(request, mac_address): try: hostname = hostname_from_principal(request.user.username) except ValueError: return HttpResponse(status=401, content='Unable to register IP and MAC addresses: invalid username') remote_addr = request.META.get('HTTP_X_FORWARDED_FOR', '') admin_mac_address = request.GET.get('mac_address') admin_ip_address = request.GET.get('ip_address') Host.register_mac_address(hostname, remote_addr, mac_address, admin_ip_address, admin_mac_address) return HttpResponse(status=201)
def set_dhcp(request, mac_address): try: hostname = hostname_from_principal(request.user.username) except ValueError: return HttpResponse( status=401, content='Unable to register IP and MAC addresses: invalid username' ) remote_addr = request.META.get('HTTP_X_FORWARDED_FOR', '') admin_mac_address = request.GET.get('mac_address') admin_ip_address = request.GET.get('ip_address') Host.register_mac_address(hostname, remote_addr, mac_address, admin_ip_address, admin_mac_address) return HttpResponse(status=201)
def handle(self, *args, **options): fqdn = options['fqdn'] short_hostname = fqdn.partition('.')[0] fqdn = '%s.%s%s' % (short_hostname, settings.PDNS_INFRA_PREFIX, settings.PENATES_DOMAIN) is_new_host = Host.objects.filter(fqdn=fqdn).count() == 0 keys = { 'owner', 'main_ip_address', 'main_mac_address', 'admin_ip_address', 'admin_mac_address', 'serial', 'model_name', 'location', 'os_name', 'bootp_filename', 'proc_model', 'proc_count', 'core_count', 'memory_size', 'disk_size', } values = {key: options[key] for key in keys if options[key]} Host.register_host(short_hostname, main_ip_address=options['main_ip_address'], admin_ip_address=options['admin_ip_address']) Host.register_mac_address(fqdn, options['main_ip_address'], options['main_mac_address'], options['admin_ip_address'], options['admin_mac_address']) Host.objects.filter(fqdn=fqdn).update(**values) == 0 if is_new_host: self.stdout.write(self.style.WARNING('Host %s created') % fqdn) else: self.stdout.write(self.style.WARNING('Host %s updated') % fqdn) host = Host.objects.get(fqdn=fqdn) keytab = options['keytab'] if keytab: call_command('keytab', host.principal, keytab=keytab)
def handle(self, *args, **options): fqdn = options['fqdn'] short_hostname = fqdn.partition('.')[0] fqdn = '%s.%s%s' % (short_hostname, settings.PDNS_INFRA_PREFIX, settings.PENATES_DOMAIN) is_new_host = Host.objects.filter(fqdn=fqdn).count() == 0 keys = {'owner', 'main_ip_address', 'main_mac_address', 'admin_ip_address', 'admin_mac_address', 'serial', 'model_name', 'location', 'os_name', 'bootp_filename', 'proc_model', 'proc_count', 'core_count', 'memory_size', 'disk_size', } values = {key: options[key] for key in keys if options[key]} Host.register_host(short_hostname, main_ip_address=options['main_ip_address'], admin_ip_address=options['admin_ip_address']) Host.register_mac_address(fqdn, options['main_ip_address'], options['main_mac_address'], options['admin_ip_address'], options['admin_mac_address']) Host.objects.filter(fqdn=fqdn).update(**values) == 0 if is_new_host: self.stdout.write(self.style.WARNING('Host %s created') % fqdn) else: self.stdout.write(self.style.WARNING('Host %s updated') % fqdn) host = Host.objects.get(fqdn=fqdn) keytab = options['keytab'] if keytab: call_command('keytab', host.principal, keytab=keytab)