Ejemplo n.º 1
0
def contract_deployment(request):
    user = request.session.get('user')
    role = request.session.get('role')
    # Present file upload to screen and give options to user
    if request.method == 'POST' and 'file' in request.FILES:
        file = request.FILES['file']
        location = request.POST['location']

        environment = request.session.get('environment')
        if environment == 'Production':
            username = request.session.get('prod_username')
            password = request.session.get('prod_password')

        elif environment == 'Pre-Production':
            # Need to put in an error as PPE search wont work!
            username = request.session.get('ppe_username')
            password = request.session.get('ppe_password')

        elif environment == 'Lab':
            username = request.session.get('lab_username')
            password = request.session.get('lab_password')

        # Get base url to use
        base_urls = get_base_url(environment)
        url_dict = base_urls['ACI']

        # Open workbook and build jason data structure.
        rule_list = CONTRACT_DEPLOYMENT_EXCEL_OPEN_WORKBOOK(file, location)

        # Validate Request names and format
        task = CONTRACT_DEPLOYMENT_VALIDATION.delay(rule_list, location,
                                                    url_dict, username,
                                                    password)

        # Return task id.
        return HttpResponse(json.dumps({
            'task_id': task.id,
            'rule_list': rule_list,
            'location': location,
            'role': role,
            'user': user
        }),
                            content_type='application/json')

    # Get base url to use
    environment = request.session.get('environment')
    base_urls = get_base_url(environment)
    url_dict = base_urls['ACI']
    location_list = list(url_dict.keys())

    content = {
        'environment': environment,
        'locations': location_list,
        'url_list': url_list,
        'role': role,
        'user': user
    }
    return render(request, 'aci_deployment/aci_contract_deployment.html',
                  content)
Ejemplo n.º 2
0
def f5_disable_enable_push(request):
    user = request.session.get('user')
    role = request.session.get('role')
    # Get data to use Enable Disable task
    if request.method == 'POST':
        response_json = request.body
        data = json.loads(response_json)

        action = data['action']
        f5_selected_items = data['f5_selected_items']
        request_type = data['request_type']

        environment = request.session.get('environment')
        if environment == 'Production':
            username = request.session.get('prod_username')
            password = request.session.get('prod_password')

        if environment == 'Pre-Production':
            # Need to put in an error as PPE search wont work!
            username = request.session.get('ppe_username')
            password = request.session.get('ppe_password')

        if environment == 'Lab':
            username = request.session.get('lab_username')
            password = request.session.get('lab_password')

        # Get base url to use
        base_urls = get_base_url(environment)

        task = f5_disable_enable.delay(base_urls, request_type, action,
                                       f5_selected_items, username, password)

        # Return task id back to client for ajax use.
        return HttpResponse(json.dumps({'task_id': task.id}),
                            content_type='application/json')
Ejemplo n.º 3
0
def ipg_search(request):
    user = request.session.get('user')
    role = request.session.get('role')
    # Get subnet to use for search task.
    if request.method == 'POST' and 'ipg_search' in request.POST:

        search_string = request.POST['ipg_search']
        environment = request.session.get('environment')

        if environment == 'Production':
            username = request.session.get('prod_username')
            password = request.session.get('prod_password')

        elif environment == 'Pre-Production':
            # Need to put in an error as PPE search wont work!
            username = request.session.get('ppe_username')
            password = request.session.get('ppe_password')

        elif environment == 'Lab':
            username = request.session.get('lab_username')
            password = request.session.get('lab_password')

        # Get base url to use
        base_urls = get_base_url(environment)

        # Submit task to celery to process
        task = aci_ipg_search.delay(base_urls, username, password,
                                    search_string)

        # Return task id back to client for ajax use.
        return HttpResponse(json.dumps({'task_id': task.id}),
                            content_type='application/json')

    # Get base url to use
    environment = request.session.get('environment')
    base_urls = get_base_url(environment)
    url_dict = base_urls['ACI']
    location_list = list(url_dict.keys())

    content = {
        'environment': environment,
        'locations': location_list,
        'url_list': url_list,
        'role': role,
        'user': user
    }
    return render(request, 'aci_deployment/aci_ipg_search.html', content)
Ejemplo n.º 4
0
def certificate_search(request):
    user = request.session.get('user')
    role = request.session.get('role')
    # Get data to use for search task.
    if request.method == 'POST' and 'f5_search' in request.POST:
        search_string = request.POST['f5_search']
        request_type = request.POST['request_type']

        environment = request.session.get('environment')
        if environment == 'Production':
            username = request.session.get('prod_username')
            password = request.session.get('prod_password')

        if environment == 'Pre-Production':
            # Need to put in an error as PPE search wont work!
            username = request.session.get('ppe_username')
            password = request.session.get('ppe_password')

        if environment == 'Lab':
            username = request.session.get('lab_username')
            password = request.session.get('lab_password')

        # Get base url to use
        base_urls = get_base_url(environment)

        task = certificate_checker_task.delay(base_urls, role, request_type,
                                              search_string, username,
                                              password)

        # Return task id back to client for ajax use.
        return HttpResponse(json.dumps({'task_id': task.id}),
                            content_type='application/json')

    environment = request.session.get('environment')
    content = {
        'environment': environment,
        'url_list': url_list,
        'role': role,
        'user': user
    }
    return render(request, 'f5_deployment/f5_certificate_search.html', content)
