Revision 502f5236

b/qa/qa_cluster.py
182 182
  AssertNotEqual(StartSSH(master["primary"],
183 183
                          utils.ShellQuoteArgs(cmd)).wait(), 0)
184 184

  
185
  # Custom RAPI certificate
186
  fh = tempfile.NamedTemporaryFile()
185
  rapi_cert_backup = qa_utils.BackupFile(master["primary"],
186
                                         constants.RAPI_CERT_FILE)
187
  try:
188
    # Custom RAPI certificate
189
    fh = tempfile.NamedTemporaryFile()
187 190

  
188
  # Ensure certificate doesn't cause "gnt-cluster verify" to complain
189
  validity = constants.SSL_CERT_EXPIRATION_WARN * 3
191
    # Ensure certificate doesn't cause "gnt-cluster verify" to complain
192
    validity = constants.SSL_CERT_EXPIRATION_WARN * 3
190 193

  
191
  bootstrap.GenerateSelfSignedSslCert(fh.name, validity=validity)
194
    bootstrap.GenerateSelfSignedSslCert(fh.name, validity=validity)
192 195

  
193
  tmpcert = qa_utils.UploadFile(master["primary"], fh.name)
194
  try:
196
    tmpcert = qa_utils.UploadFile(master["primary"], fh.name)
197
    try:
198
      cmd = ["gnt-cluster", "renew-crypto", "--force",
199
             "--rapi-certificate=%s" % tmpcert]
200
      AssertEqual(StartSSH(master["primary"],
201
                           utils.ShellQuoteArgs(cmd)).wait(), 0)
202
    finally:
203
      cmd = ["rm", "-f", tmpcert]
204
      AssertEqual(StartSSH(master["primary"],
205
                           utils.ShellQuoteArgs(cmd)).wait(), 0)
206

  
207
    # Normal case
208
    cmd = ["gnt-cluster", "renew-crypto", "--force",
209
           "--new-cluster-certificate", "--new-confd-hmac-key",
210
           "--new-rapi-certificate"]
211
    AssertEqual(StartSSH(master["primary"],
212
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
213

  
214
    # Restore RAPI certificate
195 215
    cmd = ["gnt-cluster", "renew-crypto", "--force",
196
           "--rapi-certificate=%s" % tmpcert]
216
           "--rapi-certificate=%s" % rapi_cert_backup]
197 217
    AssertEqual(StartSSH(master["primary"],
198 218
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
199 219
  finally:
200
    cmd = ["rm", "-f", tmpcert]
220
    cmd = ["rm", "-f", rapi_cert_backup]
201 221
    AssertEqual(StartSSH(master["primary"],
202 222
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
203 223

  
204
  # Normal case
205
  cmd = ["gnt-cluster", "renew-crypto", "--force",
206
         "--new-cluster-certificate", "--new-confd-hmac-key",
207
         "--new-rapi-certificate"]
208
  AssertEqual(StartSSH(master["primary"],
209
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
210

  
211 224

  
212 225
def TestClusterBurnin():
213 226
  """Burnin"""

Also available in: Unified diff