Skip to content

Commit

Permalink
Add function to check for OCP IPv6 cluster network
Browse files Browse the repository at this point in the history
The RabbitMQ config differs for IPv6 so add a function to determine if IPv6
is enabled on the OCP cluster network, similar to the FIPS mode check
  • Loading branch information
olliewalsh committed Jul 8, 2024
1 parent 6c8da3c commit 98b8d85
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions modules/common/ocp/ocp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ package ocp

import (
"context"
"strings"

"github.com/openstack-k8s-operators/lib-common/modules/common/helper"

networkv1 "github.com/openshift/api/network/v1"
"gopkg.in/yaml.v3"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

Expand All @@ -47,3 +50,24 @@ func IsFipsCluster(ctx context.Context, h *helper.Helper) (bool, error) {
}
return fipsEnabled, nil
}

// HasIPv6ClusterNetwork - Check if OCP has an IPv6 cluster network
func HasIPv6ClusterNetwork(ctx context.Context, h *helper.Helper) (bool, error) {
networkConfig := &networkv1.ClusterNetwork{
TypeMeta: metav1.TypeMeta{
APIVersion: "config.openshift.io/v1",
Kind: "Network",
},
}
err := h.GetClient().Get(ctx, types.NamespacedName{Name: "cluster"}, networkConfig)
if err != nil {
return false, err
}

for _, clusterNetwork := range networkConfig.ClusterNetworks {
if strings.Count(clusterNetwork.CIDR, ":") >= 2 {
return true, nil
}
}
return false, nil
}

0 comments on commit 98b8d85

Please sign in to comment.