Revision fcd2359a qa/qa_rapi.py
b/qa/qa_rapi.py | ||
---|---|---|
39 | 39 |
from ganeti import qlang |
40 | 40 |
from ganeti import pathutils |
41 | 41 |
|
42 |
from ganeti.http.auth import ParsePasswordFile |
|
42 | 43 |
import ganeti.rapi.client # pylint: disable=W0611 |
43 | 44 |
import ganeti.rapi.client_utils |
44 | 45 |
|
... | ... | |
103 | 104 |
print "RAPI protocol version: %s" % _rapi_client.GetVersion() |
104 | 105 |
|
105 | 106 |
|
107 |
def LookupRapiSecret(rapi_user): |
|
108 |
"""Find the RAPI secret for the given user. |
|
109 |
|
|
110 |
@param rapi_user: Login user |
|
111 |
@return: Login secret for the user |
|
112 |
|
|
113 |
""" |
|
114 |
CTEXT = "{CLEARTEXT}" |
|
115 |
master = qa_config.GetMasterNode() |
|
116 |
cmd = ["cat", qa_utils.MakeNodePath(master, pathutils.RAPI_USERS_FILE)] |
|
117 |
file_content = qa_utils.GetCommandOutput(master.primary, |
|
118 |
utils.ShellQuoteArgs(cmd)) |
|
119 |
users = ParsePasswordFile(file_content) |
|
120 |
entry = users.get(rapi_user) |
|
121 |
if not entry: |
|
122 |
raise qa_error.Error("User %s not found in RAPI users file" % rapi_user) |
|
123 |
secret = entry.password |
|
124 |
if secret.upper().startswith(CTEXT): |
|
125 |
secret = secret[len(CTEXT):] |
|
126 |
elif secret.startswith("{"): |
|
127 |
raise qa_error.Error("Unsupported password schema for RAPI user %s:" |
|
128 |
" not a clear text password" % rapi_user) |
|
129 |
return secret |
|
130 |
|
|
131 |
|
|
106 | 132 |
INSTANCE_FIELDS = ("name", "os", "pnode", "snodes", |
107 | 133 |
"admin_state", |
108 | 134 |
"disk_template", "disk.sizes", "disk.spindles", |
Also available in: Unified diff