Exemplo n.º 1
0
def TestSessionMethodsWhileNotLoggedIn(repMgr, sessionMgr):
    """Test some APIs behavior when not logged in."""

    # Valid SSL key may be left in database from startup after valid key
    # was found in guest-info
    sessionMgr.ReadGuestInfoKeys()

    # GetReplicationManager requires a valid login
    Log("Trying methods that require a login (expecting SecurityError exceptions)"
        )
    ExpectException(
        Vmodl.Fault.SecurityError,
        sessionMgr.RestartVmodlServer,
    )
    ExpectException(Vmodl.Fault.SecurityError, repMgr.GetGroup,
                    "invalid-group-id")
    ExpectException(
        Vmodl.Fault.SecurityError,
        repMgr.GetServerStats,
    )

    # Test a couple methods that are allowed even if not logged in:
    Log("Trying always-allowed methods without login")
    sessionMgr.ReadGuestInfoKeys()
    repMgr.GetStorageManager()
    repMgr.GetServerDetails()
    repMgr.GetPropertyCollector()

    Log("Trying redundant logoff")
    sessionMgr.Logoff()  # redundant logoff should be okay
Exemplo n.º 2
0
def TestAddGroupErrorCleanup(repManager):
    """Test ReplicationManager cleanup on error in AddGroup"""

    global defaultDsMgr

    gspec1 = CreateRandomizedGroupSpec()
    gspec2 = CreateRandomizedGroupSpec()

    #   Create a bogus disk

    disk = Hbr.Replica.DiskSpec()
    disk.diskIdent = Hbr.Replica.IdentSpec()
    disk.diskIdent.id = CreateRandomId("disk-id")
    disk.diskIdent.datastoreUUID = defaultDsMgr.DatastoreUUID()
    disk.diskIdent.pathname = "bogus/path/baby.vmdk"

    #   Add disk to both groups

    gspec1.vms[0].replicatedDisks.append(disk)
    gspec2.vms[0].replicatedDisks.append(disk)

    Log("Adding group 1 with bogus disk")

    group1 = ExpectNoException(repManager.CreateGroup, gspec1)

    Log("Trying to add group 2 with same bogus disk")

    ExpectException(Hbr.Replica.Fault.HbrDiskAlreadyExists,
                    repManager.CreateGroup, gspec2)

    #   Add it again, shouldn't matter

    ExpectException(Hbr.Replica.Fault.HbrDiskAlreadyExists,
                    repManager.CreateGroup, gspec2)

    Log("Removing group 1")

    ExpectNoException(group1.Remove)

    Log("Adding group 2")

    group2 = ExpectNoException(repManager.CreateGroup, gspec2)

    Log("Removing group 2")

    ExpectNoException(group2.Remove)
