'Create a user.
User can be defined as part of a stack, either via template
or created internally by a resource.  This user will be added to
the heat_stack_user_role as defined in the config
Returns the keystone ID of the resulting user'

def create_stack_user(self, username, password=''):

    if (len(username) > 64):
        LOG.warning('Truncating    the    username    %s    to    the    last    64    characters.', username)
        username = username[(-64):]
    user = self.client.users.create(username, password, ('%s@openstack.org' % username), tenant_id=self.context.tenant_id, enabled=True)
    roles = self.client.roles.list()
    stack_user_role = [r.id for r in roles if (r.name == cfg.CONF.heat_stack_user_role)]
    if (len(stack_user_role) == 1):
        role_id = stack_user_role[0]
        LOG.debug(('Adding    user    %(user)s    to    role    %(role)s' % {'user': user.id, 'role': role_id}))
        self.client.roles.add_user_role(user.id, role_id, self.context.tenant_id)
    else:
        LOG.error('Failed    to    add    user    %(user)s    to    role    %(role)s,    check    role    exists!', {'user': username, 'role': cfg.CONF.heat_stack_user_role})
    return user.id
