Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #995 from joyent/ether/v3.0-do-not-update-device-h…
Browse files Browse the repository at this point in the history
…ardware_product

v3.0: do not update device hardware product when processing reports
  • Loading branch information
karenetheridge authored Apr 17, 2020
2 parents 33d737f + 22efa5c commit 2391c3f
Show file tree
Hide file tree
Showing 44 changed files with 523 additions and 271 deletions.
5 changes: 2 additions & 3 deletions docs/_resources/full-schema.er
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ deactivated
[validation_result] {bgcolor: "#fbfbdb"}
*id
+device_id
+hardware_product_id
+validation_id
message
hint
Expand All @@ -329,7 +328,7 @@ created
+device_id
created
status
completed
+hardware_product_id

[validation_state_member] {bgcolor: "#fbfbdb"}
*+validation_state_id
Expand Down Expand Up @@ -386,10 +385,10 @@ user_workspace_role *--1 workspace
validation_plan_member *--1 validation
validation_plan_member *--1 validation_plan
validation_result *--1 device
validation_result *--1 hardware_product
validation_result *--1 validation
validation_state *--1 device
validation_state *--1 device_report
validation_state *--1 hardware_product
validation_state_member +--1 validation_result
validation_state_member *--1 validation_state
validation_state *--1 validation_plan
Expand Down
5 changes: 2 additions & 3 deletions docs/_resources/validations.er
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ deactivated
[validation_result]
*id
+device_id
+hardware_product_id
+validation_id
message
hint
Expand All @@ -107,7 +106,7 @@ created
+device_id
created
status
completed
+hardware_product_id

