Exemple #1
0
 def info(args):
     cf = CloudFront(Config())
     if not args:
         response = cf.GetList()
         for d in response['dist_list'].dist_summs:
             pretty_output("Origin",
                           S3UriS3.httpurl_to_s3uri(d.info['Origin']))
             pretty_output("DistId", d.uri())
             pretty_output("DomainName", d.info['DomainName'])
             pretty_output("Status", d.info['Status'])
             pretty_output("Enabled", d.info['Enabled'])
             output("")
     else:
         cfuris = []
         for arg in args:
             cfuris.append(S3Uri(arg))
             if cfuris[-1].type != 'cf':
                 raise ParameterError(
                     "CloudFront URI required instead of: %s" % arg)
         for cfuri in cfuris:
             response = cf.GetDistInfo(cfuri)
             d = response['distribution']
             dc = d.info['DistributionConfig']
             pretty_output("Origin",
                           S3UriS3.httpurl_to_s3uri(dc.info['Origin']))
             pretty_output("DistId", d.uri())
             pretty_output("DomainName", d.info['DomainName'])
             pretty_output("Status", d.info['Status'])
             pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
             pretty_output("Comment", dc.info['Comment'])
             pretty_output("Enabled", dc.info['Enabled'])
             pretty_output("Etag", response['headers']['etag'])
Exemple #2
0
	def info(args):
		cf = CloudFront(Config())
		if not args:
			response = cf.GetList()
			for d in response['dist_list'].dist_summs:
				pretty_output("Origin", S3UriS3.httpurl_to_s3uri(d.info['Origin']))
				pretty_output("DistId", d.uri())
				pretty_output("DomainName", d.info['DomainName'])
				pretty_output("Status", d.info['Status'])
				pretty_output("Enabled", d.info['Enabled'])
				output("")
		else:
			cfuris = []
			for arg in args:
				cfuris.append(S3Uri(arg))
				if cfuris[-1].type != 'cf':
					raise ParameterError("CloudFront URI required instead of: %s" % arg)
			for cfuri in cfuris:
				response = cf.GetDistInfo(cfuri)
				d = response['distribution']
				dc = d.info['DistributionConfig']
				pretty_output("Origin", S3UriS3.httpurl_to_s3uri(dc.info['Origin']))
				pretty_output("DistId", d.uri())
				pretty_output("DomainName", d.info['DomainName'])
				pretty_output("Status", d.info['Status'])
				pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
				pretty_output("Comment", dc.info['Comment'])
				pretty_output("Enabled", dc.info['Enabled'])
				pretty_output("Etag", response['headers']['etag'])
	def info(args):
		cf = CloudFront(Config())
		if not args:
			response = cf.GetList()
			for d in response['dist_list'].dist_summs:
				pretty_output("Origin", S3UriS3.httpurl_to_s3uri(d.info['Origin']))
				pretty_output("DistId", d.uri())
				pretty_output("DomainName", d.info['DomainName'])
				pretty_output("Status", d.info['Status'])
				pretty_output("Enabled", d.info['Enabled'])
				output("")
		else:
			cfuris = Cmd._parse_args(args)
			for cfuri in cfuris:
				response = cf.GetDistInfo(cfuri)
				d = response['distribution']
				dc = d.info['DistributionConfig']
				pretty_output("Origin", S3UriS3.httpurl_to_s3uri(dc.info['Origin']))
				pretty_output("DistId", d.uri())
				pretty_output("DomainName", d.info['DomainName'])
				pretty_output("Status", d.info['Status'])
				pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
				pretty_output("Comment", dc.info['Comment'])
				pretty_output("Enabled", dc.info['Enabled'])
				pretty_output("Logging", dc.info['Logging'] or "Disabled")
				pretty_output("Etag", response['headers']['etag'])
