Browse Source

Merge "Update non-standalone job to use uwsgi"

master
Zuul 1 week ago
parent
commit
3ac52841cd

+ 51
- 6
devstack/plugin.sh View File

@@ -14,7 +14,6 @@ IRONIC_INSPECTOR_DBSYNC_BIN_FILE=$IRONIC_INSPECTOR_BIN_DIR/ironic-inspector-dbsy
14 14
 IRONIC_INSPECTOR_CONF_DIR=${IRONIC_INSPECTOR_CONF_DIR:-/etc/ironic-inspector}
15 15
 IRONIC_INSPECTOR_CONF_FILE=$IRONIC_INSPECTOR_CONF_DIR/inspector.conf
16 16
 IRONIC_INSPECTOR_CMD="$IRONIC_INSPECTOR_BIN_FILE --config-file $IRONIC_INSPECTOR_CONF_FILE"
17
-IRONIC_INSPECTOR_CMD_API="$IRONIC_INSPECTOR_BIN_FILE_API -p 5050 -- --config-file $IRONIC_INSPECTOR_CONF_FILE"
18 17
 IRONIC_INSPECTOR_CMD_CONDUCTOR="$IRONIC_INSPECTOR_BIN_FILE_CONDUCTOR --config-file $IRONIC_INSPECTOR_CONF_FILE"
19 18
 IRONIC_INSPECTOR_DHCP_CONF_FILE=$IRONIC_INSPECTOR_CONF_DIR/dnsmasq.conf
20 19
 IRONIC_INSPECTOR_ROOTWRAP_CONF_FILE=$IRONIC_INSPECTOR_CONF_DIR/rootwrap.conf
@@ -22,6 +21,10 @@ IRONIC_INSPECTOR_ADMIN_USER=${IRONIC_INSPECTOR_ADMIN_USER:-ironic-inspector}
22 21
 IRONIC_INSPECTOR_AUTH_CACHE_DIR=${IRONIC_INSPECTOR_AUTH_CACHE_DIR:-/var/cache/ironic-inspector}
23 22
 IRONIC_INSPECTOR_DHCP_FILTER=${IRONIC_INSPECTOR_DHCP_FILTER:-iptables}
24 23
 IRONIC_INSPECTOR_STANDALONE=${IRONIC_INSPECTOR_STANDALONE:-True}
24
+# Support entry points installation of console scripts
25
+IRONIC_INSPECTOR_UWSGI=$IRONIC_INSPECTOR_BIN_DIR/ironic-inspector-api-wsgi
26
+IRONIC_INSPECTOR_UWSGI_CONF=$IRONIC_INSPECTOR_CONF_DIR/ironic-inspector-uwsgi.ini
27
+
25 28
 if [[ -n ${IRONIC_INSPECTOR_MANAGE_FIREWALL} ]] ; then
26 29
     echo "IRONIC_INSPECTOR_MANAGE_FIREWALL is deprecated." >&2
27 30
     echo "Please, use IRONIC_INSPECTOR_DHCP_FILTER == noop/iptables/dnsmasq instead." >&2
