Skip to content

Commit 8549243

Browse files
committed
fix(install): provide more options for set gw ssl
Signed-off-by: Chris Snow <[email protected]>
1 parent bb13df3 commit 8549243

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

hpecp/cli/install.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,77 @@ def examples(self):
9898

9999
@base.intercept_exception
100100
def set_gateway_ssl(
101-
self, cert_content, cert_file_name, key_content, key_file_name
101+
self,
102+
cert_file=None,
103+
cert_content=None,
104+
cert_file_name=None,
105+
key_file=None,
106+
key_content=None,
107+
key_file_name=None,
102108
):
103109
"""Set Gateway SSL.
104110
105111
Parameters
106112
----------
113+
cert_file : [type]
114+
[description]
107115
cert_content : [type]
108116
[description]
109117
cert_file_name : [type]
110118
[description]
119+
key_file : [type]
120+
[description]
111121
key_content : [type]
112122
[description]
113123
key_file_name : [type]
114124
[description]
115125
"""
126+
assert (
127+
cert_file is None
128+
and (cert_content is not None and cert_file_name is not None)
129+
) or (
130+
cert_file is not None
131+
and (cert_content is None and cert_file_name is None)
132+
), (
133+
"('cert-content' and 'cert-file-name') or 'cert-file' "
134+
"must be provided."
135+
)
136+
137+
assert (
138+
key_file is None
139+
and (key_content is not None and key_file_name is not None)
140+
) or (
141+
key_file is not None
142+
and (key_content is None and key_file_name is None)
143+
), (
144+
"('key_content' and 'key_file-name') or 'key_file' "
145+
"must be provided."
146+
)
147+
148+
if cert_file:
149+
try:
150+
with open(cert_file, "r") as f:
151+
cert_content = f.read()
152+
cert_file_name = cert_file
153+
except OSError:
154+
print(
155+
"Could not open/read 'cert-file': {}".format(cert_file),
156+
file=sys.stderr,
157+
)
158+
sys.exit(1)
159+
160+
if key_file:
161+
try:
162+
with open(key_file, "r") as f:
163+
key_content = f.read()
164+
key_file_name = key_file
165+
except OSError:
166+
print(
167+
"Could not open/read 'key-file': {}".format(key_file),
168+
file=sys.stderr,
169+
)
170+
sys.exit(1)
171+
116172
base.get_client().install.set_gateway_ssl(
117173
cert_content, cert_file_name, key_content, key_file_name
118174
)

0 commit comments

Comments
 (0)