Repair devstack plugin after rename

Also move documentation here from always broken etherpad.

Depends on https://review.openstack.org/#/c/186772/
for Ironic inspection to work.

Change-Id: I795aa9405e6141cc82ad0f37b90a3cc6f0d402c0
This commit is contained in:
Dmitry Tantsur 2015-05-29 13:25:56 +02:00
parent 730b0bf34f
commit 823aa71972
4 changed files with 187 additions and 114 deletions

View File

@ -64,9 +64,78 @@ Run the service with::
Of course you may have to modify ``example.conf`` to match your OpenStack
environment.
You can develop and test **ironic-inspector** using
`DevStack <http://docs.openstack.org/developer/devstack/>`_ plugin - see
https://etherpad.openstack.org/p/DiscoverdDevStack for the current status.
You can develop and test **ironic-inspector** using DevStack - see
`DevStack Support`_ for the current status.
DevStack Support
~~~~~~~~~~~~~~~~
`DevStack <http://docs.openstack.org/developer/devstack/>`_ provides a way to
quickly build full OpenStack development environment with requested
components. There is a plugin for installing **ironic-inspector** on DevStack.
Example local.conf
------------------
::
[[local|localrc]]
enable_service ironic ir-api ir-cond
disable_service n-net n-novnc
enable_service neutron q-svc q-agt q-dhcp q-l3 q-meta
disable_service heat h-api h-api-cfn h-api-cw h-eng
enable_plugin ironic-inspector https://github.com/stackforge/ironic-discoverd
IRONIC_BAREMETAL_BASIC_OPS=True
IRONIC_VM_COUNT=2
IRONIC_VM_SPECS_RAM=1024
IRONIC_DEPLOY_FLAVOR="fedora deploy-ironic"
IRONIC_INSPECTOR_RAMDISK_FLAVOR="fedora ironic-discoverd-ramdisk"
VIRT_DRIVER=ironic
LOGDAYS=1
LOGFILE=~/logs/stack.sh.log
SCREEN_LOGDIR=~/logs/screen
DEFAULT_INSTANCE_TYPE=baremetal
TEMPEST_ALLOW_TENANT_ISOLATION=False
Notes
-----
* Replace "fedora" with whatever you have
* You need at least 1G of RAM for VMs, default value of 512 MB won't work
* Network configuration is pretty sensitive, better not to touch it
without deep understanding
* Before restarting stack.sh::
rm -rf /opt/stack/ironic-inspector
Test
----
There is a test script included::
source devstack/openrc admin admin
/opt/stack/ironic-inspector/functest/devstack-test.sh
Usage
-----
Start introspection for a node manually::
source devstack/openrc admin admin
openstack baremetal introspection start <UUID>
Then check status via API::
openstack baremetal introspection status <UUID>
Writing a Plugin
~~~~~~~~~~~~~~~~

View File

@ -104,8 +104,7 @@ environment)::
pip install ironic-inspector
Also there is a `DevStack <http://docs.openstack.org/developer/devstack/>`_
plugin for **ironic-inspector** - see
https://etherpad.openstack.org/p/DiscoverdDevStack for the current status.
plugin for **ironic-inspector** - see CONTRIBUTING.rst_ for the current status.
Finally, some distributions (e.g. Fedora) provide **ironic-inspector**
packaged, some of them - under its old name *ironic-discoverd*.

View File