Exemple #4
0
    def info(args):
        cf = CloudFront(Config())
        if not args:
            response = cf.GetList( marker=Cmd.options.cf_marker )
            pretty_output("Current Marker", response['dist_list'].marker)
            pretty_output("Next Marker", response['dist_list'].next_marker)
            pretty_output("Max Items", response['dist_list'].max_items)
            pretty_output("Items", len(response['dist_list'].dist_summs))
            output("")

            for d in response['dist_list'].dist_summs:
                if d.info.has_key("S3Origin"):
                    origin = S3UriS3.httpurl_to_s3uri(d.info['S3Origin']['DNSName'])
                elif d.info.has_key("CustomOrigin"):
                    origin = "http://%s/" % d.info['CustomOrigin']['DNSName']
                else:
                    origin = "<unknown>"
                pretty_output("Origin", origin)
                pretty_output("DistId", d.uri())
                pretty_output("DomainName", d.info['DomainName'])
                if d.info.has_key("CNAME"):
                    pretty_output("CNAMEs", ", ".join(d.info['CNAME']))
                pretty_output("Status", d.info['Status'])
                pretty_output("Enabled", d.info['Enabled'])
                output("")
        else:
            cfuris = Cmd._parse_args(args)
            for cfuri in cfuris:
                response = cf.GetDistInfo(cfuri)
                d = response['distribution']
                dc = d.info['DistributionConfig']
                if dc.info.has_key("S3Origin"):
                    origin = S3UriS3.httpurl_to_s3uri(dc.info['S3Origin']['DNSName'])
                elif dc.info.has_key("CustomOrigin"):
                    origin = "http://%s/" % dc.info['CustomOrigin']['DNSName']
                else:
                    origin = "<unknown>"
                pretty_output("Origin", origin)
                pretty_output("DistId", d.uri())
                pretty_output("DomainName", d.info['DomainName'])
                if dc.info.has_key("CNAME"):
                    pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
                pretty_output("Status", d.info['Status'])
                pretty_output("Comment", dc.info['Comment'])
                pretty_output("Enabled", dc.info['Enabled'])
                pretty_output("DfltRootObject", dc.info['DefaultRootObject'])
                pretty_output("Logging", dc.info['Logging'] or "Disabled")
                pretty_output("Etag", response['headers']['etag'])
Exemple #5
0
	def create(args):
		cf = CloudFront(Config())
		buckets = []
		for arg in args:
			uri = S3Uri(arg)
			if uri.type != "s3":
				raise ParameterError("Bucket can only be created from a s3:// URI instead of: %s" % arg)
			if uri.object():
				raise ParameterError("Use s3:// URI with a bucket name only instead of: %s" % arg)
			if not uri.is_dns_compatible():
				raise ParameterError("CloudFront can only handle lowercase-named buckets.")
			buckets.append(uri)
		if not buckets:
			raise ParameterError("No valid bucket names found")
		for uri in buckets:
			info("Creating distribution from: %s" % uri)
			response = cf.CreateDistribution(uri, cnames_add = Cmd.options.cf_cnames_add, 
			                                 comment = Cmd.options.cf_comment,
			                                 logging = Cmd.options.cf_logging,
                                             default_root_object = Cmd.options.cf_default_root_object)
			d = response['distribution']
			dc = d.info['DistributionConfig']
			output("Distribution created:")
			pretty_output("Origin", S3UriS3.httpurl_to_s3uri(dc.info['Origin']))
			pretty_output("DistId", d.uri())
			pretty_output("DomainName", d.info['DomainName'])
			pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
			pretty_output("Comment", dc.info['Comment'])
			pretty_output("Status", d.info['Status'])
			pretty_output("Enabled", dc.info['Enabled'])
			pretty_output("DefaultRootObject", dc.info['DefaultRootObject'])
			pretty_output("Etag", response['headers']['etag'])
Exemple #6
0
 def modify(args):
     cf = CloudFront(Config())
     if len(args) > 1:
         raise ParameterError(
             "Too many parameters. Modify one Distribution at a time.")
     try:
         cfuri = Cmd._parse_args(args)[0]
     except IndexError:
         raise ParameterError("No valid Distribution URI found.")
     response = cf.ModifyDistribution(
         cfuri,
         cnames_add=Cmd.options.cf_cnames_add,
         cnames_remove=Cmd.options.cf_cnames_remove,
         comment=Cmd.options.cf_comment,
         enabled=Cmd.options.cf_enable,
         logging=Cmd.options.cf_logging,
         default_root_object=Cmd.options.cf_default_root_object)
     if response['status'] >= 400:
         error("Distribution %s could not be modified: %s" %
               (cfuri, response['reason']))
     output("Distribution modified: %s" % cfuri)
     response = cf.GetDistInfo(cfuri)
     d = response['distribution']
     dc = d.info['DistributionConfig']
     pretty_output("Origin",
                   S3UriS3.httpurl_to_s3uri(dc.info['S3Origin']['DNSName']))
     pretty_output("DistId", d.uri())
     pretty_output("DomainName", d.info['DomainName'])
     pretty_output("Status", d.info['Status'])
     pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
     pretty_output("Comment", dc.info['Comment'])
     pretty_output("Enabled", dc.info['Enabled'])
     pretty_output("DefaultRootObject", dc.info['DefaultRootObject'])
     pretty_output("Etag", response['headers']['etag'])
