Browse code

Do not hardcode ironic svc port, protocol

The Ironic API server's port and protocol are hardcoded in various
places. This updates the ironic bits to use configured values instead
and fixes a bug around iptables rule creationl.

Change-Id: I1ace68affff3afdbc0058be4d32f8044a24e9338
Closes-bug: #1393498

Adam Gandelman authored on 2014/11/18 02:59:23
Showing 2 changed files
... ...
@@ -104,7 +104,8 @@ IRONIC_BIN_DIR=$(get_python_exec_prefix)
104 104
 
105 105
 # Ironic connection info.  Note the port must be specified.
106 106
 IRONIC_SERVICE_PROTOCOL=http
107
-IRONIC_HOSTPORT=${IRONIC_HOSTPORT:-$SERVICE_HOST:6385}
107
+IRONIC_SERVICE_PORT=${IRONIC_SERVICE_PORT:-6385}
108
+IRONIC_HOSTPORT=${IRONIC_HOSTPORT:-$SERVICE_HOST:$IRONIC_SERVICE_PORT}
108 109
 
109 110
 # Tell Tempest this project is present
110 111
 TEMPEST_SERVICES+=,ironic
... ...
@@ -277,6 +278,7 @@ function configure_ironic_api {
277 277
     iniset $IRONIC_CONF_FILE DEFAULT policy_file $IRONIC_POLICY_JSON
278 278
     configure_auth_token_middleware $IRONIC_CONF_FILE ironic $IRONIC_AUTH_CACHE_DIR/api
279 279
     iniset_rpc_backend ironic $IRONIC_CONF_FILE DEFAULT
280
+    iniset $IRONIC_CONF_FILE api port $IRONIC_SERVICE_PORT
280 281
 
281 282
     cp -p $IRONIC_DIR/etc/ironic/policy.json $IRONIC_POLICY_JSON
282 283
 }
... ...
@@ -298,7 +300,7 @@ function configure_ironic_conductor {
298 298
 
299 299
     iniset $IRONIC_CONF_FILE DEFAULT rootwrap_config $IRONIC_ROOTWRAP_CONF
300 300
     iniset $IRONIC_CONF_FILE DEFAULT enabled_drivers $IRONIC_ENABLED_DRIVERS
301
-    iniset $IRONIC_CONF_FILE conductor api_url http://$HOST_IP:6385
301
+    iniset $IRONIC_CONF_FILE conductor api_url $IRONIC_SERVICE_PROTOCOL://$HOST_IP:$IRONIC_SERVICE_PORT
302 302
     iniset $IRONIC_CONF_FILE pxe tftp_server $IRONIC_TFTPSERVER_IP
303 303
     iniset $IRONIC_CONF_FILE pxe tftp_root $IRONIC_TFTPBOOT_DIR
304 304
     iniset $IRONIC_CONF_FILE pxe tftp_master_path $IRONIC_TFTPBOOT_DIR/master_images
... ...
@@ -419,7 +421,7 @@ function start_ironic {
419 419
 function start_ironic_api {
420 420
     run_process ir-api "$IRONIC_BIN_DIR/ironic-api --config-file=$IRONIC_CONF_FILE"
421 421
     echo "Waiting for ir-api ($IRONIC_HOSTPORT) to start..."
422
-    if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget --no-proxy -q -O- http://$IRONIC_HOSTPORT; do sleep 1; done"; then
422
+    if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget --no-proxy -q -O- $IRONIC_SERVICE_PROTOCOL://$IRONIC_HOSTPORT; do sleep 1; done"; then
423 423
         die $LINENO "ir-api did not start"
424 424
     fi
425 425
 }
... ...
@@ -586,7 +588,7 @@ function configure_iptables {
586 586
     sudo modprobe nf_nat_tftp
587 587
     # nodes boot from TFTP and callback to the API server listening on $HOST_IP
588 588
     sudo iptables -I INPUT -d $HOST_IP -p udp --dport 69 -j ACCEPT || true
589
-    sudo iptables -I INPUT -d $HOST_IP -p tcp --dport $IRONIC_HOSTPORT -j ACCEPT || true
589
+    sudo iptables -I INPUT -d $HOST_IP -p tcp --dport $IRONIC_SERVICE_PORT -j ACCEPT || true
590 590
     if [ "$IRONIC_DEPLOY_DRIVER" == "agent_ssh" ]; then
591 591
         # agent ramdisk gets instance image from swift
592 592
         sudo iptables -I INPUT -d $HOST_IP -p tcp --dport ${SWIFT_DEFAULT_BIND_PORT:-8080} -j ACCEPT || true
... ...
@@ -748,7 +750,7 @@ function cleanup_baremetal_basic_ops {
748 748
     sudo rm -rf /etc/xinetd.d/tftp /etc/init/tftpd-hpa.override
749 749
     restart_service xinetd
750 750
     sudo iptables -D INPUT -d $HOST_IP -p udp --dport 69 -j ACCEPT || true
751
-    sudo iptables -D INPUT -d $HOST_IP -p tcp --dport 6385 -j ACCEPT || true
751
+    sudo iptables -D INPUT -d $HOST_IP -p tcp --dport $IRONIC_SERVICE_PORT -j ACCEPT || true
752 752
     if [ "$IRONIC_DEPLOY_DRIVER" == "agent_ssh" ]; then
753 753
         # agent ramdisk gets instance image from swift
754 754
         sudo iptables -D INPUT -d $HOST_IP -p tcp --dport ${SWIFT_DEFAULT_BIND_PORT:-8080} -j ACCEPT || true
... ...
@@ -47,7 +47,7 @@ function configure_nova_hypervisor {
47 47
     iniset $NOVA_CONF ironic admin_password $ADMIN_PASSWORD
48 48
     iniset $NOVA_CONF ironic admin_url $KEYSTONE_AUTH_URI/v2.0
49 49
     iniset $NOVA_CONF ironic admin_tenant_name demo
50
-    iniset $NOVA_CONF ironic api_endpoint http://$SERVICE_HOST:6385/v1
50
+    iniset $NOVA_CONF ironic api_endpoint $IRONIC_SERVICE_PROTOCOL://$IRONIC_HOSTPORT/v1
51 51
 }
52 52
 
53 53
 # install_nova_hypervisor() - Install external components