Ejemplo n.º 5
0
def vs_deployment_push(request):
    user = request.session.get('user')
    role = request.session.get('role')
    # Deploy LTM Virtual Server configuration
    if request.method == 'POST':
        response_json = request.body
        data = json.loads(response_json)
        location = data['location']
        vs_dict = data['vs_dict']
        routeAdvertisement = data['routeAdvertisement']

        environment = request.session.get('environment')
        if environment == 'Production':
            username = request.session.get('prod_username')
            password = request.session.get('prod_password')

        elif environment == 'Pre-Production':
            # Need to put in an error as PPE search wont work!
            username = request.session.get('ppe_username')
            password = request.session.get('ppe_password')

        elif environment == 'Lab':
            username = request.session.get('lab_username')
            password = request.session.get('lab_password')

        # Get base url to use
        base_urls = get_base_url(environment)
        url_dict = base_urls['F5']

        # Deploy APIC configuration
        task = virtual_server_deployment.delay(vs_dict, location, url_dict,
                                               routeAdvertisement, username,
                                               password)

        # Return task id back to client for ajax use.
        return HttpResponse(json.dumps({'task_id': task.id}),
                            content_type='application/json')

    return redirect('/vs_deployment/')
Ejemplo n.º 6
0
def contract_deployment_push(request):
    user = request.session.get('user')
    role = request.session.get('role')
    # Deploy External EPG configuration
    if request.method == 'POST':
        response_json = request.body
        data = json.loads(response_json)
        location = data['location']
        rule_list = data['rule_list']

        environment = request.session.get('environment')
        if environment == 'Production':
            username = request.session.get('prod_username')
            password = request.session.get('prod_password')

        elif environment == 'Pre-Production':
            # Need to put in an error as PPE search wont work!
            username = request.session.get('ppe_username')
            password = request.session.get('ppe_password')

        elif environment == 'Lab':
            username = request.session.get('lab_username')
            password = request.session.get('lab_password')

        # Get base url to use
        base_urls = get_base_url(environment)
        url_dict = base_urls['ACI']

        # Deploy APIC configuration
        task = CONTRACT_DEPLOYMENT.delay(rule_list, location, url_dict,
                                         username, password)

        # Return task id back to client for ajax use.
        return HttpResponse(json.dumps({'task_id': task.id}),
                            content_type='application/json')

    return redirect('/contract_deployment/')
Ejemplo n.º 7
0
def ipg_deployment(request):
    user = request.session.get('user')
    role = request.session.get('role')
    # Present file upload to screen and give options to user
    if request.method == 'POST' and 'file' in request.FILES:
        file = request.FILES['file']
        location = request.POST['location']

        environment = request.session.get('environment')
        if environment == 'Production':
            username = request.session.get('prod_username')
            password = request.session.get('prod_password')

        elif environment == 'Pre-Production':
            # Need to put in an error as PPE search wont work!
            username = request.session.get('ppe_username')
            password = request.session.get('ppe_password')

        elif environment == 'Lab':
            username = request.session.get('lab_username')
            password = request.session.get('lab_password')

        # Get base url to use
        base_urls = get_base_url(environment)
        url_dict = base_urls['ACI']

        # Open workbook and build jason data structure.
        if file.name.endswith('yaml'):
            ipg_list = ipg_deployment_open_yaml(file, location)

        else:
            ipg_list = ipg_deployment_excel_open_workbook(file, location)

        # Validate Request names and format
        task = ipg_deployment_validation.delay(ipg_list, location, url_dict,
                                               username, password)

        # Return task id.
        return HttpResponse(json.dumps({
            'task_id': task.id,
            'ipg_list': ipg_list,
            'location': location,
            'role': role,
            'user': user
        }),
                            content_type='application/json')

    # Get base url to use
    environment = request.session.get('environment')
    base_urls = get_base_url(environment)
    url_dict = base_urls['ACI']
    location_list = list(url_dict.keys())

    content = {
        'environment': environment,
        'locations': location_list,
        'url_list': url_list,
        'role': role,
        'user': user
    }
    return render(request, 'aci_deployment/aci_ipg_deployment.html', content)
Ejemplo n.º 8
0
def vs_deployment(request):
    # Present file upload to screen and give options to user
    user = request.session.get('user')
    if request.method == 'POST' and 'file' in request.FILES:
        file = request.FILES['file']
        location = request.POST['location']

        # Check for Route Advertisment Tick
        try:
            request.POST['routeAdvertisement']
            routeAdvertisement = True
        except:
            routeAdvertisement = False

        environment = request.session.get('environment')
        role = request.session.get('role')

        if environment == 'Production':
            username = request.session.get('prod_username')
            password = request.session.get('prod_password')

        elif environment == 'Pre-Production':
            # Need to put in an error as PPE search wont work!
            username = request.session.get('ppe_username')
            password = request.session.get('ppe_password')

        elif environment == 'Lab':
            username = request.session.get('lab_username')
            password = request.session.get('lab_password')

        # Get base url to use
        base_urls = get_base_url(environment)
        url_dict = base_urls['F5']

        # Open workbook and build jason data structure.
        vs_dict = vs_deployment_excel_open_workbook(file)

        # Validate Request names and format
        task = vs_deployment_validation.delay(vs_dict, location, url_dict,
                                              username, password)
        content = {
            'task_id': task.id,
            'location': location,
            'routeAdvertisement': routeAdvertisement,
            'role': role,
            'user': user
        }
        # Return task id.
        return HttpResponse(json.dumps(content),
                            content_type='application/json')

    # Get base url to use
    environment = request.session.get('environment')
    role = request.session.get('role')
    base_urls = get_base_url(environment)
    url_dict = base_urls['F5']
    location_list = list(url_dict.keys())

    content = {
        'environment': environment,
        'locations': location_list,
        'url_list': url_list,
        'role': role,
        'user': user
    }
    return render(request, 'f5_deployment/f5_vs_deployment.html', content)