예제 #1
0
def create_sec_group(payload, ritm_no, depend_data):
    task_id = depend_data[0]['task']
    task = db_api.get_task(task_id)
    output = task.get('output')
    payload['args']['vpc_id'] = output[0].get('vpc').get('id')
    aws = service_manager.AwsCompute()
    return aws.create_security_group(payload['auth'], payload['args'], ritm_no)
def create_network(payload):
    network = {
        'name': payload['network_details']['env_sel_net'],
        'cidr': payload['network_details']['env_ip_range'],
        'tenancy': 'default',
        'tags': {
            'Name': payload['network_details']['env_sel_net']
        }
    }
    LOG.info('Calling Network creation module')
    aws = service_manager.AwsCompute()
    return aws.create_network(_get_auth(payload), network, payload['ritm_no'])
예제 #3
0
def create_subnet(payload, vpc_id=None):
    payload_sn = {}
    payload_sn['vpc_id'] = vpc_id
    payload_sn['cidr'] = payload.get('env_sub_net_range')
    payload_sn['state'] = payload.get('state') or 'present'
    payload_sn['az'] = payload.get('env_avai_zone')
    tags = {'Name': payload['network_details'].get('env_sub_net')}
    payload['tags'] = tags

    aws = service_manager.AwsCompute()
    return aws.create_subnet(_get_auth(payload), payload_sn,
                             payload['ritm_no'])
예제 #4
0
def create_network(payload):
    network = {
        'name': payload['network_details']['env_net_name'],
        'cidr': payload['network_details']['env_ip_range'],
        'tenancy': 'default',
        'tags': {
            'Name': payload['network_details']['env_net_name']
        }
    }

    aws = service_manager.AwsCompute()
    return aws.create_network(_get_auth(payload), network, payload['ritm_no'])
예제 #5
0
def create_lb(payload, ritm_no, depend_data):
    task_id = depend_data[0]['task']
    task = db_api.get_task(task_id)
    output = task.get('output')
    payload['args']['sec_groups'] = [output[0].get('group_id')]
    instance_ids = []
    task_id = depend_data[1]['task']
    task = db_api.get_task(task_id)
    output = task.get('output')
    for item in output:
        instance_ids.append(item.get('instance_id'))
    payload['args']['instance'] = instance_ids
    aws = service_manager.AwsCompute()
    return aws.create_lb(payload['auth'], payload['args'], ritm_no)
예제 #6
0
def create_sec_group(payload, vpc_id=None):
    sec_grp = {
        'name':
        payload['security_group_info'].get('security_name')
        or payload['request_no'],
        'vpc_id':
        vpc_id,
        'description':
        payload['request_no'] + '_sec_grp',
        'rules': []
    }

    aws = service_manager.AwsCompute()
    return aws.create_security_group(_get_auth(payload), sec_grp,
                                     payload['ritm_no'])
예제 #7
0
def create_lb(payload, instance_ids=[], sec_groups=[], port=[]):
    lb = {
        'name': payload['request_no'] + '_lb',
        #'zones': ['us-west-2'],
        'sec_groups': sec_groups,
        'instance_id': instance_ids,
        'listeners': []
    }
    listeners = []
    for item in port:
        data = {'load_balancer_port': item, 'instance_port': item}
        listeners.append(data)

    lb['listeners'] = listeners
    print 'LB paylaod %r' % lb
    aws = service_manager.AwsCompute()
    return aws.create_lb(_get_auth(payload), lb, payload['ritm_no'])
예제 #8
0
def create_instances(payload, vpc_id=None, sec_grp=[]):
    src_image = payload['image_details']['image']
    if 'rhel' in src_image.lower():
        src_image = 'ami-223f945a'
    else:
        src_image = 'ami-79873901'
    compute = {
        'key_name': payload['server_info'].get('key_name') or 'qa',
        'flavor': payload['flavor_details']['flavor'],
        'security_group': sec_grp,
        'count': payload['server_info'].get('quantity') or 1,
        'image_id': src_image,
        'net_id': vpc_id,
        'state': 'present',
        'init_scripts': get_public_key_command(),
        'name': payload['server_info'].get('server_name')
    }
    aws = service_manager.AwsCompute()
    return aws.create_instance(_get_auth(payload), compute, payload['ritm_no'])
def create_instances(payload, vpc_id=None, sec_grp=[], service=None):
    src_image = payload['image_details']['image']

    compute = {
        'key_name': payload['server_info'].get('key_name'),
        'flavor': payload['flavor_details']['flavor'],
        'security_group': sec_grp,
        'count': payload['server_info'].get('quantity') or 1,
        'image_id': src_image,
        'net_id': vpc_id,
        'vpc_subnet_id': payload['network_details'].get('env_sub_net'),
        'state': 'present',
        'init_scripts': get_public_key_command(),
        'name': payload['server_info'].get('server_name')
    }
    if service == 'oracle':
        compute['volumes'] = [{
            'name': '/dev/xvda',
            'size': '60',
            'type': 'gp2'
        }]
    aws = service_manager.AwsCompute()
    LOG.info('Calling Instance creation module')
    return aws.create_instance(_get_auth(payload), compute, payload['ritm_no'])
예제 #10
0
def create_network(payload, ritm_no, depend_data):
    aws = service_manager.AwsCompute()
    return aws.create_network(payload['auth'], payload['args'], ritm_no)