def setup_sdb_domain(domain_name="mqlib-domain"): sdb = boto.sdb.connect_to_region(AWS_REGION) # Only create if it doesn't exist already try: dom = sdb.get_domain(domain_name,validate=True) except: # Doesn't exist yet dom = sdb.create_domain(domain_name) return sdb, dom
def setup_sdb_domain(domain_name="mqlib-domain"): sdb = boto.sdb.connect_to_region(AWS_REGION) # Only create if it doesn't exist already try: dom = sdb.get_domain(domain_name, validate=True) except: # Doesn't exist yet dom = sdb.create_domain(domain_name) return sdb, dom
def get_domain(self, name, auto_create=False): """Get a domain in the simpledb service""" sdb = self.get_sdb() try: dom = sdb.get_domain(name) except boto.exception.SDBResponseError: if auto_create: dom = sdb.create_domain(name) else: raise return dom
exit() if not options.dump and not options.load and not options.empty: parser.print_help() exit() # # Setup # if options.domains: domains = [] for domain_name in options.domains: domains.append(sdb.get_domain(domain_name)) elif options.all_domains: domains = sdb.get_all_domains() else: domains = [choice_input(options=sdb.get_all_domains(), title="No domain specified, please choose one")] # # Execute the commands # stime = time.time() if options.empty: if confirm("WARNING!!! Are you sure you want to empty the following domains?: %s" % domains): stime = time.time() for domain in domains: print "--------> Emptying %s <--------" % domain.name
User: %(userid)s Access Key: %(accesskey)s Secret Key: %(secretkey)s Export: export AWS_ACCESS_KEY_ID=%(accesskey)s \ AWS_SECRET_ACCESS_KEY=%(secretkey)s **************************************************************************** """ % { 'userid': user_name, 'accesskey': access_key, 'secretkey': secret_key } # 3) Check if SimpleDB domain exist, if not, create. try: domain = sdb.get_domain(domain_name, True) print "INITIALIZE: Domain %s already exists, " \ "not touching it" % (domain_name,) except SDBResponseError, err: if err.error_code != 'NoSuchDomain': raise err print "INITIALIZE: Domain %s does not exist, creating it" % ( domain_name,) domain = sdb.create_domain(domain_name) # 4) Check if security group exist, if not, create. if sg_exists: print "INITIALIZE: Security group %s already exists, " \ "not touching it" % (sg_name,) else: print "INITIALIZE: Security group %s does not exist, " \
if options.list: for db in sdb.get_all_domains(): print db exit() if not options.dump and not options.load and not options.empty: parser.print_help() exit() # # Setup # if options.domains: domains = [] for domain_name in options.domains: domains.append(sdb.get_domain(domain_name)) elif options.all_domains: domains = sdb.get_all_domains() else: domains = [ choice_input(options=sdb.get_all_domains(), title="No domain specified, please choose one") ] # # Execute the commands # stime = time.time() if options.empty: if confirm( "WARNING!!! Are you sure you want to empty the following domains?: %s"