Skip to content

Instantly share code, notes, and snippets.

View jriguera's full-sized avatar

José Riguera Lopez jriguera

View GitHub Profile
@jriguera
jriguera / external_net.sh
Created November 17, 2015 16:02
Defining external networks on OpenStack
# Load the admin credentials
. /root/openrc
# Creating the external network type VLAN with VLAND ID == 300 (Online_dev).
# The name of the provider physical_network "ext" is mapped to a physical
# device on the ML2 configuration file of each network node
neutron net-create \
--provider:network_type vlan \
--provider:physical_network ext \
--router:external \
@jriguera
jriguera / ksm.sh
Created November 14, 2015 16:14
KSM
#!/usr/bin/env bash
cat <<EOF
http://www.kernel.org/doc/Documentation/vm/ksm.txt :
The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/:
pages_shared - how many shared pages are being used
pages_sharing - how many more sites are sharing them i.e. how much saved
pages_unshared - how many pages unique but repeatedly checked for merging
pages_volatile - how many pages changing too fast to be placed in a tree
@jriguera
jriguera / opensource.txt
Created August 23, 2015 23:07
Howto opensource a project ... or howto keep your configuration not public
GITHUB_URL = Public repo on GitHub.
BITBUCKET_URL = Private repo on Bitbucket.
Given a upstream repo on GitHub in order to clone it to Bitbucket to keep
the configuration non public (for example, to create specific ansible playbooks
with a set of roles), do this (only once!).
1. Create a new repo on Bitbucket. (BITBUCKET_URL)
2. Clone the upstream repo from Github to your local machine: git clone GITHUB_URL
3. git remote rename origin upstream BITBUCKET_URL
@jriguera
jriguera / strace.txt
Last active August 29, 2015 14:26
strace examples
# Examples
# Debug syscalls for a daemon
strace -e poll,select,connect,recvfrom,sendto nc www.news.com 80
# Attach to process and sent to output.txt
strace -c -p 11084 -o output.txt
# Check permissions
strace -e open,read,access ls 2>&1 | grep your-filename
@jriguera
jriguera / deploy_role.txt
Created July 14, 2015 19:20
How to deploy a single role without create a specific playbook
Create a playbook called deploy_role.yml:
- hosts: {{ hosts }}
roles: {{ roles }}
And then you can do:
ansible-playbook deploy_role.yml -e hosts=somehost -e roles=somerole
@jriguera
jriguera / delete_nova.sh
Last active August 29, 2015 14:23
Delete nova compute node
root@node-11:~# nova hypervisor-list
+----+--------------------------+
| ID | Hypervisor hostname |
+----+--------------------------+
| 3 | node-8 |
| 6 | node-12 |
| 9 | node-15 |
+----+--------------------------+
@jriguera
jriguera / nova_scheduler_options.txt
Created June 10, 2015 08:35
Openstack nova Scheduler
# To control the way the scheduler select the host where running a vm:
# Default value is 1.0, negative means that will pack vms on one host
ram_weight_multiplier = -1.0
@jriguera
jriguera / pretty_wget_download.sh
Created June 7, 2015 12:22
Pretty download wrapper for wget
#!/usr/bin/env bash
download() {
local url="$1"
local destin="$2"
echo -n " "
if [ ! -z "${destin}" ]; then
wget --progress=dot "${url}" -O "${destin}" 2>&1 | grep --line-buffered "%" | \
sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
@jriguera
jriguera / s3.java
Created April 28, 2015 14:32
S3 test in java
import java.io.ByteArrayInputStream;
import java.io.File;
import java.util.List;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.util.StringUtils;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.CannedAccessControlList;
@jriguera
jriguera / openstack_cli_create_tenant.sh
Created April 27, 2015 11:17
Example of a creation of a new tenant in OpenStack using the command line
#!/bin/bash
TENANT=cf
PASSWORD=cf
TENANT_DESC="Cloud Foundry"
TENANT_EMAIL="cloud-foundry@springer.com"
TENANT_NET="10.0.1.0/24"
TENANT_NET_GW="10.0.1.1"
export OS_USERNAME=admin