Exemple #7
0
    def modify(args):
        cf = CloudFront(Config())
        cfuri = S3Uri(args.pop(0))
        if cfuri.type != 'cf':
            raise ParameterError("CloudFront URI required instead of: %s" %
                                 arg)
        if len(args):
            raise ParameterError(
                "Too many parameters. Modify one Distribution at a time.")

        response = cf.ModifyDistribution(
            cfuri,
            cnames_add=Cmd.options.cf_cnames_add,
            cnames_remove=Cmd.options.cf_cnames_remove,
            comment=Cmd.options.cf_comment,
            enabled=Cmd.options.cf_enable)
        if response['status'] >= 400:
            error("Distribution %s could not be modified: %s" %
                  (cfuri, response['reason']))
        output("Distribution modified: %s" % cfuri)
        response = cf.GetDistInfo(cfuri)
        d = response['distribution']
        dc = d.info['DistributionConfig']
        pretty_output("Origin", S3UriS3.httpurl_to_s3uri(dc.info['Origin']))
        pretty_output("DistId", d.uri())
        pretty_output("DomainName", d.info['DomainName'])
        pretty_output("Status", d.info['Status'])
        pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
        pretty_output("Comment", dc.info['Comment'])
        pretty_output("Enabled", dc.info['Enabled'])
        pretty_output("Etag", response['headers']['etag'])
Exemple #8
0
 def modify(args):
     cf = CloudFront(Config())
     if len(args) > 1:
         raise ParameterError("Too many parameters. Modify one Distribution at a time.")
     try:
         cfuri = Cmd._parse_args(args)[0]
     except IndexError:
         raise ParameterError("No valid Distribution URI found.")
     response = cf.ModifyDistribution(cfuri,
                                      cnames_add = Cmd.options.cf_cnames_add,
                                      cnames_remove = Cmd.options.cf_cnames_remove,
                                      comment = Cmd.options.cf_comment,
                                      enabled = Cmd.options.cf_enable,
                                      logging = Cmd.options.cf_logging,
                                      default_root_object = Cmd.options.cf_default_root_object)
     if response['status'] >= 400:
         error("Distribution %s could not be modified: %s" % (cfuri, response['reason']))
     output("Distribution modified: %s" % cfuri)
     response = cf.GetDistInfo(cfuri)
     d = response['distribution']
     dc = d.info['DistributionConfig']
     pretty_output("Origin", S3UriS3.httpurl_to_s3uri(dc.info['S3Origin']['DNSName']))
     pretty_output("DistId", d.uri())
     pretty_output("DomainName", d.info['DomainName'])
     pretty_output("Status", d.info['Status'])
     pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
     pretty_output("Comment", dc.info['Comment'])
     pretty_output("Enabled", dc.info['Enabled'])
     pretty_output("DefaultRootObject", dc.info['DefaultRootObject'])
     pretty_output("Etag", response['headers']['etag'])
	def create(args):
		cf = CloudFront(Config())
		buckets = []
		for arg in args:
			uri = S3Uri(arg)
			if uri.type != "s3":
				raise ParameterError("Bucket can only be created from a s3:// URI instead of: %s" % arg)
			if uri.object():
				raise ParameterError("Use s3:// URI with a bucket name only instead of: %s" % arg)
			if not uri.is_dns_compatible():
				raise ParameterError("CloudFront can only handle lowercase-named buckets.")
			buckets.append(uri)
		if not buckets:
			raise ParameterError("No valid bucket names found")
		for uri in buckets:
			info("Creating distribution from: %s" % uri)
			response = cf.CreateDistribution(uri, cnames_add = Cmd.options.cf_cnames_add, 
			                                 comment = Cmd.options.cf_comment,
			                                 logging = Cmd.options.cf_logging)
			d = response['distribution']
			dc = d.info['DistributionConfig']
			output("Distribution created:")
			pretty_output("Origin", S3UriS3.httpurl_to_s3uri(dc.info['Origin']))
			pretty_output("DistId", d.uri())
			pretty_output("DomainName", d.info['DomainName'])
			pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
			pretty_output("Comment", dc.info['Comment'])
			pretty_output("Status", d.info['Status'])
			pretty_output("Enabled", dc.info['Enabled'])
			pretty_output("Etag", response['headers']['etag'])