@ -1,25 +1,26 @@
IRONIC_DISCOVERD_DEBUG=${IRONIC_DISCOVERD_DEBUG:-false}
IRONIC_DISCOVERD_DIR=$DEST/ironic-discoverd
IRONIC_DISCOVERD_BIN_DIR=$(get_python_exec_prefix)
IRONIC_DISCOVERD_BIN_FILE=$IRONIC_DISCOVERD_BIN_DIR/ironic-discoverd
IRONIC_DISCOVERD_CONF_DIR=${IRONIC_DISCOVERD_CONF_DIR:-/etc/ironic-discoverd}
IRONIC_DISCOVERD_CONF_FILE=$IRONIC_DISCOVERD_CONF_DIR/discoverd.conf
IRONIC_DISCOVERD_DHCP_CONF_FILE=$IRONIC_DISCOVERD_CONF_DIR/dnsmasq.conf
IRONIC_DISCOVERD_DATA_DIR=$DATA_DIR/ironic-discoverd
IRONIC_DISCOVERD_ADMIN_USER=${IRONIC_DISCOVERD_ADMIN_USER:-ironic-discoverd}
IRONIC_DISCOVERD_MANAGE_FIREWALL=$(trueorfalse True $IRONIC_DISCOVERD_MANAGE_FIREWALL)
IRONIC_DISCOVERD_HOST=$HOST_IP
IRONIC_DISCOVERD_PORT=5050
IRONIC_DISCOVERD_URI="http://$IRONIC_DISCOVERD_HOST:$IRONIC_DISCOVERD_PORT"
IRONIC_DISCOVERD_RAMDISK_ELEMENT=${IRONIC_DISCOVERD_RAMDISK_ELEMENT:-ironic-discoverd-ramdisk}
IRONIC_DISCOVERD_RAMDISK_FLAVOR=${IRONIC_DISCOVERD_RAMDISK_FLAVOR:-fedora $IRONIC_DISCOVERD_RAMDISK_ELEMENT}
IRONIC_INSPECTOR_DEBUG=${IRONIC_INSPECTOR_DEBUG:-false}
IRONIC_INSPECTOR_DIR=$DEST/ironic-inspector
IRONIC_INSPECTOR_BIN_DIR=$(get_python_exec_prefix)
IRONIC_INSPECTOR_BIN_FILE=$IRONIC_INSPECTOR_BIN_DIR/ironic-inspector
IRONIC_INSPECTOR_CONF_DIR=${IRONIC_INSPECTOR_CONF_DIR:-/etc/ironic-inspector}
IRONIC_INSPECTOR_CONF_FILE=$IRONIC_INSPECTOR_CONF_DIR/inspector.conf
IRONIC_INSPECTOR_CMD="sudo $IRONIC_INSPECTOR_BIN_FILE --config-file $IRONIC_INSPECTOR_CONF_FILE"
IRONIC_INSPECTOR_DHCP_CONF_FILE=$IRONIC_INSPECTOR_CONF_DIR/dnsmasq.conf
IRONIC_INSPECTOR_DATA_DIR=$DATA_DIR/ironic-inspector
IRONIC_INSPECTOR_ADMIN_USER=${IRONIC_INSPECTOR_ADMIN_USER:-ironic-inspector}
IRONIC_INSPECTOR_MANAGE_FIREWALL=$(trueorfalse True $IRONIC_INSPECTOR_MANAGE_FIREWALL)
IRONIC_INSPECTOR_HOST=$HOST_IP
IRONIC_INSPECTOR_PORT=5050
IRONIC_INSPECTOR_URI="http://$IRONIC_INSPECTOR_HOST:$IRONIC_INSPECTOR_PORT"
IRONIC_INSPECTOR_RAMDISK_ELEMENT=${IRONIC_INSPECTOR_RAMDISK_ELEMENT:-ironic-discoverd-ramdisk}
IRONIC_INSPECTOR_RAMDISK_FLAVOR=${IRONIC_INSPECTOR_RAMDISK_FLAVOR:-fedora $IRONIC_INSPECTOR_RAMDISK_ELEMENT}
# These should not overlap with other ranges/networks
IRONIC_DISCOVERD_INTERNAL_IP=${IRONIC_DISCOVERD_INTERNAL_IP:-172.24.5.254}
IRONIC_DISCOVERD_INTERNAL_SUBNET_SIZE=${IRONIC_DISCOVERD_INTERNAL_SUBNET_SIZE:-24}
IRONIC_DISCOVERD_DHCP_RANGE=${IRONIC_DISCOVERD_DHCP_RANGE:-172.24.5.100,172.24.5.253}
IRONIC_DISCOVERD_INTERFACE=${IRONIC_DISCOVERD_INTERFACE:-br-discoverd}
IRONIC_DISCOVERD_INTERNAL_URI="http://$IRONIC_DISCOVERD_INTERNAL_IP:$IRONIC_DISCOVERD_PORT"
IRONIC_DISCOVERD_INTERNAL_IP_WITH_NET=$IRONIC_DISCOVERD_INTERNAL_IP/$IRONIC_DISCOVERD_INTERNAL_SUBNET_SIZE
IRONIC_INSPECTOR_INTERNAL_IP=${IRONIC_INSPECTOR_INTERNAL_IP:-172.24.5.254}
IRONIC_INSPECTOR_INTERNAL_SUBNET_SIZE=${IRONIC_INSPECTOR_INTERNAL_SUBNET_SIZE:-24}
IRONIC_INSPECTOR_DHCP_RANGE=${IRONIC_INSPECTOR_DHCP_RANGE:-172.24.5.100,172.24.5.253}
IRONIC_INSPECTOR_INTERFACE=${IRONIC_INSPECTOR_INTERFACE:-br-inspector}
IRONIC_INSPECTOR_INTERNAL_URI="http://$IRONIC_INSPECTOR_INTERNAL_IP:$IRONIC_INSPECTOR_PORT"
IRONIC_INSPECTOR_INTERNAL_IP_WITH_NET=$IRONIC_INSPECTOR_INTERNAL_IP/$IRONIC_INSPECTOR_INTERNAL_SUBNET_SIZE
### Utilities
@ -30,102 +31,106 @@ function mkdir_chown_stack {
sudo chown $STACK_USER "$1"
}
function discoverd_iniset {
iniset "$IRONIC_DISCOVERD_CONF_FILE" discoverd $1 $2
function inspector_iniset {
iniset "$IRONIC_INSPECTOR_CONF_FILE" $1 $2 $3
}
### Install-start-stop
function install_discoverd {
setup_develop $IRONIC_DISCOVERD_DIR
function install_inspector {
setup_develop $IRONIC_INSPECTOR_DIR
# NOTE(dtantsur): required for tests
install_package jq
}
function install_discoverd_dhcp {
function install_inspector_dhcp {
install_package dnsmasq
}
function start_discoverd {
screen_it ironic-discoverd "cd $IRONIC_DISCOVERD_DIR && sudo $IRONIC_DISCOVERD_BIN_FILE --config-file $IRONIC_DISCOVERD_CONF_FILE"
function start_inspector {
screen_it ironic-inspector \
"cd $IRONIC_INSPECTOR_DIR && $IRONIC_INSPECTOR_CMD"
}
function start_discoverd_dhcp {
screen_it ironic-discoverd-dhcp "sudo dnsmasq --conf-file=$IRONIC_DISCOVERD_DHCP_CONF_FILE"
function start_inspector_dhcp {
screen_it ironic-inspector-dhcp \
"sudo dnsmasq --conf-file=$IRONIC_INSPECTOR_DHCP_CONF_FILE"
}
function stop_discoverd {
screen -S $SCREEN_NAME -p ironic-discoverd -X kill
function stop_inspector {
screen -S $SCREEN_NAME -p ironic-inspector -X kill
}
function stop_discoverd_dhcp {
screen -S $SCREEN_NAME -p ironic-discoverd-dhcp -X kill
function stop_inspector_dhcp {
screen -S $SCREEN_NAME -p ironic-inspector-dhcp -X kill
}
### Configuration
function prepare_tftp {
IRONIC_DISCOVERD_IMAGE_PATH="$TOP_DIR/files/ironic-discoverd"
IRONIC_DISCOVERD_KERNEL_PATH="$IRONIC_DISCOVERD_IMAGE_PATH.kernel"
IRONIC_DISCOVERD_INITRAMFS_PATH="$IRONIC_DISCOVERD_IMAGE_PATH.initramfs"
IRONIC_INSPECTOR_IMAGE_PATH="$TOP_DIR/files/ironic-inspector"
IRONIC_INSPECTOR_KERNEL_PATH="$IRONIC_INSPECTOR_IMAGE_PATH.kernel"
IRONIC_INSPECTOR_INITRAMFS_PATH="$IRONIC_INSPECTOR_IMAGE_PATH.initramfs"
if [ ! -e "$IRONIC_DISCOVERD_KERNEL_PATH" -o ! -e "$IRONIC_DISCOVERD_INITRAMFS_PATH" ]; then
if [ ! -e "$IRONIC_INSPECTOR_KERNEL_PATH" -o ! -e "$IRONIC_INSPECTOR_INITRAMFS_PATH" ]; then
if [[ $(type -P ramdisk-image-create) == "" ]]; then
pip_install diskimage_builder
fi
ramdisk-image-create $IRONIC_DISCOVERD_RAMDISK_FLAVOR \
-o $IRONIC_DISCOVERD_IMAGE_PATH
ramdisk-image-create $IRONIC_INSPECTOR_RAMDISK_FLAVOR \
-o $IRONIC_INSPECTOR_IMAGE_PATH
fi
mkdir_chown_stack "$IRONIC_TFTPBOOT_DIR/pxelinux.cfg"
cp $IRONIC_DISCOVERD_KERNEL_PATH $IRONIC_DISCOVERD_INITRAMFS_PATH \
cp $IRONIC_INSPECTOR_KERNEL_PATH $IRONIC_INSPECTOR_INITRAMFS_PATH \
$IRONIC_TFTPBOOT_DIR
cat > "$IRONIC_TFTPBOOT_DIR/pxelinux.cfg/default" <<EOF
default discover
label discover
kernel ironic-discoverd.kernel
append initrd=ironic-discoverd.initramfs discoverd_callback_url=$IRONIC_DISCOVERD_INTERNAL_URI/v1/continue
IRONIC_INSPECTOR_CALLBACK_URI="$IRONIC_INSPECTOR_INTERNAL_URI/v1/continue"
IRONIC_INSPECTOR_KERNEL_CMDLINE="discoverd_callback_url=$IRONIC_INSPECTOR_CALLBACK_URI inspector_callback_url=$IRONIC_INSPECTOR_CALLBACK_URI"
cat > "$IRONIC_TFTPBOOT_DIR/pxelinux.cfg/default" <<EOF
default inspect
label inspect
kernel ironic-inspector.kernel
append initrd=ironic-inspector.initramfs $IRONIC_INSPECTOR_KERNEL_CMDLINE
ipappend 3
EOF
}
function configure_discoverd {
mkdir_chown_stack "$IRONIC_DISCOVERD_CONF_DIR"
mkdir_chown_stack "$IRONIC_DISCOVERD_DATA_DIR"
function configure_inspector {
mkdir_chown_stack "$IRONIC_INSPECTOR_CONF_DIR"
mkdir_chown_stack "$IRONIC_INSPECTOR_DATA_DIR"
create_service_user "$IRONIC_DISCOVERD_ADMIN_USER" "admin"
create_service_user "$IRONIC_INSPECTOR_ADMIN_USER" "admin"
cp "$IRONIC_DISCOVERD_DIR/example.conf" "$IRONIC_DISCOVERD_CONF_FILE"
discoverd_iniset debug $IRONIC_DISCOVERD_DEBUG
discoverd_iniset identity_uri "$KEYSTONE_AUTH_URI"
discoverd_iniset os_auth_url "$KEYSTONE_SERVICE_URI/v2.0"
discoverd_iniset os_username $IRONIC_DISCOVERD_ADMIN_USER
discoverd_iniset os_password $SERVICE_PASSWORD
discoverd_iniset os_tenant_name $SERVICE_TENANT_NAME
cp "$IRONIC_INSPECTOR_DIR/example.conf" "$IRONIC_INSPECTOR_CONF_FILE"
inspector_iniset DEFAULT debug $IRONIC_INSPECTOR_DEBUG
inspector_iniset ironic identity_uri "$KEYSTONE_AUTH_URI"
inspector_iniset ironic os_auth_url "$KEYSTONE_SERVICE_URI/v2.0"
inspector_iniset ironic os_username $IRONIC_INSPECTOR_ADMIN_USER
inspector_iniset ironic os_password $SERVICE_PASSWORD
inspector_iniset ironic os_tenant_name $SERVICE_TENANT_NAME
discoverd_iniset listen_port $IRONIC_DISCOVERD_PORT
discoverd_iniset listen_address 0.0.0.0 # do not change
inspector_iniset DEFAULT listen_port $IRONIC_INSPECTOR_PORT
inspector_iniset DEFAULT listen_address 0.0.0.0 # do not change
discoverd_iniset manage_firewall $IRONIC_DISCOVERD_MANAGE_FIREWALL
discoverd_iniset dnsmasq_interface $IRONIC_DISCOVERD_INTERFACE
discoverd_iniset database $IRONIC_DISCOVERD_DATA_DIR/discoverd.sqlite
inspector_iniset firewall manage_firewall $IRONIC_INSPECTOR_MANAGE_FIREWALL
inspector_iniset firewall dnsmasq_interface $IRONIC_INSPECTOR_INTERFACE
inspector_iniset DEFAULT database $IRONIC_INSPECTOR_DATA_DIR/inspector.sqlite
iniset "$IRONIC_CONF_FILE" discoverd enabled True
iniset "$IRONIC_CONF_FILE" discoverd service_url $IRONIC_DISCOVERD_URI
iniset "$IRONIC_CONF_FILE" inspector enabled True
iniset "$IRONIC_CONF_FILE" inspector service_url $IRONIC_INSPECTOR_URI
}
function configure_discoverd_dhcp {
mkdir_chown_stack "$IRONIC_DISCOVERD_CONF_DIR"
function configure_inspector_dhcp {
mkdir_chown_stack "$IRONIC_INSPECTOR_CONF_DIR"
cat > "$IRONIC_DISCOVERD_DHCP_CONF_FILE" <<EOF
cat > "$IRONIC_INSPECTOR_DHCP_CONF_FILE" <<EOF
no-daemon
port=0
interface=$IRONIC_DISCOVERD_INTERFACE
interface=$IRONIC_INSPECTOR_INTERFACE
bind-interfaces
dhcp-range=$IRONIC_DISCOVERD_DHCP_RANGE
dhcp-range=$IRONIC_INSPECTOR_DHCP_RANGE
dhcp-boot=pxelinux.0
EOF
}
@ -133,66 +138,66 @@ EOF
function prepare_environment {
prepare_tftp
sudo ip link add brbm-discoverd type veth peer name $IRONIC_DISCOVERD_INTERFACE
sudo ip link set dev brbm-discoverd up
sudo ip link set dev $IRONIC_DISCOVERD_INTERFACE up
sudo ovs-vsctl add-port brbm brbm-discoverd
sudo ip addr add $IRONIC_DISCOVERD_INTERNAL_IP_WITH_NET dev $IRONIC_DISCOVERD_INTERFACE
sudo ip link add brbm-inspector type veth peer name $IRONIC_INSPECTOR_INTERFACE
sudo ip link set dev brbm-inspector up
sudo ip link set dev $IRONIC_INSPECTOR_INTERFACE up
sudo ovs-vsctl add-port brbm brbm-inspector
sudo ip addr add $IRONIC_INSPECTOR_INTERNAL_IP_WITH_NET dev $IRONIC_INSPECTOR_INTERFACE
sudo iptables -I INPUT -i $IRONIC_DISCOVERD_INTERFACE -p udp \
sudo iptables -I INPUT -i $IRONIC_INSPECTOR_INTERFACE -p udp \
--dport 69 -j ACCEPT
sudo iptables -I INPUT -i $IRONIC_DISCOVERD_INTERFACE -p tcp \
--dport $IRONIC_DISCOVERD_PORT -j ACCEPT
sudo iptables -I INPUT -i $IRONIC_INSPECTOR_INTERFACE -p tcp \
--dport $IRONIC_INSPECTOR_PORT -j ACCEPT
}
function cleanup_discoverd {
rm -rf $IRONIC_DISCOVERD_DATA_DIR
function cleanup_inspector {
rm -rf $IRONIC_INSPECTOR_DATA_DIR
rm -f $IRONIC_TFTPBOOT_DIR/pxelinux.cfg/default
rm -f $IRONIC_TFTPBOOT_DIR/ironic-discoverd.*
rm -f $IRONIC_TFTPBOOT_DIR/ironic-inspector.*
# Try to clean up firewall rules
sudo iptables -D INPUT -i $IRONIC_DISCOVERD_INTERFACE -p udp \
sudo iptables -D INPUT -i $IRONIC_INSPECTOR_INTERFACE -p udp \
--dport 69 -j ACCEPT | true
sudo iptables -D INPUT -i $IRONIC_DISCOVERD_INTERFACE -p tcp \
--dport $IRONIC_DISCOVERD_PORT -j ACCEPT | true
sudo iptables -D INPUT -i $IRONIC_DISCOVERD_INTERFACE -p udp \
--dport 67 -j discovery | true
sudo iptables -F discovery | true
sudo iptables -X discovery | true
sudo iptables -D INPUT -i $IRONIC_INSPECTOR_INTERFACE -p tcp \
--dport $IRONIC_INSPECTOR_PORT -j ACCEPT | true
sudo iptables -D INPUT -i $IRONIC_INSPECTOR_INTERFACE -p udp \
--dport 67 -j ironic-inspector | true
sudo iptables -F ironic-inspector | true
sudo iptables -X ironic-inspector | true
sudo ip link show $IRONIC_DISCOVERD_INTERFACE && sudo ip link delete $IRONIC_DISCOVERD_INTERFACE
sudo ip link show brbm-discoverd && sudo ip link delete brbm-discoverd
sudo ovs-vsctl --if-exists del-port brbm-discoverd
sudo ip link show $IRONIC_INSPECTOR_INTERFACE && sudo ip link delete $IRONIC_INSPECTOR_INTERFACE
sudo ip link show brbm-inspector && sudo ip link delete brbm-inspector
sudo ovs-vsctl --if-exists del-port brbm-inspector
}
### Entry points
if [[ "$1" == "stack" && "$2" == "install" ]]; then
echo_summary "Installing ironic-discoverd"
if [[ "$IRONIC_DISCOVERD_MANAGE_FIREWALL" == "True" ]]; then
install_discoverd_dhcp
echo_summary "Installing ironic-inspector"
if [[ "$IRONIC_INSPECTOR_MANAGE_FIREWALL" == "True" ]]; then
install_inspector_dhcp
fi
install_discoverd
install_inspector
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
echo_summary "Configuring ironic-discoverd"
cleanup_discoverd
if [[ "$IRONIC_DISCOVERD_MANAGE_FIREWALL" == "True" ]]; then
configure_discoverd_dhcp
echo_summary "Configuring ironic-inspector"
cleanup_inspector
if [[ "$IRONIC_INSPECTOR_MANAGE_FIREWALL" == "True" ]]; then
configure_inspector_dhcp
fi
configure_discoverd
configure_inspector
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
echo_summary "Initializing ironic-discoverd"
echo_summary "Initializing ironic-inspector"
prepare_environment
if [[ "$IRONIC_DISCOVERD_MANAGE_FIREWALL" == "True" ]]; then
start_discoverd_dhcp
if [[ "$IRONIC_INSPECTOR_MANAGE_FIREWALL" == "True" ]]; then
start_inspector_dhcp
fi
start_discoverd
start_inspector
fi
if [[ "$1" == "unstack" ]]; then
stop_discoverd
if [[ "$IRONIC_DISCOVERD_MANAGE_FIREWALL" == "True" ]]; then
stop_discoverd_dhcp
stop_inspector
if [[ "$IRONIC_INSPECTOR_MANAGE_FIREWALL" == "True" ]]; then
stop_inspector_dhcp
fi
cleanup_discoverd
cleanup_inspector
fi

View File

@ -1 +1 @@
enable_service ironic-discoverd ironic-discoverd-dhcp
enable_service ironic-inspector ironic-inspector-dhcp