Revision 13998ef2 lib/bootstrap.py

b/lib/bootstrap.py
63 63
    raise errors.OpExecError("Could not generate ssh keypair, error %s" %
64 64
                             result.output)
65 65

  
66
  f = open(pub_key, 'r')
67
  try:
68
    utils.AddAuthorizedKey(auth_keys, f.read(8192))
69
  finally:
70
    f.close()
66
  utils.AddAuthorizedKey(auth_keys, utils.ReadFile(auth_keys))
71 67

  
72 68

  
73 69
def _GenerateSelfSignedSslCert(file_name, validity=(365 * 5)):
......
240 236
  _InitGanetiServerSetup()
241 237

  
242 238
  # set up ssh config and /etc/hosts
243
  f = open(constants.SSH_HOST_RSA_PUB, 'r')
244
  try:
245
    sshline = f.read()
246
  finally:
247
    f.close()
239
  sshline = utils.ReadFile(constants.SSH_HOST_RSA_PUB)
248 240
  sshkey = sshline.split(" ")[1]
249 241

  
250 242
  if modify_etc_hosts:

Also available in: Unified diff