def main(): if sys.version_info[:3] > (2, 7, 8): print "There is currently an SSL issue with Python 2.7.9 and newer." print "Please setup a virtualenv with Python 2.7.8 or less to proceed." sys.exit(1) new_hash = hashlib.md5(str(time.time())).hexdigest()[:8] parser = argparse.ArgumentParser() parser.add_argument("action", choices=ALLOWED_ACTIONS, action="store", help="Action to take against the stack(s)") parser.add_argument("-l", "--location", nargs='*', action="store", dest="locations", help="""If building, provide the IP Address(es) from which ssh is allowed.\n Example: './go.py build -l xx.xx.xx.xx yy.yy.yy.yy""", type=ip_address_type, default=["0.0.0.0"]) parser.add_argument('--region', action="store", dest="region", default=DEFAULT_REGION) parser.add_argument('--hash', action="store", dest="hash_id", help="""Define the hash to use for multiple deployments. If left blank, the hash will be generated.""", default=new_hash) parser.add_argument('-u', '--user', action="store", dest="jenkins_user", default=JENKINS_USER, help="Username for Jenkins") parser.add_argument('-e', '--email', action="store", dest="jenkins_email", default=JENKINS_EMAIL, help="Email for Jenkins") parser.add_argument('-p', '--password', action="store_true", dest="password_prompt", help="Prompt for Jenkins Password") parser.add_argument('--full', action='store_true', help="Always build all components. (VPC, RDS, etc.)") parser.add_argument('--warm', action='store_true', help="Only build VPC, SG, and RDS") args = parser.parse_args() if args.password_prompt: print "WARNING: Password will be passed to CFN in plain text." args.jenkins_password = getpass.getpass() else: args.jenkins_password = JENKINS_PASSWORD connections = dict() connections['cfn'] = cfn_connect(args.region) if args.action == "info": info(connections) sys.exit(0) connections['codedeploy'] = codedeploy_connect(args.region) connections['ec2'] = ec2_connect(args.region) connections['iam'] = iam_connect(args.region) connections['s3'] = s3_connect(args.region) if args.action == "test": # Test pieces here sys.exit(0) if args.action == "build": if not args.locations: print "Please provide at least one IP Address." parser.print_help() sys.exit(1) build(connections, args) elif args.action == "destroy": destroy(connections, args)
def main(): new_hash = hashlib.md5(str(time.time())).hexdigest()[:8] parser = argparse.ArgumentParser() parser.add_argument("action", choices=ALLOWED_ACTIONS, action="store", help="Action to take against the stack(s)") parser.add_argument("-l", "--location", nargs='*', action="store", dest="locations", help="""If building, provide the IP Address(es) from which ssh is allowed.\n Example: './go.py build -l xx.xx.xx.xx yy.yy.yy.yy""", type=ip_address_type, default=["0.0.0.0"]) parser.add_argument('--region', action="store", dest="region", default=DEFAULT_REGION) parser.add_argument('--hash', action="store", dest="hash_id", help="""Define the hash to use for multiple deployments. If left blank, the hash will be generated.""", default=new_hash) parser.add_argument('--full', action='store_true', help="Always build all components. (VPC, RDS, etc.)") args = parser.parse_args() full = args.full connections = dict() connections['cfn'] = cfn_connect(args.region) if args.action == "info": info(connections) sys.exit(0) connections['codedeploy'] = codedeploy_connect(args.region) connections['ec2'] = ec2_connect(args.region) connections['iam'] = iam_connect(args.region) connections['main_s3'] = s3_connect(MAIN_S3_BUCKET_REGION) connections['s3'] = s3_connect(args.region) if args.action == "test": # Test pieces here sys.exit(0) if args.action == "build": if not args.locations: print "Please provide at least one IP Address." parser.print_help() sys.exit(1) build(connections, args.region, args.locations, args.hash_id, full) elif args.action == "destroy": destroy(connections, args.region)