Skip to content

Commit

Permalink
fix: double call of subscription-manager identity
Browse files Browse the repository at this point in the history
Adding ExternalOrganization ( 92489c2 )
introduced a performance regression that the `subscription-manager
identity` command was called twice (once for "system identiy", second
for "org ID").

Now it called only once again and thus loading of host info is bit
faster.

Signed-off-by: Petr Vobornik <[email protected]>
  • Loading branch information
pvoborni committed Oct 24, 2023
1 parent 0de885a commit dbfd869
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions hostinfo/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (
)

func LoadSubManInformation(hi *HostInfo) {
hi.HostId, _ = GetHostId()
hi.ExternalOrganization, _ = GetExternalOrganization()
identity := GetSubManIdentity()
hi.HostId, _ = GetHostId(identity)
hi.ExternalOrganization, _ = GetExternalOrganization(identity)

hi.Usage, _ = GetUsage()
hi.Support, _ = GetServiceLevel()

Expand All @@ -22,16 +24,17 @@ func LoadSubManInformation(hi *HostInfo) {
hi.Billing, _ = GetBillingInfo(facts)
}

func GetHostId() (string, error) {
func GetSubManIdentity() SubManValues {
output, _ := execSubManCommand("identity")
values := parseSubManOutput(output)
return values.get("system identity")
return parseSubManOutput(output)
}

func GetExternalOrganization() (string, error) {
output, _ := execSubManCommand("identity")
values := parseSubManOutput(output)
return values.get("org ID")
func GetHostId(identity SubManValues) (string, error) {
return identity.get("system identity")
}

func GetExternalOrganization(identity SubManValues) (string, error) {
return identity.get("org ID")
}

func GetUsage() (string, error) {
Expand Down

0 comments on commit dbfd869

Please sign in to comment.