[validation_state_member] {bgcolor: "#d0e0d0"}
*+validation_state_id
Expand All @@ -121,10 +120,10 @@ hardware_product *--1 validation_plan
validation_plan_member *--1 validation
validation_plan_member *--1 validation_plan
validation_result *--1 device
validation_result *--1 hardware_product
validation_result *--1 validation
validation_state *--1 device
validation_state *--1 device_report
validation_state *--1 hardware_product
validation_state_member +--1 validation_result
validation_state_member *--1 validation_state
validation_state *--1 validation_plan
Binary file modified docs/images/full-schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/validations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/json-schema/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,20 @@
],
"type" : "object"
},
"DeviceHardware" : {
"additionalProperties" : false,
"maxProperties" : 1,
"minProperties" : 1,
"properties" : {
"hardware_product_id" : {
"$ref" : "common.json#/definitions/uuid"
},
"sku" : {
"$ref" : "common.json#/definitions/mojo_standard_placeholder"
}
},
"type" : "object"
},
"DeviceLinks" : {
"additionalProperties" : false,
"properties" : {
Expand Down
21 changes: 12 additions & 9 deletions docs/json-schema/response.json
Original file line number Diff line number Diff line change
Expand Up @@ -2413,9 +2413,15 @@
"device_serial_number" : {
"$ref" : "common.json#/definitions/device_serial_number"
},
"hardware_product_id" : {
"$ref" : "common.json#/definitions/uuid"
},
"results" : {
"$ref" : "/definitions/ValidationResults"
},
"sku" : {
"$ref" : "common.json#/definitions/mojo_standard_placeholder"
},
"status" : {
"$ref" : "common.json#/definitions/validation_status"
},
Expand All @@ -2426,6 +2432,8 @@
"required" : [
"device_serial_number",
"validation_plan_id",
"hardware_product_id",
"sku",
"status",
"results"
],
Expand Down Expand Up @@ -2864,9 +2872,6 @@
}
]
},
"hardware_product_id" : {
"$ref" : "common.json#/definitions/uuid"
},
"hint" : {
"oneOf" : [
{
Expand Down Expand Up @@ -2901,7 +2906,6 @@
"id",
"category",
"component",
"hardware_product_id",
"hint",
"message",
"status",
Expand All @@ -2919,10 +2923,6 @@
"ValidationStateWithResults" : {
"additionalProperties" : false,
"properties" : {
"completed" : {
"format" : "date-time",
"type" : "string"
},
"created" : {
"format" : "date-time",
"type" : "string"
Expand All @@ -2933,6 +2933,9 @@
"device_report_id" : {
"$ref" : "common.json#/definitions/uuid"
},
"hardware_product_id" : {
"$ref" : "common.json#/definitions/uuid"
},
"id" : {
"$ref" : "common.json#/definitions/uuid"
},
Expand All @@ -2952,12 +2955,12 @@
},
"required" : [
"id",
"completed",
"created",
"device_id",
"results",
"status",
"validation_plan_id",
"hardware_product_id",
"device_report_id"
],
"type" : "object"
Expand Down
6 changes: 6 additions & 0 deletions docs/modules/Conch::Controller::Device.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ Moves the device to a new build.

Also requires read/write access to the old and new builds.

### set\_hardware\_product

Changes the hardware product (sku) assigned to the device.

Requires admin access to the device.

## LICENSING

Copyright Joyent, Inc.
Expand Down
6 changes: 3 additions & 3 deletions docs/modules/Conch::Controller::DeviceLocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Response uses the DeviceLocation json schema.

### set

Sets the location for a device, given a valid rack id and rack unit. The existing occupant is
removed, if there is one. The device is created based on the hardware\_product specified for
the layout if it does not yet exist.
Sets the location for a device, given a valid rack id and rack unit. If there is an existing
occupant, it is removed; the new occupant's hardware\_product is updated to match the layout
(and its health is set to unknown if it changed).

### delete

Expand Down
3 changes: 2 additions & 1 deletion docs/modules/Conch::Controller::DeviceReport.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Response uses the DeviceReportRow json schema.
### validate\_report

Process a device report without writing anything to the database; otherwise behaves like
["process"](#process). The described device does not have to exist.
["process"](#process). The validation plan is determined from the report sku if the device does not
exist; otherwise, it uses the device sku as ["process"](#process) does.

Response uses the ReportValidationResults json schema.

Expand Down
4 changes: 2 additions & 2 deletions docs/modules/Conch::DB::Result::HardwareProduct.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ Type: belongs\_to

Related object: [Conch::DB::Result::ValidationPlan](../modules/Conch%3A%3ADB%3A%3AResult%3A%3AValidationPlan)

### validation\_results
### validation\_states

Type: has\_many

Related object: [Conch::DB::Result::ValidationResult](../modules/Conch%3A%3ADB%3A%3AResult%3A%3AValidationResult)
Related object: [Conch::DB::Result::ValidationState](../modules/Conch%3A%3ADB%3A%3AResult%3A%3AValidationState)

## LICENSING

Expand Down
16 changes: 0 additions & 16 deletions docs/modules/Conch::DB::Result::ValidationResult.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ is_nullable: 0
size: 16
```

### hardware\_product\_id

```
data_type: 'uuid'
is_foreign_key: 1
is_nullable: 0
size: 16
```

### validation\_id

```
Expand Down Expand Up @@ -100,7 +91,6 @@ size: 16
### `validation_result_all_columns_key`

- ["device\_id"](#device_id)
- ["hardware\_product\_id"](#hardware_product_id)
- ["validation\_id"](#validation_id)
- ["message"](#message)
- ["hint"](#hint)
Expand All @@ -116,12 +106,6 @@ Type: belongs\_to

Related object: [Conch::DB::Result::Device](../modules/Conch%3A%3ADB%3A%3AResult%3A%3ADevice)

### hardware\_product

Type: belongs\_to

Related object: [Conch::DB::Result::HardwareProduct](../modules/Conch%3A%3ADB%3A%3AResult%3A%3AHardwareProduct)

### validation

Type: belongs\_to
Expand Down
16 changes: 12 additions & 4 deletions docs/modules/Conch::DB::Result::ValidationState.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ extra: {custom_type_name => "validation_status_enum",list => ["error","fail","pa
is_nullable: 0
```

### completed
### device\_report\_id

```
data_type: 'timestamp with time zone'
data_type: 'uuid'
is_foreign_key: 1
is_nullable: 0
size: 16
```

### device\_report\_id
### device\_id

```
data_type: 'uuid'
Expand All @@ -61,7 +63,7 @@ is_nullable: 0
size: 16
```

### device\_id
### hardware\_product\_id

```
data_type: 'uuid'
Expand All @@ -88,6 +90,12 @@ Type: belongs\_to

Related object: [Conch::DB::Result::DeviceReport](../modules/Conch%3A%3ADB%3A%3AResult%3A%3ADeviceReport)

### hardware\_product

Type: belongs\_to

Related object: [Conch::DB::Result::HardwareProduct](../modules/Conch%3A%3ADB%3A%3AResult%3A%3AHardwareProduct)

### validation\_plan

Type: belongs\_to
Expand Down
7 changes: 7 additions & 0 deletions docs/modules/Conch::DB::Result::ValidationStateMember.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ is_nullable: 0
- ["validation\_state\_id"](#validation_state_id)
- ["validation\_result\_id"](#validation_result_id)

## UNIQUE CONSTRAINTS

### `validation_state_member_validation_state_id_result_order_key`

- ["validation\_state\_id"](#validation_state_id)
- ["result\_order"](#result_order)

## RELATIONS

### validation\_result
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/Conch::DB::ResultSet::ValidationState.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Interface to queries involving validation states.

## METHODS

### latest\_completed\_state\_per\_plan
### latest\_state\_per\_plan

Generates a resultset that returns the single most recent **completed** validation\_state entry
Generates a resultset that returns the single most recent validation\_state entry
per validation plan (using whatever other search criteria are already in the resultset).

The query will be closed off as a subselect (that additional chaining will SELECT FROM),
Expand Down
8 changes: 8 additions & 0 deletions docs/modules/Conch::Route::Device.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ below.
- Request: [request.json#/definitions/DeviceBuild](../json-schema/request.json#/definitions/DeviceBuild)
- Response: Redirect to the updated device

### `POST /device/:device_id_or_serial_number/hardware_product`

### `POST /device/:device_id_or_serial_number/sku`

- User requires the admin role for the device
- Request: [request.json#/definitions/DeviceHardware](../json-schema/request.json#/definitions/DeviceHardware)
- Response: Redirect to the updated device

### `GET /device/:device_id_or_serial_number/location`

- User requires the read-only role
Expand Down
17 changes: 8 additions & 9 deletions docs/modules/Conch::Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,53 +113,52 @@ location.

### hardware\_product

The [Conch::DB::Result::HardwareProduct](../modules/Conch%3A%3ADB%3A%3AResult%3A%3AHardwareProduct) object for the device being validated
(originally determined by the sku reported for the device).
The [Conch::DB::Result::HardwareProduct](../modules/Conch%3A%3ADB%3A%3AResult%3A%3AHardwareProduct) object to be used for validation.
Note that this might not be the same hardware as what the report sku says.

Any additional data related to hardware\_products may be read as normal using [DBIx::Class](https://metacpan.org/pod/DBIx%3A%3AClass)
interfaces. The result object is built using a read-only database handle, so attempts to alter
the data will **not** be permitted.

### hardware\_product\_name

Get the expected hardware product name for the device under validation.
Get the name of the hardware product used for validation.

```perl
if ($self->hardware_product_name eq 'Joyent-123') {...}
```

### hardware\_legacy\_product\_name

Get the expected hardware legacy product name for the device under validation.
Get the expected hardware legacy product name used for validation.

```perl
if ($self->hardware_legacy_product_name eq 'Joyent-123') {...}
```

### hardware\_product\_generation

Get the expected hardware product generation for the device under validation.
Get the expected hardware product generation used for validation.

```perl
if ($self->hardware_product_generation eq 'Joyent-123') {...}
```

### hardware\_product\_sku

Get the expected hardware product SKU for the device under validation.
Get the hardware product SKU used for validation.

```perl
if ($self->hardware_product_sku eq 'Joyent-123') {...}
```

### hardware\_product\_specification

Get the expected hardware product specification for the device under
validation. Returns a JSON string (for now).
Get the hardware product specification used for validation. Returns a JSON string (for now).

### hardware\_product\_vendor

Get the expected hardware product vendor name for the device under validation.
Get the expected hardware product vendor name used for validation.

```perl
if ($self->hardware_product_vendor eq 'Dell') {...}
Expand Down
Loading

0 comments on commit 2391c3f

Please sign in to comment.