diff --git a/internal/api/connectors/inventory/inventory.go b/internal/api/connectors/inventory/inventory.go index 018acaad..9873bef8 100644 --- a/internal/api/connectors/inventory/inventory.go +++ b/internal/api/connectors/inventory/inventory.go @@ -207,6 +207,7 @@ func (this *inventoryConnectorImpl) GetHostConnectionDetails(ctx context.Context SatelliteVersion: satelliteFacts.SatelliteVersion, SatelliteOrgID: satelliteFacts.SatelliteOrgID, RHCClientID: systemProfileResults[*host.Id].SystemProfile.RhcClientId, + AnsibleHost: host.AnsibleHost, } } diff --git a/internal/api/connectors/inventory/inventory_mock.go b/internal/api/connectors/inventory/inventory_mock.go index 58ed7260..7113f73b 100644 --- a/internal/api/connectors/inventory/inventory_mock.go +++ b/internal/api/connectors/inventory/inventory_mock.go @@ -30,6 +30,7 @@ func (this *inventoryConnectorMock) GetHostConnectionDetails( satelliteOrgID := "5" satelliteVersion := "6.11" rhcClientID := "32af5948-301f-449a-a25b-ff34c83264a2" + ansibleHost := "test-ansible-host" hostDetails := HostDetails{ ID: "c484f980-ab8d-401b-90e7-aa1d4ccf8c0e", @@ -43,6 +44,7 @@ func (this *inventoryConnectorMock) GetHostConnectionDetails( ID: "fe30b997-c15a-44a9-89df-c236c3b5c540", OwnerID: &ownerID, RHCClientID: &rhcClientID, + AnsibleHost: &ansibleHost, } hostDetailsList := []HostDetails{hostDetails, directConnectDetails} diff --git a/internal/api/connectors/inventory/types.go b/internal/api/connectors/inventory/types.go index e6d7177d..b5c39ba0 100644 --- a/internal/api/connectors/inventory/types.go +++ b/internal/api/connectors/inventory/types.go @@ -17,6 +17,7 @@ type HostDetails struct { SatelliteVersion *string `json:"satellite_version,omitempty"` SatelliteOrgID *string `json:"satellite_org_id,omitempty"` RHCClientID *string `json:"rhc_client_id,omitempty"` + AnsibleHost *string `json:"ansible_host,omitempty"` } type InventoryConnector interface { diff --git a/internal/api/controllers/private/highlevelConnectionStatus.go b/internal/api/controllers/private/highlevelConnectionStatus.go index 2b3c8014..832c61b9 100644 --- a/internal/api/controllers/private/highlevelConnectionStatus.go +++ b/internal/api/controllers/private/highlevelConnectionStatus.go @@ -110,11 +110,12 @@ func sortHostsByRecipient(details []inventory.HostDetails) (satelliteDetails []i return satelliteConnectedHosts, directConnectedHosts, hostsNotConnected } -func formatConnectionResponse(satID *string, satOrgID *string, rhcClientID *string, orgID OrgId, hosts []string, recipientType string, status string) RecipientWithConnectionInfo { +func formatConnectionResponse(satID *string, satOrgID *string, rhcClientID *string, ansibleHost *string, orgID OrgId, hosts []string, recipientType string, status string) RecipientWithConnectionInfo { formatedHosts := make([]HostId, len(hosts)) var formatedSatID SatelliteId var formatedSatOrgID SatelliteOrgId var formatedRHCClientID public.RunRecipient + var formatedAnsibleHost AnsibleHost if satID != nil { formatedSatID = SatelliteId(*satID) @@ -128,6 +129,10 @@ func formatConnectionResponse(satID *string, satOrgID *string, rhcClientID *stri formatedRHCClientID = public.RunRecipient(*rhcClientID) } + if ansibleHost != nil { + formatedAnsibleHost = AnsibleHost(*ansibleHost) + } + for i, host := range hosts { formatedHosts[i] = HostId(host) } @@ -140,6 +145,7 @@ func formatConnectionResponse(satID *string, satOrgID *string, rhcClientID *stri SatOrgId: formatedSatOrgID, Status: status, Systems: formatedHosts, + AnsibleHost: formatedAnsibleHost, } return connectionInfo @@ -162,7 +168,7 @@ func getDirectConnectStatus(ctx echo.Context, client connectors.CloudConnectorCl connectionStatus = "disconnected" } - responses = append(responses, formatConnectionResponse(nil, nil, host.RHCClientID, orgId, []string{host.ID}, string(RecipientType_directConnect), connectionStatus)) + responses = append(responses, formatConnectionResponse(nil, nil, host.RHCClientID, host.AnsibleHost, orgId, []string{host.ID}, string(RecipientType_directConnect), connectionStatus)) } return responses, nil @@ -238,7 +244,7 @@ func createSatelliteConnectionResponses(ctx echo.Context, hostsGroupedBySatellit connectionStatus = "disconnected" } - responses = append(responses, formatConnectionResponse(&satellite.SatelliteInstanceID, &satellite.SatelliteOrgID, satellite.RhcClientID, orgId, satellite.Hosts, string(RecipientType_satellite), connectionStatus)) + responses = append(responses, formatConnectionResponse(&satellite.SatelliteInstanceID, &satellite.SatelliteOrgID, satellite.RhcClientID, nil, orgId, satellite.Hosts, string(RecipientType_satellite), connectionStatus)) } } @@ -252,7 +258,7 @@ func getRHCStatus(hostDetails []inventory.HostDetails, orgID OrgId) RecipientWit hostIDs[i] = host.ID } - return formatConnectionResponse(nil, nil, nil, orgID, hostIDs, "none", "rhc_not_configured") + return formatConnectionResponse(nil, nil, nil, nil, orgID, hostIDs, "none", "rhc_not_configured") } func concatResponses(satellite []RecipientWithConnectionInfo, directConnect []RecipientWithConnectionInfo, noRHC []RecipientWithConnectionInfo) []RecipientWithConnectionInfo { diff --git a/internal/api/controllers/private/runsCreateActions.go b/internal/api/controllers/private/runsCreateActions.go index 340e57e8..52755499 100644 --- a/internal/api/controllers/private/runsCreateActions.go +++ b/internal/api/controllers/private/runsCreateActions.go @@ -37,8 +37,13 @@ func parseRunHosts(input *RunInputHosts) []generic.RunHostsInput { result := make([]generic.RunHostsInput, len(*input)) for i, host := range *input { + var ansibleHost *string + if host.AnsibleHost != nil { + ansibleHostString := string(*host.AnsibleHost) + ansibleHost = &ansibleHostString + } result[i] = generic.RunHostsInput{ - AnsibleHost: host.AnsibleHost, + AnsibleHost: ansibleHost, } if host.InventoryId != nil { diff --git a/internal/api/controllers/private/spec.gen.go b/internal/api/controllers/private/spec.gen.go index 0efea993..77afa90b 100644 --- a/internal/api/controllers/private/spec.gen.go +++ b/internal/api/controllers/private/spec.gen.go @@ -135,39 +135,40 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/9RZW3PbuBX+Kxi0D+2MLpRsZzN6atbpNJpm15nc9iHxeEDySEQWBLgASK92R/+9cwAS", - "JCXakh2rdd8sEzjX71zxJ01UXigJ0hq6+JNqMIWSBtyPH1n6Hn4rwVj8lShpQbo/WVEInjDLlZx+M0ri", - "/0ySQc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Ys+Wyejy+WUyeh5GV6OEhSG7ZBdhtJx1a/Th4nyoOt7uGBtg", + "DE1Y/ocRjE3co0Q0qPwFBQzVfqeL+t7R0ZnKyNi3nCcVknWH+uPwWEDvIUIrjBJw91hRv0J0XYk4Ro4D", + "g7bKghple+jSdKua0yZXnUpoONJMp4w4WWS9ZUBit+r//xkYbLUcZxka7Bz6CbTh1XS9f1r9oTnqxdtF", + "T2A5OzqCcLxfdayxkpbFLsIgY1zQOf2q/oTlPzQkKbPjWGV0Z1zv8+grbnJm4xQ05krWjKjQJZjVJJcr", + "P41vNhmiZJ2ffVdFSs7ItVBF0vTvSo/xUrh1Ng0duJAWtGSivoCyuS46HYfj0BFpFZF0Ti/G4fgC44nZ", + "1CF4wuvdk6SW6HLJ4CODP9N0bCgM2ralssvbxioNaJuunlMSXIgFRzU/NWgXpiyHDUQTfZHzxpg24mhF", + "D2DsS5WsH/QEc2qcVsX0xg0zF9Weq2qWWf+a7vSiFWt1Xolm4U9P9jzUpZuBR6Kbf6Oul2G4T45XbNJ5", + "u3LPSUWWMb3u+LL1pFvQwqGcTWLHiPvxUDFmCwaCeg8D4pCrP81ayj63s/vvUj+Yx30COo/LK/l9bw04", + "3Rfmd+04adj/LwsuEkMEN7Y3jfyb+bsjAL4zVu0+JnQXayCsZFywSMAhqLzmq1RACaKdOL5vBjiPxc2x", + "UVTn2WgQBOHTnbbv/e1MgLiJLOOStHdJ3vtxYM8/EcP2DXtK72zXlC1eDQDox8ojNbn8VzPJj8csh3PJ", + "gxODB4eZHOOIxZNzwKeZDw/z3cH/8Gft6nHpof4Mz6hVQxK7epyRNDrzGzNIGtuoaYv4FdhjTxQrbomG", + "kpvqGdrV9uSeGRIVXFiy1Co7HPX1aWck6+aIU2LqX2BJbz22B6CNe9Z0XTSd0GDnGVowy0sgWKvTze3m", + "PwEAAP//gWrQ4aUkAAA=", } // GetSwagger returns the Swagger specification corresponding to the generated code diff --git a/internal/api/controllers/private/types.gen.go b/internal/api/controllers/private/types.gen.go index 9cd6fd5c..c2a756ab 100644 --- a/internal/api/controllers/private/types.gen.go +++ b/internal/api/controllers/private/types.gen.go @@ -7,6 +7,9 @@ import ( externalRef0 "playbook-dispatcher/internal/api/controllers/public" ) +// AnsibleHost defines model for AnsibleHost. +type AnsibleHost string + // CancelInputV2 defines model for CancelInputV2. type CancelInputV2 struct { @@ -80,6 +83,10 @@ const ( // RecipientWithConnectionInfo defines model for RecipientWithConnectionInfo. type RecipientWithConnectionInfo struct { + // Host name as known to Ansible inventory. + // Used to identify the host in status reports. + AnsibleHost AnsibleHost `json:"ansible_host"` + // Identifies the organization that the given resource belongs to OrgId OrgId `json:"org_id"` @@ -159,7 +166,7 @@ type RunInputHosts []struct { // Host name as known to Ansible inventory. // Used to identify the host in status reports. - AnsibleHost *string `json:"ansible_host,omitempty"` + AnsibleHost *AnsibleHost `json:"ansible_host,omitempty"` // Inventory id of the given host InventoryId *string `json:"inventory_id,omitempty"` diff --git a/internal/api/tests/private/client.gen.go b/internal/api/tests/private/client.gen.go index a5d4d65e..b8d30aac 100644 --- a/internal/api/tests/private/client.gen.go +++ b/internal/api/tests/private/client.gen.go @@ -17,6 +17,9 @@ import ( externalRef0 "playbook-dispatcher/internal/api/controllers/public" ) +// AnsibleHost defines model for AnsibleHost. +type AnsibleHost string + // CancelInputV2 defines model for CancelInputV2. type CancelInputV2 struct { @@ -90,6 +93,10 @@ const ( // RecipientWithConnectionInfo defines model for RecipientWithConnectionInfo. type RecipientWithConnectionInfo struct { + // Host name as known to Ansible inventory. + // Used to identify the host in status reports. + AnsibleHost AnsibleHost `json:"ansible_host"` + // Identifies the organization that the given resource belongs to OrgId OrgId `json:"org_id"` @@ -169,7 +176,7 @@ type RunInputHosts []struct { // Host name as known to Ansible inventory. // Used to identify the host in status reports. - AnsibleHost *string `json:"ansible_host,omitempty"` + AnsibleHost *AnsibleHost `json:"ansible_host,omitempty"` // Inventory id of the given host InventoryId *string `json:"inventory_id,omitempty"` diff --git a/internal/api/tests/private/runsCreateV1_test.go b/internal/api/tests/private/runsCreateV1_test.go index 7101e2fd..79e41307 100644 --- a/internal/api/tests/private/runsCreateV1_test.go +++ b/internal/api/tests/private/runsCreateV1_test.go @@ -17,7 +17,7 @@ import ( ) var ( - ansibleHost = "localhost" + ansibleHost = AnsibleHost("localhost") ) func dispatch(payload *ApiInternalRunsCreateJSONRequestBody) (*RunsCreated, *ApiInternalRunsCreateResponse) { diff --git a/schema/private.openapi.yaml b/schema/private.openapi.yaml index 49399e14..9640eacc 100644 --- a/schema/private.openapi.yaml +++ b/schema/private.openapi.yaml @@ -229,12 +229,7 @@ components: type: object properties: ansible_host: - type: string - description: | - Host name as known to Ansible inventory. - Used to identify the host in status reports. - example: localhost - minLength: 1 + $ref: '#/components/schemas/AnsibleHost' inventory_id: type: string format: uuid @@ -336,6 +331,8 @@ components: description: Indicates the current run status of the recipient type: string enum: [connected, disconnected, rhc_not_configured] + ansible_host: + $ref: '#/components/schemas/AnsibleHost' required: - recipient - org_id @@ -344,6 +341,7 @@ components: - sat_org_id - systems - status + - ansible_host HighLevelRecipientStatus: @@ -385,6 +383,14 @@ components: example: jharting minLength: 1 + AnsibleHost: + type: string + description: | + Host name as known to Ansible inventory. + Used to identify the host in status reports. + example: localhost + minLength: 1 + Version: description: Version of the API type: string