-
Notifications
You must be signed in to change notification settings - Fork 194
Security groups request ids #1099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The python api will now output a table with requestIDs for specific calls to security groups apis
Fix unit tests Fix code style issues
Add new return format
Add functionality to get event logs to slcli
Fix Security Group unit tests
Refactor Event Log Code Fix Unit Tests Add Unit Tests Fix Code Styling
Remove unneeded code left over from refactoring Fix incorrect package name
Code Styling changes
Change public facing name to Audit Logs Add functionality to get event log types
Fix ordering of test expecations to be Actual then Expected
Add functionality to filter by eventName
Add functionality to filter by dates
Add request id search functionality
Fix fixtures from merge
Fix tox issues
change date_min to date-min in click args change date_max to date-max in click args change how the event log client is initialized move filter building code into event log manager set default utc offset to +0000 move date parsing code into utils add ability to get event logs by type add ability to get event logs by name move requestID searching into Security Groups code Overhaul unit tests
…event-log which matches the API and function names.
Realignment
Finishes up #935 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK as is, but I think i'll create a few more issues off this one to expand the event-log cli features
mgr = SoftLayer.EventLogManager(env.client) | ||
|
||
request_filter = mgr.build_filter(date_min, date_max, obj_event, obj_id, obj_type, utc_offset) | ||
logs = mgr.get_event_logs(request_filter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_event_logs should likely return an empty list at least.
$ ./slcli event-log get -t "Bare Metal Instance"
An unexpected error has occured:
Traceback (most recent call last):
File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\core.py", line 182, in main
cli.main(**kwargs)
File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "C:\Users\allmi\Source\py36\lib\site-packages\click\decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Users\allmi\Source\py36\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\event_log\get.py", line 39, in cli
for log in logs:
TypeError: 'NoneType' object is not iterable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be taken care of with the latest push.
@click.option('--obj-event', '-e', | ||
help="The event we want to get event logs for") | ||
@click.option('--obj-id', '-i', | ||
help="The id of the object we want to get event logs for") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help="The id of the object (server, storage, user, etc) to get logs for"
@click.option('--obj-id', '-i', | ||
help="The id of the object we want to get event logs for") | ||
@click.option('--obj-type', '-t', | ||
help="The type of the object we want to get event logs for") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help="The type of the object we want to get event logs for. See slcli event-log types for a list"
COLUMNS = ['event', 'label', 'date', 'metadata'] | ||
|
||
|
||
@click.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
Add a way to limit results. Something like in slcli vs list
maybe.
|
||
|
||
@click.command() | ||
@click.argument('request_id') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: I'm not really sure using the request_id here is useful, as that doesn't seem to be a very accessible piece of information for a user to get. Maybe it would be better to get the logs by the security group id?
def __init__(self, client): | ||
self.event_log = client['Event_Log'] | ||
|
||
def get_event_logs(self, request_filter): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: event_log.getAllObjects should be called with self.event_log.getAllObjects(filter=request_filter, iter=True)
and likely needs to support limits so more than the default number of objects can be pulled down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see some improvements in the table, maybe they can be added later
SoftLayer/CLI/event_log/get.py
Outdated
from SoftLayer.CLI import environment | ||
from SoftLayer.CLI import formatting | ||
|
||
COLUMNS = ['event', 'label', 'date', 'metadata'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
It is a little annoying when looking the table and there are metadata information on it, maybe it would be better if metadata is an optional column or you could also create a new command which could be used to see the metadata information through the
traceId
value, similar toslcli vs detail
-
I suggest you to remove the braces { } if metadata information will be in the table.
-
I suggest to rename
label
byobject
and recommend to addobject type
andusername
columns to the table, this would help the customers to identify what user made the action/event and in what kind of object, for example I remember that a customer wanted to know what user powered on/off an specific virtual server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With commit d21cbd1, these suggestions should be implemented.
This completes some of the requested work on the other current pull request.