-
Notifications
You must be signed in to change notification settings - Fork 193
/
oci.go
88 lines (74 loc) · 2.47 KB
/
oci.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package external
import (
"fmt"
"github.com/go-openapi/swag"
"github.com/openshift/assisted-service/internal/common"
"github.com/openshift/assisted-service/internal/host/hostutil"
"github.com/openshift/assisted-service/internal/installcfg"
"github.com/openshift/assisted-service/internal/provider"
"github.com/openshift/assisted-service/models"
"github.com/sirupsen/logrus"
)
const (
OCIManufacturer string = "OracleCloud.com"
)
type ociExternalProvider struct {
baseExternalProvider
}
func NewOciExternalProvider(log logrus.FieldLogger) provider.Provider {
p := &ociExternalProvider{
baseExternalProvider: baseExternalProvider{
Log: log,
},
}
p.Provider = p
return p
}
func (p *ociExternalProvider) Name() models.PlatformType {
return models.PlatformTypeOci
}
func (p *ociExternalProvider) IsHostSupported(host *models.Host) (bool, error) {
// during the discovery there is a short time that host didn't return its inventory to the service
if host.Inventory == "" {
return false, nil
}
hostInventory, err := common.UnmarshalInventory(host.Inventory)
if err != nil {
return false, fmt.Errorf("error marshaling host to inventory, error %w", err)
}
return hostInventory.SystemVendor.Manufacturer == OCIManufacturer, nil
}
func (p *ociExternalProvider) AreHostsSupported(hosts []*models.Host) (bool, error) {
for _, h := range hosts {
supported, err := p.IsHostSupported(h)
if err != nil {
return false, fmt.Errorf("error while checking if host is supported, error is: %w", err)
}
if !supported {
return false, nil
}
}
return true, nil
}
func (p *ociExternalProvider) AddPlatformToInstallConfig(cfg *installcfg.InstallerConfigBaremetal, cluster *common.Cluster) error {
cfg.Platform = installcfg.Platform{
External: &installcfg.ExternalInstallConfigPlatform{
PlatformName: string(p.Provider.Name()),
CloudControllerManager: installcfg.CloudControllerManagerTypeExternal,
},
}
cfg.Networking.MachineNetwork = provider.GetMachineNetworkForUserManagedNetworking(p.Log, cluster)
if cluster.NetworkType != nil {
cfg.Networking.NetworkType = swag.StringValue(cluster.NetworkType)
}
if common.IsSingleNodeCluster(cluster) {
if cfg.Networking.NetworkType == "" {
cfg.Networking.NetworkType = models.ClusterNetworkTypeOVNKubernetes
}
bootstrap := common.GetBootstrapHost(cluster)
if bootstrap != nil {
cfg.BootstrapInPlace = &installcfg.BootstrapInPlace{InstallationDisk: hostutil.GetHostInstallationPath(bootstrap)}
}
}
return nil
}