Skip to content

Commit

Permalink
Detect if hub XML-RPC API is running on migrated server
Browse files Browse the repository at this point in the history
During migration, detect if the Hub XML-RPC API is enabled on the the
migrated server and enable it automatically in such a case without the
need to provide the number of replicas.
  • Loading branch information
cbosdo committed Jul 19, 2024
1 parent ae7b98e commit 81100e1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mgradm/cmd/migrate/podman/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ func migrateToPodman(globalFlags *types.GlobalFlags, flags *podmanMigrateFlags,
return err
}

if err := hub.EnableHubXmlrpc(flags.HubXmlrpc.Replicas); err != nil {
hubReplicas := flags.HubXmlrpc.Replicas
if extractedData.HasHubXmlrpcApi {
log.Info().Msg(L("Enabling Hub XML-RPC API since it is enabled on the migrated server"))
hubReplicas = 1
}
if err := hub.EnableHubXmlrpc(hubReplicas); err != nil {
return err
}

Expand Down
2 changes: 2 additions & 0 deletions mgradm/shared/templates/migrateScriptTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ grep '^db_password' /etc/rhn/rhn.conf | sed 's/[ \t]//g' >>/var/lib/uyuni-tools/
grep '^db_name' /etc/rhn/rhn.conf | sed 's/[ \t]//g' >>/var/lib/uyuni-tools/data
grep '^db_port' /etc/rhn/rhn.conf | sed 's/[ \t]//g' >>/var/lib/uyuni-tools/data
$SSH {{ .SourceFqdn }} sh -c "systemctl list-unit-files | grep hub-xmlrpc-api | grep -q active && echo has_hubxmlrpc=true || echo has_hubxmlrpc=false" >>/var/lib/uyuni-tools/data
echo "Altering configuration for domain resolution..."
sed 's/report_db_host = {{ .SourceFqdn }}/report_db_host = localhost/' -i /etc/rhn/rhn.conf;
sed 's/server\.jabber_server/java\.hostname/' -i /etc/rhn/rhn.conf;
Expand Down
2 changes: 2 additions & 0 deletions shared/utils/inspector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ db_user=myuser
db_password=mysecret
db_name=mydb
db_port=1234
has_hubxmlrpc=true
`

testDir, cleaner := test_utils.CreateTmpFolder(t)
Expand All @@ -39,4 +40,5 @@ db_port=1234
test_utils.AssertEquals(t, "Invalid DB password", "mysecret", actual.DbPassword)
test_utils.AssertEquals(t, "Invalid DB name", "mydb", actual.DbName)
test_utils.AssertEquals(t, "Invalid DB port", 1234, actual.DbPort)
test_utils.AssertTrue(t, "HasHubXmlrpcApi should be true", actual.HasHubXmlrpcApi)
}
1 change: 1 addition & 0 deletions shared/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var fqdnValid = regexp.MustCompile(`^([a-zA-Z0-9]{1}[a-zA-Z0-9-]{0,62})(\.[a-zA-
type InspectResult struct {
CommonInspectData `mapstructure:",squash"`
Timezone string
HasHubXmlrpcApi bool `mapstructure:"has_hubxmlrpc"`
}

func checkValueSize(value string, min int, max int) bool {
Expand Down

0 comments on commit 81100e1

Please sign in to comment.