Revision 6d4a1656 qa/qa_cluster.py

b/qa/qa_cluster.py
25 25

  
26 26
import tempfile
27 27

  
28
from ganeti import constants
29
from ganeti import bootstrap
28 30
from ganeti import utils
29 31

  
30 32
import qa_config
31 33
import qa_utils
32 34
import qa_error
33 35

  
34
from qa_utils import AssertEqual, StartSSH
36
from qa_utils import AssertEqual, AssertNotEqual, StartSSH
35 37

  
36 38

  
37 39
def _RemoveFileFromAllNodes(filename):
......
144 146
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
145 147

  
146 148

  
149
def TestClusterRenewCrypto():
150
  """gnt-cluster renew-crypto"""
151
  master = qa_config.GetMasterNode()
152

  
153
  # Conflicting options
154
  cmd = ["gnt-cluster", "renew-crypto", "--force",
155
         "--new-cluster-certificate", "--new-hmac-key",
156
         "--new-rapi-certificate", "--rapi-certificate=/dev/null"]
157
  AssertNotEqual(StartSSH(master["primary"],
158
                          utils.ShellQuoteArgs(cmd)).wait(), 0)
159

  
160
  # Invalid RAPI certificate
161
  cmd = ["gnt-cluster", "renew-crypto", "--force",
162
         "--rapi-certificate=/dev/null"]
163
  AssertNotEqual(StartSSH(master["primary"],
164
                          utils.ShellQuoteArgs(cmd)).wait(), 0)
165

  
166
  # Custom RAPI certificate
167
  fh = tempfile.NamedTemporaryFile()
168

  
169
  # Ensure certificate doesn't cause "gnt-cluster verify" to complain
170
  validity = constants.SSL_CERT_EXPIRATION_WARN * 3
171

  
172
  bootstrap.GenerateSelfSignedSslCert(fh.name, validity=validity)
173

  
174
  tmpcert = qa_utils.UploadFile(master["primary"], fh.name)
175
  try:
176
    cmd = ["gnt-cluster", "renew-crypto", "--force",
177
           "--rapi-certificate=%s" % tmpcert]
178
    AssertEqual(StartSSH(master["primary"],
179
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
180
  finally:
181
    cmd = ["rm", "-f", tmpcert]
182
    AssertEqual(StartSSH(master["primary"],
183
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
184

  
185
  # Normal case
186
  cmd = ["gnt-cluster", "renew-crypto", "--force",
187
         "--new-cluster-certificate", "--new-hmac-key",
188
         "--new-rapi-certificate"]
189
  AssertEqual(StartSSH(master["primary"],
190
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
191

  
192

  
147 193
def TestClusterBurnin():
148 194
  """Burnin"""
149 195
  master = qa_config.GetMasterNode()

Also available in: Unified diff