Boto3 get main route table

This entry is part 6 of 6 in the series Boto

While developing Botoform I ran into an issue with Boto3 where I couldn’t easily get the “main” route table of a VPC. I ended up adding a get_main_route_table method to do the duty. def get_main_route_table(self): “””Return the main (default) route table for VPC.””” main_route_table = [] for route_table in list(self.route_tables.all()): for association in list(route_table.associations.all()): if […]

List all installed package names in Python

pkgs = lambda : list(__import__(‘pkg_resources’).working_set) pkg_names = lambda : [x.project_name for x in pkgs()] pkg_versions = lambda : [x.project_name + ‘==’ + x.version for x in pkgs()] >>> pkg_names() [‘ansible’, ‘pycrypto’, ‘PyYAML’, ‘Jinja2’, ‘…truncated…’, ‘virt-back’, ‘Werkzeug’, ‘xmltodict’] >>> pkg_versions() [‘ansible==1.7’, ‘pycrypto==2.6.1’, ‘…truncated…’, ‘virt-back==0.1.0’, ‘xmltodict==0.9.2’]

Filtering AWS resources with Boto3

This entry is part 1 of 6 in the series Boto

This post will be updated frequently when as I learn more about how to filter AWS resources using Boto3 library. Filtering VPCs by tags In this example we want to filter a particular VPC by the “Name” tag with the value of ‘webapp01’. >>> import boto3 >>> boto3.setup_default_session(profile_name=’project1′) >>> ec2 = boto3.resource(‘ec2′, region_name=’us-west-2’) >>> filters […]

Working with botocore’s ~/.aws/config

This entry is part 2 of 6 in the series Boto

I ran into a bug in botocore and this post will serve to document a work around as well as show how to use botocore session object to work with the values stored in ~/.aws/config. Pretend you have an aws config with two accounts for two separate projects, like so: *~/.aws/config:* [profile project1] account_id = […]

My Mentor

The original purpose of this post was to recognize the teachers and mentors which have helped shape me. I planned to write about how Mr. Cassidy, my high school drafting teacher, taught me the importance precision. I prepared to explain how Mr. Mercuri, my college computer science professor, ignited my desire to engineer software. But […]

SmartOS Ubuntu guest, apt-get not working because IPv6

Turns out I don’t have IPv6 setup properly in my network so when apt attempts to connect to the Internet it tries IPv6 and fails. To disable IPv6 on the ubuntu guest, add this to end of /etc/sysctl.conf and restart the guest: sudo vim /etc/sysctl.conf: net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 This […]

A Python script which searches for available interpreters

This entry is part 5 of 6 in the series Boto

This post describes how to write a polyglot — in this case a script which runs as valid Bash or Python, to search for available Python interpreters. The script initially runs as Bash but upon finding a first match, the script will call itself again this time using the expected Python interpreter in interactive mode! […]

Migrating libvirt KVM guest to SmartOS KVM guest

The following tutorial documents how to migrate a libvirt/KVM guest from Ubuntu to SmartOS. akuma: Ubuntu Hypervisor guy: SmartOS Hypervisor sagat: guest to migrate These commands were run on akuma: WORKDIR=/KVMROOT/migrate sudo mkdir $WORKDIR cd $WORKDIR # this tool simply stops and tarballs up the qcow and xml for libvirt KVM guest. sudo /usr/local/bin/virt-back –path=$WORKDIR […]

Setting region programmatically in Boto3

This entry is part 3 of 6 in the series Boto

At work I’m looking into the possibility of porting parts of our AWS automation codebase from Boto2 to Boto3. We desire to perform this port because Boto2’s record and result pagination appears defective. I started to familiarize myself with Boto3 by using the Interactive Python interpreter. Here I show myself trying to connect to the […]

Securely publish Jenkins build artifacts on Salt Master

Do you want a secure setup for publishing and staging build artifacts from a Jenkins build server to a Salt Master? This guide describes my fully automated pipeline to transport binaries using Salt’s encrypted “bus”. We start off with some Salt States to stand up a Jenkins build server “client”: jenkins/client.sls: # # manage […]