github.com/rancher/elemental/tests@v0.0.0-20240517125144-ae048c615b3f/e2e/helpers/network/network.go (about)

     1  /*
     2  Copyright © 2022 - 2024 SUSE LLC
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7      http://www.apache.org/licenses/LICENSE-2.0
     8  Unless required by applicable law or agreed to in writing, software
     9  distributed under the License is distributed on an "AS IS" BASIS,
    10  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  See the License for the specific language governing permissions and
    12  limitations under the License.
    13  */
    14  
    15  package network
    16  
    17  import (
    18  	"github.com/rancher-sandbox/ele-testhelpers/tools"
    19  )
    20  
    21  /*
    22  Configure iPXE server for OS provisioning
    23    - @param httpSrv IP address:port where the files are shared
    24    - @returns The number of .ipxe files found or an error
    25  */
    26  func ConfigureiPXE(httpSrv string) (int, error) {
    27  	ipxeScript, err := tools.GetFilesList("../..", "install.ipxe")
    28  	if err != nil {
    29  		return 0, err
    30  	}
    31  
    32  	// NOTE: always use the first ipxe file found!
    33  	if len(ipxeScript) >= 1 {
    34  		err = tools.Sed("set url.*", "set url "+httpSrv, ipxeScript[0])
    35  		if err != nil {
    36  			return 0, err
    37  		}
    38  
    39  		err = tools.Sed(".*set config.*", "set config $${url}/install-config.yaml", ipxeScript[0])
    40  		if err != nil {
    41  			return 0, err
    42  		}
    43  	}
    44  
    45  	// Returns the number of ipxe files found
    46  	return len(ipxeScript), nil
    47  }