def _TestUpdate(self, failcmd):
    data = {constants.SSHS_SSH_HOST_KEY: [(constants.SSHK_DSA, 'dsapriv', 'dsapub'), (constants.SSHK_ECDSA, 'ecdsapriv', 'ecdsapub'), (constants.SSHK_RSA, 'rsapriv', 'rsapub')], constants.SSHS_SSH_KEY_TYPE: 'dsa', constants.SSHS_SSH_KEY_BITS: 1024}
    runcmd_fn = compat.partial(self._RunCmd, failcmd)
    if failcmd:
        self.assertRaises(_JoinError, prepare_node_join.UpdateSshDaemon, data, False, _runcmd_fn=runcmd_fn, _keyfiles=self.keyfiles)
    else:
        prepare_node_join.UpdateSshDaemon(data, False, _runcmd_fn=runcmd_fn, _keyfiles=self.keyfiles)
    self.assertEqual(sorted(os.listdir(self.tmpdir)), sorted(['rsa.public', 'rsa.private', 'dsa.public', 'dsa.private', 'ecdsa.public', 'ecdsa.private']))
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'rsa.public')), 'rsapub')
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'rsa.private')), 'rsapriv')
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'dsa.public')), 'dsapub')
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'dsa.private')), 'dsapriv')
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'ecdsa.public')), 'ecdsapub')
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'ecdsa.private')), 'ecdsapriv')
def _TestUpdate(self, failcmd):
    data = {constants.SSHS_SSH_HOST_KEY: [(constants.SSHK_DSA, 'dsapriv', 'dsapub'), (constants.SSHK_ECDSA, 'ecdsapriv', 'ecdsapub'), (constants.SSHK_RSA, 'rsapriv', 'rsapub')], constants.SSHS_SSH_KEY_TYPE: 'dsa', constants.SSHS_SSH_KEY_BITS: 1024}
    runcmd_fn = compat.partial(self._RunCmd, failcmd)
    if failcmd:
        self.assertRaises(_JoinError, prepare_node_join.UpdateSshDaemon, data, False, _runcmd_fn=runcmd_fn, _keyfiles=self.keyfiles)
    else:
        prepare_node_join.UpdateSshDaemon(data, False, _runcmd_fn=runcmd_fn, _keyfiles=self.keyfiles)
    self.assertEqual(sorted(os.listdir(self.tmpdir)), sorted(['rsa.public', 'rsa.private', 'dsa.public', 'dsa.private', 'ecdsa.public', 'ecdsa.private']))
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'rsa.public')), 'rsapub')
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'rsa.private')), 'rsapriv')
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'dsa.public')), 'dsapub')
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'dsa.private')), 'dsapriv')
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'ecdsa.public')), 'ecdsapub')
    self.assertEqual(utils.ReadFile(utils.PathJoin(self.tmpdir, 'ecdsa.private')), 'ecdsapriv')