Merge "introduce if/then & for/do rules"
This commit is contained in:
commit
116999b221
@ -431,8 +431,7 @@ function upload_baremetal_image() {
|
|||||||
|
|
||||||
function clear_baremetal_of_all_nodes() {
|
function clear_baremetal_of_all_nodes() {
|
||||||
list=$(nova baremetal-node-list | awk -F '| ' 'NR>3 {print $2}' )
|
list=$(nova baremetal-node-list | awk -F '| ' 'NR>3 {print $2}' )
|
||||||
for node in $list
|
for node in $list; do
|
||||||
do
|
|
||||||
nova baremetal-node-delete $node
|
nova baremetal-node-delete $node
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
3
lib/heat
3
lib/heat
@ -186,8 +186,7 @@ function disk_image_create {
|
|||||||
local elements=$2
|
local elements=$2
|
||||||
local arch=$3
|
local arch=$3
|
||||||
local output=$TOP_DIR/files/$4
|
local output=$TOP_DIR/files/$4
|
||||||
if [[ -f "$output.qcow2" ]];
|
if [[ -f "$output.qcow2" ]]; then
|
||||||
then
|
|
||||||
echo "Image file already exists: $output_file"
|
echo "Image file already exists: $output_file"
|
||||||
else
|
else
|
||||||
ELEMENTS_PATH=$elements_path disk-image-create \
|
ELEMENTS_PATH=$elements_path disk-image-create \
|
||||||
|
@ -44,16 +44,14 @@ function neutron_plugin_configure_plugin_agent() {
|
|||||||
function neutron_plugin_configure_service() {
|
function neutron_plugin_configure_service() {
|
||||||
iniset /$Q_PLUGIN_CONF_FILE restproxy servers $BS_FL_CONTROLLERS_PORT
|
iniset /$Q_PLUGIN_CONF_FILE restproxy servers $BS_FL_CONTROLLERS_PORT
|
||||||
iniset /$Q_PLUGIN_CONF_FILE restproxy servertimeout $BS_FL_CONTROLLER_TIMEOUT
|
iniset /$Q_PLUGIN_CONF_FILE restproxy servertimeout $BS_FL_CONTROLLER_TIMEOUT
|
||||||
if [ "$BS_FL_VIF_DRIVER" = "ivs" ]
|
if [ "$BS_FL_VIF_DRIVER" = "ivs" ]; then
|
||||||
then
|
|
||||||
iniset /$Q_PLUGIN_CONF_FILE nova vif_type ivs
|
iniset /$Q_PLUGIN_CONF_FILE nova vif_type ivs
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function neutron_plugin_setup_interface_driver() {
|
function neutron_plugin_setup_interface_driver() {
|
||||||
local conf_file=$1
|
local conf_file=$1
|
||||||
if [ "$BS_FL_VIF_DRIVER" = "ivs" ]
|
if [ "$BS_FL_VIF_DRIVER" = "ivs" ]; then
|
||||||
then
|
|
||||||
iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.IVSInterfaceDriver
|
iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.IVSInterfaceDriver
|
||||||
else
|
else
|
||||||
iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
|
iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
|
||||||
|
@ -106,8 +106,7 @@ function _neutron_setup_ovs_tunnels() {
|
|||||||
local id=0
|
local id=0
|
||||||
GRE_LOCAL_IP=${GRE_LOCAL_IP:-$HOST_IP}
|
GRE_LOCAL_IP=${GRE_LOCAL_IP:-$HOST_IP}
|
||||||
if [ -n "$GRE_REMOTE_IPS" ]; then
|
if [ -n "$GRE_REMOTE_IPS" ]; then
|
||||||
for ip in ${GRE_REMOTE_IPS//:/ }
|
for ip in ${GRE_REMOTE_IPS//:/ }; do
|
||||||
do
|
|
||||||
if [[ "$ip" == "$GRE_LOCAL_IP" ]]; then
|
if [[ "$ip" == "$GRE_LOCAL_IP" ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
3
lib/neutron_thirdparty/bigswitch_floodlight
vendored
3
lib/neutron_thirdparty/bigswitch_floodlight
vendored
@ -24,8 +24,7 @@ function init_bigswitch_floodlight() {
|
|||||||
sudo ovs-vsctl --no-wait br-set-external-id ${OVS_BRIDGE} bridge-id ${OVS_BRIDGE}
|
sudo ovs-vsctl --no-wait br-set-external-id ${OVS_BRIDGE} bridge-id ${OVS_BRIDGE}
|
||||||
|
|
||||||
ctrls=
|
ctrls=
|
||||||
for ctrl in `echo ${BS_FL_CONTROLLERS_PORT} | tr ',' ' '`
|
for ctrl in `echo ${BS_FL_CONTROLLERS_PORT} | tr ',' ' '`; do
|
||||||
do
|
|
||||||
ctrl=${ctrl%:*}
|
ctrl=${ctrl%:*}
|
||||||
ctrls="${ctrls} tcp:${ctrl}:${BS_FL_OF_PORT}"
|
ctrls="${ctrls} tcp:${ctrl}:${BS_FL_OF_PORT}"
|
||||||
done
|
done
|
||||||
|
4
stack.sh
4
stack.sh
@ -1124,8 +1124,8 @@ fi
|
|||||||
# Create a randomized default value for the keymgr's fixed_key
|
# Create a randomized default value for the keymgr's fixed_key
|
||||||
if is_service_enabled nova; then
|
if is_service_enabled nova; then
|
||||||
FIXED_KEY=""
|
FIXED_KEY=""
|
||||||
for i in $(seq 1 64);
|
for i in $(seq 1 64); do
|
||||||
do FIXED_KEY+=$(echo "obase=16; $(($RANDOM % 16))" | bc);
|
FIXED_KEY+=$(echo "obase=16; $(($RANDOM % 16))" | bc);
|
||||||
done;
|
done;
|
||||||
iniset $NOVA_CONF keymgr fixed_key "$FIXED_KEY"
|
iniset $NOVA_CONF keymgr fixed_key "$FIXED_KEY"
|
||||||
fi
|
fi
|
||||||
|
@ -49,8 +49,7 @@ function test_enable_service() {
|
|||||||
|
|
||||||
ENABLED_SERVICES="$start"
|
ENABLED_SERVICES="$start"
|
||||||
enable_service $add
|
enable_service $add
|
||||||
if [ "$ENABLED_SERVICES" = "$finish" ]
|
if [ "$ENABLED_SERVICES" = "$finish" ]; then
|
||||||
then
|
|
||||||
echo "OK: $start + $add -> $ENABLED_SERVICES"
|
echo "OK: $start + $add -> $ENABLED_SERVICES"
|
||||||
else
|
else
|
||||||
echo "changing $start to $finish with $add failed: $ENABLED_SERVICES"
|
echo "changing $start to $finish with $add failed: $ENABLED_SERVICES"
|
||||||
@ -76,8 +75,7 @@ function test_disable_service() {
|
|||||||
|
|
||||||
ENABLED_SERVICES="$start"
|
ENABLED_SERVICES="$start"
|
||||||
disable_service "$del"
|
disable_service "$del"
|
||||||
if [ "$ENABLED_SERVICES" = "$finish" ]
|
if [ "$ENABLED_SERVICES" = "$finish" ]; then
|
||||||
then
|
|
||||||
echo "OK: $start - $del -> $ENABLED_SERVICES"
|
echo "OK: $start - $del -> $ENABLED_SERVICES"
|
||||||
else
|
else
|
||||||
echo "changing $start to $finish with $del failed: $ENABLED_SERVICES"
|
echo "changing $start to $finish with $del failed: $ENABLED_SERVICES"
|
||||||
@ -102,8 +100,7 @@ echo "Testing disable_all_services()"
|
|||||||
ENABLED_SERVICES=a,b,c
|
ENABLED_SERVICES=a,b,c
|
||||||
disable_all_services
|
disable_all_services
|
||||||
|
|
||||||
if [[ -z "$ENABLED_SERVICES" ]]
|
if [[ -z "$ENABLED_SERVICES" ]]; then
|
||||||
then
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
echo "disabling all services FAILED: $ENABLED_SERVICES"
|
echo "disabling all services FAILED: $ENABLED_SERVICES"
|
||||||
@ -118,8 +115,7 @@ function test_disable_negated_services() {
|
|||||||
|
|
||||||
ENABLED_SERVICES="$start"
|
ENABLED_SERVICES="$start"
|
||||||
disable_negated_services
|
disable_negated_services
|
||||||
if [ "$ENABLED_SERVICES" = "$finish" ]
|
if [ "$ENABLED_SERVICES" = "$finish" ]; then
|
||||||
then
|
|
||||||
echo "OK: $start + $add -> $ENABLED_SERVICES"
|
echo "OK: $start + $add -> $ENABLED_SERVICES"
|
||||||
else
|
else
|
||||||
echo "changing $start to $finish failed: $ENABLED_SERVICES"
|
echo "changing $start to $finish failed: $ENABLED_SERVICES"
|
||||||
|
@ -21,9 +21,19 @@
|
|||||||
# Currently Supported checks
|
# Currently Supported checks
|
||||||
#
|
#
|
||||||
# Errors
|
# Errors
|
||||||
|
# Basic white space errors, for consistent indenting
|
||||||
# - E001: check that lines do not end with trailing whitespace
|
# - E001: check that lines do not end with trailing whitespace
|
||||||
# - E002: ensure that indents are only spaces, and not hard tabs
|
# - E002: ensure that indents are only spaces, and not hard tabs
|
||||||
# - E003: ensure all indents are a multiple of 4 spaces
|
# - E003: ensure all indents are a multiple of 4 spaces
|
||||||
|
#
|
||||||
|
# Structure errors
|
||||||
|
#
|
||||||
|
# A set of rules that help keep things consistent in control blocks.
|
||||||
|
# These are ignored on long lines that have a continuation, because
|
||||||
|
# unrolling that is kind of "interesting"
|
||||||
|
#
|
||||||
|
# - E010: *do* not on the same line as *for*
|
||||||
|
# - E011: *then* not on the same line as *if*
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import fileinput
|
import fileinput
|
||||||
@ -51,6 +61,23 @@ def print_error(error, line):
|
|||||||
print(" - %s: L%s" % (fileinput.filename(), fileinput.filelineno()))
|
print(" - %s: L%s" % (fileinput.filename(), fileinput.filelineno()))
|
||||||
|
|
||||||
|
|
||||||
|
def not_continuation(line):
|
||||||
|
return not re.search('\\\\$', line)
|
||||||
|
|
||||||
|
def check_for_do(line):
|
||||||
|
if not_continuation(line):
|
||||||
|
if re.search('^\s*for ', line):
|
||||||
|
if not re.search(';\s*do(\b|$)', line):
|
||||||
|
print_error('E010: Do not on same line as for', line)
|
||||||
|
|
||||||
|
|
||||||
|
def check_if_then(line):
|
||||||
|
if not_continuation(line):
|
||||||
|
if re.search('^\s*if \[', line):
|
||||||
|
if not re.search(';\s*then(\b|$)', line):
|
||||||
|
print_error('E011: Then non on same line as if', line)
|
||||||
|
|
||||||
|
|
||||||
def check_no_trailing_whitespace(line):
|
def check_no_trailing_whitespace(line):
|
||||||
if re.search('[ \t]+$', line):
|
if re.search('[ \t]+$', line):
|
||||||
print_error('E001: Trailing Whitespace', line)
|
print_error('E001: Trailing Whitespace', line)
|
||||||
@ -100,6 +127,8 @@ def check_files(files):
|
|||||||
|
|
||||||
check_no_trailing_whitespace(logical_line)
|
check_no_trailing_whitespace(logical_line)
|
||||||
check_indents(logical_line)
|
check_indents(logical_line)
|
||||||
|
check_for_do(logical_line)
|
||||||
|
check_if_then(logical_line)
|
||||||
|
|
||||||
|
|
||||||
def get_options():
|
def get_options():
|
||||||
|
@ -194,8 +194,7 @@ function wait_for_VM_to_halt() {
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
state=$(xe_min vm-list name-label="$GUEST_NAME" power-state=halted)
|
state=$(xe_min vm-list name-label="$GUEST_NAME" power-state=halted)
|
||||||
if [ -n "$state" ]
|
if [ -n "$state" ]; then
|
||||||
then
|
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo -n "."
|
echo -n "."
|
||||||
|
@ -63,8 +63,7 @@ get_params()
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
if [[ -z $BRIDGE ]]
|
if [[ -z $BRIDGE ]]; then
|
||||||
then
|
|
||||||
BRIDGE=xenbr0
|
BRIDGE=xenbr0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -91,8 +90,7 @@ xe_min()
|
|||||||
find_network()
|
find_network()
|
||||||
{
|
{
|
||||||
result=$(xe_min network-list bridge="$1")
|
result=$(xe_min network-list bridge="$1")
|
||||||
if [ "$result" = "" ]
|
if [ "$result" = "" ]; then
|
||||||
then
|
|
||||||
result=$(xe_min network-list name-label="$1")
|
result=$(xe_min network-list name-label="$1")
|
||||||
fi
|
fi
|
||||||
echo "$result"
|
echo "$result"
|
||||||
@ -121,8 +119,7 @@ destroy_vifs()
|
|||||||
{
|
{
|
||||||
local v="$1"
|
local v="$1"
|
||||||
IFS=,
|
IFS=,
|
||||||
for vif in $(xe_min vif-list vm-uuid="$v")
|
for vif in $(xe_min vif-list vm-uuid="$v"); do
|
||||||
do
|
|
||||||
xe vif-destroy uuid="$vif"
|
xe vif-destroy uuid="$vif"
|
||||||
done
|
done
|
||||||
unset IFS
|
unset IFS
|
||||||
|
@ -7,8 +7,7 @@ declare -a on_exit_hooks
|
|||||||
|
|
||||||
on_exit()
|
on_exit()
|
||||||
{
|
{
|
||||||
for i in $(seq $((${#on_exit_hooks[*]} - 1)) -1 0)
|
for i in $(seq $((${#on_exit_hooks[*]} - 1)) -1 0); do
|
||||||
do
|
|
||||||
eval "${on_exit_hooks[$i]}"
|
eval "${on_exit_hooks[$i]}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -17,8 +16,7 @@ add_on_exit()
|
|||||||
{
|
{
|
||||||
local n=${#on_exit_hooks[*]}
|
local n=${#on_exit_hooks[*]}
|
||||||
on_exit_hooks[$n]="$*"
|
on_exit_hooks[$n]="$*"
|
||||||
if [[ $n -eq 0 ]]
|
if [[ $n -eq 0 ]]; then
|
||||||
then
|
|
||||||
trap on_exit EXIT
|
trap on_exit EXIT
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -227,16 +227,14 @@ function test_get_local_sr_path {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ "$1" = "run_tests" ] && {
|
[ "$1" = "run_tests" ] && {
|
||||||
for testname in $($0)
|
for testname in $($0); do
|
||||||
do
|
|
||||||
echo "$testname"
|
echo "$testname"
|
||||||
before_each_test
|
before_each_test
|
||||||
(
|
(
|
||||||
set -eux
|
set -eux
|
||||||
$testname
|
$testname
|
||||||
)
|
)
|
||||||
if [ "$?" != "0" ]
|
if [ "$?" != "0" ]; then
|
||||||
then
|
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user