4
# cfadmin is similar to sdbadmin for CloudFront, it's a simple
5
# console utility to perform the most frequent tasks with CloudFront
7
def _print_distributions(dists):
8
"""Internal function to print out all the distributions provided"""
9
print "%-12s %-50s %s" % ("Status", "Domain Name", "Origin")
12
print "%-12s %-50s %-30s" % (d.status, d.domain_name, d.origin)
13
for cname in d.cnames:
14
print " "*12, "CNAME => %s" % cname
17
def help(cf, fnc=None):
18
"""Print help message, optionally about a specific function"""
20
self = sys.modules['__main__']
23
cmd = getattr(self, fnc)
26
if not inspect.isfunction(cmd):
27
print "No function named: %s found" % fnc
29
(args, varargs, varkw, defaults) = inspect.getargspec(cmd)
31
print "Usage: %s %s" % (fnc, " ".join([ "[%s]" % a for a in args[1:]]))
33
print "Usage: cfadmin [command]"
34
for cname in dir(self):
35
if not cname.startswith("_"):
36
cmd = getattr(self, cname)
37
if inspect.isfunction(cmd):
39
print "\t%s - %s" % (cname, doc)
43
"""List all distributions and streaming distributions"""
44
print "Standard Distributions"
45
_print_distributions(cf.get_all_distributions())
46
print "Streaming Distributions"
47
_print_distributions(cf.get_all_streaming_distributions())
50
if __name__ == "__main__":
53
cf = boto.connect_cloudfront()
54
self = sys.modules['__main__']
55
if len(sys.argv) >= 2:
57
cmd = getattr(self, sys.argv[1])
70
help(cf, cmd.__name__)