Skip to content
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

Merged
merged 11 commits into from
Jan 30, 2017

Conversation

ricardogpsf
Copy link
Member

@ricardogpsf ricardogpsf commented Jan 23, 2017

Description

Changed the name of method to refresh_state and the conflict was fixed.

Issues Resolved

Fixes #93

Check List

  • New functionality includes testing.
    • All tests pass ($ rake test).
  • New functionality has been documented in the README if applicable.
    • New functionality has been thoroughly documented in the examples (please include helpful comments).
  • Changes are documented in the CHANGELOG.

Copy link
Contributor

@tmiotto tmiotto left a 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!
Copy link
Contributor

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

@ricardogpsf
Copy link
Member Author

ricardogpsf commented Jan 23, 2017

@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
Copy link
Collaborator

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.

Copy link
Member Author

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)
Copy link
Collaborator

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?

Copy link
Member Author

@ricardogpsf ricardogpsf Jan 24, 2017

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',
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Member Author

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!
Copy link
Contributor

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

Copy link
Member Author

@ricardogpsf ricardogpsf Jan 24, 2017

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?

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes was done.

@ricardogpsf
Copy link
Member Author

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.
Copy link
Contributor

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:

  1. Remove the comment with the @return since it would be useless.
  2. After the REST call use the refresh or retrieve! method to update the resource

Copy link
Member Author

@ricardogpsf ricardogpsf Jan 27, 2017

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.

Copy link
Member Author

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. =)

Copy link
Contributor

@tmiotto tmiotto left a 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 👍

@ricardogpsf ricardogpsf merged commit ceccdb5 into master Jan 30, 2017
@ricardogpsf ricardogpsf deleted the bugfix/logical_switch_resfresh branch January 30, 2017 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logical Switch refresh conflict
3 participants