update to work with consul
diff --git a/automation/Dockerfile.ansible b/automation/Dockerfile.ansible
index 4b5a239..7606a61 100644
--- a/automation/Dockerfile.ansible
+++ b/automation/Dockerfile.ansible
@@ -1,21 +1,44 @@
FROM ubuntu:14.04
-RUN apt-get update -y && \
- sudo apt-get install -y software-properties-common && \
- apt-add-repository ppa:ansible/ansible && \
- apt-get update -y && \
- apt-get install -y git ansible golang
+# Base image information borrowed by official golang wheezy Dockerfile
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ g++ \
+ gcc \
+ libc6-dev \
+ make \
+ curl \
+ && rm -rf /var/lib/apt/lists/*
-RUN mkdir /go
-WORKDIR /go
-ENV GOPATH=/go
+ENV GOLANG_VERSION 1.6.2
+ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
+ENV GOLANG_DOWNLOAD_SHA256 e40c36ae71756198478624ed1bb4ce17597b3c19d243f3f0899bb5740d56212a
+
+RUN curl -kfsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
+ && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
+ && tar -C /usr/local -xzf golang.tar.gz \
+ && rm golang.tar.gz
+
+ENV GOPATH /go
+ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
+
+RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
+
+# CORD Automation Dockerfile
+WORKDIR $GOPATH
+
+RUN apt-get update && \
+ apt-get install -y software-properties-common && \
+ apt-add-repository ppa:ansible/ansible && \
+ apt-get update -y -m && \
+ apt-get install -y git ansible
+
RUN go get github.com/tools/godep
-ADD . /go/src/github.com/ciena/cord-maas-automation
+ADD . $GOPATH/src/github.com/ciena/cord-maas-automation
-WORKDIR /go/src/github.com/ciena/cord-maas-automation
-RUN /go/bin/godep restore
+WORKDIR $GOPATH/src/github.com/ciena/cord-maas-automation
+RUN $GOPATH/bin/godep restore
-WORKDIR /go
+WORKDIR $GOPATH
RUN go install github.com/ciena/cord-maas-automation
-ENTRYPOINT ["/go/bin/cord-maas-automation"]
+ENTRYPOINT ["$GOPATH/bin/cord-maas-automation"]
diff --git a/automation/Godeps/Godeps.json b/automation/Godeps/Godeps.json
index 5e6d307..cd9aa7e 100644
--- a/automation/Godeps/Godeps.json
+++ b/automation/Godeps/Godeps.json
@@ -1,6 +1,7 @@
{
"ImportPath": "_/Users/dbainbri/src/develop/mf",
- "GoVersion": "go1.5",
+ "GoVersion": "go1.6",
+ "GodepVersion": "v72",
"Packages": [
"github.com/ciena/maas-flow"
],
@@ -21,8 +22,8 @@
},
{
"ImportPath": "github.com/hashicorp/consul",
- "Comment": "v0.6.4-341-g22938ab",
- "Rev": "22938ab8b3ca069e490a4897a8ec13308ac61605"
+ "Comment": "v0.6.4-341-g22938ab",
+ "Rev": "22938ab8b3ca069e490a4897a8ec13308ac61605"
}
]
}
diff --git a/automation/lifecycle.png b/automation/lifecycle.png
index a81847e..cd77dd3 100644
--- a/automation/lifecycle.png
+++ b/automation/lifecycle.png
Binary files differ
diff --git a/automation/state.go b/automation/state.go
index 696f58f..f4c1bf9 100644
--- a/automation/state.go
+++ b/automation/state.go
@@ -77,7 +77,7 @@
const (
// defaultStateMachine Would be nice to drive from a graph language
defaultStateMachine string = `
- (New)->(Commissioning)
+ (New)->(Commissioning)
(Commissioning)->(FailedCommissioning)
(FailedCommissioning)->(New)
(Commissioning)->(Ready)
@@ -96,10 +96,16 @@
(Releasing)->(Ready)
(DiskErasing)->(Ready)
(Broken)->(Ready)
- (Deployed)->(Provisioning)
- (Provisioning)->(ProvisionError)
- (ProvisionError)->(Provisioning)
- (Provisioning)->(Provisioned)`
+ (Deployed)->(Provisioning)
+ (Provisioning)->|a|
+ |a|->(Execute Script)->|b|
+ |a|->(HTTP PUT)
+ (HTTP PUT)->(HTTP GET)
+ (HTTP GET)->(HTTP GET)
+ (HTTP GET)->|b|
+ |b|->(Provisioned)
+ |b|->(ProvisionError)
+ (ProvisionError)->(Provisioning)`
)
// updateName - changes the name of the MAAS node based on the configuration file
@@ -175,6 +181,11 @@
if len(ips) > 0 {
ip = ips[0]
}
+ macs := node.MACs()
+ mac := ""
+ if len(macs) > 0 {
+ mac = macs[0]
+ }
switch callout.Scheme {
// If the scheme is a file, then we will execute the refereced file
case "", "file":
@@ -184,7 +195,7 @@
record.State = Provisioning
record.Timestamp = time.Now().Unix()
options.ProvTracker.Set(node.ID(), record)
- err = exec.Command(callout.Path, node.ID(), node.Hostname(), ip).Run()
+ err = exec.Command(callout.Path, node.ID(), node.Hostname(), ip, mac).Run()
if err != nil {
log.Printf("[error] Failed to execute '%s' : %s", options.ProvisionURL, err)
} else {
@@ -204,6 +215,7 @@
"id": node.ID(),
"name": node.Hostname(),
"ip": ip,
+ "mac": mac,
}
hc := http.Client{}
var b []byte