Fix account be locked due to access registry without password

Correct code to let exception be raised when password cannot be
got from keyring. Account is locked due to exception is not raised,
and client try to access registry with None password, which is
incorrect.

Closes-Bug: #1871141
Change-Id: Ia68b4a4f25756fdad7a198a31d5870245ff9dc1a
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
This commit is contained in:
Shuicheng Lin
2020-04-08 10:57:50 +08:00
parent 113e0a144c
commit 1b50022d55
2 changed files with 4 additions and 4 deletions

View File

@@ -29,10 +29,10 @@ registries = json.loads(os.environ['REGISTRIES'])
def get_local_registry_auth():
password = str(keyring.get_password("CGCS", "admin"))
password = keyring.get_password("CGCS", "admin")
if not password:
raise Exception("Local registry password not found.")
return dict(username="admin", password=password)
return dict(username="admin", password=str(password))
def download_an_image(img):

View File

@@ -130,10 +130,10 @@
vars:
script_content: |
import keyring
password = str(keyring.get_password("CGCS", "admin"))
password = keyring.get_password("CGCS", "admin")
if not password:
raise Exception("Local registry password not found.")
print dict(username='admin', password=password)
print dict(username='admin', password=str(password))
shell: "{{ script_content }}"
args:
executable: /usr/bin/python