Skip to content

Instantly share code, notes, and snippets.

View grafuls's full-sized avatar
🐍
Hissing

Gonzalo Rafuls grafuls

🐍
Hissing
  • Red Hat, Inc
  • Czech Republic
View GitHub Profile
@grafuls
grafuls / quads_cprofile_trace_2019-03-15.txt
Created March 15, 2019 20:29 — forked from sadsfae/quads_cprofile_trace_2019-03-15.txt
cProfile Python trace of quads-cli
(root@quads) - (20:16) - (~)
-=>>python -m cProfile /opt/quads/bin/quads-cli --full-summary
cloud01: 0 (Initializing cloud)
cloud02: 20 (Real Shift on stack)
cloud03: 0 (Initializing cloud)
cloud04: 0 (Initializing cloud)
cloud05: 0 (Initializing cloud)
cloud06: 0 (Initializing cloud)
cloud07: 0 (Initializing cloud)
cloud08: 0 (Initializing cloud)
@grafuls
grafuls / copy_ssh_key.py
Created February 4, 2019 20:49
Copy ssh pub key to authorized keys file on remote host
from paramiko import SSHClient, AutoAddPolicy
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Execute ls on remote host')
parser.add_argument('--host', dest='host', type=str, default=None, help='Remote host')
parser.add_argument('--user', dest='user', type=str, default=None, help='Remote user')
parser.add_argument('--passwd', dest='passwd', type=str, default=None, help='Remote pass')
parser.add_argument('--ssh-key', dest='ssh_key', type=str, default=None, help='Public SSH Key')
_args = parser.parse_args()
@grafuls
grafuls / ssh_remote.py
Created February 4, 2019 19:43
Example for remote execution with paramiko
import paramiko
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Execute ls on remote host')
parser.add_argument('--host', dest='host', type=str, default=None, help='Remote host')
parser.add_argument('--user', dest='user', type=str, default=None, help='Remote user')
parser.add_argument('--passwd', dest='passwd', type=str, default=None, help='Remote pass')
_args = parser.parse_args()
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$tvvGFEPf$rRtRXMNAteB4KjEAZ2s4Z/
# System language
lang en_US
# Reboot after installation
reboot
@grafuls
grafuls / redfish.py
Last active September 24, 2018 08:28
Client tool for changing boot order and setting next boot to PXE via Redfish API
#! /usr/bin/env python
import argparse
import json
import re
import requests
import sys
import time
import warnings
import yaml
@grafuls
grafuls / kubevirt_mem.sh
Last active August 31, 2018 13:27
Reporting memory consumption for libdvirtd on kubevirt VMIs
#!/bin/bash
vhid=$(pgrep virt-handler)
vcid=$(pgrep virt-controller)
vaid=$(pgrep virt-api)
for id in $vhid $vcid $vaid; do
if [ -f /proc/$id/smaps ]; then
echo
if (( $id == $vhid )); then
proc="Virt-handler"
@grafuls
grafuls / grafana-prometheus-dashboard.json
Created August 22, 2018 13:51
Grafana Dashboard for Prometheus
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@grafuls
grafuls / prom-configmap.yaml
Created August 22, 2018 13:30
Configuration map for Prometheus OCP deployment
apiVersion: v1
kind: ConfigMap
metadata:
name: prom-k8s
data:
alerting.rules: |
groups:
- name: example-rules
interval: 30s # defaults to global interval
rules:
@grafuls
grafuls / BZ1608842-remedy.sh
Last active August 9, 2018 14:08
BZ1608842-remedy.sh
#!/usr/bin/env bash
TOKEN=$(oc whoami -t)
podman login docker-registry.default.svc:5000 -u test_admin -p $TOKEN
git clone https://github.com/ansibleplaybookbundle/import-vm-apb.git && cd import-vm-apb
docker build -t docker-registry.default.svc:5000/openshift/import-vm-apb:latest .
docker save docker-registry.default.svc:5000/openshift/import-vm-apb:latest -o import-vm-apb.tar
podman import import-vm-apb.tar docker-registry.default.svc:5000/openshift/import-vm-apb:latest
@grafuls
grafuls / async_ssh_tasks.py
Created June 23, 2018 16:26
asyncssh example
import asyncio, asyncssh, sys
class MySSHClientSession(asyncssh.SSHClientSession):
def data_received(self, data, datatype):
print(data, end='')
def connection_lost(self, exc):
if exc:
print('SSH session error: ' + str(exc), file=sys.stderr)