Skip to content

Commit

Permalink
HostPciDevice, schema: function -> device_function
Browse files Browse the repository at this point in the history
fixes #86
  • Loading branch information
Thomas-Gelf committed Sep 14, 2020
1 parent 931a226 commit 79d6996
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
1 change: 1 addition & 0 deletions doc/84-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ next (will be 1.2.0)
* FIX: sub-tasks will now terminate early on DB errors (#151)
* FIX: correct log-level is now passed to child-processes (#138)
* FIX: there was one more issue with zero-sized DataStores (#149)
* FIX: Host PCI devices fixed for Mysql 8.x (#86)
* FEATURE: synchronize Custom Values (#88)
* FEATURE: synchronize VirtualMachines belonging to vApps (#31)
* FEATURE: synchronize many Host Network related objects (#177)
Expand Down
32 changes: 16 additions & 16 deletions library/Vspheredb/DbObject/HostPciDevice.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ class HostPciDevice extends BaseDbObject
protected $table = 'host_pci_device';

protected $defaultProperties = [
'id' => null,
'host_uuid' => null,
'bus' => null,
'slot' => null,
'function' => null,
'class_id' => null,
'device_id' => null,
'device_name' => null,
'sub_device_id' => null,
'vendor_id' => null,
'vendor_name' => null,
'sub_vendor_id' => null,
'parent_bridge' => null,
'vcenter_uuid' => null,
'id' => null,
'host_uuid' => null,
'bus' => null,
'slot' => null,
'device_function' => null,
'class_id' => null,
'device_id' => null,
'device_name' => null,
'sub_device_id' => null,
'vendor_id' => null,
'vendor_name' => null,
'sub_vendor_id' => null,
'parent_bridge' => null,
'vcenter_uuid' => null,
];

protected $objectReferences = [
Expand All @@ -31,7 +31,7 @@ class HostPciDevice extends BaseDbObject
'id' => 'id',
'bus' => 'bus',
'slot' => 'slot',
'function' => 'function',
'function' => 'device_function',
'classId' => 'class_id',
'deviceId' => 'device_id',
'deviceName' => 'device_name',
Expand All @@ -50,7 +50,7 @@ public function setMapped($properties, VCenter $vCenter)

foreach ($this->propertyMap as $key => $property) {
if (property_exists($properties, $key)) {
if (in_array($key, ['bus', 'slot', 'function'])) {
if (in_array($key, ['bus', 'slot', 'device_function'])) {
if (is_int($properties->$key) || ctype_digit($properties->$key)) {
$this->set($property, chr($properties->$key));
} else {
Expand Down
6 changes: 6 additions & 0 deletions schema/mysql-migrations/upgrade_25.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE host_pci_device CHANGE
`function` device_function BINARY(1) NOT NULL;

INSERT INTO vspheredb_schema_migration
(schema_version, migration_time)
VALUES (25, NOW());
4 changes: 2 additions & 2 deletions schema/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ CREATE TABLE host_pci_device (
vcenter_uuid VARBINARY(16) NOT NULL,
bus BINARY(1) NOT NULL, -- byte
slot BINARY(1) NOT NULL, -- byte
`function` BINARY(1) NOT NULL, -- byte
device_function BINARY(1) NOT NULL, -- byte
class_id SMALLINT NOT NULL, -- short
device_id SMALLINT NOT NULL, -- short
device_name VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL,
Expand Down Expand Up @@ -860,4 +860,4 @@ CREATE TABLE counter_300x5 (

INSERT INTO vspheredb_schema_migration
(schema_version, migration_time)
VALUES (24, NOW());
VALUES (25, NOW());

0 comments on commit 79d6996

Please sign in to comment.