def aws_cluster_creator_step2(request): """This function is about VPC, subnet and security group selection. Based on previous entry vpc_selection, you will be redirected to a page to pick one of the available VPC, subnet and SG options or just create one automatically based on the name of the server. """ if request.method == 'POST': old_form = CreateClusterStep1(request.POST) log.info('Obtained CreateClusterStep1 form data') if old_form.is_valid(): region = old_form.cleaned_data['region'] vpc_selection = old_form.cleaned_data['vpc_selection'] log.debug('region= %s' % region) log.debug('vpc_selection= %s' % vpc_selection) if vpc_selection == "automatic": log.debug('Rendering aws_cluster_creator_step3.html using CreateClusterStep3 form.') form = CreateClusterStep3(request.POST or None) return render(request, 'aws_cluster_creator_step3.html', {'form': form}) if (vpc_selection == "existing") or (vpc_selection == "new"): log.debug('Rendering aws_cluster_creator_step2.html using CreateClusterStep2 form') form = CreateClusterStep2(request.POST or None) try: vpc_choices, subnet_choices, sg_choices = getVPCinfo(region) except Exception as ex: handle_exception(ex) return render(request, 'aws_cluster_creator_step2.html', {'form': form, 'vpc_selection': vpc_selection, 'vpc_choices': vpc_choices, 'subnet_choices': subnet_choices, 'sg_choices': sg_choices})
def aws_cluster_creator_step0(request): """Renders AWS cluster create step #0. It asks you to select a region to work with AWS EC2. """ # This will create a form, as defined in forms.py (CreateCluster0) form = CreateClusterStep0 try: # This will make use of the form defined above and render it using a template. return render(request, 'aws_cluster_creator_step0.html', {'form': form}) except Exception as e: handle_exception(e) return render(request, 'error.html')
def aws_cluster_creator_step1(request): """Renders AWS cluster create step #1. It asks you to select name, number, ami, instance type and more. """ if request.method == 'POST': old_form = CreateClusterStep0(request.POST) log.info('Obtained CreateClusterStep0 form data') if old_form.is_valid(): region = old_form.cleaned_data['region'] log.info('Old form value region: %s' % region) try: form = CreateClusterStep1(request.POST or None) ami_choices = getAMIs(region) except Exception as e: handle_exception(e) return render(request, 'aws_cluster_creator_step1.html', {'form': form, 'ami_choices': ami_choices}) else: return render(request, 'error.html')