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 @@
: User ID (e.g. abcd0001)
: User Principal Name
+ : Suffix
: Hostname (e.g. testsystem)
diff -Naur /var/www/html/orderportal.js /var/www.new/html/orderportal.js --- /var/www/html/orderportal.js 2016-04-21 07:47:13.735947651 +0200 +++ /var/www.new/html/orderportal.js 2016-04-21 07:46:36.195036711 +0200 @@ -33,11 +33,13 @@ dataType:"json", success:function(data, xhr, textStatus) { if (data.success == "true") { + setCookie("Suffix", data.user.Suffix, 2); setCookie("PrincipalName", data.user.PrincipalName, 2); setCookie("username", data.user.username, 2); $('#login').remove(); $('input[name="userid"]').val(data.user.username); $('input[name="PrincipalName"]').val(data.user.PrincipalName); + $('input[name="Suffix"]').val(data.user.Suffix); } else if (data.fail == "true") { alert(data.message); } diff -Nau /usr/lib/python2.6/site-packages/kira/api.py /usr/lib/python2.6/site-packages/kira/api.py.new --- /usr/lib/python2.6/site-packages/kira/api.py 2016-04-21 07:47:13.737947646 +0200 +++ /usr/lib/python2.6/site-packages/kira/api.py.new 2016-04-21 08:09:50.066729991 +0200 @@ -37,7 +37,7 @@ api = API(url=URL, ca_file=CACERT, username=USERNAME, password=PASSWORD) class CreateClass(object): - + def PrintError(self, VM_NAME, CUSTOMER_ID, ERRORCODE): print "Content-type:text/html\r\n\r\n" print """ @@ -100,7 +100,7 @@ logging.debug('VMDisk was renamed to match name of VM') except Exception as e: raise(e) - + def CreateSnapshot(self, VM_NAME, SNAPSHOT_NAME): try: api.vms.get(VM_NAME).snapshots.add(params.Snapshot(description=SNAPSHOT_NAME, vm=api.vms.get(VM_NAME))) @@ -111,29 +111,30 @@ logging.debug('Snapshot creation complete') except Exception as e: raise(e) - - def CreateUser(self, CUSTOMER_ID, DOMAIN_NAME): + + def CreateUser(self, PRINCIPAL_NAME, SUFFIX, DOMAIN_NAME): try: - logging.debug('Creating a user called "%s"' % (CUSTOMER_ID)) + print 'Creating a user called "%s%s"' % (PRINCIPAL_NAME,SUFFIX) domain = api.domains.get(name='%s' % (DOMAIN_NAME)) userparams = params.User() - userparams.set_user_name(CUSTOMER_ID) + userparams.set_user_name('%s%s' % (PRINCIPAL_NAME,SUFFIX)) + userparams.set_principal('%s%s' % (PRINCIPAL_NAME,SUFFIX)) userparams.set_domain(domain) api.users.add(userparams) except Exception as e: raise(e) - - def SetPermissions(self, VM_NAME, CUSTOMER_ID, ROLE_NAME): + + def SetPermissions(self, VM_NAME, PRINCIPAL_NAME, ROLE_NAME): try: - logging.debug('Setting Owner permissions on VM "%s" for user "%s"' % (VM_NAME,CUSTOMER_ID)) + logging.debug('Setting Owner permissions on VM "%s" for user "%s"' % (VM_NAME,PRINCIPAL_NAME)) vm = api.vms.get(name=VM_NAME) - for USER_LIST_OBJECT in api.users.list(query='usrname=%s*' % (CUSTOMER_ID)): + 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 == CUSTOMER_ID: - user = api.users.get(id='%s' % (USER_NAME_ID)) + 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 = api.users.get(id='%s' % (USER_OBJECT_ID)) except AttributeError: pass try: @@ -148,7 +149,7 @@ user.permissions.add(permit) except Exception as e: raise(e) - + def RegisterAddress(self, VM_NAME): try: logging.debug('Registering address for VM "%s"' % (VM_NAME)) @@ -165,7 +166,7 @@ subprocess.Popen(['/usr/bin/ssh', '-i', '/var/lib/ovirt-engine/.ssh/id_rsa', 'ovirt@dns1.slu.se', '/usr/local/bin/add-vps-client.sh', '>/dev/null', VM_NAME, joinedstring]) except Exception as e: raise(e) - + def StartVM(self, VM_NAME): try: if api.vms.get(VM_NAME).status.state != 'up': @@ -193,7 +194,7 @@ return "ovirt-%s.vps.slu.se" % (joinedstring) except Exception as e: raise(e) - + def SetOwner(self, CUSTOMER_ID, HOSTNAME, VM_NAME): try: logging.debug('Setting user "%s" as owner on VM "%s"' % (CUSTOMER_ID,VM_NAME)) @@ -203,17 +204,17 @@ except Exception as e: raise(e) - def SendAliasRegistration(self, CUSTOMER_ID, VM_NAME, HOSTNAME): + def SendAliasRegistration(self, PRINCIPAL_NAME, VM_NAME, HOSTNAME): try: logging.debug('Sending registration mail to domainmaster') smtpObj = smtplib.SMTP('smtp.slu.se', 25) - for USER_LIST_OBJECT in api.users.list(query='usrname=%s*' % (CUSTOMER_ID)): + 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 == CUSTOMER_ID: - sender = api.users.get(id='%s' % (USER_NAME_ID)) + 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: + sender = api.users.get(id='%s' % (USER_OBJECT_ID)) except AttributeError: pass try: @@ -236,16 +237,16 @@ logging.debug('Failed to send alias registration email:\n%s' % str(e)) raise(e) - def SendConfirmation(self, CUSTOMER_ID, VM_NAME): + def SendConfirmation(self, PRINCIPAL_NAME, VM_NAME, CUSTOMER_ID): smtpObj = smtplib.SMTP('smtp.slu.se', 25) sender = 'vpsorderportal@slu.se' - for USER_LIST_OBJECT in api.users.list(query='usrname=%s*' % (CUSTOMER_ID)): + 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 == CUSTOMER_ID: - receiver = api.users.get(id='%s' % (USER_NAME_ID)) + 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: + receiver = api.users.get(id='%s' % (USER_OBJECT_ID)) except AttributeError: pass try: @@ -253,6 +254,7 @@ pass except NameError: logging.debug('User email address was not found.') + receiver_principal = PRINCIPAL_NAME.lower() receiver_email = receiver.get_email() receiver_firstname = receiver.get_name().encode('utf-8') receiver_lastname = receiver.get_last_name().encode('utf-8') @@ -264,11 +266,15 @@ Your VPS "%s.vps.slu.se" is now registered! -To start using your new VPS, you must first go to "https://storm.slu.se/spice.html" and install a plugin for your web browser that allows you to connect to the machine´s console(the monitor). This only needs to be done once. You will then need to shut down all your open browser sessions and start them back up again for the plugin to be loaded. After that, you go to "https://storm.slu.se/ovirt-engine/userportal" where you log in using your domain account to administer the machine, like start, stop and take snapshots. You can also log in to the machine over SSH(if *NIX) or PowerShell(if Windows) from anywhere, not having to go through the portal. Regardless of whether you log in through the portal or remote, you just use your domain account and you´re in! To elevate your privileges, use sudo(if *NIX) or just "Run as Administrator"(if Windows). +To start using your new VPS, you must first go to "https://storm.slu.se/spice.html" and install a plugin for your web browser that allows you to connect to the machine´s console(the monitor). This only needs to be done once. You will then need to shut down all your open browser sessions and start them back up again for the plugin to be loaded. + +After that, you go to "https://storm.slu.se/ovirt-engine/userportal" where you log in using your userPrincipalName "%s" to administer the machine, like start, stop and take snapshots. + +You can also log in to the machine over SSH(if *NIX) or PowerShell(if Windows) from anywhere using your samAccountName "%s", not having to go through the portal. To elevate your privileges, use sudo(if *NIX) or just "Run as Administrator"(if Windows). To take a snapshot(restore point) of the machine, you have to temporarily shut it down, take the snapshot, and then power it back up again. At what time and how often snapshots are taken, you decide for yourself, it´s your machine, but we from the IT-Department thinks that it´s an important thing to do regularly in case something goes wrong and you want to go back in time to correct the problem. -If you wish to delete the your VPS, stop using it any more, you log back in to the orderportal, scroll down to the bottom of the page, click on "End Subscription", type in the name of the VPS you wish to destroy and an email will be sent to you to confirm it´s deletion. Make sure to backup anything you wish to save before doing this! +If you wish to delete the VPS, stop using it any more, you log back in to the orderportal using your samAccountName "%s", scroll down to the bottom of the page, click on "End Subscription", type in the name of the VPS you wish to destroy and an email will be sent to you to confirm it´s deletion. Make sure to backup anything you wish to save before doing this! Common questions and tips are explained at "https://storm.slu.se/tipsandtrix.html", and as usual you can send emails to our support "kundstod@slu.se" or call "(018-67)6600". @@ -282,17 +288,21 @@ Din VPS "%s.vps.slu.se" är nu registrerad! -För att komma igång och använda din VPS styr du först kosan mot "https://storm.slu.se/spice.html" för att installera en plugin till din webbläsare som gör att du har tillgång till maskinens konsoll(bildskärmen), vilket bara behöver göras en gång. Du måste sen stänga ner alla webbläsarfönster och öppna ett nytt för att plugin:en ska laddas. Sen använder du adressen "https://storm.slu.se/ovirt-engine/userportal" där du loggar in med ditt AD-konto för att administrera maskinen, så som att starta, stoppa och ta snapshots. Du kan också logga in direkt i maskinen med SSH(om *NIX), eller PowerShell(om Windows) utan att behöva gå genom portalen. Oavsett om du loggar in i maskinen genom portalen eller fjärrterminal så skriver du bara in ditt AD-konto- och lösen så är du inne! För att elevera dina behörigheter inne i maskinen använder du sudo(om *NIX), eller "Kör som Administrator"(om Windows). +För att komma igång och använda din VPS styr du först kosan mot "https://storm.slu.se/spice.html" för att installera en plugin till din webbläsare som gör att du har tillgång till maskinens konsoll(bildskärmen), vilket bara behöver göras en gång. Du måste sen stänga ner alla webbläsarfönster och öppna ett nytt för att plugin:en ska laddas. + +Sen använder du adressen "https://storm.slu.se/ovirt-engine/userportal" där du loggar in med ditt userPrincipalName "%s" för att administrera maskinen, så som att starta, stoppa och ta ögonblicksbilder (snapshots). -När du periodvis vill ta en snapshot(återställningspunkt) så måste maskinen temporärt stängas av, och sen startas upp igen när det är gjort. Vid vilket tid och hur ofta de ska tas kan du själv bestämma, det är din maskin, men vi på IT-Avdelningen tycker att det är viktigt att det ändå görs emellanåt ifall något går snett och man vill kunna backa tillbaka i tiden för att korrigera detta. +Du kan också logga in direkt i maskinen med ditt samAccountName "%s" över SSH(om *NIX), eller PowerShell(om Windows) utan att behöva gå genom portalen. För att elevera dina behörigheter inne i maskinen använder du sudo(om *NIX), eller "Kör som Administrator"(om Windows). -Om du vill radera din VPS, sluta använda den mera, så loggar man tillbaka in i orderportalen, skrollar längst ner på sidan, klickar på "End Subscription", skriver i namnet på VPS:en man vill förstöra, så kommer ett email med en länk att skickas ut till dig som man klickar på för att bekräfta raderingen. Var säker på att säkerhetskopiera allt du vill spara från VPS:en innan! +När du periodvis vill ta en snapshot så måste maskinen temporärt stängas av, och sen startas upp igen när det är gjort. Vid vilket tid och hur ofta de ska tas kan du själv bestämma, det är din maskin, men vi på IT-Avdelningen tycker att det är viktigt att det ändå görs emellanåt ifall något går snett och man vill kunna backa tillbaka i tiden för att korrigera detta. + +Om du vill radera din VPS, sluta använda den mera, så loggar man tillbaka in i orderportalen med sitt samAccountName "%s", skrollar längst ner på sidan, klickar på "End Subscription", skriver i namnet på VPS:en man vill förstöra, så kommer ett email med en länk att skickas ut till dig som man klickar på för att bekräfta raderingen. Var säker på att säkerhetskopiera allt du vill spara från VPS:en innan! Vanliga frågor och tips finns att hitta på "https://storm.slu.se/tipsandtrix.html" och andra frågor skickas till "kundstod@slu.se" eller ring "(018-67)6600". -Återigen tack så mycket, och lycka till!""" % (sender,receiver_firstname,receiver_lastname,receiver_email,VM_NAME,receiver_firstname,VM_NAME,receiver_firstname,VM_NAME) +Återigen tack så mycket, och lycka till!""" % (sender,receiver_firstname,receiver_lastname,receiver_email,VM_NAME,receiver_firstname,VM_NAME,receiver_principal,CUSTOMER_ID,CUSTOMER_ID,receiver_firstname,VM_NAME,receiver_principal,CUSTOMER_ID,CUSTOMER_ID) try: - smtpObj.sendmail(sender, receiver_email, message) + smtpObj.sendmail(sender, receiver_email, message) logging.debug('Successfully sent confirmation email to: "%s"' % (receiver_email)) except Exception as e: raise(e) @@ -322,7 +332,7 @@ """ class DestroyClass(object): - + def PrintError(self, VM_NAME, CUSTOMER_ID, ERRORCODE): print "Content-type:text/html\r\n\r\n" print """ @@ -396,17 +406,17 @@ except Exception as e: raise(e) - def SendAliasDeregistration(self, CUSTOMER_ID, VM_NAME, HOSTNAME): + def SendAliasDeregistration(self, PRINCIPAL_NAME, VM_NAME, HOSTNAME): try: logging.debug('Sending de-registration email to domainmaster') smtpObj = smtplib.SMTP('smtp.slu.se', 25) - for USER_LIST_OBJECT in api.users.list(query='usrname=%s*' % (CUSTOMER_ID)): + 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 == CUSTOMER_ID: - sender = api.users.get(id='%s' % (USER_NAME_ID)) + 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: + sender = api.users.get(id='%s' % (USER_OBJECT_ID)) except AttributeError: pass try: @@ -443,16 +453,16 @@ except Exception as e: raise(e) - def SendDeleteConfirmation(self, CUSTOMER_ID, VM_NAME, HOSTNAME, PRINCIPAL_NAME): + def SendDeleteConfirmation(self, CUSTOMER_ID, VM_NAME, HOSTNAME, PRINCIPAL_NAME, SUFFIX): smtpObj = smtplib.SMTP('smtp.slu.se', 25) sender = 'vpsorderportal@slu.se' - 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: - receiver = api.users.get(id='%s' % (USER_NAME_ID)) + 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: + receiver = api.users.get(id='%s' % (USER_OBJECT_ID)) except AttributeError: pass try: @@ -471,7 +481,7 @@ The VPS named "%s" has been marked for removal. If you have ordered this, please click on the link below. If not, disregard this message. -https://storm.slu.se/cgi-bin/vpsconfirmdestroy.cgi?userid=%s&principalname=%s&vmname=%s +https://storm.slu.se/cgi-bin/vpsconfirmdestroy.cgi?userid=%s&principalname=%s&suffix=%s&vmname=%s -------------------------------------------------------------------------------- @@ -481,7 +491,7 @@ VPS:en vid namn "%s" har markerats för borttagning. Om du har beställt detta, klicka på länken nedan. Om inte, ignorera detta meddelande. -https://storm.slu.se/cgi-bin/vpsconfirmdestroy.cgi?userid=%s&principalname=%s&vmname=%s""" % (sender,receiver_firstname,receiver_lastname,receiver_email,VM_NAME,receiver_firstname,VM_NAME,CUSTOMER_ID,PRINCIPAL_NAME,VM_NAME,receiver_firstname,VM_NAME,CUSTOMER_ID,PRINCIPAL_NAME,VM_NAME) +https://storm.slu.se/cgi-bin/vpsconfirmdestroy.cgi?userid=%s&principalname=%s&suffix=%s&vmname=%s""" % (sender,receiver_firstname,receiver_lastname,receiver_email,VM_NAME,receiver_firstname,VM_NAME,CUSTOMER_ID,PRINCIPAL_NAME,SUFFIX,VM_NAME,receiver_firstname,VM_NAME,CUSTOMER_ID,PRINCIPAL_NAME,SUFFIX,VM_NAME) try: smtpObj.sendmail(sender, receiver_email, message) logging.debug('Successfully sent delete confirmation email to: "%s"' % (receiver_email)) @@ -489,16 +499,16 @@ logging.debug('Failed to send email:\n%s' % str(e)) exit(1) - def SendDeleteSuccess(self, CUSTOMER_ID, VM_NAME, HOSTNAME, PRINCIPAL_NAME): + def SendDeleteSuccess(self, PRINCIPAL_NAME, VM_NAME, HOSTNAME): smtpObj = smtplib.SMTP('smtp.slu.se', 25) sender = 'vpsorderportal@slu.se' - 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: - receiver = api.users.get(id='%s' % (USER_NAME_ID)) + 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: + receiver = api.users.get(id='%s' % (USER_OBJECT_ID)) except AttributeError: pass try: @@ -529,7 +539,7 @@ Tack så mycket, och hoppas vi ses snart igen!""" % (sender,receiver_firstname,receiver_lastname,receiver_email,VM_NAME,receiver_firstname,VM_NAME,receiver_firstname,VM_NAME) try: - smtpObj.sendmail(sender, receiver_email, message) + smtpObj.sendmail(sender, receiver_email, message) logging.debug('Successfully sent deletion success email to: "%s"' % (receiver_email)) except Exception as e: raise(e) @@ -560,3 +570,4 @@ """ +