Add a few more scripts

This commit is contained in:
Arif Ali 2022-06-09 10:10:49 +01:00
parent e2dd85c8d7
commit ae49084c17
Signed by: arif
GPG Key ID: 369608FBA1353A70
4 changed files with 93 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
vault-token.txt

38
README.md Normal file
View File

@ -0,0 +1,38 @@
# Documeent on these scripts
## Arif's lab specific
`fix_cloud_focal.sh`
`fix_cloud.sh`
## Generic scripts
`check_juju.sh`
Does a `juju status` anc discards active, idle units htat are green
`check_mongo.sh`
logs into a juju controller directly onto mongodb, below are the 2 arguments that will be taken
1. machine-id (0)
1. model-name (controller)
`check_queues.sh`
checks to see if the queues are balanced on all juju controllers.
`check_vip_issue_db.sh`
debug-relations.sh
get_all_ips.sh
get_all_relation_info.sh
get_charm_versions.sh
get_details.sh
get_passwords.sh
get_relation_info.py
grab_vips.sh
reset.sh
test_juju.py
vault_init.sh
vault.sh

18
check_mongo2.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
machine=${1:-0}
model=${2:-controller}
read -d '' -r cmds <<'EOF'
user=$(sudo ls /var/lib/juju/agents/)
conf=/var/lib/juju/agents/${user}/agent.conf
password=$(sudo grep statepassword ${conf} | cut -d' ' -f2)
if [ -f /usr/lib/juju/mongo*/bin/mongo ]; then
client=/usr/lib/juju/mongo*/bin/mongo
else
client=/usr/bin/mongo
fi
${client} 127.0.0.1:37017/juju --authenticationDatabase admin --ssl --sslAllowInvalidCertificates --username "${user}" --password "${password}" --eval "rs.status()" | grep -P '(name|stateStr)'
EOF
juju ssh -m ${model} ${machine} "${cmds}"

36
test_juju.py Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python3
import asyncio
from juju.controller import Controller
from juju.client.connection import Connection
from juju.client.client import ClientFacade
async def _this_get_model():
controller = Controller()
endpoint="10.0.1.226:17070"
cacert_path="/home/arif/gitRepos/useful_scripts/controller_cert.crt"
cacert=open(cacert_path,'r').read()
model_uuid="8d65d934-7527-4a72-8774-941bf2be4cc2"
password="hello123"
username="admin"
#max_frame_size=8388608
max_frame_size=4194304
conn = await Connection.connect(endpoint=endpoint, uuid=model_uuid,
cacert=cacert, username=username,
password=password, max_frame_size=max_frame_size)
client = ClientFacade.from_connection(conn)
patterns = None
status = await client.FullStatus(patterns)
print(status)
await conn.close()
async def main():
await _this_get_model()
if __name__ == '__main__':
asyncio.run(main())