Merge "Make all prints python3 compatible"

This commit is contained in:
Zuul 2019-10-01 21:32:23 +00:00 committed by Gerrit Code Review
commit b401a2283b
11 changed files with 28 additions and 27 deletions

View File

@ -41,7 +41,7 @@ ceph --cluster "${CLUSTER}" -v
# Env. variables matching the pattern "<module>_" will be
# found and parsed for config-key settings by
# ceph config set mgr mgr/<module>/<key> <value>
MODULES_TO_DISABLE=`ceph mgr dump | python -c "import json, sys; print ' '.join(json.load(sys.stdin)['modules'])"`
MODULES_TO_DISABLE=`ceph mgr dump | python -c "import json, sys; print(' '.join(json.load(sys.stdin)['modules']))"`
for module in ${ENABLED_MODULES}; do
# This module may have been enabled in the past

View File

@ -41,6 +41,6 @@ max_pg_num = int(math.pow(2, math.ceil(math.log(raw_pg_num, 2))))
min_pg_num = int(math.pow(2, math.floor(math.log(raw_pg_num, 2))))
if min_pg_num >= (raw_pg_num * 0.75):
print min_pg_num
print(min_pg_num)
else:
print max_pg_num
print(max_pg_num)

View File

@ -137,7 +137,7 @@ function manage_pool () {
POOL_PLACEMENT_GROUPS=$(/tmp/pool-calc.py ${POOL_REPLICATION} ${TOTAL_OSDS} ${TOTAL_DATA_PERCENT} ${TARGET_PG_PER_OSD})
create_pool "${POOL_APPLICATION}" "${POOL_NAME}" "${POOL_REPLICATION}" "${POOL_PLACEMENT_GROUPS}" "${POOL_CRUSH_RULE}" "${POOL_PROTECTION}"
POOL_REPLICAS=$(ceph --cluster "${CLUSTER}" osd pool get "${POOL_NAME}" size | awk '{print $2}')
POOL_QUOTA=$(python -c "print int($CLUSTER_CAPACITY * $TOTAL_DATA_PERCENT * $TARGET_QUOTA / $POOL_REPLICAS / 100 / 100)")
POOL_QUOTA=$(python -c "print(int($CLUSTER_CAPACITY * $TOTAL_DATA_PERCENT * $TARGET_QUOTA / $POOL_REPLICAS / 100 / 100))")
ceph --cluster "${CLUSTER}" osd pool set-quota "${POOL_NAME}" max_bytes $POOL_QUOTA
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python
import re
import os
import subprocess
@ -30,21 +30,21 @@ def extract_mons_from_kubeapi():
current_mons = extract_mons_from_monmap()
expected_mons = extract_mons_from_kubeapi()
print "current mons:", current_mons
print "expected mons:", expected_mons
print("current mons: %s" % current_mons)
print("expected mons: %s" % expected_mons)
for mon in current_mons:
removed_mon = False
if not mon in expected_mons:
print "removing zombie mon ", mon
print("removing zombie mon %s" % mon)
subprocess.call(["ceph", "--cluster", os.environ["NAMESPACE"], "mon", "remove", mon])
removed_mon = True
elif current_mons[mon] != expected_mons[mon]: # check if for some reason the ip of the mon changed
print "ip change dedected for pod ", mon
print("ip change detected for pod %s" % mon)
subprocess.call(["kubectl", "--namespace", os.environ["NAMESPACE"], "delete", "pod", mon])
removed_mon = True
print "deleted mon %s via the kubernetes api" % mon
print("deleted mon %s via the kubernetes api" % mon)
if not removed_mon:
print "no zombie mons found ..."
print("no zombie mons found ...")

View File

@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python
import subprocess
import json
@ -6,7 +6,7 @@ import sys
import collections
if (int(len(sys.argv)) == 1):
print "Please provide pool name to test , example: checkObjectReplication.py <pool name>"
print("Please provide pool name to test , example: checkObjectReplication.py <pool name>")
sys.exit(1)
else:
poolName = sys.argv[1]
@ -14,7 +14,7 @@ else:
objectRep = subprocess.check_output(cmdRep, shell=True)
repOut = json.loads(objectRep)
osdNumbers = repOut['up']
print "Test object got replicated on these osds:" + " " + str(osdNumbers)
print("Test object got replicated on these osds: %s" % str(osdNumbers))
osdHosts= []
for osd in osdNumbers:
@ -24,7 +24,8 @@ else:
osdHostLocation = osdHost['crush_location']
osdHosts.append(osdHostLocation['host'])
print "Test object got replicated on these hosts:" + " " + str(osdHosts)
print("Test object got replicated on these hosts: %s" % str(osdHosts))
print "Hosts hosting multiple copies of a placement groups are:" + str([item for item, count in collections.Counter(osdHosts).items() if count > 1])
print("Hosts hosting multiple copies of a placement groups are: %s" %
str([item for item, count in collections.Counter(osdHosts).items() if count > 1]))
sys.exit(0)

View File

@ -7,7 +7,7 @@ set -ex
result=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
-XPUT "${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_template/{{$template}}" \
-H 'Content-Type: application/json' -d @/tmp/{{$template}}.json \
| python -c "import sys, json; print json.load(sys.stdin)['acknowledged']")
| python -c "import sys, json; print(json.load(sys.stdin)['acknowledged'])")
if [ "$result" == "True" ]; then
echo "{{$template}} template created!"
else

