From ae49084c179265d2d326a3c11f2651b639466fb6 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Thu, 9 Jun 2022 10:10:49 +0100 Subject: [PATCH] Add a few more scripts --- .gitignore | 1 + README.md | 38 ++++++++++++++++++++++++++++++++++++++ check_mongo2.sh | 18 ++++++++++++++++++ test_juju.py | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100755 check_mongo2.sh create mode 100755 test_juju.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e964dda --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vault-token.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..a60442c --- /dev/null +++ b/README.md @@ -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 + diff --git a/check_mongo2.sh b/check_mongo2.sh new file mode 100755 index 0000000..0c45867 --- /dev/null +++ b/check_mongo2.sh @@ -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}" diff --git a/test_juju.py b/test_juju.py new file mode 100755 index 0000000..4b2d4db --- /dev/null +++ b/test_juju.py @@ -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())