mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
Merge pull request #2392 from rn/p2
Better kernel cmdline handling on packet.net
This commit is contained in:
commit
1a9d736f75
@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -88,13 +89,34 @@ func runPacket(args []string) {
|
|||||||
name := getStringValue(packetNameVar, *nameFlag, prefix)
|
name := getStringValue(packetNameVar, *nameFlag, prefix)
|
||||||
osType := "custom_ipxe"
|
osType := "custom_ipxe"
|
||||||
billing := "hourly"
|
billing := "hourly"
|
||||||
// TODO(rn): Extract the kernel commandline from the file generated by moby build
|
|
||||||
userData := fmt.Sprintf("#!ipxe\n\ndhcp\nset base-url %s\nset kernel-params ip=dhcp nomodeset ro serial console=ttyS1,115200\nkernel ${base-url}/%s-kernel ${kernel-params}\ninitrd ${base-url}/%s-initrd.img\nboot", url, name, name)
|
// Read kernel command line
|
||||||
|
var cmdline string
|
||||||
|
if c, err := ioutil.ReadFile(prefix + "-cmdline"); err != nil {
|
||||||
|
log.Fatalf("Cannot open cmdline file: %v", err)
|
||||||
|
} else {
|
||||||
|
cmdline = string(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build the iPXE script
|
||||||
|
// Note, we *append* the <prefix>-cmdline. iXPE booting will
|
||||||
|
// need the first set of "kernel-params" and we don't want to
|
||||||
|
// require these to be added to every YAML file.
|
||||||
|
userData := "#!ipxe\n\n"
|
||||||
|
userData += "dhcp\n"
|
||||||
|
userData += fmt.Sprintf("set base-url %s\n", url)
|
||||||
|
userData += fmt.Sprintf("set kernel-params ip=dhcp nomodeset ro serial console=ttyS1,115200 %s\n", cmdline)
|
||||||
|
userData += fmt.Sprintf("kernel ${base-url}/%s-kernel ${kernel-params}\n", name)
|
||||||
|
userData += fmt.Sprintf("initrd ${base-url}/%s-initrd.img\n", name)
|
||||||
|
userData += "boot"
|
||||||
log.Debugf("Using userData of:\n%s\n", userData)
|
log.Debugf("Using userData of:\n%s\n", userData)
|
||||||
|
|
||||||
|
// Make sure the URL works
|
||||||
initrdURL := fmt.Sprintf("%s/%s-initrd.img", url, name)
|
initrdURL := fmt.Sprintf("%s/%s-initrd.img", url, name)
|
||||||
kernelURL := fmt.Sprintf("%s/%s-kernel", url, name)
|
kernelURL := fmt.Sprintf("%s/%s-kernel", url, name)
|
||||||
validateHTTPURL(kernelURL)
|
validateHTTPURL(kernelURL)
|
||||||
validateHTTPURL(initrdURL)
|
validateHTTPURL(initrdURL)
|
||||||
|
|
||||||
client := packngo.NewClient("", apiKey, nil)
|
client := packngo.NewClient("", apiKey, nil)
|
||||||
tags := []string{}
|
tags := []string{}
|
||||||
req := packngo.DeviceCreateRequest{
|
req := packngo.DeviceCreateRequest{
|
||||||
|
Loading…
Reference in New Issue
Block a user