Skip to content

Commit d3e5615

Browse files
committed
auditlog: handle new async client
The async client is now a thing of its own.
1 parent 82e21c4 commit d3e5615

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

cloudify_cli/async_commands/audit_log.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ async def _stream_logs(creator_name,
2727
timeout,
2828
logger,
2929
client):
30-
if not hasattr(client.auditlog, 'stream'):
31-
raise CloudifyCliError('Streaming requires Python>=3.6.')
3230
logger.info('Streaming audit log entries...')
3331
response = await client.auditlog.stream(timeout=timeout,
3432
creator_name=creator_name,

cloudify_cli/commands/audit_log.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import click
55

6+
from cloudify_cli import env
67
from cloudify_cli.cli import cfy, helptexts
78
from cloudify_cli.exceptions import CloudifyCliError
89
from cloudify_cli.table import print_data
@@ -65,18 +66,20 @@ def auditlog():
6566
@cfy.options.common_options
6667
@cfy.pass_logger
6768
@cfy.pass_client()
68-
def list_logs(creator_name,
69-
execution_id,
70-
since,
71-
follow,
72-
timeout,
73-
sort_by,
74-
descending,
75-
pagination_offset,
76-
pagination_size,
77-
logger,
78-
client,
79-
):
69+
def list_logs(
70+
creator_name,
71+
execution_id,
72+
since,
73+
follow,
74+
timeout,
75+
sort_by,
76+
descending,
77+
pagination_offset,
78+
pagination_size,
79+
logger,
80+
client,
81+
):
82+
client = env.get_rest_client(async_client=True)
8083
if follow:
8184
from cloudify_cli.async_commands.audit_log import stream_logs
8285
stream_logs(creator_name,
@@ -86,18 +89,20 @@ def list_logs(creator_name,
8689
logger,
8790
client)
8891
else:
89-
_list_logs(creator_name,
92+
import asyncio
93+
loop = asyncio.get_event_loop()
94+
loop.run_until_complete(_list_logs(creator_name,
9095
execution_id,
9196
since,
9297
sort_by,
9398
descending,
9499
pagination_offset,
95100
pagination_size,
96101
logger,
97-
client)
102+
client))
98103

99104

100-
def _list_logs(creator_name,
105+
async def _list_logs(creator_name,
101106
execution_id,
102107
since,
103108
sort_by,
@@ -108,7 +113,7 @@ def _list_logs(creator_name,
108113
client):
109114
"""List audit_log entries"""
110115
logger.info('Listing audit log entries...')
111-
logs = client.auditlog.list(
116+
logs = await client.auditlog.list(
112117
creator_name=creator_name,
113118
execution_id=execution_id,
114119
since=since,

0 commit comments

Comments
 (0)