예제 #1
0
def deploy_erlang_rest_app():

    api = OpsWorksConnection()
    instance_id = "29c92563-e53c-4b24-85bb-8109784b7275"
    app_id = "5597648b-dc7f-437b-a0ed-df8b242bf8ef"
    command = {"Name": "deploy"}
    stack_id = "55186abb-f9aa-44b3-b0c1-f607747725ab"
    res = api.create_deployment(stack_id,
                                command,
                                app_id=app_id,
                                instance_ids=[instance_id])
    return res
예제 #2
0
    def handle(self, *args, **options):
        opsworks = OpsWorksConnection()
        stack_resp = opsworks.describe_stacks()
        stack_id = None
        stack_name = None

        for stack in stack_resp['Stacks']:
            if stack['Name'].startswith('web') and stack['Name'].endswith(
                    options['environment']):
                stack_id = stack['StackId']
                stack_name = stack['Name']
                break
        if not stack_id:
            raise CommandError('Stack does not exist.' %
                               options['environment'])

        # get application
        app_resp = opsworks.describe_apps(stack_id=stack_id)
        app_id = app_resp['Apps'][0]['AppId']
        app_name = app_resp['Apps'][0]['Name']

        # get layer
        for layers in opsworks.describe_layers(stack_id=stack_id)['Layers']:
            if layers['Name'] == 'bots':

                # deploy to the instances of particular layer
                for instance in opsworks.describe_instances(
                        layer_id=layers['LayerId'])['Instances']:
                    custom_json = json.dumps(get_json())
                    comment = "Deploying %s from %s@%s at %s to %s on %s" % (
                        app_name, getpass.getuser(), socket.gethostname(),
                        datetime.now().isoformat(' '), instance['Hostname'],
                        stack_name)

                    deployment = opsworks.create_deployment(
                        stack_id, {'Name': 'deploy'},
                        app_id=app_id,
                        instance_ids=[instance['InstanceId']],
                        custom_json=custom_json,
                        comment=comment)

                    print "https://console.aws.amazon.com/opsworks/home?#/stack/%s/deployments/%s" % (
                        stack_id, deployment['DeploymentId'])
예제 #3
0
    def run(self, *args, **options):
        opsworks = OpsWorksConnection()
        stack_resp = opsworks.describe_stacks()
        stack_id = None
        stack_name = None

        # get web production stack
        for stack in stack_resp['Stacks']:
            if stack['Name'].startswith('web') and stack['Name'].endswith(self.environment):
                stack_id = stack['StackId']
                stack_name = stack['Name']
                break
        if not stack_id:
            raise Exception('Stack does not exist.' % options['environment'])

        # get application
        app_resp = opsworks.describe_apps(stack_id=stack_id)
        app_id = app_resp['Apps'][0]['AppId']
        app_name = app_resp['Apps'][0]['Name']

        # get layer
        for layers in opsworks.describe_layers(stack_id=stack_id)['Layers']:
            if layers['Name'] == 'bots':

                # deploy to the instances of particular layer
                for instance in opsworks.describe_instances(layer_id=layers['LayerId'])['Instances']:
                    custom_json = json.dumps(get_json())
                    comment = "Deploying %s from %s@%s at %s to %s on %s" % (
                        app_name,
                        getpass.getuser(),
                        socket.gethostname(),
                        datetime.now().isoformat(' '),
                        instance['Hostname'],
                        stack_name)

                    deployment = opsworks.create_deployment(stack_id, {'Name': 'deploy'}, app_id=app_id,
                        instance_ids=[instance['InstanceId']], custom_json=custom_json, comment=comment)

                    print "https://console.aws.amazon.com/opsworks/home?#/stack/%s/deployments/%s" % (stack_id, deployment['DeploymentId'])
예제 #4
0
from boto.opsworks.layer1 import OpsWorksConnection

command = "execute_recipes"
opsworks = OpsWorksConnection()
stackName = u'CIC-InnovationService01'

# set deploymentCommand
deploymentCommand = {'Name': '%s' % command}
deploymentCommand['Name'] = 'execute_recipes'
deploymentCommand['Args'] = {"recipes": ["git::sync_crawler"]}

# get stackId
desc_stacks = opsworks.describe_stacks()
stackId = u'None'
for loop in desc_stacks[u'Stacks']:
    if loop[u'Name'] == stackName:
        stackId = loop[u'StackId']
if stackId == u'None':
    print("Error: stackName not found")

# execute recipes
opsworks.create_deployment(stack_id=stackId, command=deploymentCommand)
예제 #5
0
from boto.opsworks.layer1 import OpsWorksConnection

command = "execute_recipes"
opsworks = OpsWorksConnection()
stackName = u'CIC-InnovationService01'

# set deploymentCommand
deploymentCommand = {
   'Name': '%s' % command
}
deploymentCommand['Name'] = 'execute_recipes'
deploymentCommand['Args'] = {"recipes":["git::sync_tech-info"]}

# get stackId
desc_stacks = opsworks.describe_stacks()
stackId = u'None'
for loop in desc_stacks[u'Stacks']:
   if loop[u'Name'] == stackName:
      stackId = loop[u'StackId']
if stackId == u'None':
   print ("Error: stackName not found")

# execute recipes
opsworks.create_deployment(stack_id = stackId, command = deploymentCommand )