-
Notifications
You must be signed in to change notification settings - Fork 15
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
Synergy support option 2 #99
Conversation
module OneviewCookbook | ||
module API200 | ||
# Base class for API200 resource providers | ||
class EthernetNetwork < OneviewCookbook::ResourceProvider |
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.
EthernetNetwork? I don't get it
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.
Oops. Should be fixed now.
module OneviewCookbook | ||
module API200 | ||
# Base class for API200 resource providers | ||
class ResourceProvider < OneviewCookbook::ResourceProvider |
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, but why do we have this?
It is to add any shared behavior specific to API200? If so, shouldn't we have to do something similar to API300 or C7000 and Synergy?
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.
Yes. I didn't include the one for API300 and the variants YET, but yes, the concept is the same. We'd add the default class in there. Exactly like the Resource class for the SDK
@@ -0,0 +1,4 @@ | |||
~FC011 |
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 guess foodcritic is failing because we're running it from the wrong directory.
Actually, it should receive as parameter the cookbooks/
folder, so it gets our oneview
cookbook and then analyzes it. But in this case it is being executed inside oneview/
, so this way it is interpreting the libraries
as a separate cookbook, and not a subfolder
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.
Well, it's not exactly the wrong directory, but running on cookbooks/
would solve the problem (but this is a workaround), or maybe we should just add an exclude_path
if we don't want libraries to be analyzed by it.
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 can't get it to not see the libraries directory as a separate cookbook, which is why I put that .foodcritic
file in there. How are you able to run it so it gets ignored?
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.
The travis test doesn't have a cookbooks
directory. Just this repo.
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 think the real issue is that foodcritic thinks the libraries directory is a cookbook because of the resources
directory within it. We can rename the directory to avoid these issues. See this issue
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 be fixed now
These changes from the PR #96 should be added to stop the spec from failing. |
Added some more tests and functionality. I think the functionality for EthernetNetworkProvider is now done. Just need a few more test, but I'll get to those tomorrow. |
@@ -20,7 +20,7 @@ module API300 | |||
# @return [Class] Resource class or nil if not found | |||
def self.resource_named(type, variant) | |||
raise "API300 variant #{variant} is not supported!" unless SUPPORTED_VARIANTS.include?(variant.to_s) | |||
new_type = type.to_s.downcase.gsub(/[ -_]/, '') | |||
new_type = type.to_s.downcase.gsub(/[ -_]/, '') + 'provider' |
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 we still be calling it resource_named
?
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.
What do you suggest instead? resource_provider_named
?
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 an option, or maybe just provider_named
.
@@ -27,3 +27,14 @@ | |||
expect(real_chef_run).to create_oneview_ethernet_network('EthernetNetwork1') | |||
end | |||
end | |||
|
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.
Maybe we would not want to implement tests of things that are already being tested on API200
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.
Agreed. This is just a sample of what you would do if you wanted to test API300 resources. I think this particular one is probably OK to leave in since it's the only one so far, but we wouldn't have to add these sort of tests for other resources that are the same as API200.
@jsmartt Just one more thought... As far as we go through the implementation, we'll always be using the last API version as base for the next one, i.e. Said that we won't be using any ResourceProvider other than the It won't be better to just have the |
Yeah, I guess I added the API200 sub-class prematurely. We don't need it now, so there's no need to include it. I'll remove it |
OK @tmiotto , I'm ready on this when you are 😄 |
Description
This PR offers another option for addressing support for Synergy and future OV releases. (At this point I just have the ethernet_network providers done.) The logic for resources is split up into separate providers for each API version and variant. Here are the basic features:
Compared to #96, this option will require more work to refactor, but I think it's worth it.
Issues Resolved
Fixes #97
Check List
$ rake test
).@tmiotto or others, let me know what you think!