Skip to content

Instantly share code, notes, and snippets.

View tomellis's full-sized avatar

Tom Ellis tomellis

View GitHub Profile
@tomellis
tomellis / get-ip-output
Created May 1, 2013 15:35
Intermittent connection issue
# Successful request output
trellis@debian:~/rackspace-cloud-env$ python get-ip.py
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): lon.servers.api.rackspacecloud.com
DEBUG:requests.packages.urllib3.connectionpool:"GET /v2/xxxxx/servers/detail HTTP/1.1" 200 1643
Name: xxxx
ID: xxxx
Public IP: 1.2.3.4
# Unsuccessful request output
@tomellis
tomellis / gist:5531859
Created May 7, 2013 11:05
Rax Ansible
- name: Launch a server in rax cloud # playbook name
hosts: local # target local host
connection: local # run actions locally
gather_facts: false # forget gathering facts, this is our local system
tasks:
- name: Create a server # task name
local_action:
module: rax # module to use
creds_file: /home/trellis/creds # path to your credentials
@tomellis
tomellis / gist:5531886
Created May 7, 2013 11:11
Add DNS with pyrax to Rackspace Cloud
import os
import logging
import sys
import pyrax
import pyrax.exceptions as exc
logging.basicConfig(level=logging.DEBUG)
@tomellis
tomellis / gist:5531894
Created May 7, 2013 11:13
Get IP out of Rackspace cloud
#!/usr/bin/env python
import os
import sys
import logging
import pyrax
import pyrax.exceptions as exc
import exceptions
import hmac
from hashlib import sha1
from time import time
path = 'v1/MossoCloudFS_db3a5ebc-f7dd-4108-ab6e-a0bc7b3fbc93/test'
redirect = 'http://mysite.com/thanks.html'
max_file_size = 104857600
max_file_count = 10
expires = int(time() + 600)
print "expires: "
import hmac
from hashlib import sha1
from time import time
path = '/v1/MossoCloudFS_XXXXXXXX/test'
redirect = 'done.html'
max_file_size = 104857600
max_file_count = 10
#expires = int(time() + 600)
expires = 1590835786
<html>
<form action="https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_XXXXXXX/test" method="POST" enctype="multipart/form-data">
<input type="hidden" name="redirect" value="done.htmlm" />
<input type="hidden" name="max_file_size" value="104857600" />
<input type="hidden" name="max_file_count" value="10" />
<input type="hidden" name="expires" value="1590835786" />
<input type="hidden" name="signature" value="XXXXX" />
<input type="file" name="file1" /><br />
<input type="submit" />
</html>
<html>
<form action="https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_XXXXXXX/test" method="POST" enctype="multipart/form-data">
<input type="hidden" name="redirect" value="done.html" />
<input type="hidden" name="max_file_size" value="104857600" />
<input type="hidden" name="max_file_count" value="10" />
<input type="hidden" name="expires" value="1590835786" />
<input type="hidden" name="signature" value="XXXXX" />
<input type="file" name="file1" /><br />
<input type="submit" />
</html>
@tomellis
tomellis / gist:6103852
Created July 29, 2013 11:59
RPC Environment Configuration
{
"name": "grizzly",
"description": "",
"cookbook_versions": {
},
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
},
"override_attributes": {
@tomellis
tomellis / match-az.sh
Created April 4, 2018 08:55
Matching EC2 Availability Zones Across AWS Accounts in 2018
#!/bin/bash
for region in `aws ec2 describe-regions --output text --query 'Regions[*].[RegionName]'`; do
aws ec2 describe-reserved-instances-offerings --region $region --output text --query 'ReservedInstancesOfferings[*].[AvailabilityZone,ReservedInstancesOfferingId]' --offering-type 'No Upfront' --instance-tenancy default --no-include-marketplace --instance-type m4.large --max-duration 31536000 --offering-class standard --product-description Linux/UNIX | grep -v 'None' | sort -n
done