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.
 
 
 
 
 
 

406 lines
14 KiB

  1. # Install and start **Designate** service in Devstack
  2. # Save trace setting
  3. XTRACE=$(set +o | grep xtrace)
  4. set +o xtrace
  5. # Get backend configuration
  6. # -------------------------
  7. if is_service_enabled designate && [[ -r $DESIGNATE_PLUGINS/backend-$DESIGNATE_BACKEND_DRIVER ]]; then
  8. # Load plugin
  9. source $DESIGNATE_PLUGINS/backend-$DESIGNATE_BACKEND_DRIVER
  10. fi
  11. # DevStack Plugin
  12. # ---------------
  13. # cleanup_designate - Remove residual data files, anything left over from previous
  14. # runs that a clean run would need to clean up
  15. function cleanup_designate {
  16. sudo rm -rf $DESIGNATE_STATE_PATH
  17. sudo rm -f $(apache_site_config_for designate-api)
  18. remove_uwsgi_config "$DESIGNATE_UWSGI_CONF" "$DESIGNATE_UWSGI"
  19. cleanup_designate_backend
  20. }
  21. # configure_designate - Set config files, create data dirs, etc
  22. function configure_designate {
  23. [ ! -d $DESIGNATE_CONF_DIR ] && sudo mkdir -m 755 -p $DESIGNATE_CONF_DIR
  24. sudo chown $STACK_USER $DESIGNATE_CONF_DIR
  25. [ ! -d $DESIGNATE_LOG_DIR ] && sudo mkdir -m 755 -p $DESIGNATE_LOG_DIR
  26. sudo chown $STACK_USER $DESIGNATE_LOG_DIR
  27. # (Re)create ``designate.conf``
  28. rm -f $DESIGNATE_CONF
  29. # General Configuration
  30. iniset_rpc_backend designate $DESIGNATE_CONF DEFAULT
  31. iniset $DESIGNATE_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
  32. iniset $DESIGNATE_CONF DEFAULT state_path $DESIGNATE_STATE_PATH
  33. iniset $DESIGNATE_CONF DEFAULT root-helper sudo designate-rootwrap $DESIGNATE_ROOTWRAP_CONF
  34. iniset $DESIGNATE_CONF storage:sqlalchemy connection `database_connection_url designate`
  35. # Quota Configuration
  36. iniset $DESIGNATE_CONF DEFAULT quota_zones $DESIGNATE_QUOTA_ZONES
  37. iniset $DESIGNATE_CONF DEFAULT quota_zone_recordsets $DESIGNATE_QUOTA_ZONE_RECORDSETS
  38. iniset $DESIGNATE_CONF DEFAULT quota_zone_records $DESIGNATE_QUOTA_ZONE_RECORDS
  39. iniset $DESIGNATE_CONF DEFAULT quota_recordset_records $DESIGNATE_QUOTA_RECORDSET_RECORDS
  40. iniset $DESIGNATE_CONF DEFAULT quota_api_export_size $DESIGNATE_QUOTA_API_EXPORT_SIZE
  41. # Coordination Configuration
  42. if [[ -n "$DESIGNATE_COORDINATION_URL" ]]; then
  43. iniset $DESIGNATE_CONF coordination backend_url $DESIGNATE_COORDINATION_URL
  44. fi
  45. # Agent Configuration
  46. iniset $DESIGNATE_CONF service:agent workers $API_WORKERS
  47. # API Configuration
  48. sudo cp $DESIGNATE_DIR/etc/designate/api-paste.ini $DESIGNATE_APIPASTE_CONF
  49. iniset $DESIGNATE_CONF service:api enabled_extensions_v2 $DESIGNATE_ENABLED_EXTENSIONS_V2
  50. iniset $DESIGNATE_CONF service:api enabled_extensions_admin $DESIGNATE_ENABLED_EXTENSIONS_ADMIN
  51. iniset $DESIGNATE_CONF service:api enable_host_header True
  52. iniset $DESIGNATE_CONF service:api enable_api_v2 $DESIGNATE_ENABLE_API_V2
  53. iniset $DESIGNATE_CONF service:api enable_api_admin $DESIGNATE_ENABLE_API_ADMIN
  54. # Central Configuration
  55. iniset $DESIGNATE_CONF service:central workers $API_WORKERS
  56. # mDNS Configuration
  57. iniset $DESIGNATE_CONF service:mdns listen ${DESIGNATE_SERVICE_HOST}:${DESIGNATE_SERVICE_PORT_MDNS}
  58. iniset $DESIGNATE_CONF service:mdns workers $API_WORKERS
  59. # Producer Configuration
  60. iniset $DESIGNATE_CONF service:producer workers $API_WORKERS
  61. # Sink Configuration
  62. iniset $DESIGNATE_CONF service:sink workers $API_WORKERS
  63. # Worker Configuration
  64. iniset $DESIGNATE_CONF service:worker poll_max_retries $DESIGNATE_POLL_RETRIES
  65. iniset $DESIGNATE_CONF service:worker poll_retry_interval $DESIGNATE_POLL_INTERVAL
  66. iniset $DESIGNATE_CONF service:worker workers $API_WORKERS
  67. # Set up Notifications/Ceilometer Integration
  68. iniset $DESIGNATE_CONF oslo_messaging_notifications driver "$DESIGNATE_NOTIFICATION_DRIVER"
  69. iniset $DESIGNATE_CONF oslo_messaging_notifications topics "$DESIGNATE_NOTIFICATION_TOPICS"
  70. # Root Wrap
  71. sudo cp $DESIGNATE_DIR/etc/designate/rootwrap.conf.sample $DESIGNATE_ROOTWRAP_CONF
  72. iniset $DESIGNATE_ROOTWRAP_CONF DEFAULT filters_path $DESIGNATE_DIR/etc/designate/rootwrap.d root-helper
  73. # Oslo Concurrency
  74. iniset $DESIGNATE_CONF oslo_concurrency lock_path "$DESIGNATE_STATE_PATH"
  75. # Set up the rootwrap sudoers for designate
  76. local rootwrap_sudoer_cmd="$DESIGNATE_BIN_DIR/designate-rootwrap $DESIGNATE_ROOTWRAP_CONF *"
  77. local tempfile=`mktemp`
  78. echo "$STACK_USER ALL=(root) NOPASSWD: $rootwrap_sudoer_cmd" >$tempfile
  79. chmod 0440 $tempfile
  80. sudo chown root:root $tempfile
  81. sudo mv $tempfile /etc/sudoers.d/designate-rootwrap
  82. if is_service_enabled tls-proxy; then
  83. iniset $DESIGNATE_CONF keystone cafile $SSL_BUNDLE_FILE
  84. fi
  85. # Setup the Keystone Integration
  86. if is_service_enabled keystone; then
  87. iniset $DESIGNATE_CONF service:api auth_strategy keystone
  88. configure_keystone_authtoken_middleware $DESIGNATE_CONF designate
  89. iniset $DESIGNATE_CONF keystone region_name $REGION_NAME
  90. iniset $DESIGNATE_CONF service:api quotas_verify_project_id True
  91. fi
  92. # Logging Configuration
  93. setup_systemd_logging $DESIGNATE_CONF
  94. # Backend Plugin Configuation
  95. configure_designate_backend
  96. if [[ "$DESIGNATE_WSGI_MODE" == "uwsgi" ]]; then
  97. write_uwsgi_config "$DESIGNATE_UWSGI_CONF" "$DESIGNATE_UWSGI" "/dns"
  98. else
  99. _config_designate_apache_wsgi
  100. fi
  101. }
  102. function _config_designate_apache_wsgi {
  103. local designate_api_apache_conf
  104. local venv_path=""
  105. local designate_bin_dir=""
  106. designate_bin_dir=$(get_python_exec_prefix)
  107. designate_api_apache_conf=$(apache_site_config_for designate-api)
  108. if [[ ${USE_VENV} = True ]]; then
  109. venv_path="python-path=${PROJECT_VENV["designate"]}/lib/$(python_version)/site-packages"
  110. designate_bin_dir=${PROJECT_VENV["designate"]}/bin
  111. fi
  112. sudo cp $DESIGNATE_DIR/devstack/files/apache-designate-api.template $designate_api_apache_conf
  113. sudo sed -e "
  114. s|%APACHE_NAME%|$APACHE_NAME|g;
  115. s|%DESIGNATE_BIN_DIR%|$designate_bin_dir|g;
  116. s|%SSLENGINE%|$designate_ssl|g;
  117. s|%SSLCERTFILE%|$designate_certfile|g;
  118. s|%SSLKEYFILE%|$designate_keyfile|g;
  119. s|%USER%|$STACK_USER|g;
  120. s|%VIRTUALENV%|$venv_path|g;
  121. s|%APIWORKERS%|$API_WORKERS|g;
  122. " -i $designate_api_apache_conf
  123. }
  124. function configure_designatedashboard {
  125. # Compile message catalogs
  126. if [ -d ${DESIGNATEDASHBOARD_DIR}/designatedashboard/locale ]; then
  127. (cd ${DESIGNATEDASHBOARD_DIR}/designatedashboard; DJANGO_SETTINGS_MODULE=openstack_dashboard.settings ../manage.py compilemessages)
  128. fi
  129. }
  130. # Configure the needed tempest options
  131. function configure_designate_tempest() {
  132. if is_service_enabled tempest; then
  133. # Tell tempest we're available
  134. iniset $TEMPEST_CONFIG service_available designate True
  135. # Tell tempest which APIs are available
  136. iniset $TEMPEST_CONFIG dns_feature_enabled api_v2 $DESIGNATE_ENABLE_API_V2
  137. iniset $TEMPEST_CONFIG dns_feature_enabled api_admin $DESIGNATE_ENABLE_API_ADMIN
  138. iniset $TEMPEST_CONFIG dns_feature_enabled api_v2_root_recordsets True
  139. iniset $TEMPEST_CONFIG dns_feature_enabled api_v2_quotas True
  140. iniset $TEMPEST_CONFIG dns_feature_enabled api_v2_quotas_verify_project True
  141. iniset $TEMPEST_CONFIG dns_feature_enabled bug_1573141_fixed True
  142. # Tell tempest where are nameservers are.
  143. nameservers=$DESIGNATE_SERVICE_HOST:$DESIGNATE_SERVICE_PORT_DNS
  144. # TODO(kiall): Remove hardcoded list of plugins
  145. case $DESIGNATE_BACKEND_DRIVER in
  146. bind9)
  147. nameservers="$DESIGNATE_SERVICE_HOST:$DESIGNATE_SERVICE_PORT_DNS"
  148. ;;
  149. akamai)
  150. nameservers="$DESIGNATE_AKAMAI_NAMESERVERS"
  151. ;;
  152. dynect)
  153. nameservers="$DESIGNATE_DYNECT_NAMESERVERS"
  154. ;;
  155. esac
  156. if [ ! -z "$DESIGNATE_NAMESERVERS" ]; then
  157. nameservers=$DESIGNATE_NAMESERVERS
  158. fi
  159. iniset $TEMPEST_CONFIG dns nameservers $nameservers
  160. # For legacy functionaltests
  161. iniset $TEMPEST_CONFIG designate nameservers $nameservers
  162. fi
  163. }
  164. # create_designate_accounts - Set up common required designate accounts
  165. # Tenant User Roles
  166. # ------------------------------------------------------------------
  167. # service designate admin # if enabled
  168. function create_designate_accounts {
  169. if is_service_enabled designate-api; then
  170. create_service_user "designate"
  171. local designate_api_url="$DESIGNATE_SERVICE_PROTOCOL://$DESIGNATE_SERVICE_HOST/dns"
  172. get_or_create_service "designate" "dns" "Designate DNS Service"
  173. get_or_create_endpoint \
  174. "dns" \
  175. "$REGION_NAME" \
  176. "$designate_api_url"
  177. fi
  178. }
  179. # create_designate_pool_configuration - Create Pool Configuration
  180. function create_designate_pool_configuration {
  181. # Sync Pools Config
  182. $DESIGNATE_BIN_DIR/designate-manage pool update --file $DESIGNATE_CONF_DIR/pools.yaml
  183. # Allow Backends to do backend specific tasks
  184. if function_exists create_designate_pool_configuration_backend; then
  185. create_designate_pool_configuration_backend
  186. fi
  187. }
  188. # init_designate - Initialize etc.
  189. function init_designate {
  190. # (Re)create designate database
  191. recreate_database designate utf8
  192. # Init and migrate designate database
  193. $DESIGNATE_BIN_DIR/designate-manage database sync
  194. init_designate_backend
  195. }
  196. # install_designate - Collect source and prepare
  197. function install_designate {
  198. if [[ "$DESIGNATE_WSGI_MODE" == "uwsgi" ]]; then
  199. install_apache_uwsgi
  200. else
  201. install_apache_wsgi
  202. fi
  203. if is_fedora; then
  204. # bind-utils package provides `dig`
  205. install_package bind-utils
  206. fi
  207. git_clone $DESIGNATE_REPO $DESIGNATE_DIR $DESIGNATE_BRANCH
  208. setup_develop $DESIGNATE_DIR
  209. # Install reqs for tooz driver
  210. if [[ "$DESIGNATE_COORDINATION_URL" =~ "memcached" ]]; then
  211. pip_install_gr "pymemcache"
  212. fi
  213. install_designate_backend
  214. }
  215. # install_designateclient - Collect source and prepare
  216. function install_designateclient {
  217. if use_library_from_git "python-designateclient"; then
  218. git_clone_by_name "python-designateclient"
  219. setup_dev_lib "python-designateclient"
  220. else
  221. pip_install_gr "python-designateclient"
  222. fi
  223. }
  224. # install_designatedashboard - Collect source and prepare
  225. function install_designatedashboard {
  226. git_clone_by_name "designate-dashboard"
  227. setup_dev_lib "designate-dashboard"
  228. for panel in _1710_project_dns_panel_group.py \
  229. _1721_dns_zones_panel.py \
  230. _1722_dns_reversedns_panel.py; do
  231. ln -fs $DESIGNATEDASHBOARD_DIR/designatedashboard/enabled/$panel $HORIZON_DIR/openstack_dashboard/local/enabled/$panel
  232. done
  233. }
  234. # install_designatetempest - Collect source and prepare
  235. function install_designatetempest {
  236. git_clone_by_name "designate-tempest-plugin"
  237. setup_dev_lib "designate-tempest-plugin"
  238. }
  239. # start_designate - Start running processes
  240. function start_designate {
  241. start_designate_backend
  242. run_process designate-central "$DESIGNATE_BIN_DIR/designate-central --config-file $DESIGNATE_CONF"
  243. run_process designate-mdns "$DESIGNATE_BIN_DIR/designate-mdns --config-file $DESIGNATE_CONF"
  244. run_process designate-agent "$DESIGNATE_BIN_DIR/designate-agent --config-file $DESIGNATE_CONF"
  245. run_process designate-sink "$DESIGNATE_BIN_DIR/designate-sink --config-file $DESIGNATE_CONF"
  246. run_process designate-worker "$DESIGNATE_BIN_DIR/designate-worker --config-file $DESIGNATE_CONF"
  247. run_process designate-producer "$DESIGNATE_BIN_DIR/designate-producer --config-file $DESIGNATE_CONF"
  248. if [[ "$DESIGNATE_WSGI_MODE" == "uwsgi" ]]; then
  249. run_process "designate-api" "$(which uwsgi) --procname-prefix designate-api --ini $DESIGNATE_UWSGI_CONF"
  250. else
  251. enable_apache_site designate-api
  252. restart_apache_server
  253. tail_log designate-api /var/log/$APACHE_NAME/designate-api.log
  254. fi
  255. echo "Waiting for designate-api to start..."
  256. if ! wait_for_service $SERVICE_TIMEOUT $DESIGNATE_SERVICE_PROTOCOL://$DESIGNATE_SERVICE_HOST/dns; then
  257. die $LINENO "designate-api did not start"
  258. fi
  259. }
  260. # stop_designate - Stop running processes
  261. function stop_designate {
  262. if [[ "$DESIGNATE_WSGI_MODE" == "uwsgi" ]]; then
  263. stop_process "designate-api"
  264. else
  265. disable_apache_site designate-api
  266. restart_apache_server
  267. fi
  268. stop_process designate-central
  269. stop_process designate-mdns
  270. stop_process designate-agent
  271. stop_process designate-sink
  272. stop_process designate-worker
  273. stop_process designate-producer
  274. stop_designate_backend
  275. }
  276. # This is the main for plugin.sh
  277. if is_service_enabled designate; then
  278. # Sanify check for agent backend
  279. # ------------------------------
  280. if ! is_service_enabled designate-agent && [ "$DESIGNATE_BACKEND_DRIVER" == "agent" ]; then
  281. die $LINENO "To use the agent backend, you must enable the designate-agent service"
  282. fi
  283. if [[ "$1" == "stack" && "$2" == "install" ]]; then
  284. echo_summary "Installing Designate client"
  285. install_designateclient
  286. echo_summary "Installing Designate"
  287. stack_install_service designate
  288. if is_service_enabled horizon; then
  289. echo_summary "Installing Designate dashboard"
  290. install_designatedashboard
  291. fi
  292. if is_service_enabled tempest; then
  293. echo_summary "Installing Designate Tempest Plugin"
  294. install_designatetempest
  295. fi
  296. elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
  297. echo_summary "Configuring Designate"
  298. configure_designate
  299. if is_service_enabled horizon; then
  300. echo_summary "Configuring Designate dashboard"
  301. configure_designatedashboard
  302. fi
  303. if is_service_enabled keystone; then
  304. echo_summary "Creating Designate Keystone accounts"
  305. create_designate_accounts
  306. fi
  307. elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
  308. echo_summary "Initializing Designate"
  309. init_designate
  310. echo_summary "Starting Designate"
  311. start_designate
  312. echo_summary "Creating Pool Configuration"
  313. create_designate_pool_configuration
  314. elif [[ "$1" == "stack" && "$2" == "test-config" ]]; then
  315. echo_summary "Configuring Tempest options for Designate"
  316. configure_designate_tempest
  317. fi
  318. if [[ "$1" == "unstack" ]]; then
  319. stop_designate
  320. fi
  321. if [[ "$1" == "clean" ]]; then
  322. echo_summary "Cleaning Designate"
  323. cleanup_designate
  324. fi
  325. fi
  326. # Restore xtrace
  327. $XTRACE