View File

@ -28,7 +28,7 @@ function create_test_index () {
}
}
}
' | python -c "import sys, json; print json.load(sys.stdin)['acknowledged']")
' | python -c "import sys, json; print(json.load(sys.stdin)['acknowledged'])")
if [ "$index_result" == "True" ];
then
echo "PASS: Test index created!";
@ -59,7 +59,7 @@ function check_templates () {
{{ range $template, $fields := .Values.conf.templates }}
{{$template}}_total_hits=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
-XGET "${ELASTICSEARCH_ENDPOINT}/_template/{{$template}}" -H 'Content-Type: application/json' \
| python -c "import sys, json; print len(json.load(sys.stdin))")
| python -c "import sys, json; print(len(json.load(sys.stdin)))")
if [ "${{$template}}_total_hits" -gt 0 ]; then
echo "PASS: Successful hits on {{$template}} template!"
else

View File

@ -36,7 +36,7 @@ function register_snapshot_repository() {
"access_key": "'"$S3_ACCESS_KEY"'",
"secret_key": "'"$S3_SECRET_KEY"'"
}
}' | python -c "import sys, json; print json.load(sys.stdin)['acknowledged']")
}' | python -c "import sys, json; print(json.load(sys.stdin)['acknowledged'])")
if [ "$result" == "True" ];
then
echo "Snapshot repository $1 created!";

View File

@ -21,7 +21,7 @@ set -ex
function endpoints_up () {
endpoints_result=$(curl -K- <<< "--user ${PROMETHEUS_ADMIN_USERNAME}:${PROMETHEUS_ADMIN_PASSWORD}" \
"${PROMETHEUS_ENDPOINT}/api/v1/query?query=up" \
| python -c "import sys, json; print json.load(sys.stdin)['status']")
| python -c "import sys, json; print(json.load(sys.stdin)['status'])")
if [ "$endpoints_result" = "success" ];
then
echo "PASS: Endpoints successfully queried!"
@ -34,7 +34,7 @@ function endpoints_up () {
function get_targets () {
targets_result=$(curl -K- <<< "--user ${PROMETHEUS_ADMIN_USERNAME}:${PROMETHEUS_ADMIN_PASSWORD}" \
"${PROMETHEUS_ENDPOINT}/api/v1/targets" \
| python -c "import sys, json; print json.load(sys.stdin)['status']")
| python -c "import sys, json; print(json.load(sys.stdin)['status'])")
if [ "$targets_result" = "success" ];
then
echo "PASS: Targets successfully queried!"
@ -47,7 +47,7 @@ function get_targets () {
function get_alertmanagers () {
alertmanager=$(curl -K- <<< "--user ${PROMETHEUS_ADMIN_USERNAME}:${PROMETHEUS_ADMIN_PASSWORD}" \
"${PROMETHEUS_ENDPOINT}/api/v1/alertmanagers" \
| python -c "import sys, json; print json.load(sys.stdin)['status']")
| python -c "import sys, json; print(json.load(sys.stdin)['status'])")
if [ "$alertmanager" = "success" ];
then
echo "PASS: Alertmanager successfully queried!"

View File

@ -30,7 +30,7 @@ function create_index () {
}
}
}
' | python -c "import sys, json; print json.load(sys.stdin)['acknowledged']")
' | python -c "import sys, json; print(json.load(sys.stdin)['acknowledged'])")
if [ "$index_result" == "True" ];
then
echo "$1's index successfully created!";
@ -48,7 +48,7 @@ function insert_test_data () {
"name" : "Elasticsearch",
"message" : "Test data text entry"
}
' | python -c "import sys, json; print json.load(sys.stdin)['result']")
' | python -c "import sys, json; print(json.load(sys.stdin)['result'])")
if [ "$insert_result" == "created" ]; then
sleep 20
echo "Test data inserted into $1's index!";
@ -72,7 +72,7 @@ function check_hits () {
}
}
}
' | python -c "import sys, json; print json.load(sys.stdin)['hits']['total']")
' | python -c "import sys, json; print(json.load(sys.stdin)['hits']['total'])")
if [ "$total_hits" -gt 0 ]; then
echo "Successful hits on test data query on $1's index!"
else

View File

@ -19,7 +19,7 @@ if [ "x${ACTION}" == "xgenerate-join-cmd" ]; then
: ${TTL:="10m"}
DISCOVERY_TOKEN="$(kubeadm token --kubeconfig /etc/kubernetes/admin.conf create --ttl ${TTL} --usages signing,authentication --groups '')"
DISCOVERY_TOKEN_CA_HASH="$(openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* /sha256:/')"
API_SERVER=$(cat /etc/kubernetes/admin.conf | python -c "import sys, yaml; print yaml.safe_load(sys.stdin)['clusters'][0]['cluster']['server'].split(\"//\",1).pop()")
API_SERVER=$(cat /etc/kubernetes/admin.conf | python -c "import sys, yaml; print(yaml.safe_load(sys.stdin)['clusters'][0]['cluster']['server'].split(\"//\",1).pop())")
exec echo "kubeadm join \
--token ${DISCOVERY_TOKEN} \
--discovery-token-ca-cert-hash ${DISCOVERY_TOKEN_CA_HASH} \