HewlettPackard / oneview-puppet

This project is no longer being developed and has limited support. In the near future this repository will be fully deprecated. Please consider using other OneView projects, such as Terraform and Ansible Collection
https://forge.puppet.com/hewlettpackard/oneview
Apache License 2.0
8 stars 17 forks source link

Refactor resource_update method and improve idempotency on update operations. #138

Closed fgbulsoni closed 7 years ago

fgbulsoni commented 7 years ago

Description

This PR improves our idempotency in regards to server profiles and server profile templates. When using nested hashes before, the resource would run updates even when nothing had been updated. With this change, hopefully we will just be running things when needed be.

To achieve such idempotency, this PR includes a major refactor to the resource_update method which is used by most resources, and a few changes to the exists? method of SP and SPT resources. These changes in the resources make the idempotency a lot more viable and should be added to the oneview_resource's exists? method in order to be cascaded to every single resource. However, since this will generate a lot of changes as well and make review worse, I'm leaving that for a separate/future PR.

Issues Resolved

95

Check List

fgbulsoni commented 7 years ago

@tmiotto The amount of files in the PR increased a lot, but it's due to swapping out instances of resourcetype for resource_type. Should not be impactful.

marikrg commented 7 years ago

I got an error running the oneview_fc_network.pp manifest.

More details:

Debug: Puppet::Type::Oneview_fc_network::ProviderC7000: false value when expecting true
Debug: Creating default schedules
Debug: Loaded state in 0.02 seconds
Debug: Loaded state in 0.03 seconds
Debug: Loaded transaction store file in 0.00 seconds
Info: Applying configuration version '1490725945'
Debug: /Stage[main]/Main/Oneview_fc_network[fc2]/require: subscribes to Oneview_fc_network[fc1]
Debug: /Stage[main]/Main/Oneview_fc_network[fc3]/require: subscribes to Oneview_fc_network[fc2]
Debug: /Stage[main]/Main/Oneview_fc_network[fc4]/require: subscribes to Oneview_fc_network[fc3]
Notice: /Stage[main]/Main/Oneview_fc_network[fc1]/ensure: created
Debug: /Stage[main]/Main/Oneview_fc_network[fc1]: The container Class[Main] will propagate my refresh event
Notice: OneviewSDK::API300::Synergy::FCNetwork Updated OneViewSDK Test FC Network differs from resource in appliance.
Debug: Current attributes: {
  "autoLoginRedistribution": true,
  "type": "fc-networkV300",
  "linkStabilityTime": 30,
  "fabricType": "FabricAttach",
  "name": "OneViewSDK Test FC Network",
  "new_name": "Updated OneViewSDK Test FC Network",
  "managedSanUri": null,
  "connectionTemplateUri": "/rest/connection-templates/129a46a7-1d40-4c21-85ee-a4a64c87591e",
  "scopeUris": [

  ],
  "description": null,
  "status": "OK",
  "state": "Active",
  "eTag": "2628b353-f355-4c5f-9046-3ad4fc9a22b4",
  "created": "2017-03-28T18:32:48.266Z",
  "modified": "2017-03-28T18:32:48.279Z",
  "category": "fc-networks",
  "uri": "/rest/fc-networks/13405849-39f1-4e67-9c40-2720b6541435"
}
Debug: Desired attributes: {
  "name": "Updated OneViewSDK Test FC Network"
}
Error: Could not set 'present' on ensure: 400 BAD REQUEST {"details":"The field named new_name near line 1, column 164 is not a valid field in this JSON object.","recommendedActions":["Check the valid fields for this JSON object and remove or correct the unrecognized field."],"errorSource":null,"nestedErrors":[],"data":{},"errorCode":"UNRECOGNIZED_JSON_FIELD","message":"Unrecognized JSON field."} at /home/marikrg/dev/oneview/examples/fc_network.pp:29
Error: Could not set 'present' on ensure: 400 BAD REQUEST {"details":"The field named new_name near line 1, column 164 is not a valid field in this JSON object.","recommendedActions":["Check the valid fields for this JSON object and remove or correct the unrecognized field."],"errorSource":null,"nestedErrors":[],"data":{},"errorCode":"UNRECOGNIZED_JSON_FIELD","message":"Unrecognized JSON field."} at /home/marikrg/dev/oneview/examples/fc_network.pp:29
Wrapped exception:
400 BAD REQUEST {"details":"The field named new_name near line 1, column 164 is not a valid field in this JSON object.","recommendedActions":["Check the valid fields for this JSON object and remove or correct the unrecognized field."],"errorSource":null,"nestedErrors":[],"data":{},"errorCode":"UNRECOGNIZED_JSON_FIELD","message":"Unrecognized JSON field."}
Error: /Stage[main]/Main/Oneview_fc_network[fc2]/ensure: change from absent to present failed: Could not set 'present' on ensure: 400 BAD REQUEST {"details":"The field named new_name near line 1, column 164 is not a valid field in this JSON object.","recommendedActions":["Check the valid fields for this JSON object and remove or correct the unrecognized field."],"errorSource":null,"nestedErrors":[],"data":{},"errorCode":"UNRECOGNIZED_JSON_FIELD","message":"Unrecognized JSON field."} at /home/marikrg/dev/oneview/examples/fc_network.pp:29
Notice: /Stage[main]/Main/Oneview_fc_network[fc3]: Dependency Oneview_fc_network[fc2] has failures: true
Warning: /Stage[main]/Main/Oneview_fc_network[fc3]: Skipping because of failed dependencies
Debug: /Stage[main]/Main/Oneview_fc_network[fc3]: Resource is being skipped, unscheduling all events
Notice: /Stage[main]/Main/Oneview_fc_network[fc4]: Dependency Oneview_fc_network[fc2] has failures: true
Warning: /Stage[main]/Main/Oneview_fc_network[fc4]: Skipping because of failed dependencies
Debug: /Stage[main]/Main/Oneview_fc_network[fc4]: Resource is being skipped, unscheduling all events
Debug: Class[Main]: Resource is being skipped, unscheduling all events
Info: Class[Main]: Unscheduling all events on Class[Main]
Debug: Stage[main]: Resource is being skipped, unscheduling all events
Debug: Finishing transaction 47362221333100
Debug: Storing state
Debug: Stored state in 0.05 seconds
Notice: Applied catalog in 15.86 seconds
Debug: Applying settings catalog for sections reporting, metrics
Debug: Finishing transaction 47362241528960
Debug: Received report to process from marikrg.dbserver.com.br
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Debug: Processing report from marikrg.dbserver.com.br with processor Puppet::Reports::Store
fgbulsoni commented 7 years ago

I got an error running the oneview_fc_network.pp manifest.

Hmmm, I see the mistake already. Thanks! Will fix it soon.