def start_staging(): """Start STAGING server.""" print 'Logging into Amazon AWS....' conn = _EC2Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) print 'Starting ' + STAGING['hostname'] + ' server:' print conn.start_instances(STAGING['ec2_instance']) _sleep(10) # seconds. Otherwise will get "The instance is not in the # 'running' state" error. print 'Associate Elastic IP with ' + STAGING['hostname'] + ' server:' print conn.associate_address(STAGING['ec2_instance'], STAGING['ip']) print '(Note that it might take a couple of minutes for the Elastic IP to work....)'
def stop_staging(): """Shut down STAGING server to prevent environment pollution.""" print 'Logging into Amazon AWS....' conn = _EC2Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) print 'Stopping ' + STAGING['hostname'] + ' server:' print conn.stop_instances(STAGING['ec2_instance'])