(request, topology_id)
:param request: Django request
    :param topology_id: id of the topology to export
    :return: renders the heat template
:param request: Django request
    :param topology_id: id of the topology to export
    :return: renders the heat template
: param request : Django request : param topology_id : id of the topology to export : return : renders the heat template
def deploy_stack(request, topology_id):
    """
    :param request: Django request
    :param topology_id: id of the topology to export
    :return: renders the heat template
    """
    try:
        topology = Topology.objects.get(pk=topology_id)
    except ObjectDoesNotExist:
        return render(request, 'error.html', {'error': "Topology not found!"})

    try:
        # generate a stack name
        # FIXME should add a check to verify this is a unique name
        stack_name = topology.name.replace(' ', '_')

        # let's parse the json and convert to simple lists and dicts
        logger.debug("loading config")
        config = wistarUtils.load_config_from_topology_json(topology.json, topology_id)
        logger.debug("Config is loaded")
        heat_template = wistarUtils.get_heat_json_from_topology_config(config, stack_name)
        logger.debug("heat template created")
        if not openstackUtils.connect_to_openstack():
            return render(request, 'error.html', {'error': "Could not connect to Openstack"})

        # get the tenant_id of the desired project
        tenant_id = openstackUtils.get_project_id(configuration.openstack_project)
        logger.debug("using tenant_id of: %s" % tenant_id)
        if tenant_id is None:
            raise Exception("No project found for %s" % configuration.openstack_project)

        # FIXME - verify all images are in glance before jumping off here!

        logger.debug(openstackUtils.create_stack(stack_name, heat_template))

        return HttpResponseRedirect('/topologies/' + topology_id + '/')

    except Exception as e:
        logger.debug("Caught Exception in deploy")
        logger.debug(str(e))
        return render(request, 'error.html', {'error': str(e)})
def deploy_stack ( request , topology_id ) : try : topology = Topology . objects . get ( pk = topology_id ) except ObjectDoesNotExist : return render ( request , 'error.html' , { 'error' : "Topology not found!" } ) try : # generate a stack name # FIXME should add a check to verify this is a unique name stack_name = topology . name . replace ( ' ' , '_' ) # let's parse the json and convert to simple lists and dicts logger . debug ( "loading config" ) config = wistarUtils . load_config_from_topology_json ( topology . json , topology_id ) logger . debug ( "Config is loaded" ) heat_template = wistarUtils . get_heat_json_from_topology_config ( config , stack_name ) logger . debug ( "heat template created" ) if not openstackUtils . connect_to_openstack ( ) : return render ( request , 'error.html' , { 'error' : "Could not connect to Openstack" } ) # get the tenant_id of the desired project tenant_id = openstackUtils . get_project_id ( configuration . openstack_project ) logger . debug ( "using tenant_id of: %s" % tenant_id ) if tenant_id is None : raise Exception ( "No project found for %s" % configuration . openstack_project ) # FIXME - verify all images are in glance before jumping off here! logger . debug ( openstackUtils . create_stack ( stack_name , heat_template ) ) return HttpResponseRedirect ( '/topologies/' + topology_id + '/' ) except Exception as e : logger . debug ( "Caught Exception in deploy" ) logger . debug ( str ( e ) ) return render ( request , 'error.html' , { 'error' : str ( e ) } )