ungleich-tools/vm-create

53 lines
2 KiB
Text
Raw Normal View History

2019-01-18 16:25:08 +00:00
#!/bin/random
2019-01-20 17:10:21 +00:00
# This is a sample script / prototype to create a VM:
# 1. user registers a payment method (Credit card) -> stores at stripe
# 2. user adds ssh key(s)
# 3. user creates a VM
2019-01-18 16:25:08 +00:00
#
2019-01-20 17:10:21 +00:00
# Flow to register payment method:
2019-01-18 16:25:08 +00:00
#
# - Connect to account.ungleich.ch with (username, password) for getting (name, realm, seed)
# - Connect to pay.ungleich.ch with (name, realm, token) { JSON }
# Json similar to:
#
# { type: "credit-card" cc number, name, verify, ... }
#
#
# Flow to add an ssh key:
# - Connect to account.ungleich.ch with (username, password) for getting (name, realm, seed)
# - Connect to infra.ungleich.ch/api using (name, realm, token) POST { json }
# { key: ... }
# Standard rest, registering it internally to a user
#
# Flow to create a VM:
#
# - Connect to account.ungleich.ch with (username, password) for getting (name, realm, seed)
# - Connect to infra.ungleich.ch/api using (name, realm, token) POST { json }
# - infra.ungleich.ch then connects to otp.ungleich.ch verifying the (name, realm, token)
# - infra.ungleich.ch checks that user has >= 1 ssh keys registered, otherwise gives error message
# - infra.ungleich.ch then connects to pay.ungleich.ch verifying that the user can "afford" the VM / books it
# infra passes (user, product, productvariant)
2019-01-20 16:32:48 +00:00
# --> infra needs to be able to derive a product from the parameters to pass to pay.ungleich.ch
2019-01-18 16:25:08 +00:00
# --> if user is not able to afford, return error to the user
2019-01-20 16:32:48 +00:00
# - pay.ungleich.ch stores the order / subscription (depending on the type)
# - Variant a)
# - infra.ungleich.ch returns { OK + ticket number }
# - client can poll / get the status of the VM on infra.ungleich.ch
# - Meanwhile infra.ungleich.ch then creates the VM/configures the VM/ensures the ssh key(s) are added
# - Variant b)
# - infra.ungleich.ch then creates the VM/configures the VM/ensures the ssh key(s) are added
2019-01-18 16:25:08 +00:00
#
#
#
#
if [ $# -ne 2 ]; then
echo "$0: username password template ssdsizegb ramgb cpunum hddsizegb onlyipv6"
exit 1
fi
2019-01-20 17:10:21 +00:00
curl https://...