#!/bin/bash -x
. ./common-vars $@

. ./hackfest-credentials.rc

for PARTICIPANT in `seq ${START} ${MAX}` ; do

    IP=`expr ${PARTICIPANT} + 100`

    OS_USERNAME=hackfest-${PARTICIPANT}
    OS_PASSWORD=hackfest
    OS_PROJECT_NAME=hackfest-${PARTICIPANT}

    cat << EOF > ${OS_USERNAME}.rc
export OS_AUTH_URL=${OS_AUTH_URL}
export OS_PROJECT_NAME=${OS_PROJECT_NAME}
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_ID=default
export OS_USERNAME=${OS_USERNAME}
export OS_PASSWORD=hackfest
export OS_REGION_NAME='RegionOne'
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3
EOF

    scp ${OS_USERNAME}.rc ubuntu@${SUBNET}.${IP}:
    ssh ubuntu@${SUBNET}.${IP} ". .profile;echo osm vim-create --name openstack --user ${OS_USERNAME} --password ${OS_PASSWORD} --auth_url ${OS_AUTH_URL} --tenant ${OS_PROJECT_NAME} --account_type openstack --config=\"{ management_network_name: osm-ext, security_groups: default, insecure: true, project_domain_name:${OS_PROJECT_DOMAIN_ID}, user_domain_name: ${OS_USER_DOMAIN_NAME} }\""
    scp whitemist.yaml ubuntu@${SUBNET}.${IP}:
    ssh ubuntu@${SUBNET}.${IP} '. .profile;osm k8scluster-add --creds whitemist.yaml --vim openstack --k8s-nets "{"net1": "osm-ext"}" --version 1.20 --namespace test --description "k8s cluster" whitemist'
done

