Installed Licences

Installed Licences
  1ot = impact.gui.output_toolbox
  2
  3db = impact.active_database
  4
  5
  6def describe_licence(licence):
  7    if licence is None:
  8        return
  9
 10    ot.add("Licence ID: " + str(licence.id))
 11    ot.add("  Created: " + str(licence.created_date_time))
 12    ot.add("  Type: " + str(licence.type))
 13    ot.add("  Enabled: " + str(licence.enabled))
 14    ot.add("  description: " + str(licence.description))
 15    ot.add("  Expiration: " + str(licence.expiration))
 16    ot.add("  GUID: " + str(licence.guid))
 17    ot.add("  Licences: " + str(licence.count))
 18
 19def describe_licences(licences):
 20    if licences is None:
 21        return
 22
 23    ot.add("Licence Server: " + str(licences.address) + ":" + str(licences.port))
 24    ot.add("Installed Licence Count: " + str(licences.count))
 25
 26    for i in range(1, licences.count  + 1):
 27        describe_licence(licences.item(i))
 28
 29    # Alternative syntax
 30    # for each lic in licences
 31    # DescribeLicence lic
 32    # next
 33
 34def describe_in_use(in_use):
 35    if in_use is None:
 36        return
 37
 38    ot.add("    Workstation: " + str(in_use.workstation))
 39    ot.add("    User: " + str(in_use.user))
 40    ot.add("    Granted: " + str(in_use.granted_date_time))
 41
 42def describe_licences_in_use(licence):
 43    if licence is None:
 44        return
 45
 46    in_use = licence.licences_in_use
 47
 48    ot.add("  Licence: " + str(licence.description))
 49    ot.add("  Licences: " + str(licence.count))
 50    ot.add("  Allocated: " + str(in_use.count))
 51
 52    for i in range(1, in_use.count  + 1):
 53        describe_in_use(in_use.item(i))
 54
 55    # Alternative syntax
 56    # for each use in in_use
 57    # DescribeInUse use
 58    # next
 59
 60def revoke_licence(licence, user):
 61    if licence is None:
 62        return
 63
 64    use = licence.licences_in_use.item(user)
 65
 66    if use.isNone():
 67        ot.add("  Licence " + str(licence.id) + " is not allocated to " + str(user))
 68        return
 69
 70    describe_in_use(use)
 71
 72    ot.add("  Revoking Licence")
 73    use.revoke()
 74    ot.add("  Successfully revoked licence")
 75
 76
 77ot.clear()
 78
 79ot.add("**** Licences from active/configured Licence Server ****")
 80licences = db.server_licences("")
 81describe_licences(licences)
 82
 83# ot.add() "**** Licences from specific Licence Server (SABREONE) ****"
 84# DescribeLicences(db.server_licences("SABREONE"))
 85
 86# ot.add() "**** Licences from specific Licence Server (SABREONE:3000) ****"
 87# DescribeLicences(db.server_licences("SABREONE:3000"))
 88
 89ot.add("*** Find licence by dongleid + uniqueid (107323001) ***")
 90describe_licence(licences.item(107323001))
 91
 92ot.add("*** Find licence by Guid ({F944E480-D47B-4DAE-AA63-15A43F5350DF}) ***")
 93describe_licence(licences.item("{F944E480-D47B-4DAE-AA63-15A43F5350DF}"))
 94
 95ot.add("*** Display LicencesInUse for specific licence (107323001) ***")
 96describe_licences_in_use(licences.item(107323001))
 97
 98ot.add("*** Revoke a specific licence (107323001) for ADMIN ***")
 99revoke_licence(licences.item(107323001), "ADMIN")
100