def test_publish_stack(): stack_name = settings['publish']['stack_name'] try: stack.publish_stack(settings) out = stack.get_outputs(stack_name, wait=True) url = out['WebsiteURL'] response = urllib2.urlopen(url) html = response.read() assert html == 'Hello, World!' finally: stack.delete_stack(stack_name, wait=True)
def publish(data, push_www=True, push_app=False): data = ConfigDict(data) www_archive = upload_www(data, push_www) app_archive = upload_app(data, push_app) config_file = File(File(__file__).parent.child('stack/gitbot.yaml')) config = yaml.load(config_file.read_all()) config['file_path'] = config_file.path params = data.get('stack_params', dict()) params.update(dict(AppSource=app_archive, WebSource=www_archive)) worker_params = get_worker_outputs(data) if not worker_params or 'QueueURL' not in worker_params: raise Exception('Failed to create the worker stack') params.update(dict( WorkerQueueURL=worker_params['QueueURL'], ManagerAccessKey=worker_params['ManagerKey'], ManagerSecretKey=worker_params['ManagerSecret'] )) config['data'] = data stack.publish_stack(config, params=params, debug=True, wait=True)
def get_worker_outputs(data): result = None try: region = data.region or 'us-east-1' root = Folder(data.root or '~') source = root.child_folder('src') source.make() source = source.child_folder('worker') repo = data.worker_repo or 'git://github.com/gitbot/worker.git' branch = data.worker_branch or 'master' # 1. Pull worker repo tree = Tree(source, repo, branch) tree.clone(tip_only=True) # 2. Call gitbot.stack.publish with 'gitbot.yaml' worker_stack_name = stack.publish_stack( source.child_file('gitbot.yaml'), wait=True) result = stack.get_outputs(worker_stack_name, region) except Exception, e: print repr(e) raise
def publish_stack(self, args): self.main(args, skip=True) stack.publish_stack(self.config) print 'done.'
from gitbot import stack from gitbot.lib.s3 import Bucket import json from time import sleep import urllib2 import yaml HERE = File(__file__).parent # Create worker stack config = yaml.load(HERE.parent.child_file('gitbot.yaml').read_all()) publish = yaml.load(HERE.child_file('test.gitbot.yaml').read_all()) config.update(publish) try: stack.publish_stack(config, {}, debug=True) except: pass # # Wait for stack to be operational result = stack.get_outputs(config['publish']['stack_name'], wait=True) print '\n Stack operational. Sending message.\n' queue_url = result['QueueURL'] access_key = result['ManagerKey'] secret = result['ManagerSecret'] # Send SQS message