Added option --opennebula-start-retries to the docker machine addon (#2118)

* Added option --opennebula-start-retries to the docker machine addon

* updated default number of retries
This commit is contained in:
Christian González authored and Tino Vázquez committed 2018-05-25 13:10:34 +02:00
1 parent 45308248a7
commit 46207af68a
2 files changed
+19 -8

No files matched your search

@@ -3,7 +3,7 @@ SHELL := /bin/bash
BUILD_ID := $(shell head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')
REPO_ROOT ?= $(shell realpath ../../../../)
GOCA_PATH ?= ${REPO_ROOT}/src/oca/go
GOPATH ?= ${REPO_ROOT}/src/docker_machine
GOPATH := $(GOPATH):${REPO_ROOT}/src/docker_machine
USE_LOCAL_GOCA ?= yes
.PHONY: clean build
@@ -38,15 +38,16 @@ type Driver struct {
Xmlrpcurl string
Config goca.OneConfig
DisableVNC bool
StartRetries string
}
const (
defaultTimeout = 1 * time.Second
defaultSSHUser = "docker"
defaultCPU = "1"
defaultVCPU = "1"
defaultMemory = "1024"
defaultTimeout = 1 * time.Second
defaultSSHUser = "docker"
defaultCPU = "1"
defaultVCPU = "1"
defaultMemory = "1024"
defaultStartRetries = "600"
// This is the contextualization script that will be executed by OpenNebula
contextScript = `#!/bin/sh
@@ -222,6 +223,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Usage: "Set the url for one xmlrpc server",
EnvVar: "ONE_XMLRPC",
},
mcnflag.StringFlag{
Name: "opennebula-start-retries",
Usage: "Set the number of retries until de vm is running",
EnvVar: "ONE_START_RETRIES",
Value: defaultStartRetries,
},
}
}
@@ -262,6 +269,9 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
// VNC
d.DisableVNC = flags.Bool("opennebula-disable-vnc")
// CONFIG
d.StartRetries = flags.String("opennebula-start-retries")
// Either TemplateName or TemplateID
if d.TemplateName != "" && d.TemplateID != "" {
return errors.New("specify only one of: --opennebula-template-name or --opennebula-template-id, not both")
@@ -646,7 +656,8 @@ func (d *Driver) Start() error {
vm.Resume()
s := state.None
for retry := 0; retry < 50 && s != state.Running; retry++ {
retries, _ := strconv.Atoi(d.StartRetries)
for retry := 0; retry < retries && s != state.Running; retry++ {
s, err = d.GetState()
if err != nil {
return err