Exemplo n.º 3
0
def TestSupportBundles(sMgr):
    """Test the support bundle APIs"""

    Log("Simple negative tests of supportBundleChunk")
    # XXX what's up with BadStatusLine here?
    ExpectException(Vmodl.Fault.InvalidArgument, sMgr.SupportBundleChunk, "",
                    0, 0)
    ExpectException(Vmodl.Fault.InvalidArgument, sMgr.SupportBundleChunk, "",
                    0, 0)
    ExpectException(Vmodl.Fault.InvalidArgument, sMgr.SupportBundleChunk, "",
                    10 * 100, 0)
    ExpectException(Vmodl.Fault.InvalidArgument, sMgr.SupportBundleChunk, "",
                    0, 1)
    ExpectException(Vmodl.Fault.InvalidArgument, sMgr.SupportBundleChunk,
                    "../etc/passwd", 0, 0)
    ExpectException(Vmodl.Fault.InvalidArgument, sMgr.SupportBundleChunk,
                    "foo/../etc/passwd", 0, 0)
    ExpectException(Vmodl.Fault.InvalidArgument, sMgr.SupportBundleChunk,
                    "doesnotexist.tgz", 0, 0)

    Log("Generate a bundle.")
    sbi = sMgr.GenerateSupportBundle()
    chunk = sMgr.SupportBundleChunk(sbi.key, 0, 10)
    if len(chunk) != 10:
        raise TestFailedExc("Chunk should have at least 10 bytes")

    sMgr.SupportBundleChunk(sbi.key, 0, 10)
    if len(chunk) != 10:
        raise TestFailedExc("(Idempotent) chunk should have at least 10 bytes")

    sMgr.SupportBundleChunk(sbi.key, 0, 10 * 1000 * 1000)
    ExpectException(Vmodl.Fault.InvalidArgument, sMgr.SupportBundleChunk,
                    sbi.key, 1000 * 1000 * 1000 * 100, 10)

    Log("Generate 5 bundles to force recycling.")
    sbiFirst = sMgr.GenerateSupportBundle()
    sbi = sMgr.GenerateSupportBundle()
    sbi = sMgr.GenerateSupportBundle()
    sbi = sMgr.GenerateSupportBundle()
    sbi = sMgr.GenerateSupportBundle()

    Log("Ensure old bundle keys expire.")
    ExpectException(Vmodl.Fault.InvalidArgument, sMgr.SupportBundleChunk,
                    sbiFirst.key, 0, 10)

    return
Exemplo n.º 4
0
def TestHosts(repManager, datastoreConf):

    storageManager = repManager.GetStorageManager()

    # unpack the legitimate datastore configuration
    (host, user, password) = datastoreConf

    randHost = CreateRandomId("host-")
    randUser1 = CreateRandomId("user-")
    randUser2 = CreateRandomId("user1-")
    randPass = CreateRandomId("pass-")

    Log("Test EnableHost")
    # Test adding a new host
    hspec = CreateHostSpec(randHost, randUser1 + ":" + randPass)
    newHost1 = ExpectNoException(storageManager.EnableHost, hspec)
    print("Added host %s" % newHost1.GetId)

    # Test modifying the user of existing host
    hspec = CreateHostSpec(randHost, randUser2 + ":" + randPass)
    newHost2 = ExpectNoException(storageManager.EnableHost, hspec)

    # Test modifying password of existing host
    hspec = CreateHostSpec(randHost, randUser2 + ":")
    newHost2 = ExpectNoException(storageManager.EnableHost, hspec)

    # Since EnableHost is idempotent, get a reference to existing valid host
    hspec = CreateHostSpec(host, user + ":" + password)
    validHost = ExpectNoException(storageManager.EnableHost, hspec)

    # Test removing the host
    Log("Test removing hosts...")
    ExpectNoException(newHost1.Remove)
    ExpectNoException(validHost.Remove)

    # There should be no valid hosts existing and hence all configured
    # datastores should be marked inaccessible.
    dsList = storageManager.GetExpectedDatastores()
    for ds in dsList:
        if (ds.accessible):
            PrintDatastores(dsList)
            raise TestFailedExc(
                "Removing all hosts should mark all datastores inaccessible")

    Log("Test EnableHost with null configurations")

    # Try with ..
    # .. invalid host name
    ExpectException(Hbr.Replica.Fault.InvalidHostSpec,
                    storageManager.EnableHost,
                    CreateHostSpec("", randUser1 + ":" + randPass))
    # .. invalid user/pass
    ExpectException(Hbr.Replica.Fault.InvalidHostSpec,
                    storageManager.EnableHost, CreateHostSpec("valid", ":"))

    ExpectException(Hbr.Replica.Fault.InvalidHostSpec,
                    storageManager.EnableHost, CreateHostSpec("valid", "@"))
    # .. invalid user
    ExpectException(Hbr.Replica.Fault.InvalidHostSpec,
                    storageManager.EnableHost,
                    CreateHostSpec("valid", ":" + randPass))

    # Add the valid host with an invalid password, expect failures:
    validHost = ExpectNoException(
        storageManager.EnableHost,
        CreateHostSpec(host, user + ":" + password + "BORKED"))

    if validHost.accessible:
        raise TestFailedExc(
            "Valid host, with bad password, should not be accessible.")

    # Fixup the host (later tests expect it to be present in the server)
    validHost = ExpectNoException(storageManager.EnableHost,
                                  CreateHostSpec(host, user + ":" + password))
    if not validHost.accessible:
        raise TestFailedExc("Valid host should be accessible.")

    return
