From 37d5fd2d57224186bd4644ba853c70c892dfc25d Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 5 Aug 2015 23:33:12 +0200 Subject: cac build: import from Makefile --- Makefile | 13 ------------- cac | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index f6f6614..e69de29 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +0,0 @@ - - - -# cpu=1/2/3/4/5/6/7/8/9 -# ram=1024 (must be multiple of 4. ex. 1024 / 2048 / 3096) -# storage=10/20/30/40/50 ... etc -# os=75 (must be an #id from /v1/listtemplates.php) -# 26 is CentOS-7-64bit -cloudpro-build: - @ set -eu; \ - . ~/.secrets/cac; \ - ssh -q $$cac_via -t curl -fsS \ - "https://panel.cloudatcost.com/api/v1/cloudpro/build.php?key=$$cac_key\\&login=$$cac_login\\&cpu=$${cpu}\\&ram=$${ram}\\&storage=$${storage}\\&os=$${os-26}" diff --git a/cac b/cac index 5762803..1347f70 100755 --- a/cac +++ b/cac @@ -364,6 +364,34 @@ __cac_cli__poll() { __cac_cli__poll "$@" } +#? cac build cpu=.. ram=.. storage=.. os=.. +#? Build a server from available resources. +#? cpu = 1/2/3/4/5/6/7/8 limit: 16 +#? ram = 1024 (must be multiple of 4. ex. 1024 / 2048 / 3096) limit: 32768 +#? storage = 10/20/30/40/50 ... etc limit: 1000 +#? os = 75 (must be an #id from `cac templates`) +#? +__cac_cli__build() {( + reply=$(export "$@"; _cac_post_api_v1 cloudpro/build \ + cpu="$cpu" \ + ram="$ram" \ + storage="$storage" \ + os="$os" \ + ) + + case $(echo $reply | jq -r .status) in + ok) + echo $reply | jq -r . >&2 + __cac_cli__update + ;; + *) + echo bad reply: >&2 + echo $reply | jq -r . >&2 + exit 23 + ;; + esac +)} + #? #? SERVERSPEC is a query like "mode:Safe", "sdate:08/04/2015", etc. -- cgit v1.2.3