diff --git a/ceph-client/templates/bin/mgr/_start.sh.tpl b/ceph-client/templates/bin/mgr/_start.sh.tpl index ebab6b9a1..680328aef 100644 --- a/ceph-client/templates/bin/mgr/_start.sh.tpl +++ b/ceph-client/templates/bin/mgr/_start.sh.tpl @@ -41,7 +41,7 @@ ceph --cluster "${CLUSTER}" -v # Env. variables matching the pattern "_" will be # found and parsed for config-key settings by # ceph config set mgr mgr// -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 diff --git a/ceph-client/templates/bin/pool/_calc.py.tpl b/ceph-client/templates/bin/pool/_calc.py.tpl index 897b0efd3..a56e8cb79 100644 --- a/ceph-client/templates/bin/pool/_calc.py.tpl +++ b/ceph-client/templates/bin/pool/_calc.py.tpl @@ -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) diff --git a/ceph-client/templates/bin/pool/_init.sh.tpl b/ceph-client/templates/bin/pool/_init.sh.tpl index b40cb1159..4fcd6e6ab 100644 --- a/ceph-client/templates/bin/pool/_init.sh.tpl +++ b/ceph-client/templates/bin/pool/_init.sh.tpl @@ -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 } diff --git a/ceph-mon/templates/bin/moncheck/_reap-zombies.py.tpl b/ceph-mon/templates/bin/moncheck/_reap-zombies.py.tpl index 546f20c1f..f83f726e3 100644 --- a/ceph-mon/templates/bin/moncheck/_reap-zombies.py.tpl +++ b/ceph-mon/templates/bin/moncheck/_reap-zombies.py.tpl @@ -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 ...") diff --git a/ceph-mon/templates/bin/utils/_checkObjectReplication.py.tpl b/ceph-mon/templates/bin/utils/_checkObjectReplication.py.tpl index 0b87c7f2d..ce4037bc2 100755 --- a/ceph-mon/templates/bin/utils/_checkObjectReplication.py.tpl +++ b/ceph-mon/templates/bin/utils/_checkObjectReplication.py.tpl @@ -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 " + print("Please provide pool name to test , example: checkObjectReplication.py ") 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) diff --git a/elasticsearch/templates/bin/_create_template.sh.tpl b/elasticsearch/templates/bin/_create_template.sh.tpl index f071a2639..22ee33f82 100644 --- a/elasticsearch/templates/bin/_create_template.sh.tpl +++ b/elasticsearch/templates/bin/_create_template.sh.tpl @@ -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 diff --git a/elasticsearch/templates/bin/_helm-tests.sh.tpl b/elasticsearch/templates/bin/_helm-tests.sh.tpl index 877659232..0f0e55965 100644 --- a/elasticsearch/templates/bin/_helm-tests.sh.tpl +++ b/elasticsearch/templates/bin/_helm-tests.sh.tpl @@ -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 diff --git a/elasticsearch/templates/bin/_register-repository.sh.tpl b/elasticsearch/templates/bin/_register-repository.sh.tpl index 175c853f4..decb2bc86 100644 --- a/elasticsearch/templates/bin/_register-repository.sh.tpl +++ b/elasticsearch/templates/bin/_register-repository.sh.tpl @@ -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!"; diff --git a/prometheus/templates/bin/_helm-tests.sh.tpl b/prometheus/templates/bin/_helm-tests.sh.tpl index bc2c9e448..70d3a7953 100644 --- a/prometheus/templates/bin/_helm-tests.sh.tpl +++ b/prometheus/templates/bin/_helm-tests.sh.tpl @@ -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!" diff --git a/tools/deployment/osh-infra-logging/055-elasticsearch-ldap.sh b/tools/deployment/osh-infra-logging/055-elasticsearch-ldap.sh index c7166a9c1..b5a9d5816 100755 --- a/tools/deployment/osh-infra-logging/055-elasticsearch-ldap.sh +++ b/tools/deployment/osh-infra-logging/055-elasticsearch-ldap.sh @@ -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 diff --git a/tools/images/kubeadm-aio/assets/entrypoint.sh b/tools/images/kubeadm-aio/assets/entrypoint.sh index 05561f3fd..23db9897b 100755 --- a/tools/images/kubeadm-aio/assets/entrypoint.sh +++ b/tools/images/kubeadm-aio/assets/entrypoint.sh @@ -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} \