-
Notifications
You must be signed in to change notification settings - Fork 9
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
Inter adapter communication #36
Conversation
…ary of loaded adapters to be passed to each adapter by the API
…lace the full HTTP Requests used in Get and Put methods for internal Adapter Communication
…test the adapter communication
…d for the inter adapter communication
… the Put method of the target adapter via IAC
…e it's used in a couple places
Created this PR even though it can't be automatically merged. Not sure what the usual tactic here is so please let me know. |
You can rebase your branch off master and resolve the merge conflict, then force push the branch. Rebasing public branches is regarded as a bad thing, but it's OK on a feature branch that only you are working on. You can also just merge from master, resolve the conflict and push again. I'm never convinced which is preferable. |
The Merge Conflict was a part of the test_adapter.py file (since both me and @timcnicholls had modified the adapter class and thus the tests) but I've manually fixed that conflict and we are okay now. I was hesitant to rebase because I've broken things by doing that before and I'd rather not run the risk this time |
odin/adapters/adapter.py
Outdated
def initialize(self, adapters): | ||
"""Initialize the ApiAdapter after it has been registered by the API Route. | ||
|
||
This is an abstract implimentation of the initialize mechinism that allows |
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.
Typo on implementation
odin/adapters/adapter.py
Outdated
class ApiAdapterRequest(object): | ||
"""API Adapter Request object. | ||
|
||
Designed to emulate the HTTP Request Object used in the Get and Put requests |
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.
Suggest this should read
'Emulates the HTTPServerRequest' class passed as an argument to adapter HTTP verb methods (GET, PUT, ...)'
odin/adapters/iac_dummy.py
Outdated
@@ -0,0 +1,83 @@ | |||
import logging |
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.
To avoid proliferation of test code source files in the main source tree I suggest we, as a minimum, merge iac_dummy.py and iac_dummy_target.py. They could also be merged into dummy.py.
odin/adapters/iac_dummy_target.py
Outdated
@@ -0,0 +1,60 @@ | |||
import logging |
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.
See above comment
@@ -0,0 +1,49 @@ | |||
from nose.tools import assert_equal |
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.
Ditto merging these sources into one file
Thanks @ANeaves for implementing this. Looks good! Comments above are minor suggestions for improvement. |
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.
As discussed, let's refactor location and use of IAC dummy adapters. We should also allow IAC on all 'core' adapters, i.e. system_info
, system_status
and proxy
…e IAC Dummy Adapter is for
@timcnicholls I've merged the IAC dummy adapter into the original Dummy adapter. I also merged the tests, and removed the dummy target since it wasn't really any different from the dummy adapter that already existed. |
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.
Looks good @ANeaves thanks for doing this. Have made a few very minor comments.
odin/adapters/adapter.py
Outdated
"""API Adapter Request object. | ||
|
||
Emulate the HTTPServerRequest class passed as an argument to adatper HTTP | ||
verb methods(GET, PUT etc), for internal communication between adapters. |
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.
Missing space before (GET, ...
odin/adapters/dummy.py
Outdated
@@ -1,8 +1,12 @@ | |||
""" Dummy adapter class for the ODIN 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.
Should now be "classes"
odin/adapters/dummy.py
Outdated
@@ -1,8 +1,12 @@ | |||
""" Dummy adapter class for the ODIN server. | |||
|
|||
This class implements a dummy adapter for the ODIN server, demonstrating the | |||
The "DummyAdapter" class implements a dummy adapter for the ODIN server, demonstrating the |
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.
Can remove quotes from these docstrings
odin/adapters/dummy.py
Outdated
Call the get method of each other adapter that is loaded and return the responses | ||
in a dictionary. | ||
""" | ||
logging.debug("IAC DUMMY GET") |
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.
Shouty-shouty debug messages 😉
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.
Debug's gotta get your attention somehow ;)
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.
True, but that's through the sheer force of your coding brilliance, not gratuitous use of all-caps!
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.
😆
odin/adapters/adapter.py
Outdated
class ApiAdapterRequest(object): | ||
"""API Adapter Request object. | ||
|
||
Emulate the HTTPServerRequest class passed as an argument to adatper HTTP |
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.
type: adatper
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.
Rubber stamp! (Apologies, I can't take too much of a close look)
I suggest at least @ajgdls should have a closer look as he is the one who works most with odin-control - and perhaps one of the other reviewers. We don't generally need the full gang for review...
odin/adapters/dummy.py
Outdated
for key, value in self.adapters.items(): | ||
if value is self: | ||
del self.adapters[key] | ||
break |
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.
break | |
self.adapters = dict((k, v) for k, v in adapters.items() if v is not self) |
Maybe?
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.
Looks good, the changes weren't very intrusive to the existing infrastructure which is nice.
…pter initialize method to a tidier single line pythonic for loop
Adds the possibility for an adapter to receive references to other loaded adapters, so that it can potentially interact with those other adapters. It is designed so that this interaction is done via the GET and PUT methods as if done over HTTP, but the created ApiAdapterRequest object replaces the resource heavy HTTP request with a lightweight version that contains only what we need.
Closes #28