Skip to content

Commit

Permalink
Preserving my changes
Browse files Browse the repository at this point in the history
Conflicts:
	boto/route53/connection.py
  • Loading branch information
Jay Deiman committed Dec 19, 2012
2 parents 05cb516 + 412c2e9 commit 5eceafc
Show file tree
Hide file tree
Showing 106 changed files with 5,895 additions and 1,027 deletions.
26 changes: 22 additions & 4 deletions bin/elbadmin
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,30 @@ def get(elb, name):

print

# Make map of all instance Id's to Name tags
ec2 = boto.connect_ec2()

instance_health = b.get_instance_health()
instances = [state.instance_id for state in instance_health]

names = {}
for r in ec2.get_all_instances(instances):
for i in r.instances:
names[i.id] = i.tags.get('Name', '')

name_column_width = max([4] + [len(v) for k,v in names.iteritems()]) + 2

print "Instances"
print "---------"
print "%-12s %-15s %s" % ("ID", "STATE", "DESCRIPTION")
for state in b.get_instance_health():
print "%-12s %-15s %s" % (state.instance_id, state.state,
state.description)
print "%-12s %-15s %-*s %s" % ("ID",
"STATE",
name_column_width, "NAME",
"DESCRIPTION")
for state in instance_health:
print "%-12s %-15s %-*s %s" % (state.instance_id,
state.state,
name_column_width, names[state.instance_id],
state.description)

print

Expand Down
34 changes: 20 additions & 14 deletions bin/fetch_file
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,29 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
if __name__ == "__main__":
from optparse import OptionParser
parser = OptionParser(version="0.1", usage="Usage: %prog [options] url")
parser.add_option("-o", "--out-file", help="Output file", dest="outfile")
from optparse import OptionParser
usage = """%prog [options] URI
Fetch a URI using the boto library and (by default) pipe contents to STDOUT
The URI can be either an HTTP URL, or "s3://bucket_name/key_name"
"""
parser = OptionParser(version="0.1", usage=usage)
parser.add_option("-o", "--out-file",
help="File to receive output instead of STDOUT",
dest="outfile")

(options, args) = parser.parse_args()
if len(args) < 1:
parser.print_help()
exit(1)
from boto.utils import fetch_file
f = fetch_file(args[0])
if options.outfile:
open(options.outfile, "w").write(f.read())
else:
print f.read()
(options, args) = parser.parse_args()
if len(args) < 1:
parser.print_help()
exit(1)
from boto.utils import fetch_file
f = fetch_file(args[0])
if options.outfile:
open(options.outfile, "w").write(f.read())
else:
print f.read()
6 changes: 3 additions & 3 deletions bin/glacier
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ def connect(region, debug_level=0, access_key=None, secret_key=None):


def list_vaults(region, access_key=None, secret_key=None):
layer2 = connect(region, access_key, secret_key)
layer2 = connect(region, access_key = access_key, secret_key = secret_key)
for vault in layer2.list_vaults():
print vault.arn


def list_jobs(vault_name, region, access_key=None, secret_key=None):
layer2 = connect(region, access_key, secret_key)
layer2 = connect(region, access_key = access_key, secret_key = secret_key)
print layer2.layer1.list_jobs(vault_name)


def upload_files(vault_name, filenames, region, access_key=None, secret_key=None):
layer2 = connect(region, access_key, secret_key)
layer2 = connect(region, access_key = access_key, secret_key = secret_key)
layer2.create_vault(vault_name)
glacier_vault = layer2.get_vault(vault_name)
for filename in filenames:
Expand Down
10 changes: 9 additions & 1 deletion bin/list_instances
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ def main():
parser.add_option("-r", "--region", help="Region (default us-east-1)", dest="region", default="us-east-1")
parser.add_option("-H", "--headers", help="Set headers (use 'T:tagname' for including tags)", default=None, action="store", dest="headers", metavar="ID,Zone,Groups,Hostname,State,T:Name")
parser.add_option("-t", "--tab", help="Tab delimited, skip header - useful in shell scripts", action="store_true", default=False)
parser.add_option("-f", "--filter", help="Filter option sent to DescribeInstances API call, format is key1=value1,key2=value2,...", default=None)
(options, args) = parser.parse_args()


# Connect the region
for r in regions():
if r.name == options.region:
Expand All @@ -62,13 +64,19 @@ def main():
format_string += "%%-%ds" % HEADERS[h]['length']


# Parse filters (if any)
if options.filter:
filters = dict([entry.split('=') for entry in options.filter.split(',')])
else:
filters = {}

# List and print

if not options.tab:
print format_string % headers
print "-" * len(format_string % headers)

for r in ec2.get_all_instances():
for r in ec2.get_all_instances(filters=filters):
groups = [g.name for g in r.groups]
for i in r.instances:
i.groups = ','.join(groups)
Expand Down
Loading

0 comments on commit 5eceafc

Please sign in to comment.