api: Read cloud-config-url cmdline entry from boot config json

This commit is contained in:
Dalton Hubble
2015-12-15 14:39:59 -08:00
parent 9d6e0309e3
commit da2440ed2e
7 changed files with 8 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ chain ipxe?uuid=${uuid}
`
var ipxeTemplate = template.Must(template.New("ipxe boot").Parse(`#!ipxe
kernel {{.Kernel}} cloud-config-url=http://172.17.0.2:8080/cloud?uuid=${uuid}{{range $key, $value := .Cmdline}} {{if $value}}{{$key}}={{$value}}{{else}}{{$key}}{{end}}{{end}}
kernel {{.Kernel}}{{range $key, $value := .Cmdline}} {{if $value}}{{$key}}={{$value}}{{else}}{{$key}}{{end}}{{end}}
initrd {{ range $element := .Initrd }}{{$element}}{{end}}
boot
`))

View File

@@ -14,6 +14,7 @@ func pixiecoreHandler(store Store) http.Handler {
macAddr, err := parseMAC(filepath.Base(req.URL.Path))
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
// pixiecore only provides MAC addresses
attrs := MachineAttrs{MAC: macAddr}

View File

@@ -37,7 +37,7 @@ func (s *Server) HTTPHandler() http.Handler {
mux.Handle("/boot.ipxe", ipxeInspect())
mux.Handle("/ipxe", ipxeHandler(s.store))
// Pixiecore
mux.Handle("/pixiecore/v1/boot", pixiecoreHandler(s.store))
mux.Handle("/pixiecore/v1/boot/", pixiecoreHandler(s.store))
// cloud configs
mux.Handle("/cloud", cloudHandler(s.store))
// Kernel and Initrd Images

View File

@@ -50,8 +50,8 @@ func main() {
capnslog.SetFormatter(capnslog.NewPrettyFormatter(os.Stdout, false))
config := &api.Config{
ImagePath: *imagesPath,
Store: api.NewFileStore(http.Dir(*dataPath)),
ImagePath: *imagesPath,
}
// API server

View File

@@ -2,6 +2,7 @@
"kernel": "/images/stable/coreos_production_pxe.vmlinuz",
"initrd": ["/images/stable/coreos_production_pxe_image.cpio.gz"],
"cmdline": {
"cloud-config-url": "http://172.17.0.2:8080/cloud?uuid=${uuid}",
"coreos.autologin": ""
}
}

View File

@@ -1,3 +1,3 @@
#!/bin/bash -e
docker run -p 8080:8080 --name=bootcfg --rm -v $PWD/data:/data -v $PWD/images:/images dghubble/bootcfg:latest -address=0.0.0.0:8080 -data-path=/data
docker run -p 8080:8080 --name=bootcfg --rm -v $PWD/data:/data -v $PWD/images:/images dghubble/bootcfg:latest -address=0.0.0.0:8080

View File

@@ -1,8 +1,8 @@
#!/bin/bash -e
CHANNEL="stable"
VERSION="current"
DEST=${PWD}/images/$CHANNEL
VERSION="835.9.0"
DEST=${PWD}/images/coreos/$VERSION
mkdir -p $DEST
echo "Downloading CoreOS kernel and initrd"