Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible host #348

Closed
Closed
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions internal/api/connectors/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func (this *inventoryConnectorImpl) GetHostConnectionDetails(ctx context.Context
satelliteFacts := getSatelliteFacts(host.Facts)
hostConnectionDetails[i] = HostDetails{
ID: *host.Id,
AnsibleHost: host.AnsibleHost,
OwnerID: systemProfileResults[*host.Id].SystemProfile.OwnerId,
SatelliteInstanceID: satelliteFacts.SatelliteInstanceID,
SatelliteVersion: satelliteFacts.SatelliteVersion,
Expand Down
2 changes: 2 additions & 0 deletions internal/api/connectors/inventory/inventory_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ func (this *inventoryConnectorMock) GetHostConnectionDetails(
satelliteOrgID := "5"
satelliteVersion := "6.11"
rhcClientID := "32af5948-301f-449a-a25b-ff34c83264a2"
ansibleHost := "host1.mydomain.com"

hostDetails := HostDetails{
ID: "c484f980-ab8d-401b-90e7-aa1d4ccf8c0e",
OwnerID: &ownerID,
SatelliteInstanceID: &satelliteInstanceID,
SatelliteVersion: &satelliteVersion,
SatelliteOrgID: &satelliteOrgID,
AnsibleHost: &ansibleHost,
}

directConnectDetails := HostDetails{
Expand Down
4 changes: 4 additions & 0 deletions internal/api/connectors/inventory/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var _ = Describe("Inventory", func() {
Expect(*resultData.SatelliteVersion).To(Equal("6.11.3"))
Expect(*resultData.SatelliteOrgID).To(Equal("5"))
Expect(*resultData.RHCClientID).To(Equal("7bc66a39-e719-4bc5-b10a-77bfbd3a0ead"))
Expect(resultData.AnsibleHost).ToNot(BeNil())
Expect(*resultData.AnsibleHost).To(Equal("host1.mydomain.com"))
justinorringer marked this conversation as resolved.
Show resolved Hide resolved
})

It("Interperates response correctly on unexpected status code from hostDetails", func() {
Expand Down Expand Up @@ -81,6 +83,7 @@ var _ = Describe("Inventory", func() {
Expect(resultData.SatelliteInstanceID).To(BeNil())
Expect(resultData.SatelliteVersion).To(BeNil())
Expect(resultData.SatelliteOrgID).To(BeNil())
Expect(resultData.AnsibleHost).To(BeNil())
Expect(*resultData.RHCClientID).To(Equal("7bc66a39-e719-4bc5-b10a-77bfbd3a0ead"))
})

Expand All @@ -102,6 +105,7 @@ var _ = Describe("Inventory", func() {
Expect(*resultData.SatelliteInstanceID).To(Equal("5678"))
Expect(*resultData.SatelliteVersion).To(Equal("6.11.3"))
Expect(*resultData.SatelliteOrgID).To(Equal("5"))
Expect(*resultData.AnsibleHost).To(Equal("host1.mydomain.com"))
justinorringer marked this conversation as resolved.
Show resolved Hide resolved
Expect(resultData.RHCClientID).To(BeNil())
})
})
Expand Down
1 change: 1 addition & 0 deletions internal/api/connectors/inventory/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions schema/private.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ components:
type: array
items:
$ref: '#/components/schemas/HostId'
ansible_host:
$ref: '#/components/schemas/AnsibleHost'
status:
description: Indicates the current run status of the recipient
type: string
Expand Down Expand Up @@ -373,6 +375,13 @@ components:
type: string
enum: [satellite, directConnect, none]
minLength: 1

AnsibleHost:
description: >-
From inventory: the ansible host name for remediations
type: string
example: host1.mydomain.com
nullable: true

OrgId:
description: Identifies the organization that the given resource belongs to
Expand Down
Loading