Make all prints python3 compatible
Change-Id: Ie5a08859010453d276b42253f5f2130f80b82224
This commit is contained in:
parent
d0b32ed88a
commit
fdcc9b7e0e
@ -41,7 +41,7 @@ ceph --cluster "${CLUSTER}" -v
|
|||||||
# Env. variables matching the pattern "<module>_" will be
|
# Env. variables matching the pattern "<module>_" will be
|
||||||
# found and parsed for config-key settings by
|
# found and parsed for config-key settings by
|
||||||
# ceph config set mgr mgr/<module>/<key> <value>
|
# 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
|
for module in ${ENABLED_MODULES}; do
|
||||||
# This module may have been enabled in the past
|
# This module may have been enabled in the past
|
||||||
|
@ -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))))
|
min_pg_num = int(math.pow(2, math.floor(math.log(raw_pg_num, 2))))
|
||||||
|
|
||||||
if min_pg_num >= (raw_pg_num * 0.75):
|
if min_pg_num >= (raw_pg_num * 0.75):
|
||||||
print min_pg_num
|
print(min_pg_num)
|
||||||
else:
|
else:
|
||||||
print max_pg_num
|
print(max_pg_num)
|
||||||
|
@ -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})
|
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}"
|
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_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
|
ceph --cluster "${CLUSTER}" osd pool set-quota "${POOL_NAME}" max_bytes $POOL_QUOTA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -30,21 +30,21 @@ def extract_mons_from_kubeapi():
|
|||||||
current_mons = extract_mons_from_monmap()
|
current_mons = extract_mons_from_monmap()
|
||||||
expected_mons = extract_mons_from_kubeapi()
|
expected_mons = extract_mons_from_kubeapi()
|
||||||
|
|
||||||
print "current mons:", current_mons
|
print("current mons: %s" % current_mons)
|
||||||
print "expected mons:", expected_mons
|
print("expected mons: %s" % expected_mons)
|
||||||
|
|
||||||
for mon in current_mons:
|
for mon in current_mons:
|
||||||
removed_mon = False
|
removed_mon = False
|
||||||
if not mon in expected_mons:
|
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])
|
subprocess.call(["ceph", "--cluster", os.environ["NAMESPACE"], "mon", "remove", mon])
|
||||||
removed_mon = True
|
removed_mon = True
|
||||||
elif current_mons[mon] != expected_mons[mon]: # check if for some reason the ip of the mon changed
|
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])
|
subprocess.call(["kubectl", "--namespace", os.environ["NAMESPACE"], "delete", "pod", mon])
|
||||||
removed_mon = True
|
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:
|
if not removed_mon:
|
||||||
print "no zombie mons found ..."
|
print("no zombie mons found ...")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
@ -6,7 +6,7 @@ import sys
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
if (int(len(sys.argv)) == 1):
|
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)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
poolName = sys.argv[1]
|
poolName = sys.argv[1]
|
||||||
@ -14,7 +14,7 @@ else:
|
|||||||
objectRep = subprocess.check_output(cmdRep, shell=True)
|
objectRep = subprocess.check_output(cmdRep, shell=True)
|
||||||
repOut = json.loads(objectRep)
|
repOut = json.loads(objectRep)
|
||||||
osdNumbers = repOut['up']
|
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= []
|
osdHosts= []
|
||||||
for osd in osdNumbers:
|
for osd in osdNumbers:
|
||||||
@ -24,7 +24,8 @@ else:
|
|||||||
osdHostLocation = osdHost['crush_location']
|
osdHostLocation = osdHost['crush_location']
|
||||||
osdHosts.append(osdHostLocation['host'])
|
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)
|
sys.exit(0)
|
||||||
|
@ -7,7 +7,7 @@ set -ex
|
|||||||
result=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
result=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
||||||
-XPUT "${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_template/{{$template}}" \
|
-XPUT "${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_template/{{$template}}" \
|
||||||
-H 'Content-Type: application/json' -d @/tmp/{{$template}}.json \
|
-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
|
if [ "$result" == "True" ]; then
|
||||||
echo "{{$template}} template created!"
|
echo "{{$template}} template created!"
|
||||||
else
|
else
|
||||||
|
@ -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" ];
|
if [ "$index_result" == "True" ];
|
||||||
then
|
then
|
||||||
echo "PASS: Test index created!";
|
echo "PASS: Test index created!";
|
||||||
@ -59,7 +59,7 @@ function check_templates () {
|
|||||||
{{ range $template, $fields := .Values.conf.templates }}
|
{{ range $template, $fields := .Values.conf.templates }}
|
||||||
{{$template}}_total_hits=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
{{$template}}_total_hits=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
||||||
-XGET "${ELASTICSEARCH_ENDPOINT}/_template/{{$template}}" -H 'Content-Type: application/json' \
|
-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
|
if [ "${{$template}}_total_hits" -gt 0 ]; then
|
||||||
echo "PASS: Successful hits on {{$template}} template!"
|
echo "PASS: Successful hits on {{$template}} template!"
|
||||||
else
|
else
|
||||||
|
@ -36,7 +36,7 @@ function register_snapshot_repository() {
|
|||||||
"access_key": "'"$S3_ACCESS_KEY"'",
|
"access_key": "'"$S3_ACCESS_KEY"'",
|
||||||
"secret_key": "'"$S3_SECRET_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" ];
|
if [ "$result" == "True" ];
|
||||||
then
|
then
|
||||||
echo "Snapshot repository $1 created!";
|
echo "Snapshot repository $1 created!";
|
||||||
|
@ -21,7 +21,7 @@ set -ex
|
|||||||
function endpoints_up () {
|
function endpoints_up () {
|
||||||
endpoints_result=$(curl -K- <<< "--user ${PROMETHEUS_ADMIN_USERNAME}:${PROMETHEUS_ADMIN_PASSWORD}" \
|
endpoints_result=$(curl -K- <<< "--user ${PROMETHEUS_ADMIN_USERNAME}:${PROMETHEUS_ADMIN_PASSWORD}" \
|
||||||
"${PROMETHEUS_ENDPOINT}/api/v1/query?query=up" \
|
"${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" ];
|
if [ "$endpoints_result" = "success" ];
|
||||||
then
|
then
|
||||||
echo "PASS: Endpoints successfully queried!"
|
echo "PASS: Endpoints successfully queried!"
|
||||||
@ -34,7 +34,7 @@ function endpoints_up () {
|
|||||||
function get_targets () {
|
function get_targets () {
|
||||||
targets_result=$(curl -K- <<< "--user ${PROMETHEUS_ADMIN_USERNAME}:${PROMETHEUS_ADMIN_PASSWORD}" \
|
targets_result=$(curl -K- <<< "--user ${PROMETHEUS_ADMIN_USERNAME}:${PROMETHEUS_ADMIN_PASSWORD}" \
|
||||||
"${PROMETHEUS_ENDPOINT}/api/v1/targets" \
|
"${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" ];
|
if [ "$targets_result" = "success" ];
|
||||||
then
|
then
|
||||||
echo "PASS: Targets successfully queried!"
|
echo "PASS: Targets successfully queried!"
|
||||||
@ -47,7 +47,7 @@ function get_targets () {
|
|||||||
function get_alertmanagers () {
|
function get_alertmanagers () {
|
||||||
alertmanager=$(curl -K- <<< "--user ${PROMETHEUS_ADMIN_USERNAME}:${PROMETHEUS_ADMIN_PASSWORD}" \
|
alertmanager=$(curl -K- <<< "--user ${PROMETHEUS_ADMIN_USERNAME}:${PROMETHEUS_ADMIN_PASSWORD}" \
|
||||||
"${PROMETHEUS_ENDPOINT}/api/v1/alertmanagers" \
|
"${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" ];
|
if [ "$alertmanager" = "success" ];
|
||||||
then
|
then
|
||||||
echo "PASS: Alertmanager successfully queried!"
|
echo "PASS: Alertmanager successfully queried!"
|
||||||
|
@ -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" ];
|
if [ "$index_result" == "True" ];
|
||||||
then
|
then
|
||||||
echo "$1's index successfully created!";
|
echo "$1's index successfully created!";
|
||||||
@ -48,7 +48,7 @@ function insert_test_data () {
|
|||||||
"name" : "Elasticsearch",
|
"name" : "Elasticsearch",
|
||||||
"message" : "Test data text entry"
|
"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
|
if [ "$insert_result" == "created" ]; then
|
||||||
sleep 20
|
sleep 20
|
||||||
echo "Test data inserted into $1's index!";
|
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
|
if [ "$total_hits" -gt 0 ]; then
|
||||||
echo "Successful hits on test data query on $1's index!"
|
echo "Successful hits on test data query on $1's index!"
|
||||||
else
|
else
|
||||||
|
@ -19,7 +19,7 @@ if [ "x${ACTION}" == "xgenerate-join-cmd" ]; then
|
|||||||
: ${TTL:="10m"}
|
: ${TTL:="10m"}
|
||||||
DISCOVERY_TOKEN="$(kubeadm token --kubeconfig /etc/kubernetes/admin.conf create --ttl ${TTL} --usages signing,authentication --groups '')"
|
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:/')"
|
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 \
|
exec echo "kubeadm join \
|
||||||
--token ${DISCOVERY_TOKEN} \
|
--token ${DISCOVERY_TOKEN} \
|
||||||
--discovery-token-ca-cert-hash ${DISCOVERY_TOKEN_CA_HASH} \
|
--discovery-token-ca-cert-hash ${DISCOVERY_TOKEN_CA_HASH} \
|
||||||
|
Loading…
Reference in New Issue
Block a user