auth_command.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
  2. #
  3. # Permission to use, copy, modify, and distribute this software for any
  4. # purpose with or without fee is hereby granted, provided that the above
  5. # copyright notice and this permission notice appear in all copies.
  6. #
  7. # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
  8. # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  9. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  10. # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  12. # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  13. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  14. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. '''This module is a utility to create some intermodule command(s) for Auth.'''
  16. from isc.dns import *
  17. import isc.log
  18. from isc.config.ccsession import create_command
  19. from isc.log_messages.server_common_messages import *
  20. from isc.server_common.logger import logger
  21. AUTH_MODULE_NAME = 'Auth'
  22. AUTH_LOADZONE_COMMAND = 'loadzone'
  23. def auth_loadzone_params(zone_name, zone_class):
  24. return {
  25. "origin": zone_name.to_text(),
  26. "class": zone_class.to_text()
  27. }
  28. def auth_loadzone_command(module_cc, zone_name, zone_class):
  29. '''Create a 'loadzone' command with a given zone for Auth server.
  30. This function generates an inter-module command for Auth
  31. to force it to reload the zone.
  32. Parameters:
  33. module_cc (CCSession): a CC session that can get access to auth module
  34. configuration as a remote configuration
  35. zone_name (isc.dns.Name): the zone name to be possibly reloaded
  36. zone_class (isc.dns.RRClass): the RR class of the zone to be possibly
  37. reloaded.
  38. Return: a CC command message for the reload.
  39. '''
  40. # Note: this function was originally a dedicated subroutine of xfrin,
  41. # but was moved here so it can be shared by some other modules
  42. # (specifically, by ddns). It's expected that we'll soon fundamentally
  43. # revisit the whole data source related configuration, at which point
  44. # this function should be substantially modified if not completely
  45. # deprecated (which is a more likely scenario). For this reason, the
  46. # corresponding tests were still kept in xfrin.
  47. # Note: The function got very simplified by #1976. There's plan to move
  48. # to notification-driven approach, at which point the function would
  49. # be changed a lot.
  50. return create_command(AUTH_LOADZONE_COMMAND,
  51. auth_loadzone_params(zone_name, zone_class))