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

Fix like? method for Server Profile #219

Closed
fgbulsoni opened this issue Mar 23, 2017 · 2 comments
Closed

Fix like? method for Server Profile #219

fgbulsoni opened this issue Mar 23, 2017 · 2 comments

Comments

@fgbulsoni
Copy link
Contributor

Scenario/Intent

I'd like to use the .like? method for a ServerProfile with connections declared and it should tell me if my resource is similar or not. This seems related/similar to #89

Environment Details

  • OneView SDK Version: 4.1

Steps to Reproduce

Create a server profile with connections specified.
Sample connections:

[
  {
    "id": 1,
    "name": "deploy-network",
    "functionType": "Ethernet",
    "networkUri": "/rest/ethernet-networks/86c5fb2a-563c-4eaa-9927-a73b2f56685f",
    "requestedMbps": 2500,
    "requestedVFs": "Auto",
    "boot": {
      "priority": "Primary",
      "initiatorNameSource": "ProfileInitiatorName"
    }
  },
  {
    "id": 2,
    "name": "corp",
    "functionType": "Ethernet",
    "networkUri": "/rest/ethernet-networks/21cf8ee3-0579-480b-8f77-f595d348d877",
    "requestedMbps": 2500,
    "requestedVFs": "Auto"
  }
]

After the SP is created, assign it to a variable and retrieve it.

Then run

sp_instance.like?(sample_connections)

Expected Result

Since we created the SP with those connections, it should return true to like?

Actual Result

returns false.

@fgbulsoni
Copy link
Contributor Author

@tmiotto found the issue. Thanks!
in resource.rb, inside the recursive_like? method, in its last elsif:

elsif val != data[key.to_s] && val != data[key.to_sym]

This is not accounting for type differences such as integers and strings.
To fix it:

elsif val.to_s != data[key.to_s].to_s && val.to_s != data[key.to_sym].to_s

@fgbulsoni
Copy link
Contributor Author

fgbulsoni commented Mar 23, 2017

Just for the record, it was identified that ov is returning:
"requestedMbps": "2500"
While when we create the resource, we have:
"requestedMbps": 2500
This type mismatch caused the comparison to evaluate to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant