Skip to content

Instantly share code, notes, and snippets.

@aravindavk
aravindavk / dirname_from_gfid.py
Last active February 24, 2016 08:46
To find directory path from GFID. Usage: python dirname_from_gfid.py <BRICK_ROOT> <GFID>
#!/usr/bin/env python
import os
import sys
ROOT_GFID = "00000000-0000-0000-0000-000000000001"
def symlink_gfid_to_path(brick, gfid):
"""
Each directories are symlinked to file named GFID
@aravindavk
aravindavk / Main.elm
Last active June 23, 2016 13:33
elm-lang JS port Example - Sending Elm Record as JS Object
-- ELM VERSION 0.17.0
port module Converter exposing (..)
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (..)
-- MAIN
@aravindavk
aravindavk / crawl_and_worker.py
Created May 29, 2017 11:09
Crawl and Worker
# Popen find command and start a thread to distribute the load
from errno import ENOENT
import logging
import os
import subprocess
import sys
from threading import Thread, RLock
import time
outfile = None
@aravindavk
aravindavk / cli.md
Last active August 31, 2017 08:21
Glusterd2 CLI and Plugin

Gd2 exposes REST APIs and CLI is one consumer of these APIs.

+------------+                                          +--------------------+
|    gd2     |------REST APIs---------------------------| restclient --- CLI |
+------------+                                          +--------------------+

restclient is a Go library available in github.com/gluster/glusterd2/pkg/restclient

To add a CLI subcommand,

@aravindavk
aravindavk / watch_stime.py
Created September 7, 2017 12:20
Watch stime Geo-replication
import xattr
import struct
import sys
from datetime import datetime
DEFAULT_STATUS = "-"
def human_time(ts):
try:
import sys
defines = {
"VKEY_DIAG_LAT_MEASUREMENT" : "diagnostics.latency-measurement",
"VKEY_DIAG_CNT_FOP_HITS" : "diagnostics.count-fop-hits",
"AUTH_ALLOW_MAP_KEY" : "auth.allow",
"AUTH_REJECT_MAP_KEY" : "auth.reject",
"SSL_OWN_CERT_OPT" : "ssl.own-cert",
"SSL_PRIVATE_KEY_OPT" : "ssl.private-key",
"SSL_CA_LIST_OPT" : "ssl.ca-list",
openapi: 3.0.0
info:
title: Gluster Management APIs
description: Gluster Peer and Volume Management APIs
version: 1
servers:
- url: http://gluster.example.com/v1
description: Gluster node
paths:
/volumes:
@aravindavk
aravindavk / glustercli-auth-header.py
Last active July 17, 2018 05:56
Glusterd2 REST API Authentication Helper script for curl
#!/usr/bin/python3
import sys
from datetime import datetime, timedelta
import jwt
def jwt_token(user, secret):
claims = dict()

Gluster Management APIs

Gluster Management APIs

Get Volumes information

URL

/volumes

HTTP Method

get

# Collects the stats of PVC claims created in Kubernetes
# Install dependencies using `pip3 install kubernetes`
# Run this file and redirect the output to a file
# KUBECONFIG=<path_to_kube_config> python3 pv_claims_stats.py > data.txt
# For example, kubeconfig file will be available in the gcs/deploy directory
# KUBECONFIG=/root/gcs/deploy/kubeconfig python3 pv_claims_stats.py > data.txt
import time
from datetime import datetime
from kubernetes import client, config