diff -Naur /var/www/cgi-bin/login.py /var/www.new/cgi-bin/login.py
--- /var/www/cgi-bin/login.py 2016-04-21 07:47:13.733947656 +0200
+++ /var/www.new/cgi-bin/login.py 2016-04-21 07:46:36.342036362 +0200
@@ -18,7 +18,7 @@
SERVER_NAME = 'ad'
DOMAIN_NAME = 'slu.se'
BASE_DN = "DC=AD,DC=SLU,DC=SE"
-
+
LDAP_SERVER = 'ldap://%s.%s' % (SERVER_NAME,DOMAIN_NAME)
LDAP_USERNAME = '%s@%s.%s' % (username,SERVER_NAME,DOMAIN_NAME)
LDAP_PASSWORD = password
@@ -59,13 +59,16 @@
if key == "userPrincipalName":
split_userPrincipalName = value[0].split('@')
userPrincipalName = split_userPrincipalName[0]
+ suffix = '@%s' % (split_userPrincipalName[1])
ldap_client.unbind()
response["success"] = "true"
response["code"] = 0
response["message"] = "Successful authentication"
response["user"]["username"] = username
response["user"]["PrincipalName"] = userPrincipalName
+ response["user"]["Suffix"] = suffix
print json.dumps(response)
exit(response["code"])
check_credentials(username,password)
+
diff -Naur /var/www/cgi-bin/vpsconfirmdestroy.cgi /var/www.new/cgi-bin/vpsconfirmdestroy.cgi
--- /var/www/cgi-bin/vpsconfirmdestroy.cgi 2016-04-21 07:47:13.733947656 +0200
+++ /var/www.new/cgi-bin/vpsconfirmdestroy.cgi 2016-04-21 07:46:36.343036360 +0200
@@ -14,6 +14,7 @@
form = cgi.FieldStorage()
CUSTOMER_ID = form.getvalue('userid')
PRINCIPAL_NAME = form.getvalue('principalname')
+SUFFIX = form.getvalue('suffix')
VM_NAME = form.getvalue('vmname')
import re
import subprocess
@@ -29,7 +30,7 @@
HOSTNAME = dc.GetHostname(VM_NAME)
ALIAS = VM_NAME + '.vps.slu.se'
-
+
try:
cc.StartVM(VM_NAME)
except Exception as e:
@@ -55,7 +56,7 @@
if re.search('%s is an alias for %s' % (ALIAS,HOSTNAME), host):
logging.debug('Alias "%s" is registered in DNS. De-registering alias.' % (ALIAS))
try:
- dc.SendAliasDeregistration(CUSTOMER_ID, VM_NAME, HOSTNAME)
+ dc.SendAliasDeregistration(PRINCIPAL_NAME, VM_NAME, HOSTNAME)
except Exception as e:
logging.debug('Failed to send alias de-registration email to domainmaster:\n%s' % str(e))
ERRORCODE = '6'
@@ -69,7 +70,7 @@
logging.debug('Failed to de-register domain name "%s.vps.slu.se":\n%s' % VM_NAME,str(e))
ERRORCODE = '6'
dc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
- exit(1)
+ exit(1)
except Exception as e:
logging.debug('Unhandled exception:\n%s' % str(e))
ERRORCODE = '100'
@@ -93,7 +94,7 @@
exit(1)
try:
- dc.SendDeleteSuccess(CUSTOMER_ID, VM_NAME, HOSTNAME, PRINCIPAL_NAME)
+ dc.SendDeleteSuccess(PRINCIPAL_NAME, VM_NAME, HOSTNAME)
except Exception as e:
logging.debug('Failed to send deletion confirmation email:\n%s' % str(e))
ERRORCODE = '9'
@@ -103,3 +104,4 @@
CODE = '2'
dc.PrintDeleteSuccess(CODE)
logging.debug('VPS Deletion sequence complete for user "%s" on VM "%s"' % (CUSTOMER_ID,VM_NAME))
+
diff -Naur /var/www/cgi-bin/vpscreate.cgi /var/www.new/cgi-bin/vpscreate.cgi
--- /var/www/cgi-bin/vpscreate.cgi 2016-04-21 07:47:13.734947654 +0200
+++ /var/www.new/cgi-bin/vpscreate.cgi 2016-04-21 08:10:37.441617598 +0200
@@ -14,6 +14,7 @@
form = cgi.FieldStorage()
CUSTOMER_ID = form.getvalue('userid')
PRINCIPAL_NAME = form.getvalue('PrincipalName')
+SUFFIX = form.getvalue('Suffix')
TEMPLATE_NAME = form.getvalue('template')
VM_NAME = form.getvalue('vmname')
import socket
@@ -28,7 +29,7 @@
from kira.api import api
if __name__ == '__main__':
-
+
cc = CreateClass()
logging.debug('VPS Creation sequence started for user "%s" on VM "%s"' % (CUSTOMER_ID,VM_NAME))
@@ -147,20 +148,20 @@
exit(1)
try:
- for USER_LIST_OBJECT in api.users.list(query='usrname=%s*' % (PRINCIPAL_NAME)):
+ for USER_LIST_OBJECT in api.users.list(query='*'):
try:
- USER_NAME_ID = USER_LIST_OBJECT.get_id()
- FULL_USER_NAME = api.users.get(id='%s' % (USER_NAME_ID)).get_user_name()
- USER_NAME = FULL_USER_NAME.split("@")[0]
- if USER_NAME == PRINCIPAL_NAME:
- user = USER_NAME
+ USER_OBJECT_ID = USER_LIST_OBJECT.get_id()
+ USER_EMAIL_ADDRESS = api.users.get(id='%s' % (USER_OBJECT_ID)).get_email()
+ SPLIT_EMAIL_ADDRESS = USER_EMAIL_ADDRESS.split("@")[0]
+ if SPLIT_EMAIL_ADDRESS == PRINCIPAL_NAME:
+ user = SPLIT_EMAIL_ADDRESS
logging.debug('Found existing user registered in oVirt: "%s". Proceeding.' % (user))
try:
cc.SetPermissions(VM_NAME, PRINCIPAL_NAME, ROLE_NAME)
except Exception as e:
logging.debug('Failed to set permissions:\n%s' % str(e))
ERRORCODE = '8'
- cc.PrintError(VM_NAME,PRINCIPAL_NAME,ERRORCODE)
+ cc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
exit(1)
except AttributeError:
pass
@@ -170,23 +171,24 @@
except NameError:
logging.debug('No existing user registered in oVirt: "%s". Needs registration.' % (PRINCIPAL_NAME))
try:
- cc.CreateUser(CUSTOMER_ID, DOMAIN_NAME)
+
+ cc.CreateUser(PRINCIPAL_NAME,SUFFIX,DOMAIN_NAME)
except Exception as e:
logging.debug('Failed to create user:\n%s' % str(e))
ERRORCODE = '9'
- cc.PrintError(VM_NAME,PRINCIPAL_NAME,ERRORCODE)
+ cc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
exit(1)
try:
- cc.SetPermissions(VM_NAME, PRINCIPAL_NAME, ROLE_NAME)
+ cc.SetPermissions(VM_NAME,PRINCIPAL_NAME,ROLE_NAME)
except Exception as e:
logging.debug('Failed to set permissions:\n%s' % str(e))
ERRORCODE = '8'
- cc.PrintError(VM_NAME,PRINCIPAL_NAME,ERRORCODE)
+ cc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
exit(1)
except Exception as e:
logging.debug('Unhandled exception:\n%s' % str(e))
ERRORCODE = '100'
- cc.PrintError(VM_NAME,PRINCIPAL_NAME,ERRORCODE)
+ cc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
exit(1)
try:
@@ -222,7 +224,7 @@
exit(1)
try:
- cc.SendConfirmation(PRINCIPAL_NAME, VM_NAME)
+ cc.SendConfirmation(PRINCIPAL_NAME, VM_NAME, CUSTOMER_ID)
except Exception as e:
logging.debug('Failed to send confirmation email:\n%s' % str(e))
ERRORCODE = '13'
diff -Naur /var/www/cgi-bin/vpsdestroy.cgi /var/www.new/cgi-bin/vpsdestroy.cgi
--- /var/www/cgi-bin/vpsdestroy.cgi 2016-04-21 07:47:13.734947654 +0200
+++ /var/www.new/cgi-bin/vpsdestroy.cgi 2016-04-21 07:46:36.343036360 +0200
@@ -5,6 +5,7 @@
form = cgi.FieldStorage()
CUSTOMER_ID = form.getvalue('userid')
PRINCIPAL_NAME = form.getvalue('PrincipalName')
+SUFFIX = form.getvalue('Suffix')
VM_NAME = form.getvalue('vmname')
import logging
logging.basicConfig(filename='/var/log/vpscreate.log', format='%(asctime)s: %(message)s', level=logging.DEBUG)
@@ -12,11 +13,11 @@
from kira.api import api
if __name__ == '__main__':
-
+
dc = DestroyClass()
logging.debug('VPS Deletion sequence started for user "%s" on VM "%s"' % (CUSTOMER_ID,VM_NAME))
-
+
if CUSTOMER_ID == None:
logging.debug('Error: Variable "CUSTOMER_ID" was empty')
ERRORCODE = '1'
@@ -25,7 +26,7 @@
elif PRINCIPAL_NAME == None:
logging.debug('Error: Variable "PRINCIPAL_NAME" was empty')
ERRORCODE = '1'
- cc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
+ dc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
exit(1)
elif VM_NAME == None:
logging.debug('Error: Variable "VM_NAME" was empty')
@@ -42,13 +43,13 @@
VM_NAME = VM_NAME.lower()
try:
- for USER_LIST_OBJECT in api.users.list(query='usrname=%s*' % (PRINCIPAL_NAME)):
+ for USER_LIST_OBJECT in api.users.list(query='*'):
try:
- USER_NAME_ID = USER_LIST_OBJECT.get_id()
- FULL_USER_NAME = api.users.get(id='%s' % (USER_NAME_ID)).get_user_name()
- USER_NAME = FULL_USER_NAME.split("@")[0]
- if USER_NAME == PRINCIPAL_NAME:
- user = USER_NAME
+ USER_OBJECT_ID = USER_LIST_OBJECT.get_id()
+ USER_EMAIL_ADDRESS = api.users.get(id='%s' % (USER_OBJECT_ID)).get_email()
+ SPLIT_EMAIL_ADDRESS = USER_EMAIL_ADDRESS.split("@")[0]
+ if SPLIT_EMAIL_ADDRESS == PRINCIPAL_NAME:
+ user = SPLIT_EMAIL_ADDRESS
logging.debug('Found matching user name registered in oVirt: "%s". Proceeding.' % (user))
except AttributeError:
pass
@@ -58,21 +59,21 @@
except NameError:
logging.debug('User name is not registered in oVirt: "%s". Aborting.' % (PRINCIPAL_NAME))
ERRORCODE = '4'
- dc.PrintError(VM_NAME,PRINCIPAL_NAME,ERRORCODE)
+ dc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
except Exception as e:
logging.debug('Unhandled exception:\n%s' % str(e))
ERRORCODE = '100'
- dc.PrintError(VM_NAME,PRINCIPAL_NAME,ERRORCODE)
+ dc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
exit(1)
try:
for VM_PERMISSIONS_LIST_OBJECT in api.vms.get(VM_NAME).permissions.list():
try:
USER_NAME_ID = VM_PERMISSIONS_LIST_OBJECT.get_user().get_id()
- FULL_USER_NAME = api.users.get(id='%s' % (USER_NAME_ID)).get_user_name()
- USER_NAME = FULL_USER_NAME.split("@")[0]
- if USER_NAME == PRINCIPAL_NAME:
- owner = USER_NAME
+ USER_EMAIL_ADDRESS = api.users.get(id='%s' % (USER_NAME_ID)).get_email()
+ SPLIT_EMAIL_ADDRESS = USER_EMAIL_ADDRESS.split("@")[0]
+ if SPLIT_EMAIL_ADDRESS == PRINCIPAL_NAME:
+ owner = SPLIT_EMAIL_ADDRESS
logging.debug('Found matching user name in VM Permissions list: "%s". Proceeding.' % (owner))
except AttributeError:
pass
@@ -82,12 +83,12 @@
except NameError:
logging.debug('User name not found in VM Permissions list: "%s". Aborting.' % (PRINCIPAL_NAME))
ERRORCODE = '5'
- dc.PrintError(VM_NAME,PRINCIPAL_NAME,ERRORCODE)
+ dc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
exit(1)
except Exception as e:
logging.debug('Unhandled exception:\n%s' % str(e))
ERRORCODE = '100'
- dc.PrintError(VM_NAME,PRINCIPAL_NAME,ERRORCODE)
+ dc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
exit(1)
try:
@@ -97,9 +98,9 @@
ERRORCODE = '100'
dc.PrintError(VM_NAME,CUSTOMER_ID,ERRORCODE)
exit(1)
-
+
try:
- dc.SendDeleteConfirmation(CUSTOMER_ID, VM_NAME, HOSTNAME, PRINCIPAL_NAME)
+ dc.SendDeleteConfirmation(CUSTOMER_ID, VM_NAME, HOSTNAME, PRINCIPAL_NAME, SUFFIX)
except Exception as e:
logging.debug('Failed to send delete confirmation:\n%s' % str(e))
ERRORCODE = '9'
@@ -108,3 +109,4 @@
CODE = '1'
dc.PrintDeleteSuccess(CODE)
+
diff -Naur /var/www/html/orderportal.html /var/www.new/html/orderportal.html
--- /var/www/html/orderportal.html 2016-04-21 07:47:13.734947654 +0200
+++ /var/www.new/html/orderportal.html 2016-04-21 07:46:36.195036711 +0200
@@ -215,6 +215,7 @@
: User ID (e.g. abcd0001)
: User Principal Name
+ : Suffix
: Desired Hostname (e.g. testsystem)
Only characters "a-z", "0-9" and "-" are allowed. Maximum length is 15 characters.
@@ -265,6 +266,7 @@