def signup(activationkey, productcode, customer_name, customer_email, customer_keyinfo, stdout, stderr, seed, secretsfile, logfilename, configpath='../secret_config/lae_automation_config.json', serverinfopath=None, ec2secretpath=None, clock=None): config = Config(configpath) myclock = clock or reactor bucketname = "lae-%s-%s" % (productcode.lower(), seed) location = None # default location for now product = lookup_product(config, productcode) fullname = product['full_name'] producttoken = product['product_token'] amiimageid = product['ami_image_id'] instancesize = product['instance_size'] print >>stdout, "Signing up customer for %s..." % (fullname,) d = activate_user_account_desktop(activationkey, producttoken, stdout, stderr) def _activated(adpr): useraccesskeyid = adpr.access_key_id usersecretkey = adpr.secret_key usertoken = adpr.usertoken def _wait_until_verified(how_long_secs): d3 = verify_user_account(useraccesskeyid, usersecretkey, usertoken, producttoken, stdout, stderr) def _maybe_again(res): if res: print >>stdout, "Subscription verified." return if how_long_secs <= 0.0: print >>stdout, "Timed out waiting for verification of subscription." raise TimeoutError() print >>stdout, "Waiting another %d seconds..." % (POLL_TIME,) return task.deferLater(myclock, POLL_TIME, _wait_until_verified, how_long_secs - POLL_TIME) d3.addCallback(_maybe_again) return d3 d2 = _wait_until_verified(CC_VERIFICATION_TIME) d2.addCallback(lambda ign: create_user_bucket(useraccesskeyid, usersecretkey, usertoken, bucketname, stdout, stderr, producttoken=producttoken, location=location)) # We could deploy and configure the instance in parallel with the above wait and delete it # if necessary, but let's keep it simple and sequential. d2.addCallback(lambda ign: deploy_server(useraccesskeyid, usersecretkey, usertoken, producttoken, bucketname, None, amiimageid, instancesize, customer_name, customer_email, customer_keyinfo, stdout, stderr, secretsfile, config, serverinfopath, ec2secretpath, clock=myclock)) return d2 d.addCallback(_activated) d.addErrback(lambda f: send_notify_failure(f, customer_name, customer_email, logfilename, stdout, stderr)) return d
def signup(activationkey, productcode, customer_name, customer_email, customer_keyinfo, stdout, stderr, seed, secretsfile, logfilename, configpath='../secret_config/lae_automation_config.json', serverinfopath=None, ec2secretpath=None, clock=None): config = Config(configpath) myclock = clock or reactor bucketname = "lae-%s-%s" % (productcode.lower(), seed) location = None # default location for now product = lookup_product(config, productcode) fullname = product['full_name'] producttoken = product['product_token'] amiimageid = product['ami_image_id'] instancesize = product['instance_size'] print >>stdout, "Signing up customer for %s..." % (fullname,) d = activate_user_account_desktop(activationkey, producttoken, stdout, stderr) def _activated(adpr): useraccesskeyid = adpr.access_key_id usersecretkey = adpr.secret_key usertoken = adpr.usertoken def _wait_until_verified(how_long_secs): d3 = verify_user_account(useraccesskeyid, usersecretkey, usertoken, producttoken, stdout, stderr) def _maybe_again(res): if res: print >>stdout, "Subscription verified." return if how_long_secs <= 0.0: print >>stdout, "Timed out waiting for verification of subscription." raise TimeoutError() print >>stdout, "Waiting another %d seconds..." % (POLL_TIME,) return task.deferLater(myclock, POLL_TIME, _wait_until_verified, how_long_secs - POLL_TIME) d3.addCallback(_maybe_again) return d3 d2 = _wait_until_verified(CC_VERIFICATION_TIME) d2.addCallback(lambda ign: create_user_bucket(useraccesskeyid, usersecretkey, usertoken, bucketname, stdout, stderr, producttoken=producttoken, location=location)) # We could deploy and configure the instance in parallel with the above wait and delete it # if necessary, but let's keep it simple and sequential. d2.addCallback(lambda ign: deploy_server(useraccesskeyid, usersecretkey, usertoken, producttoken, bucketname, None, amiimageid, instancesize, customer_name, customer_email, customer_keyinfo, stdout, stderr, secretsfile, config, serverinfopath, ec2secretpath, clock=myclock)) return d2 d.addCallback(_activated) d.addErrback(lambda f: send_notify_failure(f, customer_name, customer_email, logfilename, stdout, stderr)) return d
def replace_server(oldsecrets, amiimageid, instancesize, customer_email, stdout, stderr, secretsfile, logfilename, configpath='../secret_config/lae_automation_config.json', serverinfopath=None, ec2secretpath=None, clock=None): config = Config(configpath) useraccesskeyid = oldsecrets['access_key_id'] usersecretkey = oldsecrets['secret_key'] usertoken = oldsecrets['user_token'] producttoken = oldsecrets['product_token'] bucketname = oldsecrets["bucket_name"] d = deploy_server(useraccesskeyid, usersecretkey, usertoken, producttoken, bucketname, oldsecrets, amiimageid, instancesize, "someone", customer_email, None, stdout, stderr, secretsfile, config, serverinfopath, ec2secretpath, clock) d.addErrback(lambda f: send_notify_failure(f, "someone", customer_email, logfilename, stdout, stderr)) return d
def replace_server(oldsecrets, amiimageid, instancesize, customer_email, stdout, stderr, secretsfile, logfilename, configpath='../secret_config/lae_automation_config.json', serverinfopath=None, ec2secretpath=None, clock=None): config = Config(configpath) useraccesskeyid = oldsecrets['access_key_id'] usersecretkey = oldsecrets['secret_key'] usertoken = oldsecrets['user_token'] producttoken = oldsecrets['product_token'] bucketname = oldsecrets["bucket_name"] d = deploy_server(useraccesskeyid, usersecretkey, usertoken, producttoken, bucketname, oldsecrets, amiimageid, instancesize, "someone", customer_email, None, stdout, stderr, secretsfile, config, serverinfopath, ec2secretpath, clock) d.addErrback(lambda f: send_notify_failure(f, "someone", customer_email, logfilename, stdout, stderr)) return d
def activate_subscribed_service(customer_email, customer_pgpinfo, customer_id, subscription_id, plan_id, stdout, stderr, secretsfile, logfile, configpath='../secret_config/lae_automation_config.json', serverinfopath=None, clock=None): print >>stderr, "entering activate_subscribed_service call." print >>stderr, "configpath is %s" % configpath config = Config(configpath) myclock = clock or reactor s3_access_key_id = config.other["s3_access_key_id"] s3_secret_path = config.other["s3_secret_path"] s3_secretkey = FilePath(s3_secret_path).getContent().strip() bucketname = get_bucket_name(subscription_id, customer_id) location = None # default S3 location for now print >>stderr, "plan_id is %s" % plan_id product = lookup_product(config, plan_id) fullname = product['plan_name'] amiimageid = product['ami_image_id'] instancesize = product['instance_size'] print >>stdout, "Signing up customer for %s..." % (fullname,) d = create_stripe_user_bucket(s3_access_key_id, s3_secretkey, bucketname, stdout, stderr, location) print >>stdout, "After create_stripe_account_user_bucket %s..." % str( (s3_access_key_id, s3_secretkey, bucketname, None, amiimageid, instancesize, customer_email, customer_pgpinfo, stdout, stderr, secretsfile, config, serverinfopath, myclock)) d.addCallback(lambda ign: deploy_server(s3_access_key_id, s3_secretkey, None, None, bucketname, None, amiimageid, instancesize, customer_email, customer_pgpinfo, stdout, stderr, secretsfile, config, serverinfopath, clock=myclock)) d.addErrback(lambda f: send_notify_failure(f, customer_email, logfile, stdout, stderr)) return d