Exemplo n.º 5
0
def TestReplicaGroup(repManager):
    rpo = 42
    retentionPolicy = AddTierToRetentionPolicy(None, 60, 4)

    gspec = CreateRandomizedGroupSpec(rpo=rpo, retentionPolicy=retentionPolicy)
    group = ExpectNoException(repManager.CreateGroup, gspec)

    Log("Created group for testing ReplicaGroup API: " + str(group))

    TestGroupVMs(gspec, group)

    Log("Test GetRpo")
    returnRpo = group.GetRpo()
    if returnRpo != rpo:
        raise TestFailedExc("RPO should be " + str(rpo) + ", not " +
                            str(returnRpo))

    Log("Test UpdateRpo (valid RPO values)")
    for nRpo in [0, 1, 11, 13, 99, 100, 1000, 1440]:
        ExpectNoException(group.UpdateRpo, nRpo)
        returnRpo = group.GetRpo()
        if returnRpo != nRpo:
            raise TestFailedExc("RPO should be " + str(nRpo) + ", not " +
                                str(returnRpo))

    Log("Test UpdateRpo (invalid RPO values)")
    invalRpoFault = Vmodl.Fault.InvalidArgument
    for nRpo in [-1000, -1, 1441, 100 * 1000 * 1000]:
        ExpectException(invalRpoFault, group.UpdateRpo, nRpo)

    Log("Test GetRetentionPolicy")
    returnPolicy = group.GetRetentionPolicy()
    if RetentionPolicyToString(returnPolicy) != RetentionPolicyToString(
            retentionPolicy):
        raise TestFailedExc("Retention policy should be " +
                            RetentionPolicyToString(retentionPolicy) +
                            ", not " + RetentionPolicyToString(returnPolicy))

    Log("Test UpdateRetentionPolicy (valid retention policy values)")
    testPolicy = AddTierToRetentionPolicy(None, 0, 8)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 5, 14)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 15, 3)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 45, 16)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 120, 8)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 360, 10)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 1140, 2)
    totalSlots = 0
    retentionPolicy = None
    for tier in testPolicy.tiers:
        if totalSlots + tier.GetNumSlots() > 24:
            totalSlots = 0
            retentionPolicy = None
        retentionPolicy = AddTierToRetentionPolicy(
            retentionPolicy, tier.GetGranularityMinutes(), tier.GetNumSlots())
        totalSlots += tier.GetNumSlots()
        ExpectNoException(group.UpdateRetentionPolicy, retentionPolicy)
        returnPolicy = group.GetRetentionPolicy()
        if RetentionPolicyToString(returnPolicy) != RetentionPolicyToString(
                retentionPolicy):
            raise TestFailedExc("Retention policy should be " +
                                RetentionPolicyToString(retentionPolicy) +
                                ", not " +
                                RetentionPolicyToString(returnPolicy))

    Log("Test UpdateRetentionPolicy (invalid retention policy values)")
    testPolicy = AddTierToRetentionPolicy(None, -1, 8)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 0, -1)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 15, 0)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 45, 36)
    invalidPolicyFault = Vmodl.Fault.InvalidArgument
    for tier in testPolicy.tiers:
        retentionPolicy = AddTierToRetentionPolicy(
            None, tier.GetGranularityMinutes(), tier.GetNumSlots())
        ExpectException(invalidPolicyFault, group.UpdateRetentionPolicy,
                        retentionPolicy)

    # Test repeating the same granularity mins
    testPolicy = AddTierToRetentionPolicy(None, 5, 2)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 10, 6)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 10, 12)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 20, 1)
    ExpectException(invalidPolicyFault, group.UpdateRetentionPolicy,
                    testPolicy)

    # Test total number of slots greater than default max of 24
    testPolicy = AddTierToRetentionPolicy(None, 3, 9)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 19, 8)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 43, 6)
    testPolicy = AddTierToRetentionPolicy(testPolicy, 111, 7)
    ExpectException(invalidPolicyFault, group.UpdateRetentionPolicy,
                    testPolicy)

    Log("Test GetState")
    st = group.GetState()
    if st != "passive":
        raise TestFailedExc("State should be 'passive'")
    else:
        Log("Group is 'passive'")

    Log("Test GetId")
    ExpectNoException(group.GetId)

    Log("Test GetCurrentRpoViolation")
    rpoViolation = group.GetCurrentRpoViolation()
    if (rpoViolation != -1):
        raise TestFailedExc("Rpo violation should initially be -1, not " +
                            str(rpoViolation))

    # group.Remove tested elsewhere

    # Can't test CommitToImage without an image ...
    #Log("Test CommitToImage");
    #ExpectNotImplemented(group.CommitToImage, None)

    # Note that .Instances is a property, not a method
    Log("Test .instances property")
    insts = group.instances
    if len(insts) > 0:
        raise TestFailedExc("Groups should contain 0 instances!")
    else:
        Log("No instances.")

    # Note: that .latestInstance is a property, not a method
    inst = group.latestInstance
    Log("Got .latestInstance " + str(inst))
    if inst:
        raise TestFailedExc("Group should not have a 'latest' instance!")
    else:
        Log("No latest instance.")
