You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2018/10/22 10:05:45 UTC

[kibble] branch master updated: allow non-interactive setups for docker et al.

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble.git


The following commit(s) were added to refs/heads/master by this push:
     new 49c6519  allow non-interactive setups for docker et al.
49c6519 is described below

commit 49c6519b68769041283296041eefb63dd2cd810e
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Oct 22 10:53:49 2018 +0200

    allow non-interactive setups for docker et al.
---
 setup/setup.py | 38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/setup/setup.py b/setup/setup.py
index 9f9fb30..7e93032 100644
--- a/setup/setup.py
+++ b/setup/setup.py
@@ -61,21 +61,34 @@ elif dopip:
         print("pip install elasticsearch certifi")
         sys.exit(-1)
 
+
+# Arguments for non-interactive setups like docker
+arg_parser = argparse.ArgumentParser()
+arg_parser.add_argument("-e", "--hostname", help="Pre-defined hostname for ElasticSearch (docker setups)")
+arg_parser.add_argument("-p", "--port", help="Pre-defined port for ES (docker setups)")
+arg_parser.add_argument("-d", "--dbname", help="Pre-defined Database prefix (docker setups)")
+arg_parser.add_argument("-s", "--shards", help="Predefined number of ES shards (docker setups)")
+arg_parser.add_argument("-r", "--replicas", help="Predefined number of replicas for ES (docker setups)")
+arg_parser.add_argument("-m", "--mailhost", help="Pre-defined mail server host (docker setups)")
+arg_parser.add_argument("-a", "--autoadmin", action='store_true', help="Generate generic admin account (docker setups)")
+arg_parser.add_argument("-k", "--skiponexist", action='store_true', help="Skip DB creation if DBs exist (docker setups)")
+args = arg_parser.parse_args()
+
 print("Welcome to the Apache Kibble setup script!")
 print("Let's start by determining some settings...")
 print("")
 
 
-hostname = ""
-port = 0
-dbname = ""
-mlserver = ""
+hostname = args.hostname or ""
+port = int(args.port) if args.port else 0
+dbname = args.dbname or ""
+mlserver = args.mailhost or ""
 mldom = ""
 wc = ""
 genname = ""
 wce = False
-shards = 0
-replicas = -1
+shards = int(args.shards) if args.shards else 0
+replicas = int(args.replicas) if args.replicas else -1
 
 while hostname == "":
     hostname = input("What is the hostname of the ElasticSearch server? [localhost]: ")
@@ -125,10 +138,12 @@ while replicas < 0:
         pass
 
 adminName = ""
+adminPass = ""
+if args.autoadmin:
+    adminName = "admin@kibble"
+    adminPass = "kibbleAdmin"
 while adminName == "":
     adminName = input("Enter an email address for the adminstrator account: ")
-
-adminPass = ""
 while adminPass == "":
     adminPass = input("Enter a password for the adminstrator account: ")
     
@@ -152,8 +167,11 @@ def createIndex():
         print("New Kibble installations require ElasticSearch 6.x or newer! You appear to be running %s!" % es.info()['version']['number'])
         sys.exit(-1)
     # Check if index already exists
-    if es.indices.exists(dbname):
-        print("Error: ElasticSearch index '%s' already exists!" % dbname)
+    if es.indices.exists(dbname+"_api"):
+        if args.skiponexist: # Skip this is DB exists and -k added
+            print("DB prefix exists, but --skiponexist used, skipping this step.")
+            return
+        print("Error: ElasticSearch DB prefix '%s' already exists!" % dbname)
         sys.exit(-1)
 
     types = [