@@ -44,9 +47,15 @@ IRONIC_INSPECTOR_DHCP_HOSTSDIR=${IRONIC_INSPECTOR_DHCP_HOSTSDIR:-/etc/ironic-ins
44 47
 IRONIC_INSPECTOR_DNSMASQ_STOP_COMMAND=${IRONIC_INSPECTOR_DNSMASQ_STOP_COMMAND:-systemctl stop devstack@ironic-inspector-dhcp}
45 48
 IRONIC_INSPECTOR_DNSMASQ_START_COMMAND=${IRONIC_INSPECTOR_DNSMASQ_START_COMMAND:-systemctl start devstack@ironic-inspector-dhcp}
46 49
 
47
-IRONIC_INSPECTOR_HOST=$HOST_IP
50
+IRONIC_INSPECTOR_HOST=$SERVICE_HOST
48 51
 IRONIC_INSPECTOR_PORT=5050
49
-IRONIC_INSPECTOR_URI="http://$IRONIC_INSPECTOR_HOST:$IRONIC_INSPECTOR_PORT"
52
+
53
+if [[ "$IRONIC_INSPECTOR_STANDALONE" == "False" ]]; then
54
+    IRONIC_INSPECTOR_URI="http://$IRONIC_INSPECTOR_HOST/baremetal-introspection"
55
+else
56
+    IRONIC_INSPECTOR_URI="http://$IRONIC_INSPECTOR_HOST:$IRONIC_INSPECTOR_PORT"
57
+fi
58
+
50 59
 IRONIC_INSPECTOR_BUILD_RAMDISK=$(trueorfalse False IRONIC_INSPECTOR_BUILD_RAMDISK)
51 60
 IRONIC_AGENT_KERNEL_URL=${IRONIC_AGENT_KERNEL_URL:-http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe.vmlinuz}
52 61
 IRONIC_AGENT_RAMDISK_URL=${IRONIC_AGENT_RAMDISK_URL:-http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe_image-oem.cpio.gz}
@@ -61,7 +70,13 @@ IRONIC_INSPECTOR_INTERNAL_SUBNET_SIZE=${IRONIC_INSPECTOR_INTERNAL_SUBNET_SIZE:-2
61 70
 IRONIC_INSPECTOR_DHCP_RANGE=${IRONIC_INSPECTOR_DHCP_RANGE:-172.24.42.100,172.24.42.253}
62 71
 IRONIC_INSPECTOR_INTERFACE=${IRONIC_INSPECTOR_INTERFACE:-br-inspector}
63 72
 IRONIC_INSPECTOR_INTERFACE_PHYSICAL=$(trueorfalse False IRONIC_INSPECTOR_INTERFACE_PHYSICAL)
64
-IRONIC_INSPECTOR_INTERNAL_URI="http://$IRONIC_INSPECTOR_INTERNAL_IP:$IRONIC_INSPECTOR_PORT"
73
+
74
+if [[ "$IRONIC_INSPECTOR_STANDALONE" == "False" ]]; then
75
+    IRONIC_INSPECTOR_INTERNAL_URI="http://$IRONIC_INSPECTOR_INTERNAL_IP/baremetal-introspection"
76
+else
77
+    IRONIC_INSPECTOR_INTERNAL_URI="http://$IRONIC_INSPECTOR_INTERNAL_IP:$IRONIC_INSPECTOR_PORT"
78
+fi
79
+
65 80
 IRONIC_INSPECTOR_INTERNAL_IP_WITH_NET="$IRONIC_INSPECTOR_INTERNAL_IP/$IRONIC_INSPECTOR_INTERNAL_SUBNET_SIZE"
66 81
 # Whether DevStack will be setup for bare metal or VMs
67 82
 IRONIC_IS_HARDWARE=$(trueorfalse False IRONIC_IS_HARDWARE)
@@ -107,6 +122,10 @@ function inspector_iniset {
107 122
 
108 123
 function install_inspector {
109 124
     setup_develop $IRONIC_INSPECTOR_DIR
125
+
126
+    if [[ "$IRONIC_INSPECTOR_STANDALONE" == "False" ]]; then
127
+        install_apache_wsgi
128
+    fi
110 129
 }
111 130
 
112 131
 function install_inspector_dhcp {
@@ -126,8 +145,13 @@ function start_inspector {
126 145
     if [[ "$IRONIC_INSPECTOR_STANDALONE" == "True" ]]; then
127 146
         run_process ironic-inspector "$IRONIC_INSPECTOR_CMD"
128 147
     else
129
-        run_process ironic-inspector-api "$IRONIC_INSPECTOR_CMD_API"
130
-        run_process ironic-inspector-conductor "$IRONIC_INSPECTOR_CMD_CONDUCTOR"
148
+      run_process ironic-inspector-api "$IRONIC_INSPECTOR_BIN_DIR/uwsgi --procname-prefix ironic-inspector-api --ini $IRONIC_INSPECTOR_UWSGI_CONF --pyargv \"--config-file $IRONIC_INSPECTOR_CONF_FILE\""
149
+      run_process ironic-inspector-conductor "$IRONIC_INSPECTOR_CMD_CONDUCTOR"
150
+    fi
151
+
152
+    echo "Waiting for ironic-inspector API to start..."
153
+    if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget --no-proxy -q -O- $IRONIC_INSPECTOR_URI; do sleep 1; done"; then
154
+        die $LINENO "ironic-inspector API did not start"
131 155
     fi
132 156
 }
133 157
 
@@ -317,6 +341,11 @@ function configure_inspector {
317 341
 
318 342
     setup_logging $IRONIC_INSPECTOR_CONF_FILE DEFAULT
319 343
 
344
+    # Adds uWSGI for inspector API
345
+    if [[ "$IRONIC_INSPECTOR_STANDALONE" == "False" ]]; then
346
+        write_uwsgi_config "$IRONIC_INSPECTOR_UWSGI_CONF" "$IRONIC_INSPECTOR_UWSGI" "/baremetal-introspection"
347
+    fi
348
+
320 349
     cp "$IRONIC_INSPECTOR_DIR/rootwrap.conf" "$IRONIC_INSPECTOR_ROOTWRAP_CONF_FILE"
321 350
     cp -r "$IRONIC_INSPECTOR_DIR/rootwrap.d" "$IRONIC_INSPECTOR_CONF_DIR"
322 351
     local ironic_inspector_rootwrap=$(get_rootwrap_location ironic-inspector)
@@ -406,6 +435,12 @@ function prepare_environment {
406 435
         --dport 69 -j ACCEPT
407 436
     sudo iptables -I INPUT -i $IRONIC_INSPECTOR_INTERFACE -p tcp \
408 437
         --dport $IRONIC_INSPECTOR_PORT -j ACCEPT
438
+
439
+    if [[ "$IRONIC_INSPECTOR_STANDALONE" == "False" ]]; then
440
+        sudo iptables -I INPUT -i $IRONIC_INSPECTOR_INTERFACE -p tcp --dport 80 -j ACCEPT
441
+        sudo iptables -I INPUT -i $IRONIC_INSPECTOR_INTERFACE -p tcp --dport 443 -j ACCEPT
442
+    fi
443
+
409 444
 }
410 445
 
411 446
 # create_ironic_inspector_cache_dir() - Part of the prepare_environment() process
@@ -428,6 +463,11 @@ function cleanup_inspector {
428 463
     sudo rm -rf $IRONIC_INSPECTOR_AUTH_CACHE_DIR
429 464
     sudo rm -rf "$IRONIC_INSPECTOR_RAMDISK_LOGDIR"
430 465
 
466
+    if [[ "$IRONIC_INSPECTOR_STANDALONE" == "False" ]]; then
467
+        sudo iptables -D INPUT -i $IRONIC_INSPECTOR_INTERFACE -p tcp --dport 80 -j ACCEPT | true
468
+        sudo iptables -D INPUT -i $IRONIC_INSPECTOR_INTERFACE -p tcp --dport 443 -j ACCEPT | true
469
+    fi
470
+
431 471
     # Always try to clean up firewall rules, no matter filter driver used
432 472
     sudo iptables -D INPUT -i $IRONIC_INSPECTOR_INTERFACE -p udp \
433 473
         --dport 69 -j ACCEPT | true
@@ -443,6 +483,11 @@ function cleanup_inspector {
443 483
     fi
444 484
     sudo ip link show $IRONIC_INSPECTOR_OVS_PORT && sudo ip link delete $IRONIC_INSPECTOR_OVS_PORT
445 485
     sudo ovs-vsctl --if-exists del-port $IRONIC_INSPECTOR_OVS_PORT
486
+
487
+    if [[ "$IRONIC_INSPECTOR_STANDALONE" == "False" ]]; then
488
+        remove_uwsgi_config "$IRONIC_INSPECTOR_UWSGI_CONF" "$IRONIC_INSPECTOR_UWSGI"
489
+        restart_apache_server
490
+    fi
446 491
 }
447 492
 
448 493
 function sync_inspector_database {

+ 6
- 9
ironic_inspector/common/rpc.py View File

@@ -22,12 +22,9 @@ CONF = cfg.CONF
22 22
 TRANSPORT = None
23 23
 
24 24
 
25
-def get_transport():
25
+def init():
26 26
     global TRANSPORT
27
-
28
-    if TRANSPORT is None:
29
-        TRANSPORT = messaging.get_rpc_transport(CONF)
30
-    return TRANSPORT
27
+    TRANSPORT = messaging.get_rpc_transport(CONF)
31 28
 
32 29
 
33 30
 def get_client(topic=None):
@@ -36,22 +33,22 @@ def get_client(topic=None):
36 33
     :param topic: The topic of the message will be delivered to. This argument
37 34
                   is ignored if CONF.standalone is True.
38 35
     """
36
+    assert TRANSPORT is not None
39 37
     if CONF.standalone:
40 38
         target = messaging.Target(topic=manager.MANAGER_TOPIC,
41 39
                                   server=CONF.host,
42 40
                                   version='1.3')
43 41
     else:
44 42
         target = messaging.Target(topic=topic, version='1.3')
45
-    transport = get_transport()
46
-    return messaging.RPCClient(transport, target)
43
+    return messaging.RPCClient(TRANSPORT, target)
47 44
 
48 45
 
49 46
 def get_server(endpoints):
50 47
     """Get a RPC server instance."""
51 48
 
52
-    transport = get_transport()
49
+    assert TRANSPORT is not None
53 50
     target = messaging.Target(topic=manager.MANAGER_TOPIC, server=CONF.host,
54 51
                               version='1.3')
55 52
     return messaging.get_rpc_server(
56
-        transport, target, endpoints, executor='eventlet',
53
+        TRANSPORT, target, endpoints, executor='eventlet',
57 54
         access_policy=dispatcher.DefaultRPCAccessPolicy)

+ 3
- 0
ironic_inspector/common/service_utils.py View File

@@ -13,8 +13,10 @@
13 13
 from oslo_config import cfg
14 14
 from oslo_log import log
15 15
 
16
+from ironic_inspector.common import rpc
16 17
 from ironic_inspector.conf import opts
17 18
 
19
+
18 20
 LOG = log.getLogger(__name__)
19 21
 CONF = cfg.CONF
20 22
 
@@ -24,6 +26,7 @@ def prepare_service(args=None):
24 26
     log.register_options(CONF)
25 27
     opts.set_config_defaults()
26 28
     opts.parse_args(args)
29
+    rpc.init()
27 30
     log.setup(CONF, 'ironic_inspector')
28 31
 
29 32
     LOG.debug("Configuration:")

+ 1
- 1
ironic_inspector/test/unit/test_main.py View File

@@ -671,7 +671,7 @@ class TestTopic(test_base.BaseTest):
671 671
     def setUp(self):
672 672
         super(TestTopic, self).setUp()
673 673
         self.transport_mock = self.useFixture(
674
-            fixtures.MockPatchObject(rpc, 'get_transport',
674
+            fixtures.MockPatchObject(rpc, 'TRANSPORT',
675 675
                                      autospec=True)).mock
676 676
         self.target_mock = self.useFixture(
677 677
             fixtures.MockPatchObject(rpc.messaging, 'Target',

Loading…
Cancel
Save