From a9e358a7591b2f9bbbc1183c0d10fe5ebfe6487b Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Wed, 13 May 2015 06:14:36 -0700 Subject: [PATCH] small updates --- base/app/do/core.hook | 179 ++++++++++++++++++++++++++-------------- base/pub/do/src/main.js | 2 +- 2 files changed, 116 insertions(+), 65 deletions(-) diff --git a/base/app/do/core.hook b/base/app/do/core.hook index 27d8e27d4..6833c135b 100644 --- a/base/app/do/core.hook +++ b/base/app/do/core.hook @@ -2,17 +2,20 @@ :: :::: :: -/? 310 +/? 314 +/- *talk +/+ talk, sole, http + :: :: -:::: sivtyv-barnel +:::: sivtyv-barnels :: !: |% ++ droplet $: id=@ud name=@t memory=@ud vcpus=@ud disk=@ud locked=? - created=@t status=@t backup-ids=(list ,@t) snapshot-ids=(list ,@t) + created=@t status=@t backup-ids=(list ,@t) snapshot-ids=(list ,@ud) features=(list ,@t) region=regi image=img size=syze size-slug=@t networks=ntwrks kernel=kern next-backup-window=json @@ -31,26 +34,30 @@ $: memory=@ud price-monthly=@t price-hourly=@t disk=@ud vcpus=@ud == ++ reqbody $: -name=@t region=@t size=@t image=@t ssh=(list cord) +name=@t region=@t size=@t image=@ud ssh=(list cord) backups=(unit ,?) ipv6=(unit ,?) private-networking=(unit ,?) user-data=(unit ,@t) == ++ axle ,[ke=keys toke=tokens drops=(list droplet)] ++ keys ,[authc=(unit ,@t) client-secret=(unit ,@t)] ++ tokens ,[access=@t refresh=@t] +++ hapt ,[ship path] ++ move ,[bone (mold note gift)] ++ note -$: %e - %them -(unit hiss) -== +$% +[%t %wait @da] +[%g %mess hapt ship cage] +[%e %them (unit hiss)] +== ++ gift $% [%nice ~] [%rush %json json] -== +== ++ sign -$: %e -$% [%thou p=httr] -== == +$% +[%t %wake ~] +[%g %nice ~] +[%e %thou p=httr] +== -- !: |% ::: @@ -76,12 +83,12 @@ $% [%thou p=httr] => jo (ot name/so slug/so sizes/(ar so) ~) ++ create-body - |= $: name=@t region=@t size=@t image=@t ssh-keys=(list cord) + |= $: name=@t region=@t size=@t image=@ud ssh-keys=(list cord) backups=(unit ,?) ipv6=(unit ,?) private-networking=(unit ,?) user-data=(unit ,@t) == %- jobe - :~ name/s/name region/s/region size/s/size image/s/image - 'ssh_keys'^a/(turn ssh-keys |=(cord s/+<)) backups/?~(backups ~ b/u.backups) ipv6/?~(ipv6 ~ b/u.ipv6) + :~ name/s/name region/s/region size/s/size image/(jone image) ::(jone image) + backups/?~(backups ~ b/u.backups) ipv6/?~(ipv6 ~ b/u.ipv6) 'user_data'^?~(user-data ~ s/u.user-data) 'private_networking'^?~(private-networking ~ b/u.private-networking) == ++ state-to-json @@ -99,7 +106,7 @@ $% [%thou p=httr] created/s/created status/s/status backup-ids/a/(turn backup-ids |=(el=cord s/el)) - snapshot-ids/a/(turn snapshot-ids |=(el=cord s/el)) + snapshot-ids/a/(turn snapshot-ids jone) features/a/(turn features |=(el=cord s/el)) =+ ^= reg :~ name/s/name.region slug/s/slug.region @@ -140,12 +147,20 @@ $% [%thou p=httr] !: |_ [hid=hide vat=axle] :: -++ auth-queries +++ prep ,_`. +::: +++ spam + |= jon=json + %+ turn (~(tap by sup.hid)) + |= [sub=bone @ pax=path] + ^- move + [sub %give %rush %json jon] +++ auth-queries :~ 'grant_type'^'authorization_code' 'code'^(need authc.ke.vat) :- 'client_id' 'd8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f' - 'redirect_uri'^'http://localhost:8443/main/pub/do/fab' + 'redirect_uri'^'http://localhost:8443/home/pub/do/fab' == ++ httpreq |= $: ost=bone pour-path=wire @@ -169,7 +184,6 @@ $% [%thou p=httr] :^ ost %pass pour-path :+ %e %them `(unit hiss)`[~ request] -::++ prep ,_`. :: wipe state when app code is changed :: ++ peer |= [ost=bone you=ship pax=path] @@ -191,7 +205,7 @@ $% [%thou p=httr] ^- [(list move) _+>.$] =. client-secret.ke.vat [~ secret] - ~& client-secret.ke.vat + ~& [secret=client-secret.ke.vat code=authc.ke.vat] :_ +>.$ :_ [ost %give %nice ~]~ %^ httpreq ost /auth @@ -201,77 +215,88 @@ $% [%thou p=httr] :: ++ receive-auth |= [ost=bone pour-path=path resp=sign] + ^- [(list move) _+>.$] + ?> ?=(%thou +<.resp) + ~| resp =+ body=(rash q:(need r.p.+.resp) apex:poja) - ~& body + ~| recieve-auth/resp(r.p.+ body) =+ [ac re]=(need ((ot 'access_token'^so 'refresh_token'^so ~):jo body)) =: access.toke.vat ac refresh.toke.vat re == - ~& toke.vat :_ +>.$ - [ost %give %nice ~]~ + :~ (list-droplets ost) + (publish ost our.hid [%lin & 'successfully authenticated']~) + == :: ++ poke-json |= [ost=bone you=ship act=json] ^- [(list move) _+>.$] =+ do=(need ((ot action/so ~):jo act)) ?+ do !! - %list + %list :_ +>.$ - :+ [(list-droplets ost)] - [ost %give %nice ~] - ~ - %create + :- (list-droplets ost) + [ost %give %nice ~]~ + :: + %create :_ +>.$ =+ ^- deets=reqbody %- need %. act => jo %- ot - :~ name/so region/so size/so image/so ssh/(ar so) backups/(mu bo) + :~ name/so region/so size/so image/(su dem) ssh/(ar so) backups/(mu bo) 'ipv6'^(mu bo) 'priv_networking'^(mu bo) 'user_data'^(mu so) == - :+ [(create-droplet ost deets)] - [ost %give %nice ~] - ~ - %reboot - :_ +>.$ - =+ id=(need ((ot id/ni ~):jo act)) - ~& id - ^- (list move) - :+ `move`(reboot-droplet ost id) - [ost %give %nice ~] - ~ + :- (create-droplet ost deets) + [ost %give %nice ~]~ + :: + $? %reboot %'power_cycle' %shutdown %'power_off' %'power_on' + %'password_reset' %'enable_ipv6' %'enable_private_networking' + %snapshot %upgrade + == + =+ id=(need ((ot id/no ~):jo act)) + (droplet-action ost id do) == - -++ reboot-droplet - |= [os=bone id=@ud] +:: +++ droplet-action + |= $: os=bone id=@t + $= action $? + %delete %reboot %'power_cycle' %shutdown %'power_off' + %'power_on' %'password_reset' %'enable_ipv6' %'enable_private_networking' + %snapshot %upgrade :: add retrieve droplet action + == == + :: restore, resize, rebuild, change_kernelm, retrieve droplet action + :_ +>.$ + ^- (list move) + :_ [os %give %nice ~]~ + =+ ^= req %- httpreq :* - os - /reboot - ~[%digitalocean %api] - =+ path=`path`/v2/droplets/'5073686'/actions - ~& path - path - [%post `json`(jobe type/s/'reboot' ~)] + os /reboot + ~[%digitalocean %api] /v2/droplets/[id]/actions + [%post `json`(jobe type/s/action ~)] (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] ~) *quay == + req ++ list-droplets |= os=bone - ~& 'poked' =+ ^= lis :~ os /list ~[%digitalocean %api] /v2/droplets %get (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] ~) == - (httpreq lis) + (httpreq lis) :: ++ receive-list |= [ost=bone pour-path=path resp=sign] + ^- [(list move) _+>.$] + ?> ?=(%thou +<.resp) =+ parsed=(rash q:(need r.p.+.resp) apex:poja) + ~| recieve-list/parsed =+ dar=(need ((ot droplets/(ar some) ~):jo parsed)) =+ ^- dropz=(list droplet) ~| bad-json/-.dar @@ -283,20 +308,20 @@ $% [%thou p=httr] :~ id/ni name/so memory/ni vcpus/ni disk/ni locked/bo 'created_at'^so status/so - 'backup_ids'^(ar so) 'snapshot_ids'^(ar so) features/(ar so) + 'backup_ids'^(ar so) 'snapshot_ids'^(ar ni) features/(ar so) region/parse-region image/parse-img size/parse-size 'size_slug'^so networks/parse-ntwrks kernel/(ot id/ni name/so version/so ~) 'next_backup_window'^some == =. drops.vat dropz - ~& drops/drops.vat + =+ buf=`@da`(add ~s10 lat.hid) :_ +>.$ - [ost %give %nice ~]~ + :_ (spam (state-to-json drops.vat)) + [ost %pass /refresh %t [%wait p=buf]] :: ++ create-droplet |= [os=bone reqbody] - ~& 'reached' =+ ^= create :* os /create ~[%digitalocean %api] /v2/droplets @@ -309,26 +334,52 @@ $% [%thou p=httr] ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] ~ ~ == - (httpreq create) + ~& (httpreq create) + (httpreq create) :: ++ pour |= [ost=bone pour-path=path resp=sign] ^- [(list move) _+>.$] ?+ -.pour-path !! %auth - (receive-auth ost pour-path resp) + (receive-auth `bone`ost `path`pour-path `sign`resp) :: %list (receive-list ost pour-path resp) :: + $? + %delete %reboot %'power_cycle' %shutdown %'power_off' + %'power_on' %'password_reset' %'enable_ipv6' %'enable_private_networking' + %snapshot %upgrade :: add retrieve droplet action %create - ~& created/resp - :_ +>.$ - [ost %give %nice ~]~ + == + ~& resp + :_ +>.$ ~ :: - %reboot - ~& resp + %pub + :_ +>.$ ~ + :: + %refresh :_ +>.$ - [ost %give %nice ~]~ + [(list-droplets ost)]~ == +++ publish + |= [ost=bone you=ship act=(list speech)] + ^- move + =+ ^= spchz + %+ turn act + |= sp=speech + =+ ^= tail + :- ^- audience + :+ :- `partner`[%& our.hid ?+((clan our.hid) !! %czar %court, %duke %porch)] + ^- (pair envelope delivery) + [`envelope`[& ~] %pending] + ~ + ~ + `statement`[lat.hid ~ sp] + ^- thought + :- `@`(sham eny.hid tail) + tail + =+ cag=`cage`[%talk-command !>([%publish `(list thought)`spchz])] + [ost %pass /pub %g %mess [our.hid /talk] you cag] -- diff --git a/base/pub/do/src/main.js b/base/pub/do/src/main.js index 4c9cb162b..fdb1c85ee 100644 --- a/base/pub/do/src/main.js +++ b/base/pub/do/src/main.js @@ -80,7 +80,7 @@ Page = recl({ region:$('#region').val(), size:$('#size').val(), image:$('#image').val(), - ssh:[$('#ssh').val()], + ssh:[] // $('#ssh').val()], backups:null,//$('#backups').val(), ipv6:null,//$('#ipv6').val(), priv_networking:null,//$('#priv-networking').val(),