-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fixes #93: Logical Switch refresh conflict #136
Conversation
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 would also need to change it in the /examples
@@ -49,7 +49,7 @@ def create | |||
# Updates this object using the data that exists on OneView | |||
# @note Will overwrite any data that differs from OneView | |||
# @return [Resource] self | |||
def refresh | |||
def refresh_data_state! |
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 would prefer calling it refresh_state
to follow the pattern with the other refreshes
@tmiotto The method is not referenced in the examples. But I'll put it in there. |
@@ -49,7 +49,7 @@ def create | |||
# Updates this object using the data that exists on OneView | |||
# @note Will overwrite any data that differs from OneView |
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.
Are these comments true? Looks like a copy-paste that we forgot to change.
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.
Really, this comment is not good. I will use the documentation description.
logical_switch.set_switch_credentials('172.16.11.11', ssh_credentials, snmp_v1) | ||
logical_switch.set_switch_credentials('172.16.11.12', ssh_credentials, snmp_v1_2) | ||
logical_switch.set_switch_credentials('172.18.16.91', ssh_credentials, snmp_v1) | ||
logical_switch.set_switch_credentials('172.18.16.92', ssh_credentials, snmp_v1_2) |
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 these IPs and credentials be moved into the _client.rb file?
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.
yep. It is the better approach. :)
I'm working in this now.
- Method documentation comment was changed - The method returning the LogicalSwitch object
|
||
logical_switch_group = OneviewSDK::LogicalSwitchGroup.get_all(@client).first | ||
|
||
logical_switch = OneviewSDK::LogicalSwitch.new( | ||
@client, | ||
name: 'Teste_SDK', |
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 know it was not added right now, but could we change the name of this LogicalSwitch?
@@ -50,7 +50,7 @@ def create | |||
# @return [OneviewSDK::LogicalSwitch] self | |||
def refresh_state! | |||
response = @client.rest_put(@data['uri'] + '/refresh') | |||
@client.response_handler(response) | |||
body = @client.response_handler(response) | |||
set_all(body) | |||
self |
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.
Redundant self
, set_all
already returns self
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.
oh, yeah! Changing that. =)
def refresh | ||
# Reclaims the top-of-rack switches in a logical switch. | ||
# @return [OneviewSDK::LogicalSwitch] self | ||
def refresh_state! |
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.
Regarding the method implementation, I took a look in the API and I don't think the refresh/
endpoint does what this method think it does.
I mean, the response does not returns the Logical Switch, it reclaims the associated ToR switches... So, it won't make sense using the set_all
at all.
Also, since it does not changes anything in the resource, you will probably have to remove the ! from the method signature
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.
But, the return of the request is a LogicalSwitch with associated data (Switches uris and SwitchGroup uris, etc).
And the http verb of request used in this method is the PUT (like documentation describes), I imagine that server can change the data of LogicalSwitch when applyes the refresh.
Please, tell me if I am with wrong undestanding.
What are you think?
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.
Actually, the return is a task indicating wether the refresh is complete or not. If you want to return the Refreshed LogicalSwitch, you need to wait until the refresh state changes from Refreshing, then perform a retrieve!/refresh so this way you will have the refreshed LogicalSwitch.
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 changes was done.
The changes was done. |
@@ -47,11 +47,10 @@ def create | |||
end | |||
|
|||
# Reclaims the top-of-rack switches in a logical switch. | |||
# @return [OneviewSDK::LogicalSwitch] self | |||
def refresh_state! | |||
# @return [Hash] Http response body with logical switch data. |
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 REST call returns only a task, not the logical switch. I guess you have two alternatives:
- Remove the comment with the
@return
since it would be useless. - After the REST call use the
refresh
orretrieve!
method to update the resource
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.
But, the @client.response_handler(response)
is called that waits for task finish and return the LogicalSwitch Hash.
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.
Anyway, I did the first option. =)
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.
Good to go now 👍
Description
Changed the name of method to refresh_state and the conflict was fixed.
Issues Resolved
Fixes #93
Check List
$ rake test
).