Exemplo n.º 1
0
    def set_serial(self, request):
        """@description-title Set the SOA serial number
        @description Set the SOA serial number for all DNS zones.

        @param (int) "serial" [required=true] Serial number to use next.

        @success (http-status-code) "server-success" 200
        @success (content) "success-text" No content returned.
        """
        try:
            serial = int(request.data["serial"])
        except KeyError:
            raise MAASAPIValidationError({"serial": "Missing parameter"})
        except ValueError:
            raise MAASAPIValidationError(
                {"serial": "Expected a serial number"}
            )
        if serial == 0 or serial > INT_MAX:
            raise MAASAPIValidationError(
                {
                    "serial": "Expected a serial number between 1 and %d"
                    % INT_MAX
                }
            )
        zone_serial.set_value(serial)
        dns_force_reload()
Exemplo n.º 2
0
 def test_dns_force_reload_saves_new_publication(self):
     # A 'sys_dns' signal is also sent, but that is a side-effect of
     # inserting into the DNS publications table, and is tested as part of
     # the system triggers code.
     self.assertThat(
         DNSPublication.objects.get_most_recent(),
         MatchesStructure.byEquality(source="Initial publication"))
     dns_force_reload()
     self.assertThat(DNSPublication.objects.get_most_recent(),
                     MatchesStructure.byEquality(source="Force reload"))
Exemplo n.º 3
0
    def set_serial(self, request):
        """Set the SOA serial number (for all DNS zones.)

        :param serial: serial number to use next.
        """
        try:
            serial = int(request.data['serial'])
        except KeyError:
            raise MAASAPIValidationError({'serial': 'Missing parameter'})
        except ValueError:
            raise MAASAPIValidationError(
                {'serial': 'Expected a serial number'})
        if serial == 0 or serial > INT_MAX:
            raise MAASAPIValidationError({
                'serial':
                'Expected a serial number between 1 and %d' % INT_MAX
            })
        zone_serial.set_value(serial)
        dns_force_reload()