Skip to content

Instantly share code, notes, and snippets.

View chiradeep's full-sized avatar

Chiradeep Vittal chiradeep

View GitHub Profile
#!/bin/bash
set -x
install_docker() {
curl -fsSL https://get.docker.com/ | sh
systemctl start docker
}
install_etcd() {
@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])
@chiradeep
chiradeep / gist:c66f0e61774a8f62546d
Created May 18, 2015 05:47
Non-working terraform
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 / 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"
Verifying myself: My Bitcoin username is +chiradeep. https://onename.io/chiradeep
@chiradeep
chiradeep / cfgdiff.py
Created June 5, 2014 06:02
Python script to diff 2 global configurations in CloudStack
# This script takes 2 json files as input. The json file describes the global configuration of a CloudStack installation
# To generate a json file of the configuration, use cloudmonkey:
#
# cloudmonkey -c staging.cfg
# > set display json
# > exit
# cloudmonkey -c production.cfg
# > set display json
# > exit
# cloudmonkey -c staging.cfg list configurations > staging.json
@chiradeep
chiradeep / provision.rb
Created April 29, 2014 18:05
Ruby script to ssh into base wheezy template and install stuff necessary for systemvm
#!/usr/bin/env ruby
require 'rubygems'
require 'net/ssh'
host = ''
user = 'root'
pass = 'root'
options = {}
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: provision.rb IP [options]"
@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 / postinstall_lxc.sh
Created April 29, 2014 00:48
post-install for a debian wheezy lxc container that installs stuff necessary for a systemvm
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@chiradeep
chiradeep / gist:10442766
Created April 11, 2014 05:46
Patch to get AWS Ruby SDK v1.34.1 working with Apache CloudStack awsapi module v4.2.1
--- aws-sdk-1.34.1-original/lib/aws/core/client.rb 2014-04-10 22:07:31.722036263 -0700
+++ aws-sdk-1.34.1/lib/aws/core/client.rb 2014-04-10 22:10:49.538138111 -0700
@@ -551,6 +551,9 @@
http_request.service_ruby_name = service_ruby_name
http_request.host = endpoint
http_request.port = port
+ if AWS.config.respond_to?("#{service_ruby_name}_service_path")
+ http_request.uri = config.send(:"#{service_ruby_name}_service_path")
+ end
http_request.region = @region