Skip to content

Commit 107c1d6

Browse files
committed
fix formatting
Signed-off-by: Chris Snow <[email protected]>
1 parent dda03fb commit 107c1d6

24 files changed

+274
-100
lines changed

bin/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def configure_cli():
6161
controller_username = None
6262
controller_password = None
6363

64-
config_path = os.path.join(os.path.expanduser("~"), ".hpecp.conf",)
64+
config_path = os.path.join(os.path.expanduser("~"), ".hpecp.conf")
6565

6666
if os.path.exists(config_path):
6767
config_reader = ContainerPlatformClient.create_from_config_file()
@@ -204,7 +204,7 @@ def _get_metadata(self):
204204

205205
return (modules, columns)
206206

207-
def bash(self,):
207+
def bash(self):
208208
"""Create autocompletion script for bash."""
209209
__bash_template = dedent(
210210
"""\
@@ -401,7 +401,7 @@ def __dir__(self):
401401
"""Return modules names."""
402402
return list(vars(self))
403403

404-
def __init__(self,):
404+
def __init__(self):
405405
"""Create a CLI instance."""
406406
self.autocomplete = AutoComplete(self)
407407
self.configure_cli = configure_cli

hpecp/cli/base.py

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def _unknown_exception_handler(ex):
8787
"""Handle unknown exceptions."""
8888
if _log.level == 10: # "DEBUG"
8989
print(
90-
"Unknown error.", file=sys.stderr,
90+
"Unknown error.",
91+
file=sys.stderr,
9192
)
9293
else:
9394
print(
@@ -125,7 +126,8 @@ def _unknown_exception_handler(ex):
125126
def get_client(start_session=True):
126127
"""Retrieve a reference to an authenticated client object."""
127128
client = ContainerPlatformClient.create_from_config_file(
128-
config_file=get_config_file(), profile=get_profile(),
129+
config_file=get_config_file(),
130+
profile=get_profile(),
129131
)
130132
if start_session:
131133
client.create_session()
@@ -168,12 +170,21 @@ def get(self, id, output="yaml", params=None):
168170
if output == "json":
169171
print(json.dumps(json_data))
170172
elif output == "json-pp":
171-
print(json.dumps(json_data, indent=4, sort_keys=True,))
173+
print(
174+
json.dumps(
175+
json_data,
176+
indent=4,
177+
sort_keys=True,
178+
)
179+
)
172180
else:
173181

174182
print(
175183
yaml.dump(
176-
yaml.load(json.dumps(json_data), Loader=yaml.FullLoader,)
184+
yaml.load(
185+
json.dumps(json_data),
186+
Loader=yaml.FullLoader,
187+
)
177188
)
178189
)
179190

@@ -337,16 +348,26 @@ def print_list(self, list_instance, output, columns, query):
337348
obj = jmespath.search(str(query), data)
338349
print(TextOutput.dump(obj))
339350
else:
340-
print(json.dumps(jmespath.search(str(query), data),))
351+
print(
352+
json.dumps(
353+
jmespath.search(str(query), data),
354+
)
355+
)
341356

342357
def wait_for_state(
343-
self, id, states=[], timeout_secs=60,
358+
self,
359+
id,
360+
states=[],
361+
timeout_secs=60,
344362
):
345363
"""See wait_for_status()."""
346364
self.wait_for_status(id, states, timeout_secs)
347365

348366
def wait_for_status(
349-
self, id, status=[], timeout_secs=60,
367+
self,
368+
id,
369+
status=[],
370+
timeout_secs=60,
350371
):
351372
"""Wait for resource to have one or more statuses.
352373
@@ -370,22 +391,27 @@ def wait_for_status(
370391

371392
try:
372393
success = self.client_module_property.wait_for_status(
373-
id=id, status=resource_status, timeout_secs=timeout_secs,
394+
id=id,
395+
status=resource_status,
396+
timeout_secs=timeout_secs,
374397
)
375398
except Exception:
376399
success = False
377400

378401
if not success:
379402
print(
380403
"Failed to reach state(s) {} in {}s".format(
381-
str(status), str(timeout_secs),
404+
str(status),
405+
str(timeout_secs),
382406
),
383407
file=sys.stderr,
384408
)
385409
sys.exit(1)
386410

387411
def wait_for_delete(
388-
self, id, timeout_secs=1200,
412+
self,
413+
id,
414+
timeout_secs=1200,
389415
):
390416
"""Wait for Gateway to be deleted.
391417
@@ -394,5 +420,6 @@ def wait_for_delete(
394420
:returns True if gateway was deleted within timeout_secs.
395421
"""
396422
self.wait_for_state(
397-
id=id, timeout_secs=timeout_secs,
423+
id=id,
424+
timeout_secs=timeout_secs,
398425
)

hpecp/cli/gateway.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def create_with_ssh_key(
100100
)
101101
print(gateway_id)
102102

103-
def states(self,):
103+
def states(
104+
self,
105+
):
104106
"""Return a list of valid states."""
105107
print([s.name for s in GatewayStatus])

hpecp/cli/httpclient.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def __dir__(self):
3737

3838
@base.intercept_exception
3939
def get(
40-
self, url,
40+
self,
41+
url,
4142
):
4243
"""Make HTTP GET request.
4344
@@ -46,13 +47,16 @@ def get(
4647
$ hpecp httpclient get /api/v1/workers
4748
"""
4849
response = base.get_client()._request(
49-
url, http_method="get", description="CLI HTTP GET",
50+
url,
51+
http_method="get",
52+
description="CLI HTTP GET",
5053
)
5154
print(response.text, file=sys.stdout)
5255

5356
@base.intercept_exception
5457
def delete(
55-
self, url,
58+
self,
59+
url,
5660
):
5761
"""Make HTTP DELETE request.
5862
@@ -61,12 +65,16 @@ def delete(
6165
$ hpecp httpclient delete /api/v1/workers/1
6266
"""
6367
base.get_client()._request(
64-
url, http_method="delete", description="CLI HTTP DELETE",
68+
url,
69+
http_method="delete",
70+
description="CLI HTTP DELETE",
6571
)
6672

6773
@base.intercept_exception
6874
def post(
69-
self, url, json_file="",
75+
self,
76+
url,
77+
json_file="",
7078
):
7179
"""Make HTTP POST request.
7280
@@ -91,28 +99,42 @@ def post(
9199
92100
hpecp httpclient post /api/v2/config/auth --json-file my.json
93101
"""
94-
with open(json_file, "r",) as f:
102+
with open(
103+
json_file,
104+
"r",
105+
) as f:
95106
data = json.load(f)
96107

97108
response = base.get_client()._request(
98-
url, http_method="post", data=data, description="CLI HTTP POST",
109+
url,
110+
http_method="post",
111+
data=data,
112+
description="CLI HTTP POST",
99113
)
100114
print(response.text, file=sys.stdout)
101115

102116
@base.intercept_exception
103117
def put(
104-
self, url, json_file="",
118+
self,
119+
url,
120+
json_file="",
105121
):
106122
"""Make HTTP PUT request.
107123
108124
Examples
109125
--------
110126
$ hpecp httpclient put /api/v2/config/auth --json-file my.json
111127
""" # noqa: W293
112-
with open(json_file, "r",) as f:
128+
with open(
129+
json_file,
130+
"r",
131+
) as f:
113132
data = json.load(f)
114133

115134
response = base.get_client()._request(
116-
url, http_method="put", data=data, description="CLI HTTP PUT",
135+
url,
136+
http_method="put",
137+
data=data,
138+
description="CLI HTTP PUT",
117139
)
118140
print(response.text, file=sys.stdout)

hpecp/cli/k8scluster.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,15 @@ def admin_kube_config(self, id):
124124
print(
125125
base.get_client()
126126
.k8s_cluster.get(id)
127-
.admin_kube_config.replace("\\n", "\n",)
127+
.admin_kube_config.replace(
128+
"\\n",
129+
"\n",
130+
)
128131
)
129132

130133
def dashboard_url(
131-
self, id,
134+
self,
135+
id,
132136
):
133137
"""Retrieve a K8s Cluster Dashboard URL.
134138
@@ -140,7 +144,8 @@ def dashboard_url(
140144
print(url)
141145

142146
def dashboard_token(
143-
self, id,
147+
self,
148+
id,
144149
):
145150
"""Retrieve a K8s Cluster Dashboard Token.
146151
@@ -157,7 +162,12 @@ def k8smanifest(self):
157162
"""Retrieve the k8smanifest."""
158163
response = base.get_client().k8s_cluster.k8smanifest()
159164
print(
160-
yaml.dump(yaml.load(json.dumps(response), Loader=yaml.FullLoader,))
165+
yaml.dump(
166+
yaml.load(
167+
json.dumps(response),
168+
Loader=yaml.FullLoader,
169+
)
170+
)
161171
)
162172

163173
@base.intercept_exception
@@ -224,7 +234,9 @@ def add_addons(self, id, addons, wait_for_ready_sec=0):
224234
id=id, status=["ready"], timeout_secs=wait_for_ready_sec
225235
)
226236

227-
def statuses(self,):
237+
def statuses(
238+
self,
239+
):
228240
"""Return a list of valid statuses."""
229241
print([s.name for s in K8sClusterStatus])
230242

hpecp/cli/k8sworker.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def create_with_ssh_key(
121121
sys.exit(1)
122122

123123
worker_id = base.get_client().k8s_worker.create_with_ssh_key(
124-
ip=ip, ssh_key_data=ssh_key, tags=tags,
124+
ip=ip,
125+
ssh_key_data=ssh_key,
126+
tags=tags,
125127
)
126128

127129
if wait_for_operation_secs > 0:
@@ -170,7 +172,10 @@ def create_with_ssh_key(
170172

171173
@base.intercept_exception
172174
def set_storage(
173-
self, id, ephemeral_disks, persistent_disks=None,
175+
self,
176+
id,
177+
ephemeral_disks,
178+
persistent_disks=None,
174179
):
175180
"""Set storage for a k8s worker.
176181
@@ -196,9 +201,13 @@ def set_storage(
196201
e_disks = ephemeral_disks.split(",")
197202

198203
base.get_client().k8s_worker.set_storage(
199-
worker_id=id, persistent_disks=p_disks, ephemeral_disks=e_disks,
204+
worker_id=id,
205+
persistent_disks=p_disks,
206+
ephemeral_disks=e_disks,
200207
)
201208

202-
def statuses(self,):
209+
def statuses(
210+
self,
211+
):
203212
"""Return a list of valid statuses."""
204213
print([s.name for s in WorkerK8sStatus])

hpecp/cli/license.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@ def __dir__(self):
4040
return ["delete", "delete_all", "list", "platform_id", "register"]
4141

4242
@base.intercept_exception
43-
def platform_id(self,):
43+
def platform_id(
44+
self,
45+
):
4446
"""Get the platform ID."""
4547
print(base.get_client().license.platform_id())
4648

4749
def list(
48-
self, output="yaml", license_key_only=False,
50+
self,
51+
output="yaml",
52+
license_key_only=False,
4953
):
5054
"""Retrieve the list of licenses.
5155
@@ -62,7 +66,8 @@ def list(
6266
print(
6367
yaml.dump(
6468
yaml.load(
65-
json.dumps(response), Loader=yaml.FullLoader,
69+
json.dumps(response),
70+
Loader=yaml.FullLoader,
6671
)
6772
)
6873
)
@@ -71,7 +76,8 @@ def list(
7176

7277
@base.intercept_exception
7378
def register(
74-
self, server_filename,
79+
self,
80+
server_filename,
7581
):
7682
"""Register a license.
7783
@@ -128,7 +134,8 @@ def register(
128134

129135
@base.intercept_exception
130136
def delete(
131-
self, license_key,
137+
self,
138+
license_key,
132139
):
133140
"""Delete a license by LicenseKey.
134141
@@ -138,7 +145,9 @@ def delete(
138145
base.get_client().license.delete(license_key=license_key)
139146

140147
@base.intercept_exception
141-
def delete_all(self,):
148+
def delete_all(
149+
self,
150+
):
142151
"""Delete all licenses."""
143152
response = base.get_client().license.list()
144153
all_license_keys = [

0 commit comments

Comments
 (0)