Exemplo n.º 6
0
def TestAddRemoveDisk(repManager):
    """Test ReplicationManager RemoveGroup method"""

    groupID = CreateRandomId("addrm-group-id")

    disk1Spec = CreateRandomizedDiskSpec(datastoreMgr=None)
    disk2Spec = CreateRandomizedDiskSpec(datastoreMgr=None)
    disk3Spec = CreateRandomizedDiskSpec(datastoreMgr=None)

    vmSpec = Hbr.Replica.VirtualMachineSpec()
    vmSpec.virtualMachineIdent = CreateRandomizedVMIdent(datastoreMgr=None,
                                                         vmID=groupID)
    vmSpec.replicatedDisks = [disk1Spec]

    gSpec = Hbr.Replica.GroupSpec()
    gSpec.id = groupID
    gSpec.rpo = 13
    gSpec.vms = [vmSpec]

    Log("Creating group")

    g = ExpectNoException(repManager.CreateGroup, gSpec)
    vms = g.GetVms()

    ExpectCond(len(vms) == 1, "Group should contain 1 VM")
    vm = vms[0]

    Log("Adding disk 2")

    d2 = ExpectNoException(vm.AddDisk, disk2Spec)
    ExpectException(Hbr.Replica.Fault.HbrDiskAlreadyExists, vm.AddDisk,
                    disk2Spec)
    ExpectCond(not d2.unconfigured, "Disk is unconfigured after add!")

    ExpectException(Hbr.Replica.Fault.HbrDiskNotUnconfigured, vm.RemoveDisk,
                    d2)
    ExpectCond(not d2.unconfigured, "Disk became unconfigured!")

    ExpectNoException(vm.UnconfigureDisk, d2)
    ExpectCond(d2.unconfigured, "Disk is not unconfigured after unconfigure!")

    ExpectNoException(vm.UnconfigureDisk, d2)
    ExpectCond(d2.unconfigured, "Disk became configured!")

    ExpectNoException(vm.RemoveDisk, d2)
    ExpectManagedObjectNotFound(vm.RemoveDisk, d2)

    Log("Removing disk 1")

    d1 = ExpectNoException(vm.GetDisk, disk1Spec.diskIdent.id)
    ExpectCond(not d1.unconfigured, "Disk is already unconfigured!")

    ExpectException(Hbr.Replica.Fault.HbrDiskNotUnconfigured, vm.RemoveDisk,
                    d1)
    ExpectCond(not d1.unconfigured, "Disk became configured!")

    ExpectNoException(vm.UnconfigureDisk, d1)
    ExpectCond(d1.unconfigured, "Disk is not unconfigured after unconfigure!")
    ExpectNoException(vm.RemoveDisk, d1)

    Log("Adding all disks and removing")

    d1 = ExpectNoException(vm.AddDisk, disk1Spec)
    d2 = ExpectNoException(vm.AddDisk, disk2Spec)
    d3 = ExpectNoException(vm.AddDisk, disk3Spec)

    ExpectNoException(vm.UnconfigureDisk, d1)
    ExpectNoException(vm.UnconfigureDisk, d2)
    ExpectNoException(vm.RemoveDisk, d2)
    ExpectNoException(vm.UnconfigureDisk, d3)
    ExpectNoException(vm.RemoveDisk, d1)
    ExpectNoException(vm.RemoveDisk, d3)

    ExpectNoException(g.Remove)
