Jan Ulrich Hasecke
2019-11-21 47bc28d554b0c474b06cdd291d6e7b8c942af359
source/referenz/hsadmin/createall.py
@@ -2,11 +2,18 @@
import string
import sys
from hs.admin.api import API
from subprocess import check_output
paketadmin = sys.argv[1]
domainname = sys.argv[2]
projektid = sys.argv[3]
pw = check_output(["pass", "hostsharing/"+paketadmin]).decode("utf-8").strip("\n")
api = API(cas=dict(
    uri='https://login.hostsharing.net/cas/v1/tickets',
    service='https://config.hostsharing.net:443/hsar/backend'),
    credentials=dict(username='xyz00', password='Y2kbZb)d*GQF%q1~m?7d8,]+'),
    credentials=dict(username=paketadmin, password=pw),
    backends=[
        'https://config.hostsharing.net:443/hsar/xmlrpc/hsadmin',
        'https://config2.hostsharing.net:443/hsar/xmlrpc/hsadmin'])
@@ -19,16 +26,16 @@
pw_dadmin = pwGen()
pw_dbuser = pwGen()
dadmin = paketadmin+'-'+domainname.replace("-", "_")
dbuser = paketadmin+'_'+projektid
dbname = paketadmin+'_'+projektid
domainname = sys.argv[1]
dbname = domainname.replace(".", "_")
api.user.add(set={'name': 'xyz00-'+domainname, 'password': pw_dadmin, 'shell': '/bin/bash'})
api.domain.add(set={'name': domainname, 'user': 'xyz00-'+domainname})
api.mysqluser.add(set={'name': 'xyz00_'+dbname, 'password': pw_dbuser})
api.mysqldb.add(set={'name': 'xyz00_'+dbname, 'owner': 'xyz00_'+dbname})
api.user.add(set={'name': dadmin, 'password': pw_dadmin, 'shell': '/bin/bash'})
api.domain.add(set={'name': domainname, 'user': dadmin})
api.mysqluser.add(set={'name': dbuser, 'password': pw_dbuser})
api.mysqldb.add(set={'name': dbname, 'owner': dbuser})
print("Domainname:" +domainname)
print("Domain-Admin: xyz00-"+domainname + "Passwort:" +pw_dadmin)
print("Datenbank-Nutzer: " +dbname + "Passwort:" +pw_dbuser)
print("Datenbank: " +dbname)
print("Domain-Admin: " + dadmin + " mit dem Passwort:" +pw_dadmin)
print("Datenbank-Nutzer: " +dbuser + " Passwort:" +pw_dbuser)
print("Datenbankname: " +dbname)