OpenStack DNS As A Service (Designate)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

backend-dynect 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. # Configure the dynect backend
  2. # Requirements:
  3. # An active DynECT account / contract will be requied to use this DevStack
  4. # plugin.
  5. # Enable with:
  6. # DESIGNATE_BACKEND_DRIVER=dynect
  7. # Dependencies:
  8. # ``functions`` file
  9. # ``designate`` configuration
  10. # install_designate_backend - install any external requirements
  11. # configure_designate_backend - make configuration changes, including those to other services
  12. # init_designate_backend - initialize databases, etc.
  13. # start_designate_backend - start any external services
  14. # stop_designate_backend - stop any external services
  15. # cleanup_designate_backend - remove transient data and cache
  16. # Save trace setting
  17. DP_DYNECT_XTRACE=$(set +o | grep xtrace)
  18. set +o xtrace
  19. # Defaults
  20. # --------
  21. DESIGNATE_DYNECT_CUSTOMER=${DESIGNATE_DYNECT_CUSTOMER:-customer}
  22. DESIGNATE_DYNECT_USERNAME=${DESIGNATE_DYNECT_USERNAME:-username}
  23. DESIGNATE_DYNECT_PASSWORD=${DESIGNATE_DYNECT_PASSWORD:-password}
  24. DESIGNATE_DYNECT_CONTACT_NICKNAME=${DESIGNATE_DYNECT_CONTACT_NICKNAME:-}
  25. DESIGNATE_DYNECT_JOB_TIMEOUT=${DESIGNATE_DYNECT_JOB_TIMEOUT:-}
  26. DESIGNATE_DYNECT_TIMEOUT=${DESIGNATE_DYNECT_TIMEOUT:-}
  27. DESIGNATE_DYNECT_MASTERS=${DESIGNATE_DYNECT_MASTERS:-"$DESIGNATE_SERVICE_HOST:$DESIGNATE_SERVICE_PORT_MDNS"}
  28. DESIGNATE_DYNECT_NAMESERVERS=${DESIGNATE_DYNECT_NAMESERVERS:-""}
  29. DESIGNATE_DYNECT_ALSO_NOTIFIES=${DESIGNATE_DYNECT_ALSO_NOTIFIES:-"204.13.249.65,208.78.68.65"}
  30. # Pull in DESIGNATE_3RDPARTY_CREDS user/pass if set
  31. if [ -n "$DESIGNATE_3RDPARTY_CREDS" ]; then
  32. DESIGNATE_DYNECT_CUSTOMER=`echo $DESIGNATE_3RDPARTY_CREDS | cut -f1 -d:`
  33. DESIGNATE_DYNECT_USERNAME=`echo $DESIGNATE_3RDPARTY_CREDS | cut -f2 -d:`
  34. DESIGNATE_DYNECT_PASSWORD=`echo $DESIGNATE_3RDPARTY_CREDS | cut -f3- -d:`
  35. fi
  36. # Sanity Checks
  37. # -------------
  38. if [ -z "$DESIGNATE_DYNECT_NAMESERVERS" ]; then
  39. die $LINENO "You must configure DESIGNATE_DYNECT_NAMESERVERS"
  40. fi
  41. if [ "$DESIGNATE_SERVICE_PORT_MDNS" != "53" ]; then
  42. die $LINENO "DynECT requires DESIGNATE_SERVICE_PORT_MDNS is set to '53'"
  43. fi
  44. # Entry Points
  45. # ------------
  46. # install_designate_backend - install any external requirements
  47. function install_designate_backend {
  48. :
  49. }
  50. # configure_designate_backend - make configuration changes, including those to other services
  51. function configure_designate_backend {
  52. # Generate Designate pool.yaml file
  53. sudo tee $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
  54. ---
  55. - name: default
  56. description: DevStack DynECT Pool
  57. attributes: {}
  58. targets:
  59. - type: dynect
  60. description: DynECT API
  61. options:
  62. customer_name: $DESIGNATE_DYNECT_CUSTOMER
  63. username: $DESIGNATE_DYNECT_USERNAME
  64. password: $DESIGNATE_DYNECT_PASSWORD
  65. masters:
  66. EOF
  67. # Create a Pool Master for each of the DynECT Masters
  68. IFS=',' read -a masters <<< "$DESIGNATE_DYNECT_MASTERS"
  69. for master in "${masters[@]}"; do
  70. sudo tee -a $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
  71. - host: $master
  72. port: 53
  73. EOF
  74. done
  75. # Create a Pool NS Record for each of the DynECT Nameservers
  76. IFS=',' read -a nameservers <<< "$DESIGNATE_DYNECT_NAMESERVERS"
  77. sudo tee -a $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
  78. ns_records:
  79. EOF
  80. for nameserver in "${nameservers[@]}"; do
  81. sudo tee -a $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
  82. - hostname: $nameserver
  83. priority: 1
  84. EOF
  85. done
  86. # Create a Pool Nameserver for each of the DynECT Nameservers
  87. sudo tee -a $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
  88. nameservers:
  89. EOF
  90. for nameserver in "${nameservers[@]}"; do
  91. sudo tee -a $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
  92. - host: `dig +short A $nameserver | head -n 1`
  93. port: 53
  94. EOF
  95. done
  96. # Create a Pool Also Notifies for each of the DynECT Also Notifies
  97. IFS=',' read -a also_notifies <<< "$DESIGNATE_DYNECT_ALSO_NOTIFIES"
  98. sudo tee -a $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
  99. also_notifies:
  100. EOF
  101. for also_notify in "${also_notifies[@]}"; do
  102. sudo tee -a $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
  103. - host: $also_notify
  104. port: 53
  105. EOF
  106. done
  107. }
  108. # init_designate_backend - initialize databases, etc.
  109. function init_designate_backend {
  110. :
  111. }
  112. # start_designate_backend - start any external services
  113. function start_designate_backend {
  114. :
  115. }
  116. # stop_designate_backend - stop any external services
  117. function stop_designate_backend {
  118. :
  119. }
  120. # cleanup_designate_backend - remove transient data and cache
  121. function cleanup_designate_backend {
  122. :
  123. }
  124. # Restore xtrace
  125. $DP_DYNECT_XTRACE