-
Notifications
You must be signed in to change notification settings - Fork 0
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
Adds minimal controller interface #193
Open
dalonsoa
wants to merge
7
commits into
main
Choose a base branch
from
controller_interface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+45
−0
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
539bccb
:wrench: Add ROOT_CONTROLLER_URL to settings.
dalonsoa f52b54b
:sparkles: Add minimal controller interface.
dalonsoa 9b3aedc
:sparkles: Add testing script.
dalonsoa 4b6bc0f
:white_check_mark: Add test_get_controller_status.
dalonsoa 6151985
:recycle: Use drunc as the URL.
dalonsoa 8204f64
Merge branch 'main' into controller_interface
dalonsoa 11ac351
Merge branch 'main' into controller_interface
dalonsoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Module providing functions to interact with the drunc controller.""" | ||
|
||
from django.conf import settings | ||
from drunc.controller.controller_driver import ControllerDriver | ||
from drunc.utils.shell_utils import create_dummy_token_from_uname | ||
from druncschema.request_response_pb2 import Description | ||
|
||
|
||
def get_controller_driver() -> ControllerDriver: | ||
"""Get a ControllerDriver instance.""" | ||
token = create_dummy_token_from_uname() | ||
return ControllerDriver(settings.ROOT_CONTROLLER_URL, token=token, aio_channel=True) | ||
|
||
|
||
def get_controller_status() -> Description: | ||
"""Get the controller status.""" | ||
return get_controller_driver().get_status() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Example script used to check communication with the controller. | ||
|
||
This is intended to be run within docker from the `app` service, i.e.: | ||
|
||
``` | ||
docker compose exec app python scripts/talk_to_controller.py | ||
``` | ||
|
||
and provides a basic proof of principle of communicating with the controller via | ||
gRPC. | ||
""" | ||
|
||
from drunc.controller.controller_driver import ControllerDriver | ||
from drunc.utils.shell_utils import create_dummy_token_from_uname | ||
|
||
if __name__ == "__main__": | ||
token = create_dummy_token_from_uname() | ||
controller = ControllerDriver("localhost:3333", token=token, aio_channel=True) | ||
|
||
val = controller.get_status() | ||
print(val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def test_get_controller_status(mocker): | ||
"""Test the _boot_process function.""" | ||
from controller.controller_interface import get_controller_status | ||
|
||
mock = mocker.patch("controller.controller_interface.get_controller_driver") | ||
get_controller_status() | ||
mock.assert_called_once() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Being pedantic, we probably want to check that the
get_status()
method was called and not justget_controller_driver