Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions base/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ type Workloads struct {
Intersystems IntersystemsWorkload `json:"intersystems,omitempty"`
OracleDb OracleDbWorkload `json:"oracle_db,omitempty"`
RhelAi RhelAiWorkload `json:"rhel_ai,omitempty"`
Satellite SatelliteWorkload `json:"satellite,omitempty"`
}

type SapWorkload struct {
Expand Down Expand Up @@ -126,3 +127,8 @@ type OracleDbWorkload struct {
type RhelAiWorkload struct {
Variant string `json:"variant,omitempty"`
}

type SatelliteWorkload struct {
Type string `json:"type,omitempty"`
Version string `json:"version,omitempty"`
}
1 change: 1 addition & 0 deletions base/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type SystemInventory struct {
IntersystemsWorkload bool `gorm:"column:intersystems_workload"`
OracleDbWorkload bool `gorm:"column:oracle_db_workload"`
RhelAiWorkload bool `gorm:"column:rhel_ai_workload"`
SatelliteWorkload bool `gorm:"column:satellite_workload"`
}

func (SystemInventory) TableName() string {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE system_inventory
DROP COLUMN IF EXISTS satellite_workload;
2 changes: 2 additions & 0 deletions database_admin/migrations/164_add_satellite_workload.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE system_inventory
ADD COLUMN IF NOT EXISTS satellite_workload BOOLEAN NOT NULL DEFAULT false;
3 changes: 2 additions & 1 deletion database_admin/schema/create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS schema_migrations


INSERT INTO schema_migrations
VALUES (163, false);
VALUES (164, false);

-- ---------------------------------------------------------------------------
-- Functions
Expand Down Expand Up @@ -661,6 +661,7 @@ CREATE TABLE IF NOT EXISTS system_inventory
intersystems_workload BOOLEAN NOT NULL DEFAULT false,
oracle_db_workload BOOLEAN NOT NULL DEFAULT false,
rhel_ai_workload BOOLEAN NOT NULL DEFAULT false,
satellite_workload BOOLEAN NOT NULL DEFAULT false,
PRIMARY KEY (rh_account_id, id),
UNIQUE (rh_account_id, inventory_id)
) PARTITION BY HASH (rh_account_id);
Expand Down
6 changes: 3 additions & 3 deletions dev/test_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ INSERT INTO system_patch (system_id, rh_account_id, last_evaluation, packages_in
(14, 3, '2018-09-22 12:00:00-04', 0),
(15, 3, '2018-09-22 12:00:00-04', 0);

INSERT INTO system_inventory (id, inventory_id, rh_account_id, vmaas_json, json_checksum, last_upload, display_name, tags, created, stale_timestamp, stale_warning_timestamp, workspace_id, workspace_name, os_name, os_major, os_minor, rhsm_version, ansible_workload, ansible_workload_controller_version, mssql_workload, mssql_workload_version, crowdstrike_workload, ibm_db2_workload, intersystems_workload, oracle_db_workload, rhel_ai_workload) VALUES
(16, '00000000-0000-0000-0000-000000000016', 3, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-01-22 12:00:00-04', '00000000-0000-0000-0000-000000000016', '[]', '2018-08-26 12:00:00-04', '2018-08-26 12:00:00-04', '2018-09-02 12:00:00-04', '00000000-0000-0000-0000-999999999999', 'root-ws', 'RHEL', 8, 2, '8.2', false, NULL, false, NULL, false, true, true, true, false),
(17, '00000000-0000-0000-0000-000000000017', 1, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-01-22 12:00:00-04', '00000000-0000-0000-0000-000000000017', '[]', '2018-08-26 12:00:00-04', '2018-08-26 12:00:00-04', '2018-09-02 12:00:00-04', '00000000-0000-0000-0000-999999999999', 'root-ws', 'RHEL', 8, 1, '8.1', true, '1.0', true, '15.3.0', true, false, false, false, true);
INSERT INTO system_inventory (id, inventory_id, rh_account_id, vmaas_json, json_checksum, last_upload, display_name, tags, created, stale_timestamp, stale_warning_timestamp, workspace_id, workspace_name, os_name, os_major, os_minor, rhsm_version, ansible_workload, ansible_workload_controller_version, mssql_workload, mssql_workload_version, crowdstrike_workload, ibm_db2_workload, intersystems_workload, oracle_db_workload, rhel_ai_workload, satellite_workload) VALUES
(16, '00000000-0000-0000-0000-000000000016', 3, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-01-22 12:00:00-04', '00000000-0000-0000-0000-000000000016', '[]', '2018-08-26 12:00:00-04', '2018-08-26 12:00:00-04', '2018-09-02 12:00:00-04', '00000000-0000-0000-0000-999999999999', 'root-ws', 'RHEL', 8, 2, '8.2', false, NULL, false, NULL, false, true, true, true, false, true),
(17, '00000000-0000-0000-0000-000000000017', 1, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-01-22 12:00:00-04', '00000000-0000-0000-0000-000000000017', '[]', '2018-08-26 12:00:00-04', '2018-08-26 12:00:00-04', '2018-09-02 12:00:00-04', '00000000-0000-0000-0000-999999999999', 'root-ws', 'RHEL', 8, 1, '8.1', true, '1.0', true, '15.3.0', true, false, false, false, true, false);
INSERT INTO system_patch (system_id, rh_account_id, last_evaluation, packages_installed, packages_installable, packages_applicable, template_id) VALUES
(16, 3, '2018-09-22 12:00:00-04', 1, 1, 1, 4),
(17, 1, '2018-09-22 12:00:00-04', 2, 2, 2, NULL);
Expand Down
7 changes: 7 additions & 0 deletions listener/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ func assertSystemInventoryProfileMatchesHost(t *testing.T, inventoryID uuid.UUID
assert.Nil(t, inv.MssqlWorkloadVersion)
}

expSatellite := host.SystemProfile.Workloads.Satellite.Type != ""
assert.Equal(t, expSatellite, inv.SatelliteWorkload)

if host.SystemProfile.OwnerID != nil {
require.NotNil(t, inv.SubscriptionManagerID)
assert.Equal(t, *host.SystemProfile.OwnerID, *inv.SubscriptionManagerID)
Expand Down Expand Up @@ -246,6 +249,10 @@ func createTestUploadEvent(orgID string, inventoryID uuid.UUID, reporter string,
Mssql: inventory.MssqlWorkload{
Version: "15.0",
},
Satellite: inventory.SatelliteWorkload{
Type: "server",
Version: "6.17.6.1",
},
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions listener/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ func updateSystemPlatform(tx *gorm.DB, accountID int, host *Host,
"intersystems_workload",
"oracle_db_workload",
"rhel_ai_workload",
"satellite_workload",
}

displayName := inventoryID.String()
Expand Down Expand Up @@ -421,6 +422,7 @@ func updateSystemPlatform(tx *gorm.DB, accountID int, host *Host,
IntersystemsWorkload: host.SystemProfile.Workloads.Intersystems.IsIntersystems,
OracleDbWorkload: host.SystemProfile.Workloads.OracleDb.IsRunning,
RhelAiWorkload: host.SystemProfile.Workloads.RhelAi.Variant != "",
SatelliteWorkload: host.SystemProfile.Workloads.Satellite.Type != "",
},
Patch: models.SystemPatch{
RhAccountID: accountID,
Expand Down
4 changes: 4 additions & 0 deletions listener/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ func TestStoreOrUpdateSysPlatform(t *testing.T) {
AnsibleWorkloadControllerVersion: utils.EmptyToNil(&hostEvent.Host.SystemProfile.Workloads.Ansible.ControllerVersion), // nolint:lll
MssqlWorkload: hostEvent.Host.SystemProfile.Workloads.Mssql.Version != "",
MssqlWorkloadVersion: utils.EmptyToNil(&hostEvent.Host.SystemProfile.Workloads.Mssql.Version),
SatelliteWorkload: hostEvent.Host.SystemProfile.Workloads.Satellite.Type != "",
},
Patch: models.SystemPatch{RhAccountID: 1},
}
Expand Down Expand Up @@ -558,6 +559,8 @@ func TestStoreOrUpdateSysPlatform(t *testing.T) {
assert.Equal(t, true, inventoryAfterInsert.MssqlWorkload)
assert.Equal(t, hostEvent.Host.SystemProfile.Workloads.Mssql.Version, *inventoryAfterInsert.MssqlWorkloadVersion)

assert.Equal(t, true, inventoryAfterInsert.SatelliteWorkload)

updateJSON := "updated_json"
reporter := 2
var patchAfterInsert models.SystemPatch
Expand Down Expand Up @@ -588,6 +591,7 @@ func TestStoreOrUpdateSysPlatform(t *testing.T) {
AnsibleWorkloadControllerVersion: utils.EmptyToNil(&hostEvent.Host.SystemProfile.Workloads.Ansible.ControllerVersion), // nolint:lll
MssqlWorkload: hostEvent.Host.SystemProfile.Workloads.Mssql.Version != "",
MssqlWorkloadVersion: utils.EmptyToNil(&hostEvent.Host.SystemProfile.Workloads.Mssql.Version),
SatelliteWorkload: hostEvent.Host.SystemProfile.Workloads.Satellite.Type != "",
},
Patch: models.SystemPatch{
RhAccountID: outStore.RhAccountID,
Expand Down
11 changes: 11 additions & 0 deletions manager/controllers/systems_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,17 @@ func TestRhelAiFilter(t *testing.T) {
assert.Equal(t, testMap, output.Meta.Filter)
}

func TestSatelliteFilter(t *testing.T) {
output := testSystems(t, `?filter[system_profile][satellite]=true`, 3)
testMap := map[string]FilterData{
"system_profile][satellite": {Operator: "eq", Values: []string{"true"}},
"stale": {Operator: "eq", Values: []string{"false"}},
}
assert.Equal(t, 1, output.Meta.TotalItems)
assert.Equal(t, uuid.MustParse("00000000-0000-0000-0000-000000000016"), output.Data[0].ID)
assert.Equal(t, testMap, output.Meta.Filter)
}

func TestWorkloadOrLogic(t *testing.T) {
output := testSystems(t,
`?filter[system_profile][rhel_ai]=true&filter[system_profile][sap_sids]=ABC`, 1)
Expand Down
1 change: 1 addition & 0 deletions manager/controllers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ var workloadFilters = NestedFilterMap{
"system_profile][intersystems": "(si.intersystems_workload)",
"system_profile][oracle_db": "(si.oracle_db_workload)",
"system_profile][rhel_ai": "(si.rhel_ai_workload)",
"system_profile][satellite": "(si.satellite_workload)",
}

var inventoryFilters = NestedFilterMap{
Expand Down
Loading