From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 694B726709 for ; Fri, 22 Jun 2018 17:43:59 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oMaOR_aUdw7y for ; Fri, 22 Jun 2018 17:43:59 -0400 (EDT) Received: from smtp36.i.mail.ru (smtp36.i.mail.ru [94.100.177.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 1721B24B8F for ; Fri, 22 Jun 2018 17:43:59 -0400 (EDT) From: AKhatskevich Subject: [tarantool-patches] [PATCH 2/3] Allow use existing user Date: Sat, 23 Jun 2018 00:43:34 +0300 Message-Id: <9e713265548c04cbc3325929ae6ba3fbef533245.1529703268.git.avkhatskevich@tarantool.org> In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org This commit allows to create vshard user outside of vshard. This feature is tested in the next commit (destroy). Closes #52 --- vshard/storage/init.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua index 57076e1..059e705 100644 --- a/vshard/storage/init.lua +++ b/vshard/storage/init.lua @@ -138,11 +138,19 @@ end -------------------------------------------------------------------------------- -- Schema -------------------------------------------------------------------------------- +local function create_user(username, password) + box.schema.user.create(username, { + password = password, + if_not_exists = true, + }) + -- Replication may has not been granted, if user exists. + box.schema.user.grant(username, 'replication', nil, nil, + {if_not_exists = true}) +end local function storage_schema_v1(username, password) log.info("Initializing schema") - box.schema.user.create(username, {password = password}) - box.schema.user.grant(username, 'replication') + create_user(username, password) local bucket = box.schema.space.create('_bucket') bucket:format({ -- 2.14.1