#!/bin/bash

echo "Running local.sh"

set -o xtrace

openrc=/home/stack/devstack/openrc
authorized_keys_file=/home/stack/.ssh/authorized_keys

source "$openrc"

if is_service_enabled n-api; then
    # Extract valid public key into tmp file to work around the issue,
    # introduced by puppet adding comments in the beginning of authorized_keys
    pubkey_file=`mktemp`
    grep -vE '^\s*#' "$authorized_keys_file" | head -n 1 > "$pubkey_file"

    for user in admin demo; do
        source "$openrc" "$user" "$user"
        openstack keypair create --public-key "$pubkey_file" default
        openstack security group rule create --proto icmp --dst-port -1 --src-ip 0.0.0.0/0 default
        openstack security group rule create --proto tcp --dst-port 22 --src-ip 0.0.0.0/0 default
    done

    # Tmp file cleanup
    rm -f "$pubkey_file"
fi

#!/bin/bash

echo "Running local.sh"

set -o xtrace

openrc=/home/stack/devstack/openrc
authorized_keys_file=/home/stack/.ssh/authorized_keys

source "$openrc"

if is_service_enabled n-api; then
    # Extract valid public key into tmp file to work around the issue,
    # introduced by puppet adding comments in the beginning of authorized_keys
    pubkey_file=`mktemp`
    grep -vE '^\s*#' "$authorized_keys_file" | head -n 1 > "$pubkey_file"

    for user in admin demo; do
        source "$openrc" "$user" "$user"
        openstack keypair create --public-key "$pubkey_file" default
        openstack security group rule create --proto icmp --dst-port -1 --remote-ip 0.0.0.0/0 default
        openstack security group rule create --proto tcp --dst-port 22 --remote-ip 0.0.0.0/0 default
    done

    # Tmp file cleanup
    rm -f "$pubkey_file"
fi

Change to use --remote-ip with security group rules
Change to use --remote-ip with security group rules

--src-ip was deprecated in 2016, change to use --remote-ip.
Related to https://review.opendev.org/#/c/613644/

Change-Id: I6b9f17c94bdf9de070d5f2e32e97dff600a3545a