Exemple #10
0
	def modify(args):
		cf = CloudFront(Config())
		cfuri = S3Uri(args.pop(0))
		if cfuri.type != 'cf':
			raise ParameterError("CloudFront URI required instead of: %s" % arg)
		if len(args):
			raise ParameterError("Too many parameters. Modify one Distribution at a time.")

		response = cf.ModifyDistribution(cfuri,
		                                 cnames_add = Cmd.options.cf_cnames_add,
		                                 cnames_remove = Cmd.options.cf_cnames_remove,
		                                 comment = Cmd.options.cf_comment,
		                                 enabled = Cmd.options.cf_enable)
		if response['status'] >= 400:
			error("Distribution %s could not be modified: %s" % (cfuri, response['reason']))
		output("Distribution modified: %s" % cfuri)
		response = cf.GetDistInfo(cfuri)
		d = response['distribution']
		dc = d.info['DistributionConfig']
		pretty_output("Origin", S3UriS3.httpurl_to_s3uri(dc.info['Origin']))
		pretty_output("DistId", d.uri())
		pretty_output("DomainName", d.info['DomainName'])
		pretty_output("Status", d.info['Status'])
		pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
		pretty_output("Comment", dc.info['Comment'])
		pretty_output("Enabled", dc.info['Enabled'])
		pretty_output("Etag", response['headers']['etag'])
Exemple #11
0
 def info(args):
     cf = CloudFront(Config())
     if not args:
         response = cf.GetList()
         for d in response['dist_list'].dist_summs:
             if d.info.has_key("S3Origin"):
                 origin = S3UriS3.httpurl_to_s3uri(
                     d.info['S3Origin']['DNSName'])
             elif d.info.has_key("CustomOrigin"):
                 origin = "http://%s/" % d.info['CustomOrigin']['DNSName']
             else:
                 origin = "<unknown>"
             pretty_output("Origin", origin)
             pretty_output("DistId", d.uri())
             pretty_output("DomainName", d.info['DomainName'])
             if d.info.has_key("CNAME"):
                 pretty_output("CNAMEs", ", ".join(d.info['CNAME']))
             pretty_output("Status", d.info['Status'])
             pretty_output("Enabled", d.info['Enabled'])
             output("")
     else:
         cfuris = Cmd._parse_args(args)
         for cfuri in cfuris:
             response = cf.GetDistInfo(cfuri)
             d = response['distribution']
             dc = d.info['DistributionConfig']
             if dc.info.has_key("S3Origin"):
                 origin = S3UriS3.httpurl_to_s3uri(
                     dc.info['S3Origin']['DNSName'])
             elif dc.info.has_key("CustomOrigin"):
                 origin = "http://%s/" % dc.info['CustomOrigin']['DNSName']
             else:
                 origin = "<unknown>"
             pretty_output("Origin", origin)
             pretty_output("DistId", d.uri())
             pretty_output("DomainName", d.info['DomainName'])
             if dc.info.has_key("CNAME"):
                 pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
             pretty_output("Status", d.info['Status'])
             pretty_output("Comment", dc.info['Comment'])
             pretty_output("Enabled", dc.info['Enabled'])
             pretty_output("DfltRootObject", dc.info['DefaultRootObject'])
             pretty_output("Logging", dc.info['Logging'] or "Disabled")
             pretty_output("Etag", response['headers']['etag'])
