Skip to content

Instantly share code, notes, and snippets.

View chiradeep's full-sized avatar

Chiradeep Vittal chiradeep

View GitHub Profile
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<label t="translate(0,346)">
@chiradeep
chiradeep / policy_export.py
Last active July 15, 2018 23:53
Export existing content switching policies and cs vserver into NetScaler Ansible playbook
import requests
from collections import OrderedDict
import yaml
import yamlloader
cs_vserver = 'test_csvserver'
ns_host = 'localhost:32769'
ns_login = 'nsroot'
ns_password= 'nsroot'
url = 'http://%s/nitro/v1/config/csvserver_cspolicy_binding/%s' % (ns_host, cs_vserver)
{
"$schema": "https://vega.github.io/schema/vega/v4.json",
"width": 720,
"height": 720,
"padding": 5,
"autosize": "none",
"signals": [
{
"name": "labels", "value": true,
@chiradeep
chiradeep / gist:80a76a661309b193a458351814bf398f
Created September 21, 2018 16:38
Watch for changes in Endpoints using K8s native Python client
from kubernetes import client, config, watch
config.load_kube_config()
api_v1 = client.CoreV1Api()
def watch_endpoints():
w = watch.Watch()
for event in w.stream(api_v1.list_namespaced_endpoints, "default"):
print(event)
#!/bin/bash
set -x
master_ip=$1
ipaddr=$(ip addr show dev eth0 | grep "inet " | cut -d ' ' -f 6 | cut -f 1 -d '/')
is_master=${2:-"true"}
[ -n "$master_ip" ] || exit 1
@chiradeep
chiradeep / create-lxc-systemvm.sh
Last active October 23, 2019 19:41
LXC script to initiate build of CloudStack LXC systemvm
#!/bin/bash
# tested on Ubuntu 14.04
#set -x
sudo lxc-create --template=debian --name=systemvm -- --release=wheezy
sudo lxc-start -n systemvm -d
sleep 2
ip=$(sudo lxc-info -n systemvm -i | awk '{print $2}')
#start provisioning using ssh
@chiradeep
chiradeep / citrix-k8s-cpx-ingress.yaml
Last active November 21, 2019 06:39
Deploy Citrix CPX as an Ingress Controller with Prometheus monitoring
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: cpx-ingress-k8s-role
rules:
- apiGroups: [""]
resources: ["services", "endpoints", "ingresses", "pods", "secrets"]
verbs: ["*"]
- apiGroups: ["extensions"]
@chiradeep
chiradeep / gist:eb4367f7b03bebe412a3
Last active January 11, 2020 22:56
Working terraform VPC config
provider "cloudstack" {
api_url = "http://localhost:8080/client/api"
api_key = "tZTPtxAfbZfTrIiIDe4XHfZupjlCoVYy3JnIfvlqyxWvHbVJ9TDw8UWxQ_INj6r5NWGglLMYHX4hN33sMuoI1g"
secret_key = "9u1bizzTQrfhnp3Y_Cs-Zu9uiOr-nAmRcN5Eo6Pp8dlbeKgq_V0TqUqhDdDGgrXFqzT8yZ731UUPTPDeFKLzzQ"
}
resource "cloudstack_vpc" "default" {
name = "test-vpc"
display_text = "test-vpc"
cidr = "10.0.0.0/16"
@chiradeep
chiradeep / generate_haproxy_cfg.py
Created August 10, 2016 19:02
Simple Jinja2 template to generate HAProxy cfg
from jinja2 import Environment, FileSystemLoader
def render_haproxy_cfg(services):
env = Environment(loader=FileSystemLoader ('templates'), trim_blocks=True)
templ = env.get_template('haproxy.jinja2.cfg')
outp = templ.render(services=services)
outp = templ.render(services=services)
with open('haproxy.cfg', 'wb') as f:
f.write(outp)
@chiradeep
chiradeep / idling.py
Last active February 14, 2022 04:35
boto script to find and stop idle instances
import argparse
import boto3
import datetime
from dateutil.tz import tzutc
def is_in_autoscale_group(region, instance_id):
asg = boto3.client('autoscaling', region_name=region)
instances = \
asg.describe_auto_scaling_instances(InstanceIds=[instance_id])