|
@@ -29,10 +29,6 @@ def initialize(args):
|
|
# set up database software
|
|
# set up database software
|
|
if not __init_database(fwroot, dbuser, dbhost, dbiden, args.quiet) and not args.quiet:
|
|
if not __init_database(fwroot, dbuser, dbhost, dbiden, args.quiet) and not args.quiet:
|
|
return __print_failure()
|
|
return __print_failure()
|
|
- else:
|
|
|
|
- # set up database docker images
|
|
|
|
- if not __build_database_docker_images(fwroot, dbuser, dbhost, dbiden, args.quiet) and not args.quiet:
|
|
|
|
- return __print_failure()
|
|
|
|
|
|
|
|
def __print_failure():
|
|
def __print_failure():
|
|
print("""
|
|
print("""
|
|
@@ -53,13 +49,6 @@ def __print_failure():
|
|
|
|
|
|
def __ssh_string(user, host, identity_file):
|
|
def __ssh_string(user, host, identity_file):
|
|
return ["ssh", "-T", "-o", "StrictHostKeyChecking=no", "%s@%s" % (user, host), "-i", identity_file]
|
|
return ["ssh", "-T", "-o", "StrictHostKeyChecking=no", "%s@%s" % (user, host), "-i", identity_file]
|
|
-
|
|
|
|
-def __scp_string(user, host, identity_file, files):
|
|
|
|
- scpstr = ["scp", "-i", identity_file]
|
|
|
|
- for file in files:
|
|
|
|
- scpstr.append(file)
|
|
|
|
- scpstr.append("%s@%s:~/" % (user, host))
|
|
|
|
- return scpstr
|
|
|
|
|
|
|
|
def __check_connection(user, host, identity_file, app_host):
|
|
def __check_connection(user, host, identity_file, app_host):
|
|
'''
|
|
'''
|
|
@@ -113,32 +102,4 @@ def __init_database(fwroot, user, host, identity_file, quiet):
|
|
p = subprocess.Popen(__ssh_string(user, host, identity_file),
|
|
p = subprocess.Popen(__ssh_string(user, host, identity_file),
|
|
stdin=subprocess.PIPE)
|
|
stdin=subprocess.PIPE)
|
|
p.communicate(remote_script)
|
|
p.communicate(remote_script)
|
|
- return p.returncode == 0
|
|
|
|
-
|
|
|
|
-def __build_database_docker_images(fwroot, user, host, identity_file, quiet):
|
|
|
|
- '''
|
|
|
|
- Transfers all the files required by each database to the database machine and
|
|
|
|
- builds the docker image for each on the database machine.
|
|
|
|
- '''
|
|
|
|
- if not quiet:
|
|
|
|
- print("INSTALL: Building database docker images")
|
|
|
|
-
|
|
|
|
- returncode = 0
|
|
|
|
- databases_path = os.path.join(fwroot, "toolset", "setup", "linux", "docker", "databases")
|
|
|
|
- for database in os.listdir(databases_path):
|
|
|
|
- dbpath = os.path.join(databases_path, database)
|
|
|
|
- dbfiles = ""
|
|
|
|
- for dbfile in os.listdir(dbpath):
|
|
|
|
- dbfiles += "%s " % os.path.join(dbpath,dbfile)
|
|
|
|
- p = subprocess.Popen(__scp_string(user, host, identity_file, dbfiles.split()),
|
|
|
|
- stdin=subprocess.PIPE)
|
|
|
|
- p.communicate()
|
|
|
|
- returncode += p.returncode
|
|
|
|
-
|
|
|
|
- if p.returncode == 0:
|
|
|
|
- p = subprocess.Popen(__ssh_string(user, host, identity_file),
|
|
|
|
- stdin=subprocess.PIPE)
|
|
|
|
- p.communicate("docker build -f ~/%s.dockerfile -t %s ~/" % (database, database))
|
|
|
|
- returncode += p.returncode
|
|
|
|
-
|
|
|
|
- return returncode == 0
|
|
|
|
|
|
+ return p.returncode == 0
|