示例#1
0
    def restoreUsers(self):
        '''Retrieve any previous users from userchoices and populate.'''

        for account in userchoices.getUsers():
            self.accounts.append((account['username'], account['password']))

        self.updateAccounts()
示例#2
0
    def restoreUsers(self):
        '''Retrieve any previous users from userchoices and populate.'''

        for account in userchoices.getUsers():
            self.accounts.append((account['username'], account['password']))

        self.updateAccounts()
示例#3
0
文件: users.py 项目: vmware/weasel
def hostActionSetupAccounts(context):
    rootPassword = userchoices.getRootPassword()
    rp = RootPassword(rootPassword['password'],
                      isCrypted=True,
                      useMD5=(rootPassword['passwordType'] ==
                              userchoices.ROOTPASSWORD_TYPE_MD5))
    rp.write()

    # write out the rest of the users
    Accounts(userchoices.getUsers()).write()
示例#4
0
def hostActionSetupAccounts(context):
    rootPassword = userchoices.getRootPassword()
    rp = RootPassword(
        rootPassword['password'],
        isCrypted=True,
        useMD5=(
            rootPassword['passwordType'] == userchoices.ROOTPASSWORD_TYPE_MD5))
    rp.write()

    # write out the rest of the users
    Accounts(userchoices.getUsers()).write()
示例#5
0
def test_addingAdditionalUsers():
    fauxroot.FAUXROOT = [os.path.join(TEST_DIR, "good-config.1")]
    authXMLFile = "/mnt/sysimage/etc/vmware/hostd/authorization.xml"
    expectedOutput = """<ConfigRoot>
  <ACEData id="11">
    <ACEDataEntity>ha-folder-root</ACEDataEntity>
    <ACEDataId>11</ACEDataId>
    <ACEDataIsGroup>false</ACEDataIsGroup>
    <ACEDataPropagate>true</ACEDataPropagate>
    <ACEDataRoleId>-1</ACEDataRoleId>
    <ACEDataUser>dcui</ACEDataUser>
  </ACEData><ACEData id="12">
    <!-- generated by weasel/users.py -->
    <ACEDataEntity>ha-folder-root</ACEDataEntity>
    <ACEDataId>12</ACEDataId>
    <ACEDataIsGroup>false</ACEDataIsGroup>
    <ACEDataPropagate>true</ACEDataPropagate>
    <ACEDataRoleId>-1</ACEDataRoleId>
    <ACEDataUser>root</ACEDataUser>
  </ACEData>
  <ACEData id="13">
    <!-- generated by weasel/users.py -->
    <ACEDataEntity>ha-folder-root</ACEDataEntity>
    <ACEDataId>13</ACEDataId>
    <ACEDataIsGroup>false</ACEDataIsGroup>
    <ACEDataPropagate>true</ACEDataPropagate>
    <ACEDataRoleId>-1</ACEDataRoleId>
    <ACEDataUser>foobar</ACEDataUser>
  </ACEData>
  <ACEData id="14">
    <!-- generated by weasel/users.py -->
    <ACEDataEntity>ha-folder-root</ACEDataEntity>
    <ACEDataId>14</ACEDataId>
    <ACEDataIsGroup>false</ACEDataIsGroup>
    <ACEDataPropagate>true</ACEDataPropagate>
    <ACEDataRoleId>-1</ACEDataRoleId>
    <ACEDataUser>bazbar</ACEDataUser>
  </ACEData>
  <NextAceId>15</NextAceId>
</ConfigRoot>"""

    try:
        users = ["foobar", "bazbar"]
        for user in users:
            userchoices.addUser(user, "password", "md5")

        Accounts(userchoices.getUsers()).write()
    finally:
        fauxroot.FAUXROOT = None

    assert authXMLFile in fauxroot.WRITTEN_FILES

    actual = fauxroot.WRITTEN_FILES[authXMLFile].getvalue()

    print "Expected: ==============="
    print expectedOutput
    print "Got: ===================="
    print actual
    print "========================="

    assert expectedOutput == actual