diff options
author | Harald Musum <musum@yahoo-inc.com> | 2016-06-28 14:43:38 +0200 |
---|---|---|
committer | Harald Musum <musum@yahoo-inc.com> | 2016-06-28 14:43:38 +0200 |
commit | e941ae18a2efdac4450390c1fb5fd4c418b94d01 (patch) | |
tree | 1cd3bb884bf6421d9f0aca8f6611e08ce2f468ab /node-admin/scripts | |
parent | 95c79e22adc07931d4a935ecf6df2da0c3662ea0 (diff) |
Extend script to support adding docker host to node repo
Diffstat (limited to 'node-admin/scripts')
-rwxr-xr-x | node-admin/scripts/node-repo.sh | 78 |
1 files changed, 75 insertions, 3 deletions
diff --git a/node-admin/scripts/node-repo.sh b/node-admin/scripts/node-repo.sh index 38b30a4d662..788cfca0fdd 100755 --- a/node-admin/scripts/node-repo.sh +++ b/node-admin/scripts/node-repo.sh @@ -14,6 +14,8 @@ Script for manipulating the Node Repository. Commands add [-c <configserverhost>] -p <parenthostname> <hostname>... Provision node <hostname> in node repo with flavor "docker". + add-host [-c <configserverhost>] <hostname>... + Provision Docker host <hostname> in node repo with type "host". reprovision [-c <configserverhost>] -p <parenthostname> <hostname>... Fail node <hostname>, then rm and add. rm [-c <configserverhost>] <hostname>... @@ -124,17 +126,45 @@ function ProvisionDockerNode { local container_hostname="$2" local parent_hostname="$3" - local url="http://$config_server_hostname:19071/nodes/v2/node" - local json="[ { \"hostname\":\"$container_hostname\", \"parentHostname\":\"$parent_hostname\", \"openStackId\":\"fake-$container_hostname\", - \"flavor\":\"docker\" + \"flavor\":\"docker\", + \"type\":\"tenant\" } ]" + ProvisionNode $config_server_hostname "$json" +} + + +# Docker host, the docker nodes points to this host in parentHostname in their node config +function ProvisionDockerHost { + local config_server_hostname="$1" + local docker_host_hostname="$2" + local flavor="$3" + + local json="[ + { + \"hostname\":\"$docker_host_hostname\", + \"openStackId\":\"$docker_host_hostname\", + \"flavor\":\"$flavor\", + \"type\":\"host\" + } + ]" + + ProvisionNode $config_server_hostname "$json" +} + +# Docker node in node repo (both docker hosts and docker nodes) +function ProvisionNode { + local config_server_hostname="$1" + local json="$2" + + local url="http://$config_server_hostname:19071/nodes/v2/node" + CurlOrFail -H "Content-Type: application/json" -X POST -d "$json" "$url" } @@ -190,6 +220,47 @@ function AddCommand { echo " done" } +function AddHostCommand { + local config_server_hostname=config-server + + OPTIND=1 + local option + while getopts "c:" option + do + case "$option" in + c) config_server_hostname="$OPTARG" ;; + ?) exit 1 ;; # E.g. option lacks argument, in case error has been + # already been printed + *) Fail "Unknown option '$option' with value '$OPTARG'" + esac + done + + shift $((OPTIND - 1)) + + if (($# == 0)) + then + Fail "No hostname was specified" + fi + + local hostname=$1 + shift + + if (($# == 0)) + then + Fail "No flavor was specified" + fi + local flavor=$1 + shift + + echo "Provisioning Docker host $hostname with flavor $flavor" + + ProvisionDockerHost "$config_server_hostname" \ + "$hostname" \ + "$flavor" + + echo " done" +} + function ReprovisionCommand { local config_server_hostname=config-server local parent_hostname= @@ -307,6 +378,7 @@ function Main { case "$command" in add) AddCommand "$@" ;; + add-host) AddHostCommand "$@" ;; reprovision) ReprovisionCommand "$@" ;; rm) RemoveCommand "$@" ;; set-state) SetStateCommand "$@" ;; |