Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
baremetal: make provisioning networks more configurable
This makes the provisioning network more configurable, by allowing to specify a specific interface, as well as which network should be used. This is a prerequisite for enabling IPv6 provisioning, as well as permitting an end-user to provide their own DHCP service in the provisioning network. This also adds a ProvisioningDHCPRange to the baremetal platform, and makes that information available to the startironic template that runs on the bootstrap. It provides the ability to disable DHCP and rely on an external provider within the datacenter, by setting provisioningDHCPDisabled to 'true'. This introduces the ability to have platform-specific information in the templating struct. Co-authored-by: Ian Main <imain@redhat.com> Co-authored-by: Stephen Benjamin <stephen@redhat.com>
- Loading branch information
Showing
8 changed files
with
561 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package defaults | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/openshift/installer/pkg/types" | ||
"github.com/openshift/installer/pkg/types/baremetal" | ||
) | ||
|
||
const testClusterName = "test-cluster" | ||
|
||
func TestSetPlatformDefaults(t *testing.T) { | ||
// Stub the call to net.LookupHost | ||
lookupHost = func(host string) (addrs []string, err error) { | ||
if host == "api.test-cluster.test" { | ||
ips := []string{"192.168.111.2"} | ||
return ips, nil | ||
} else if host == "test.apps.test-cluster.test" { | ||
ips := []string{"192.168.111.3"} | ||
return ips, nil | ||
} else { | ||
return nil, errors.New("Unknown Host " + host) | ||
} | ||
} | ||
|
||
cases := []struct { | ||
name string | ||
platform *baremetal.Platform | ||
expected *baremetal.Platform | ||
}{ | ||
{ | ||
name: "default_empty", | ||
platform: &baremetal.Platform{}, | ||
expected: &baremetal.Platform{ | ||
LibvirtURI: "qemu:///system", | ||
ClusterProvisioningIP: "172.22.0.3", | ||
BootstrapProvisioningIP: "172.22.0.2", | ||
ExternalBridge: "baremetal", | ||
ProvisioningBridge: "provisioning", | ||
APIVIP: "192.168.111.2", | ||
IngressVIP: "192.168.111.3", | ||
ProvisioningNetworkCIDR: "172.22.0.0/24", | ||
ProvisioningDHCPRange: "172.22.0.10,172.22.0.100", | ||
ProvisioningNetworkInterface: "ens3", | ||
}, | ||
}, | ||
{ | ||
name: "alternate_cidr", | ||
platform: &baremetal.Platform{ | ||
ProvisioningNetworkCIDR: "172.23.0.0/24", | ||
}, | ||
expected: &baremetal.Platform{ | ||
LibvirtURI: "qemu:///system", | ||
ClusterProvisioningIP: "172.23.0.3", | ||
BootstrapProvisioningIP: "172.23.0.2", | ||
ExternalBridge: "baremetal", | ||
ProvisioningBridge: "provisioning", | ||
APIVIP: "192.168.111.2", | ||
IngressVIP: "192.168.111.3", | ||
ProvisioningNetworkCIDR: "172.23.0.0/24", | ||
ProvisioningDHCPRange: "172.23.0.10,172.23.0.100", | ||
ProvisioningNetworkInterface: "ens3", | ||
}, | ||
}, | ||
{ | ||
name: "alternate_cidr_dhcp_disabled", | ||
platform: &baremetal.Platform{ | ||
ProvisioningNetworkCIDR: "172.23.0.0/24", | ||
ProvisioningDHCPDisabled: true, | ||
}, | ||
expected: &baremetal.Platform{ | ||
LibvirtURI: "qemu:///system", | ||
ClusterProvisioningIP: "172.23.0.3", | ||
BootstrapProvisioningIP: "172.23.0.2", | ||
ExternalBridge: "baremetal", | ||
ProvisioningBridge: "provisioning", | ||
APIVIP: "192.168.111.2", | ||
IngressVIP: "192.168.111.3", | ||
ProvisioningNetworkCIDR: "172.23.0.0/24", | ||
ProvisioningDHCPDisabled: true, | ||
ProvisioningNetworkInterface: "ens3", | ||
}, | ||
}, | ||
} | ||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
ic := &types.InstallConfig{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: testClusterName, | ||
}, | ||
BaseDomain: "test", | ||
} | ||
SetPlatformDefaults(tc.platform, ic) | ||
assert.Equal(t, tc.expected, tc.platform, "unexpected platform") | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.