From da2440ed2e605213214acd4a3de4b2be003ec9a4 Mon Sep 17 00:00:00 2001 From: Dalton Hubble Date: Tue, 15 Dec 2015 14:39:59 -0800 Subject: [PATCH] api: Read cloud-config-url cmdline entry from boot config json --- api/ipxe.go | 2 +- api/pixiecore.go | 1 + api/server.go | 2 +- cmd/bootcfg/main.go | 2 +- data/boot/default | 1 + docker-run | 2 +- scripts/get-coreos | 4 ++-- 7 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/ipxe.go b/api/ipxe.go index bef64d35..55d551b3 100644 --- a/api/ipxe.go +++ b/api/ipxe.go @@ -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 `)) diff --git a/api/pixiecore.go b/api/pixiecore.go index fd26145a..e19f6dcd 100644 --- a/api/pixiecore.go +++ b/api/pixiecore.go @@ -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} diff --git a/api/server.go b/api/server.go index 397e0b5c..19b14fbb 100644 --- a/api/server.go +++ b/api/server.go @@ -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 diff --git a/cmd/bootcfg/main.go b/cmd/bootcfg/main.go index 7e0e6484..0a36d77f 100644 --- a/cmd/bootcfg/main.go +++ b/cmd/bootcfg/main.go @@ -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 diff --git a/data/boot/default b/data/boot/default index f35b9334..2157c563 100644 --- a/data/boot/default +++ b/data/boot/default @@ -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": "" } } \ No newline at end of file diff --git a/docker-run b/docker-run index 1b005653..42179e97 100755 --- a/docker-run +++ b/docker-run @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/scripts/get-coreos b/scripts/get-coreos index 3a259561..ab1e611f 100755 --- a/scripts/get-coreos +++ b/scripts/get-coreos @@ -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"