item_updater: Return NotAllowed when attempting to clear FieldMode

Clearing FieldMode used to be a no-op, but by returning success, the
user wouldn't necessarily know that the PUT request did not take effect,
unless they checked the property value.
Changed it to return an error to let the user know that their request
did not take effect.

Tested: Verified an error is returned if the property is requested to
be cleared when it's already set, but no error is returned if it's
already cleared:

$ curl -b cjar -k -H "X-Auth-Token:$sha" -X PUT -d '{"data":"false"}' https://$bmc/xyz/openbmc_project/software/attr/FieldModeEnabled
{
  "data": null,
  "message": "200 OK",
  "status": "ok"
}
$ curl -b cjar -k -H "X-Auth-Token:$sha" -X PUT -d '{"data":"true"}' https://$bmc/xyz/openbmc_project/software/attr/FieldModeEnabled
{
  "data": null,
  "message": "200 OK",
  "status": "ok"
$ curl -b cjar -k -H "X-Auth-Token: $sha" -X PUT -d '{"data":"false"}' https://$bmc/xyz/openbmc_project/software/attr/FieldModeEnabled
{
  "data": {
    "description": "The specified property cannot be created"
  },
  "message": "Input/output error",
  "status": "error"
}

May 01 19:36:16 witherspoon phosphor-image-updater[1465]: The operation is not allowed

"MESSAGE" : "The operation is not allowed",
"REASON" : "FieldMode is not allowed to be cleared",
"SYSLOG_IDENTIFIER" : "phosphor-image-updater",

Change-Id: I1c0226c58956a28d903a85dfe98ac11daca4c7d4
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
1 file changed