Exemplo n.º 7
0
def TestGetInvalidGroup(repManager):
    """Test ReplicationManager.GetGroup with invalid group."""
    ExpectException(Hbr.Replica.Fault.GroupNotFound, repManager.GetGroup,
                    "invalid-group-id")
Exemplo n.º 8
0
def TestCreateGroup(count, repManager):
    """Test ReplicationManager CreateGroup method."""

    # Create 'count' random (valid) groups.
    for x in xrange(0, count):
        gspec = CreateRandomizedGroupSpec()
        Log("Created spec: " + str(gspec))
        g = ExpectNoException(repManager.CreateGroup, gspec)
        Log("Got group: " + str(g))
        # check idempotency
        g2 = ExpectNoException(repManager.CreateGroup, gspec)
        if g._moId != g2._moId:
            raise TestFailedExc(
                "Group returned to duplicate CreateGroup call '" + str(g2) +
                "' is not equivalent to existing '" + str(g) + "'.")

    Log("Valid group create tests complete.")

    # Create a valid spec (with at least one valid disk).  To use for
    # causing duplicate-disk errors.
    while True:  # Retry until we get at least one valid disk
        validSpec = CreateRandomizedGroupSpec()
        if len(validSpec.vms[0].replicatedDisks) != 0:
            break

    validDiskID = validSpec.vms[0].replicatedDisks[0].diskIdent.id

    invalidGroups = (
        (Hbr.Replica.Fault.InvalidGroupSpec, "groupid-same disk twice",
         (("gr1-disk1", "valid-disk-1"), ("gr1-disk1", "valid-disk-1"))),
        (Hbr.Replica.Fault.InvalidGroupSpec, "groupid-same diskid twice",
         (("gr2-disk1", "valid-disk-1"), ("gr2-disk1", "valid-disk-2"))),
        (Hbr.Replica.Fault.HbrDiskAlreadyExists, "groupid-reused diskid",
         (("gr3-disk1", "valid-disk-1"), (validDiskID, "valid-disk-2"))),
        (Hbr.Replica.Fault.InvalidGroupSpec,
         "group-with-a-too-long-invalid-group-id-that-should-not-be-accepted-ever-no-matter-what-no-matter-how-superb-hbrsrv-ever-becomes",
         (("gr4-disk-1", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidHbrDiskSpec, "groupid-too long diskid",
         (("disk-with-a-too-long-invalid-disk-id-that-should-not-be-accepted-ever-no-matter-what-no-matter-how-superb-hbrsrv-ever-becomes",
           "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidGroupSpec, "id-invalid-period.",
         (("gr1-d1", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidGroupSpec, "id-invalid-bang!",
         (("gr1-d1", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidGroupSpec, "id-invalid-hash#",
         (("gr1-d1", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidGroupSpec, "id-invalid-quote'",
         (("gr1-d1", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidGroupSpec, "id-invalid-dblquote\"",
         (("gr1-d1", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidGroupSpec, "id-invalid-nl\n",
         (("gr1-d1", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidGroupSpec, "id-invalid-tab\t",
         (("gr1-d1", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidGroupSpec, "id-invalid-dollar$",
         (("gr1-d1", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidGroupSpec, "$#!@_&$**()",
         (("gr1-d1", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidGroupSpec, "", (("gr1-d1",
                                                   "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidHbrDiskSpec, "valid-gr1",
         (("gr1-d1-invalid-period.", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidHbrDiskSpec, "valid-gr1",
         (("", "valid-disk-1"), )),
        (Hbr.Replica.Fault.InvalidHbrDiskSpec, "valid-gr1",
         (("_@$#!$**&&", "valid-disk-1"), )),
    )

    # Create the valid group for 'groupid-reused diskid' to conflict with
    g = ExpectNoException(repManager.CreateGroup, validSpec)
    Log("Got 'valid' group (for reused id test): " + str(g))

    for fault, groupID, disks in invalidGroups:
        Log("Creating group with invalid ID(s): " + str(groupID))
        invalGr = CreateInvalidGroupSpec(groupID, disks)
        ExpectException(fault, repManager.CreateGroup, invalGr)

    Log("Try with mismatch between 'group' and 'vm' ids:")
    invalGr = CreateInvalidGroupSpec("group-id-different-from-vm",
                                     (("gr1-d1", "valid-disk-1"), ))
    invalGr.id = "group-id-VERY-DIFFERENT-from-vm"
    ExpectException(Hbr.Replica.Fault.InvalidVirtualMachineSpec,
                    repManager.CreateGroup, invalGr)

    Log("Try with invalid vm datastore configuration:")

    baseSpec = CreateRandomizedGroupSpec()
    for ds in ("invalid/datastore", "/", "/invalid", "invalid/"):
        Log("Setting datastore to: '%s'" % ds)
        baseSpec.vms[0].virtualMachineIdent.datastoreUUID = ds
        ExpectException(Hbr.Replica.Fault.InvalidVirtualMachineSpec,
                        repManager.CreateGroup, baseSpec)

    # Test that we don't accidentally allow duplicate calls when the spec changes
    Log("Negative idempotency tests")

    gspec = CreateRandomizedGroupSpec()
    g = ExpectNoException(repManager.CreateGroup, gspec)
    g2 = ExpectNoException(repManager.CreateGroup, gspec)
    if g._moId != g2._moId:
        raise TestFailedExc("Group returned to duplicate CreateGroup call '" +
                            str(g2) + "' is not equivalent to existing '" +
                            str(g) + "'.")

    # Test with completely different spec
    gspec2 = CreateRandomizedGroupSpec()
    gspec2.id = gspec.id
    gspec2.vms[0].virtualMachineIdent.id = gspec.id
    ExpectException(Hbr.Replica.Fault.GroupAlreadyExists,
                    repManager.CreateGroup, gspec2)

    # Test with slightly different specs
    gpsec2 = copy.deepcopy(gspec)
    gspec2.rpo = gspec2.rpo + 1
    ExpectException(Hbr.Replica.Fault.GroupAlreadyExists,
                    repManager.CreateGroup, gspec2)

    # Test with different VM spec
    gpsec2 = copy.deepcopy(gspec)
    gspec2.vms = [CreateRandomizedVMSpec(None, vmID=gspec.id)]
    ExpectException(Hbr.Replica.Fault.GroupAlreadyExists,
                    repManager.CreateGroup, gspec2)

    # Test with different disks
    gpsec2 = copy.deepcopy(gspec)
    gspec2.vms[0].replicatedDisks.append(CreateRandomizedDiskSpec(None))
    ExpectException(Hbr.Replica.Fault.GroupAlreadyExists,
                    repManager.CreateGroup, gspec2)

    Log("All invalid group create tests complete.")
Exemplo n.º 9
0
def TestSessionManager(repMgr,
                       sessionMgr,
                       localuser='******',
                       localpasswd='vmware'):
    """
   Test the interfaces of hbr.replica.SessionManager.  Assumes the session
   is not yet authenticated.
   """

    TestSessionMethodsWhileNotLoggedIn(repMgr, sessionMgr)

    Log("Trying simple valid login/logoff.")
    sessionMgr.Login(localuser, localpasswd)
    sessionMgr.Logoff()

    Log("Trying login and double-login")
    sessionMgr.Login(localuser, localpasswd)
    # double-login is a failure
    ExpectException(Hbr.Replica.Fault.AlreadyLoggedIn, sessionMgr.Login,
                    localuser, localpasswd)

    Log("Logging off")
    sessionMgr.Logoff()

    TestSessionMethodsWhileNotLoggedIn(repMgr, sessionMgr)

    #
    # We don't validate user/pass anymore so there's no need
    # to test for bad user/pass combos here.
    #

    Log("Trying bad thumbprint login")

    RunCommand([
        guestInfoScript, "set", hmsThumbprintKey, "bad-login-test-thumbprint"
    ])

    sessionMgr.ReadGuestInfoKeys()

    ExpectException(Hbr.Replica.Fault.InvalidLogin,
                    sessionMgr.LoginBySSLThumbprint)

    Log("Trying good thumbprint login")

    RunCommand(
        [guestInfoScript, "set", hmsThumbprintKey, testCertificateThumbprint])

    sessionMgr.ReadGuestInfoKeys()

    sessionMgr.LoginBySSLThumbprint()

    Log("Trying double thumbprint login")
    ExpectException(Hbr.Replica.Fault.AlreadyLoggedIn,
                    sessionMgr.LoginBySSLThumbprint)

    Log("Double log off")
    sessionMgr.Logoff()
    sessionMgr.Logoff()  # should be ok

    Log("Forcing the server to generate new certficate")
    sessionMgr.LoginBySSLThumbprint()

    cmd = "%s get %s" % (guestInfoScript, srvThumbprintKey)
    (status, oldThumbprint) = commands.getstatusoutput(cmd)

    if status != 0:
        raise TestFailedExc(
            "Error getting server thumbprint, script returned: " + str(rc))

    if not re.match("[0-9A-F][0-9A-F](:[0-9A-F][0-9A-F])+$", oldThumbprint):
        raise TestFailedExc("Guestinfo contains invalid hbrsrv thumbprint: " +
                            oldThumbprint)

    # BEWARE: this changes the *REAL* server's SSL key (we're generally
    # running a secondary server on the side), but this stuff is shared.
    # The test-hbrsrv.sh wrapper script saves/restores the original SSL
    # key.
    RunCommand([guestInfoScript, "set", srvRevokedKey, "1"])

    RunCommand([
        guestInfoScript, "set", hmsThumbprintKey, "post-login-test-thumbprint"
    ])

    # Kick hbrsrv, disconnects all VMODL connections
    Log("Restarting VMODL service")
    sessionMgr.RestartVmodlServer()

    sessionMgr = None  # The session manager moref (and soap stub) are useless now

    (status, newThumbprint) = commands.getstatusoutput(cmd)

    if status != 0:
        raise TestFailedExc(
            "Error getting server thumbprint, script returned: " + str(rc))

    if not re.match("[0-9A-F][0-9A-F](:[0-9A-F][0-9A-F])+$", oldThumbprint):
        raise TestFailedExc("Guestinfo contains invalid hbrsrv thumbprint: " +
                            oldThumbprint)

    if oldThumbprint == newThumbprint:
        raise TestFailedExc("Thumbprint didn't change!")

    Log("Done with SessionManager tests")

    return