Exemple #12
0
 def info(args):
     cf = CloudFront(Config())
     if not args:
         response = cf.GetList()
         for d in response["dist_list"].dist_summs:
             if d.info.has_key("S3Origin"):
                 origin = S3UriS3.httpurl_to_s3uri(d.info["S3Origin"]["DNSName"])
             elif d.info.has_key("CustomOrigin"):
                 origin = "http://%s/" % d.info["CustomOrigin"]["DNSName"]
             else:
                 origin = "<unknown>"
             pretty_output("Origin", origin)
             pretty_output("DistId", d.uri())
             pretty_output("DomainName", d.info["DomainName"])
             if d.info.has_key("CNAME"):
                 pretty_output("CNAMEs", ", ".join(d.info["CNAME"]))
             pretty_output("Status", d.info["Status"])
             pretty_output("Enabled", d.info["Enabled"])
             output("")
     else:
         cfuris = Cmd._parse_args(args)
         for cfuri in cfuris:
             response = cf.GetDistInfo(cfuri)
             d = response["distribution"]
             dc = d.info["DistributionConfig"]
             if dc.info.has_key("S3Origin"):
                 origin = S3UriS3.httpurl_to_s3uri(dc.info["S3Origin"]["DNSName"])
             elif dc.info.has_key("CustomOrigin"):
                 origin = "http://%s/" % dc.info["CustomOrigin"]["DNSName"]
             else:
                 origin = "<unknown>"
             pretty_output("Origin", origin)
             pretty_output("DistId", d.uri())
             pretty_output("DomainName", d.info["DomainName"])
             if dc.info.has_key("CNAME"):
                 pretty_output("CNAMEs", ", ".join(dc.info["CNAME"]))
             pretty_output("Status", d.info["Status"])
             pretty_output("Comment", dc.info["Comment"])
             pretty_output("Enabled", dc.info["Enabled"])
             pretty_output("DfltRootObject", dc.info["DefaultRootObject"])
             pretty_output("Logging", dc.info["Logging"] or "Disabled")
             pretty_output("Etag", response["headers"]["etag"])
	@staticmethod
	def modify(args):
		cf = CloudFront(Config())
		if len(args) > 1:
			raise ParameterError("Too many parameters. Modify one Distribution at a time.")
		try:
			cfuri = Cmd._parse_args(args)[0]
		except IndexError, e:
			raise ParameterError("No valid Distribution URI found.")
		response = cf.ModifyDistribution(cfuri,
		                                 cnames_add = Cmd.options.cf_cnames_add,
		                                 cnames_remove = Cmd.options.cf_cnames_remove,
		                                 comment = Cmd.options.cf_comment,
		                                 enabled = Cmd.options.cf_enable,
		                                 logging = Cmd.options.cf_logging)
		if response['status'] >= 400:
			error("Distribution %s could not be modified: %s" % (cfuri, response['reason']))
		output("Distribution modified: %s" % cfuri)
		response = cf.GetDistInfo(cfuri)
		d = response['distribution']
		dc = d.info['DistributionConfig']
		pretty_output("Origin", S3UriS3.httpurl_to_s3uri(dc.info['Origin']))
		pretty_output("DistId", d.uri())
		pretty_output("DomainName", d.info['DomainName'])
		pretty_output("Status", d.info['Status'])
		pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
		pretty_output("Comment", dc.info['Comment'])
		pretty_output("Enabled", dc.info['Enabled'])
		pretty_output("Etag", response['headers']['etag'])
