Skip to content

Instantly share code, notes, and snippets.

@toravir
toravir / helloEs.py
Created April 4, 2020 03:03
Python Client For Elasticsearch
from elasticsearch import Elasticsearch
indexName='tstidx1'
es = Elasticsearch([{'host':'sprint.cisco.com', 'port':9200}])
es.info()
indexBody= {
"settings" : {
"number_of_shards": 1,
"number_of_replicas" : 0
@toravir
toravir / create_vagrant_network_lab_with_maas_uefi.sh
Last active March 21, 2020 14:05 — forked from ruzickap/create_vagrant_network_lab_with_maas_uefi.sh
Create Vagrant lab environment with 3 separated networks with 3 VMs running MAAS and building 2 UEFI based VMs
# Centos may not have dnf - so install it first and update
yum install dnf
dnf update
# Install Vagrant and virsh command
dnf install -y libvirt-client vagrant-hostmanager vagrant-libvirt
# Allow to manage VMs via libvirt remotely (using TCP connection)
cat >> /etc/libvirt/libvirtd.conf << EOF
@toravir
toravir / httpFS.go
Created March 16, 2020 05:17
Golang HTTP File Server With DELETE
package main
import (
"net/http"
"fmt"
"os"
)
func main() {
mux := http.NewServeMux()
@toravir
toravir / notes.txt
Created February 28, 2020 01:07
libvirt / KVM Cheatsheet
List Partitions in a QCOW2:
virt-filesystems -a /var/lib/libvirt/images/vpod1.qcow2 -l
Mount a Specific Partition from qcow2:
guestmount --ro -a /var/lib/libvirt/images/vpod1.qcow2 -m /dev/vg_ifc0/root /mnt/gm
guestunmount /mnt/gm
Create/Attach/Detach Disks:
@toravir
toravir / hypervisorType.py
Last active February 4, 2020 20:42
Get Hypervisor Type (assumes you are running IN a vm) - does not check if it is running on bare metal..
from __future__ import print_function
import socket
import ctypes
from ctypes import c_uint32, c_int, c_long, c_ulong, c_size_t, c_void_p, POINTER, CFUNCTYPE
class CPUID_struct(ctypes.Structure):
_fields_ = [(r, c_uint32) for r in ("eax", "ebx", "ecx", "edx")]
@toravir
toravir / Logs.md
Last active January 31, 2020 01:03
VPP Fib ipv4 Debugging

For Example, if you are programming a route to fib 1.2.3.4/24, you will find these entries at these indices:

Suppose this route is to be added into fib table with (fib_index of 10) - get the fib pointer

#1 Get Fib pointer

(gdb) set $fib_idx=0
(gdb) ptype ip4_main.v4_fibs[$fib_idx]
type = struct ip4_fib_t_ {
@toravir
toravir / find_delta.c
Created January 25, 2020 15:00
Finding Dela from different snapshots..
#include <stdio.h>
#include <stdlib.h>
typedef struct hentry_st_ {
struct hentry_st_ *next;
int data;
} hentry;
typedef struct htable_st_ {
hentry **arr;
@toravir
toravir / 01_vpp_type5.py
Last active December 20, 2019 20:55
VPP Install BGP Type 5 Route
#!/usr/bin/env python2.7
from __future__ import print_function
import os
import fnmatch
import socket
from vpp_papi import VPP, mac_pton
@toravir
toravir / gomockvpp.go
Last active September 4, 2019 06:58
VPP mock example
package main
import (
"fmt"
"github.com/FDio/govpp/adapter/mock"
"github.com/FDio/govpp"
"try1/binapi/vpe"
)
//go:generate binapi-generator --input-file=./vppApiJson/vpe.api.json --output-dir=binapi
package main
import (
"fmt"
"github.com/gorilla/mux"
"net"
"net/http"
)
func returnFj(w http.ResponseWriter, r *http.Request) {