github.com/openshift/installer@v1.4.17/pkg/infrastructure/baremetal/baremetal.go (about) 1 package baremetal 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/openshift/installer/pkg/asset" 8 "github.com/openshift/installer/pkg/infrastructure" 9 "github.com/openshift/installer/pkg/types" 10 ) 11 12 // Provider is the baremetal platform provider. 13 type Provider struct{} 14 15 // InitializeProvider initializes an empty Provider. 16 func InitializeProvider() infrastructure.Provider { 17 return Provider{} 18 } 19 20 // Provision creates a baremetal platform bootstrap node. 21 func (a Provider) Provision(ctx context.Context, dir string, parents asset.Parents) ([]*asset.File, error) { 22 config, err := getConfig(dir) 23 if err != nil { 24 return []*asset.File{}, fmt.Errorf("failed to get baremetal platform config: %w", err) 25 } 26 27 err = createBootstrap(config) 28 if err != nil { 29 return []*asset.File{}, fmt.Errorf("failed to create bootstrap: %w", err) 30 } 31 32 return []*asset.File{}, nil 33 } 34 35 // DestroyBootstrap destroys the temporary bootstrap resources. 36 func (a Provider) DestroyBootstrap(ctx context.Context, dir string) error { 37 config, err := getConfig(dir) 38 if err != nil { 39 return fmt.Errorf("failed to get baremetal platform config: %w", err) 40 } 41 err = destroyBootstrap(config) 42 if err != nil { 43 return fmt.Errorf("failed to create bootstrap: %w", err) 44 } 45 46 return nil 47 } 48 49 // ExtractHostAddresses extracts the IPs of the bootstrap and control plane machines. 50 func (a Provider) ExtractHostAddresses(dir string, ic *types.InstallConfig, ha *infrastructure.HostAddresses) error { 51 ha.Bootstrap = ic.Platform.BareMetal.BootstrapProvisioningIP 52 53 masters, err := getMasterAddresses(dir) 54 if err != nil { 55 return err 56 } 57 58 ha.Masters = masters 59 60 return nil 61 }