aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorhakonhall <hakon@yahoo-inc.com>2016-06-30 11:49:13 +0200
committerGitHub <noreply@github.com>2016-06-30 11:49:13 +0200
commit11f4b2a78e05189a14e5cf4f696dc2ac6dbbf547 (patch)
tree325bede96acd2981876eb341ecb1dd424468d37e /node-admin
parentd33d88da5a845395273046ff34bee05c6cbbafd2 (diff)
parent62add73bc6b3862952daf2060b2d31d1ebb73652 (diff)
Merge pull request #244 from yahoo/musum/add-host-command
Extend script to support adding docker host to node repo
Diffstat (limited to 'node-admin')
-rwxr-xr-xnode-admin/scripts/node-repo.sh54
1 files changed, 43 insertions, 11 deletions
diff --git a/node-admin/scripts/node-repo.sh b/node-admin/scripts/node-repo.sh
index 38b30a4d662..94173a6726b 100755
--- a/node-admin/scripts/node-repo.sh
+++ b/node-admin/scripts/node-repo.sh
@@ -12,8 +12,9 @@ Usage: ${0##*/} <command> [<args>...]
Script for manipulating the Node Repository.
Commands
- add [-c <configserverhost>] -p <parenthostname> <hostname>...
- Provision node <hostname> in node repo with flavor "docker".
+ add [-c <configserverhost>] [-f <parent host flavor>] -p <parenthostname> [<hostname>...]
+ Provision Docker host <parenthostname> in node repo with type "host", flavor <parent host flavor> (only if -f option supplied).
+ Provision Docker nodes <hostname...> list (0 or more) in node repo with flavor "docker" and parent host <parenthostname>.
reprovision [-c <configserverhost>] -p <parenthostname> <hostname>...
Fail node <hostname>, then rm and add.
rm [-c <configserverhost>] <hostname>...
@@ -124,17 +125,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"
}
@@ -153,11 +182,12 @@ function AddCommand {
OPTIND=1
local option
- while getopts "c:p:" option
+ while getopts "c:p:f:" option
do
case "$option" in
c) config_server_hostname="$OPTARG" ;;
p) parent_hostname="$OPTARG" ;;
+ f) parent_host_flavor="$OPTARG" ;;
?) exit 1 ;; # E.g. option lacks argument, in case error has been
# already been printed
*) Fail "Unknown option '$option' with value '$OPTARG'"
@@ -166,18 +196,20 @@ function AddCommand {
if [ -z "$parent_hostname" ]
then
- Fail "Parent hostname not specified (-d)"
+ Fail "Parent hostname not specified (-p)"
fi
shift $((OPTIND - 1))
- if (($# == 0))
+ if [ -n "$parent_host_flavor" ]
then
- Fail "No node hostnames were specified"
+ echo "Provisioning Docker host $parent_hostname with flavor $parent_host_flavor"
+ ProvisionDockerHost "$config_server_hostname" \
+ "$parent_hostname" \
+ "$parent_host_flavor"
fi
- echo -n "Provisioning $# nodes"
-
+ echo -n "Provisioning $# nodes with parent host $parent_hostname"
local container_hostname
for container_hostname in "$@"
do