Exemple #14
0
class Cmd(object):
    """
    Class that implements CloudFront commands
    """
    class Options(object):
        cf_cnames_add = []
        cf_cnames_remove = []
        cf_comment = None
        cf_enable = None
        cf_logging = None
        cf_default_root_object = None

        def option_list(self):
            return [opt for opt in dir(self) if opt.startswith("cf_")]

        def update_option(self, option, value):
            setattr(Cmd.options, option, value)

    options = Options()

    @staticmethod
    def _parse_args(args):
        cf = CloudFront(Config())
        cfuris = []
        for arg in args:
            uri = cf.get_dist_name_for_bucket(S3Uri(arg))
            cfuris.append(uri)
        return cfuris

    @staticmethod
    def info(args):
        cf = CloudFront(Config())
        if not args:
            response = cf.GetList()
            for d in response['dist_list'].dist_summs:
                if d.info.has_key("S3Origin"):
                    origin = S3UriS3.httpurl_to_s3uri(
                        d.info['S3Origin']['DNSName'])
                elif d.info.has_key("CustomOrigin"):
                    origin = "http://%s/" % d.info['CustomOrigin']['DNSName']
                else:
                    origin = "<unknown>"
                pretty_output("Origin", origin)
                pretty_output("DistId", d.uri())
                pretty_output("DomainName", d.info['DomainName'])
                if d.info.has_key("CNAME"):
                    pretty_output("CNAMEs", ", ".join(d.info['CNAME']))
                pretty_output("Status", d.info['Status'])
                pretty_output("Enabled", d.info['Enabled'])
                output("")
        else:
            cfuris = Cmd._parse_args(args)
            for cfuri in cfuris:
                response = cf.GetDistInfo(cfuri)
                d = response['distribution']
                dc = d.info['DistributionConfig']
                if dc.info.has_key("S3Origin"):
                    origin = S3UriS3.httpurl_to_s3uri(
                        dc.info['S3Origin']['DNSName'])
                elif dc.info.has_key("CustomOrigin"):
                    origin = "http://%s/" % dc.info['CustomOrigin']['DNSName']
                else:
                    origin = "<unknown>"
                pretty_output("Origin", origin)
                pretty_output("DistId", d.uri())
                pretty_output("DomainName", d.info['DomainName'])
                if dc.info.has_key("CNAME"):
                    pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
                pretty_output("Status", d.info['Status'])
                pretty_output("Comment", dc.info['Comment'])
                pretty_output("Enabled", dc.info['Enabled'])
                pretty_output("DfltRootObject", dc.info['DefaultRootObject'])
                pretty_output("Logging", dc.info['Logging'] or "Disabled")
                pretty_output("Etag", response['headers']['etag'])

    @staticmethod
    def create(args):
        cf = CloudFront(Config())
        buckets = []
        for arg in args:
            uri = S3Uri(arg)
            if uri.type != "s3":
                raise ParameterError(
                    "Bucket can only be created from a s3:// URI instead of: %s"
                    % arg)
            if uri.object():
                raise ParameterError(
                    "Use s3:// URI with a bucket name only instead of: %s" %
                    arg)
            if not uri.is_dns_compatible():
                raise ParameterError(
                    "CloudFront can only handle lowercase-named buckets.")
            buckets.append(uri)
        if not buckets:
            raise ParameterError("No valid bucket names found")
        for uri in buckets:
            info("Creating distribution from: %s" % uri)
            response = cf.CreateDistribution(
                uri,
                cnames_add=Cmd.options.cf_cnames_add,
                comment=Cmd.options.cf_comment,
                logging=Cmd.options.cf_logging,
                default_root_object=Cmd.options.cf_default_root_object)
            d = response['distribution']
            dc = d.info['DistributionConfig']
            output("Distribution created:")
            pretty_output("Origin",
                          S3UriS3.httpurl_to_s3uri(dc.info['Origin']))
            pretty_output("DistId", d.uri())
            pretty_output("DomainName", d.info['DomainName'])
            pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
            pretty_output("Comment", dc.info['Comment'])
            pretty_output("Status", d.info['Status'])
            pretty_output("Enabled", dc.info['Enabled'])
            pretty_output("DefaultRootObject", dc.info['DefaultRootObject'])
            pretty_output("Etag", response['headers']['etag'])

    @staticmethod
    def delete(args):
        cf = CloudFront(Config())
        cfuris = Cmd._parse_args(args)
        for cfuri in cfuris:
            response = cf.DeleteDistribution(cfuri)
            if response['status'] >= 400:
                error("Distribution %s could not be deleted: %s" %
                      (cfuri, response['reason']))
            output("Distribution %s deleted" % cfuri)

    @staticmethod
    def modify(args):
        cf = CloudFront(Config())
        if len(args) > 1:
            raise ParameterError(
                "Too many parameters. Modify one Distribution at a time.")
        try:
            cfuri = Cmd._parse_args(args)[0]
        except IndexError, e:
            raise ParameterError("No valid Distribution URI found.")
        response = cf.ModifyDistribution(
            cfuri,
            cnames_add=Cmd.options.cf_cnames_add,
            cnames_remove=Cmd.options.cf_cnames_remove,
            comment=Cmd.options.cf_comment,
            enabled=Cmd.options.cf_enable,
            logging=Cmd.options.cf_logging,
            default_root_object=Cmd.options.cf_default_root_object)
        if response['status'] >= 400:
            error("Distribution %s could not be modified: %s" %
                  (cfuri, response['reason']))
        output("Distribution modified: %s" % cfuri)
        response = cf.GetDistInfo(cfuri)
        d = response['distribution']
        dc = d.info['DistributionConfig']
        pretty_output("Origin", S3UriS3.httpurl_to_s3uri(dc.info['Origin']))
        pretty_output("DistId", d.uri())
        pretty_output("DomainName", d.info['DomainName'])
        pretty_output("Status", d.info['Status'])
        pretty_output("CNAMEs", ", ".join(dc.info['CNAME']))
        pretty_output("Comment", dc.info['Comment'])
        pretty_output("Enabled", dc.info['Enabled'])
        pretty_output("DefaultRootObject", dc.info['DefaultRootObject'])
        pretty_output("Etag", response['headers']['etag'])