'Create a new stack using the template provided.
Note that at this stage the template has already been fetched from the
heat-api process if using a template-url.
:param cnxt: RPC context.
:param stack_name: Name of the stack you want to create.
:param template: Template of stack you want to create.
:param params: Stack Input Params
:param files: Files referenced from the template
:param args: Request parameters/args passed from API
:param environment_files: optional ordered list of environment file
names included in the files dict
:type  environment_files: list or None
:param owner_id: parent stack ID for nested stacks, only expected when
called from another heat-engine (not a user option)
:param nested_depth: the nested depth for nested stacks, only expected
when called from another heat-engine
:param user_creds_id: the parent user_creds record for nested stacks
:param stack_user_project_id: the parent stack_user_project_id for
nested stacks
:param parent_resource_name: the parent resource name
:param template_id: the ID of a pre-stored template in the DB'

@context.request_context
def create_stack(self, cnxt, stack_name, template, params, files, args, environment_files=None, owner_id=None, nested_depth=0, user_creds_id=None, stack_user_project_id=None, parent_resource_name=None, template_id=None):

    LOG.info('Creating    stack    %s', stack_name)
    def _create_stack_user(stack):
        if (not stack.stack_user_project_id):
            try:
                stack.create_stack_user_project_id()
            except exception.AuthorizationFailure as ex:
                stack.state_set(stack.action, stack.FAILED, six.text_type(ex))
    def _stack_create(stack, msg_queue=None):
        if stack.adopt_stack_data:
            stack.adopt()
        elif (stack.status != stack.FAILED):
            stack.create(msg_queue=msg_queue)
        if ((stack.action in (stack.CREATE, stack.ADOPT)) and (stack.status == stack.COMPLETE)):
            if self.stack_watch:
                self.stack_watch.start_watch_task(stack.id, cnxt)
        else:
            LOG.info('Stack    create    failed,    status    %s', stack.status)
    convergence = cfg.CONF.convergence_engine
    stack = self._parse_template_and_validate_stack(cnxt, stack_name, template, params, files, environment_files, args, owner_id, nested_depth, user_creds_id, stack_user_project_id, convergence, parent_resource_name, template_id)
    stack_id = stack.store()
    if (cfg.CONF.reauthentication_auth_method == 'trusts'):
        stack = parser.Stack.load(cnxt, stack_id=stack_id, use_stored_context=True)
    _create_stack_user(stack)
    if convergence:
        action = stack.CREATE
        if stack.adopt_stack_data:
            action = stack.ADOPT
        stack.thread_group_mgr = self.thread_group_mgr
        stack.converge_stack(template=stack.t, action=action)
    else:
        msg_queue = eventlet.queue.LightQueue()
        th = self.thread_group_mgr.start_with_lock(cnxt, stack, self.engine_id, _stack_create, stack, msg_queue=msg_queue)
        th.link(self.thread_group_mgr.remove_msg_queue, stack.id, msg_queue)
        self.thread_group_mgr.add_msg_queue(stack.id, msg_queue)
    return dict(stack.identifier())
