From 485a4d84826a27c44cf590c47a7f57723b48f2b3 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 1 Jun 2015 14:27:28 -0700 Subject: [PATCH 01/11] missing cats --- base/cat/hood/breload/gate.hook | 12 ++++++++++++ base/cat/hood/reload-desk/gate.hook | 12 ++++++++++++ base/cat/hood/reset/gate.hook | 11 +++++++++++ base/lib/syntax/hoon.js | 7 +++++-- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 base/cat/hood/breload/gate.hook create mode 100644 base/cat/hood/reload-desk/gate.hook create mode 100644 base/cat/hood/reset/gate.hook diff --git a/base/cat/hood/breload/gate.hook b/base/cat/hood/breload/gate.hook new file mode 100644 index 0000000000..7f3ad66863 --- /dev/null +++ b/base/cat/hood/breload/gate.hook @@ -0,0 +1,12 @@ +:: +:::: /hook/gate/reload/hood/cat + :: +/? 314 +:: +:::: + !: +|= $: [now=@da eny=@uvI bec=beak] + [arg=(list term) ~] + == +:+ %hood-reload-desk %home +arg diff --git a/base/cat/hood/reload-desk/gate.hook b/base/cat/hood/reload-desk/gate.hook new file mode 100644 index 0000000000..fbc5fe7c97 --- /dev/null +++ b/base/cat/hood/reload-desk/gate.hook @@ -0,0 +1,12 @@ +:: +:::: /hook/gate/reload/hood/cat + :: +/? 314 +:: +:::: + !: +|= $: [now=@da eny=@uvI bec=beak] + [arg=[desk (list term)] ~] + == +:- %hood-reload-desk +arg diff --git a/base/cat/hood/reset/gate.hook b/base/cat/hood/reset/gate.hook new file mode 100644 index 0000000000..499122800e --- /dev/null +++ b/base/cat/hood/reset/gate.hook @@ -0,0 +1,11 @@ +:: +:::: /hook/gate/reset/hood/cat + :: +/? 314 +:: +:::: + !: +|= $: [now=@da eny=@uvI bec=beak] + [arg=~ ~] + == +[%hood-reset ~] diff --git a/base/lib/syntax/hoon.js b/base/lib/syntax/hoon.js index 726f06d3a5..0cb9b07834 100644 --- a/base/lib/syntax/hoon.js +++ b/base/lib/syntax/hoon.js @@ -110,7 +110,7 @@ CodeMirror.defineMode("hoon", function() { } if(stream.eat('`')){ - state.space = false + state.space = true return 'operator' } if(stream.sol() && stream.eatWhile(glyph)){ @@ -131,8 +131,10 @@ CodeMirror.defineMode("hoon", function() { return 'builtin' return 'operator' } - if(stream.eat(/[=:.^]/)) + if(stream.eat(/[=:.^]/)){ + state.space = true return 'operator' + } stream.next() return 'builtin' } @@ -154,4 +156,5 @@ CodeMirror.defineMode("hoon", function() { return res }); +CodeMirror.registerHelper("wordChars", "hoon", /[-\\w]/); CodeMirror.defineMIME("text/x-hoon", "hoon"); From 6fbca6aabfaadf0dbeca9499e82d87df98fae56e Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 1 Jun 2015 16:16:55 -0700 Subject: [PATCH 02/11] turn on gages, use them to ignore files that crash on sync --- base/arvo/clay.hoon | 19 ++++++++++++++++++- base/arvo/ford.hoon | 6 ++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/base/arvo/clay.hoon b/base/arvo/clay.hoon index b9f8773f5f..f3c3690c6e 100644 --- a/base/arvo/clay.hoon +++ b/base/arvo/clay.hoon @@ -184,6 +184,23 @@ |= gag=gage ^- (list (pair cage cage)) (unwrap-tang (gage-to-tage gag)) :: + ++ gage-to-success-cages + |= gag=gage + ^- (list (pair cage cage)) + ?. ?=(%tabl -.gag) + (ford-fail ?-(-.gag %| p.gag, %& [>%strange-gage p.p.gag<]~)) + %+ murn p.gag + |= [key=gage val=gage] ^- (unit ,[cage cage]) + ?. ?=(%& -.key) + (ford-fail ?-(-.key %| p.key, %tabl [>%strange-gage<]~)) + ?- -.val + %tabl (ford-fail >%strange-gage< ~) + %& (some [p.key p.val]) + %| =. p.val [(sell q.p.key) p.val] + ~> %slog.[0 %*(. >%ford-fail syd %for %why< |2.+> p.val)] + ~ + == + :: ++ gage-to-tage |= gag=gage ^- (each (list (pair cage cage)) tang) @@ -567,7 +584,7 @@ (apply-edit wen) +>.$ ^- (list (pair path cage)) - %+ turn (gage-to-cages res) + %+ turn (gage-to-success-cages res) |= [pax=cage cay=cage] ?. ?=(%path p.pax) ~|(%clay-take-inserting-strange-path-mark !!) diff --git a/base/arvo/ford.hoon b/base/arvo/ford.hoon index 5fcb412cf5..f5a324be53 100644 --- a/base/arvo/ford.hoon +++ b/base/arvo/ford.hoon @@ -275,6 +275,8 @@ %lime lime %lima lima %link link + %lion lion + %lily lily %lope lope %make make %meow meow @@ -1174,9 +1176,9 @@ %+ cope |- ^- (bolt (list (pair gage gage))) ?~ p.kas (fine cof ~) - %+ cope (make cof p.i.p.kas) + %+ cope (fret (make cof p.i.p.kas)) |= [cof=cafe key=gage] - %+ cope (make cof q.i.p.kas) + %+ cope (fret (make cof q.i.p.kas)) |= [cof=cafe val=gage] %+ cope ^^$(cof cof, p.kas t.p.kas) |= [cof=cafe rex=(list (pair gage gage))] From a46173ce7418851ee33cb46ec89d3bd9366bae6b Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 2 Jun 2015 13:09:21 -0700 Subject: [PATCH 03/11] pointed breload actually at /=base= --- base/cat/hood/breload/gate.hook | 2 +- base/lib/helm/core.hook | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/base/cat/hood/breload/gate.hook b/base/cat/hood/breload/gate.hook index 7f3ad66863..cb712d7cbf 100644 --- a/base/cat/hood/breload/gate.hook +++ b/base/cat/hood/breload/gate.hook @@ -8,5 +8,5 @@ |= $: [now=@da eny=@uvI bec=beak] [arg=(list term) ~] == -:+ %hood-reload-desk %home +:+ %hood-reload-desk %base arg diff --git a/base/lib/helm/core.hook b/base/lib/helm/core.hook index 5fc3b0c43d..d93730723b 100644 --- a/base/lib/helm/core.hook +++ b/base/lib/helm/core.hook @@ -91,7 +91,8 @@ %- emil %- flop %+ turn all - =+ ark=(arch .^(%cy /(scot %p our)/[syd]/(scot %da now)/arvo)) + =+ top=`path`/(scot %p our)/[syd]/(scot %da now)/arvo + =+ ark=(arch .^(%cy top)) =+ van=(~(tap by r.ark)) |= nam=@tas =. nam @@ -102,12 +103,9 @@ ?> ?=([[@ ~] ~] zaz) `term`p.i.zaz =+ tip=(end 3 1 nam) - =+ way=[(scot %p our) %home (scot %da now) %arvo nam %hoon ~] - =+ fil=(,@ .^(%cx way)) - :* %flog - /reload - [%veer ?:(=('z' tip) %$ tip) way (,@ .^(%cx way))] - == + =+ way=(welp top /[nam]) + =+ fil=(,@ .^(%cx (welp way /hoon))) + [%flog /reload [%veer ?:(=('z' tip) %$ tip) way fil]] :: ++ poke-reset :: reset system |= hood-reset =< abet From 088397fac71dc5ab9205192ed3a490edbaf677d3 Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Tue, 2 Jun 2015 13:15:40 -0700 Subject: [PATCH 04/11] merging back into test --- base/ape/cloud/core.hook | 321 +++++++++++++++++++++++++-------------- 1 file changed, 204 insertions(+), 117 deletions(-) diff --git a/base/ape/cloud/core.hook b/base/ape/cloud/core.hook index 4e355647df..d9dfe2fe15 100644 --- a/base/ape/cloud/core.hook +++ b/base/ape/cloud/core.hook @@ -14,18 +14,20 @@ !: |% ++ instance -$: name=@t id=@ud status=@t created=@t region=@t snapshot=json disk=@u ip=(list ,@if) +$: plat=?(%do %gce) name=@t id=@t status=@t created=@da snapshot=name=@t ::disk=@u region=@t +ip=(list ,@if) == -++ create-req-do +++ create-req-do $: -name=@t region=@t size=@t image=@t ssh=(list cord) +name=@t ::region=@t +size=@t image=@t ssh=(list cord) backups=(unit ,?) ipv6=(unit ,?) private-networking=(unit ,?) user-data=(unit ,@t) == ++ create-req-gce ,[project=@t zone=@t name=@t machine-type=@t] ++ axle $: auth=[do=keys gce=keys] toke=[do=tokens gce=tokens] - insts=(list instance) + insts=(map ,@t instance) == ++ keys ,[authc=(unit ,@t) client-secret=(unit ,@t)] ++ tokens ,[access=@t refresh=@t] @@ -38,30 +40,72 @@ $% [%diff %json json] == -- !: -|% ::: -++ parse-img - => jo - %- ot - :~ id/ni name/so distribution/so slug/(mu so) public/bo - regions/(ar so) 'created_at'^so type/so 'min_disk_size'^ni - == -++ parse-ip +|% ::: +++ parse-iso8601 + =< (cook to-time (parsf ;"{parse-day}T{parse-seconds}{parse-zone}")) + |% + ++ to-time + |= [[y=@u m=@u d=@u] t=[h=@u m=@u s=@u ms=@u] [syn=? zh=@u zm=@u]] + ^- @da + %- year + ^- date + =: h.t ?:(syn (sub h.t zh) (add h.t zh)) + m.t ?:(syn (sub m.t zm) (add m.t zm)) + == + [[& y] m d h.t m.t s.t (div (mul ms.t 0x1.0000) 1.000) ~] + ++ parse-day (parsf ;"{dem}\-{dem}\-{dem}") + ++ parse-seconds (parsf ;"{dem}:{dem}:{dem}{(optional ;~(pfix dot dem))}") + ++ optional |*(fel=_rule ;~(pose fel (easy 0))) + ++ parse-zone + ;~ pose + (cold [& 0 0] (jest 'Z')) + (parsf ;"{parse-zone-sign}{dem}:{dem}") + == + ++ parse-zone-sign ;~(plug ;~(pose (cold & lus) (cold | hep))) + -- +++ key-do + (mo [%start 'power_on'] [%stop 'shutdown'] [%reboot 'power_cycle'] ~) +++ adapter-do + |= a=cord + (~(got by key-do) a) +++ parse-ip-do => jo %- ot - :- v4/(ar (ot 'ip_address'^(su lip:ag) ~)) - ~ + :_ ~ v4/(ar (ot 'ip_address'^(su lip:ag) ~)) +++ parse-ip-gce + => jo + %+ cu |=(a=(list (list ,@if)) `(list ,@if)`(zing a)) + (ar (ot 'accessConfigs'^(ar (ot 'natIP'^(su lip:ag) ~)) ~)) +++ tail-url + |= a=cord + -:(flop q.q:(need (epur a))) ++ parse-region => jo (ot name/so ~) +++ parse-id-text + |= jon=json + ?.(?=([?(%n %s) *] jon) ~ (some p.jon)) ++ create-do-body - |= $: name=@t region=@t size=@t image=@t ssh-keys=(list cord) + |= $: name=@t ::region=@t + size=@t image=@t 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 ::(jone image) + :~ name/s/name ::region/s/region + size/s/size image/s/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) == +++ convert-do + |= a=?(%start %stop %reboot) + ?- a + %start + 'power_on' + %stop + 'shutdown' + %reboot + 'power_cycle' + == ++ state-to-json |= a=(list instance) :- %a @@ -70,38 +114,37 @@ $% [%diff %json json] ^- json %- jobe :~ name/`json`s/name - id/`json`(jone id) + id/s/id status/s/status - created/s/created - region/s/region - snapshot/s/'xx replace' - disk/`json`(jone disk) + created/s/(crip (dust (yore created))) + ::region/s/region + snapshot/s/snapshot + :: disk/`json`(jone disk) ip/a/(turn ip |=(a=@if s/(rsh 3 1 (scot %if a)))) == -- !: |_ [hid=hide vat=axle] :: -++ prep ,_`. -::: +::++ prep ,_`. +:: +++ peer + |= [[ost=bone you=ship] pax=path] + ^- [(list move) _+>.$] + :_ +>.$ + =+ lis=(~(tap by insts.vat)) + [ost %diff %json (state-to-json (turn lis |=(a=[@t instance] +.a)))]~ +:: ++ spam |= jon=json %+ turn (~(tap by sup.hid)) |= [sub=bone @ pax=path] ^- move [sub %diff %json jon] -++ auth-queries - |= code=cord - :~ 'grant_type'^'authorization_code' - 'code'^code - :- 'client_id' - 'd8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f' - 'redirect_uri'^'http://localhost:8443/home/pub/cloud/fab' - == ++ httpreq |= $: ost=bone pour-path=wire domain=(list cord) end-point=path - req-type=$?(%get [%post json]) headers=math + req-type=$?(%get %delt [%post json]) headers=math queries=quay == ^- move @@ -115,26 +158,27 @@ $% [%diff %json json] =+ ^- request=hiss :: cast to hiss :- parsed-url ?@ req-type - [%get headers ~] + [req-type headers ~] [%post headers ~ (tact (pojo +.req-type))] :^ ost %them pour-path `(unit hiss)`[~ request] :: -++ peer - |= [[ost=bone you=ship] pax=path] - ^- [(list move) _+>.$] - :_ +>.$ - [ost %diff %json (state-to-json insts.vat)]~ +++ auth-queries + |= code=cord + :~ 'grant_type'^'authorization_code' + 'code'^code + :- 'client_id' + 'd8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f' + 'redirect_uri'^'http://localhost:8443/home/pub/cloud/fab' + == :: ++ poke-cloud-auth |= [[ost=bone you=ship] [cde=cord typ=cord]] ^- [(list move) _+>.$] - ~& [cde typ] ?: =(%do typ) =. authc.do.auth.vat [~ cde] - :_ +>.$ - ~ + :_ +>.$ ~ =. access.gce.toke.vat cde :_ +>.$ @@ -144,9 +188,6 @@ $% [%diff %json json] ++ poke-cloud-secret |= [[ost=bone you=ship] secret=cord typ=cord] ^- [(list move) _+>.$] - ~& [secret typ] - ::=+ [newvat code path]=[vat(auth auth.vat) ...] - ::=. vat newvat ?+ typ ~|(missing-platform=typ !!) %do =. client-secret.do.auth.vat @@ -186,8 +227,6 @@ $% [%diff %json json] (publish ost our.hid [%lin & 'successfully authenticated']~) == %auth-gce - ::=+ ac=(need ((ot ~):jo - ~& [body resp] :_ +>.$ ~ == @@ -200,21 +239,19 @@ $% [%diff %json json] :_ ~ ?+ do !! %list - ^- move (list-instances-do ost) + (list-instances-do ost) :: %create-do - ^- move (create-do ost act) + (create-do ost act) :: %create-gce-disk -^- move (create-gce-disk ost act) - + (create-gce-disk ost act) :: %create-gce - ^- move (create-gce ost act) + (create-gce ost act) :: - ?(%start %stop %reboot %delete) ::%'power_on' %'power_off' %reboot %'power_cycle' - ^- move - =+ id=(need ((ot id/no ~):jo act)) + ?(%start %stop %reboot %delete) + =+ id=(need ((ot id/so ~):jo act)) (instance-action ost id do) == :: @@ -223,62 +260,31 @@ $% [%diff %json json] $= action $? %start %stop %reboot %delete == == - :: restore, resize, rebuild, change_kernelm, retrieve droplet action + =+ d=(~(got by insts.vat) id) + ~| 'can\'t find id' + =+ typ=?~(d !! -.d) + ~& typ + ~! typ + ?- typ + %do + =+ meth=?:(?=(%delete action) %delt [%post (jobe type/s/(convert-do action) ~)]) ^- move + ~& 'do i get here?' =+ ^= req %- httpreq :* - os /reboot - ~[%digitalocean %api] /v2/droplets/[id]/actions - [%post `json`(jobe type/s/action ~)] - (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~) + os /action-test + ~[%digitalocean %api] + ?:(?=(%delt meth) /v2/droplets/[id] /v2/droplets/[id]/actions) + meth + %^ mo ['Content-Type' 'application/json' ~] + ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~ *quay == req - -++ list-instances-gce - |= os=bone - =+ ^= lis - :* os /list-gce - ~[%googleapis %www] /compute/v1/projects/urbcloud/zones/['us-central1-a']/'instances' - %get ~ - ^- quay - [%'access_token' access.gce.toke.vat]~ - == - (httpreq lis) - -++ list-instances-do - |= os=bone - =+ ^= lis - :~ os /list-do - ~[%digitalocean %api] /v2/droplets - %get - (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~) - == - (httpreq lis) + %gce + !! + == :: -++ receive-list-do - |= [ost=bone resp=httr] - ^- [(list move) _+>.$] - =+ parsed=(rash q:(need r.resp) apex:poja) :: parse httr to json - ~| recieve-list/parsed - =+ dar=(need ((ot droplets/(ar some) ~):jo parsed)) :: reparse ar of insts - =+ ^- dropz=(list instance) - ~| bad-json/-.dar - %+ turn dar - |= drp=json - %- need - %. drp =+ jo - %- ot - :~ name/so id/ni status/so 'created_at'^so region/parse-region - image/some disk/ni networks/parse-ip - == - =. insts.vat - dropz - =+ buf=`@da`(add ~s10 lat.hid) - :_ +>.$ - :_ (spam (state-to-json insts.vat)) - [ost %wait /refresh-do buf] - ++ create-do |= [os=bone act=json] =+ ^- deets=create-req-do @@ -286,13 +292,13 @@ $% [%diff %json json] %. act => jo %- ot - :~ name/so region/so size/so image/so :: id key:img object + :~ name/so size/so image/so :: id key:img object region/so ssh/(ar so) backups/(mu bo) 'ipv6'^(mu bo) 'priv_networking'^(mu bo) 'user_data'^(mu so) == =+ ^- body=json %- create-do-body :* - name.deets region.deets size.deets image.deets ssh.deets backups.deets + name.deets size.deets image.deets ssh.deets backups.deets ::region.deets ipv6.deets private-networking.deets user-data.deets == %- httpreq :* @@ -304,10 +310,7 @@ $% [%diff %json json] ~ ~ == -::++ batch-request -::|= [os=bone name=@t number=@ud snap=@t] -::(list httr) ^- httr - +:: ++ create-gce-disk |= [os=bone act=json] :: num=(unit ,@u) :: =. name ?~(num name ... @@ -331,7 +334,7 @@ $% [%diff %json json] =. r.link ['access_token'^access.gce.toke.vat r.link] :^ os %them `wire`/disk-status `(unit hiss)`[~ [link [%get ~ ~]]] - +:: ++ disk-status ::receive |= [ost=bone resp=httr] ^- [(list move) _+>.$] @@ -342,7 +345,6 @@ $% [%diff %json json] =+ :- status=(need ((ot status/so ~) parsed)) lin=(need ((ot 'selfLink'^so ~) parsed)) =+ link=(scot %uv lin) - ~& lin ?: =('DONE' status) ~& resp ~& 'boot disk now running, now starting instance' @@ -353,7 +355,7 @@ $% [%diff %json json] :- ~ +>.$ :_ +>.$ [ost %wait `path`[%check-status link ~] `@da`(add ~s3 lat.hid)]~ :: refesh every 10 sec - +:: ++ create-gce |= [os=bone act=json] =+ ^- deets=create-req-gce @@ -381,17 +383,102 @@ $% [%diff %json json] ~ `quay`[%key access.gce.toke.vat]~ == - +:: ++ wake |= [[ost=bone him=ship pour-path=path] ~] ?+ -.pour-path !! %refresh-do :_ +>.$ [(list-instances-do ost)]~ + %refresh-gce + :_ +>.$ + [(list-instances-gce ost)]~ %check-status :_ +>.$ [(ask-disk-status ost +.pour-path)]~ == +:: +++ list-instances-gce + |= os=bone + =+ ^= lis + :* os /list-gce + ~[%googleapis %www] /compute/v1/projects/urbcloud/zones/['us-central1-a']/'instances' + %get ~ + ^- quay + [%'access_token' access.gce.toke.vat]~ + == + (httpreq lis) +:: +++ receive-list-gce + |= [os=bone resp=httr] + ^- [(list move) _+>.$] + =+ parsed=(rash q:(need r.resp) apex:poja) :: body httr to json + =+ items=(need ((ot items/(ar some) ~):jo parsed)) + =+ ^- ins=(list ,[@t instance]) + ~| 'bad-json'^items + %+ turn items + |= in=json + =< [id .] + ^- instance + :- %gce + %- need + %. in =+ jo + %- ot + :~ name/so id/so status/so 'creationTimestamp'^(su parse-iso8601) ::zone/so + 'machineType'^(cu tail-url so) + 'networkInterfaces'^parse-ip-gce + == + =+ ^= new + %+ skip ins + |=(a=[@t instance] (~(has by insts.vat) id.a)) + =. insts.vat + (~(gas by insts.vat) new) + =+ buf=`@da`(add ~s10 lat.hid) + :_ +>.$ + =+ lis=(~(tap by insts.vat)) + :_ (spam (state-to-json (turn lis |=(a=[@t instance] +.a)))) + [os %wait /refresh-gce buf] +:: +++ list-instances-do + |= os=bone + =+ ^= lis + :~ os /list-do + ~[%digitalocean %api] /v2/droplets + %get + (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~) + == + (httpreq lis) +:: +++ receive-list-do + |= [ost=bone resp=httr] + ^- [(list move) _+>.$] + =+ parsed=(rash q:(need r.resp) apex:poja) :: parse httr to json + ~| recieve-list/parsed + =+ dar=(need ((ot droplets/(ar some) ~):jo parsed)) :: reparse ar of insts + =. insts.vat + %- ~(gas by insts.vat) + ^- dropz=(list ,[@t instance]) + ~| bad-json/-.dar + %+ turn dar + |= drp=json ^- [@t instance] + =- ~! - - + =< [id .] + ^- instance + :- %do + %- need + %. drp + =+ jo + %- ot + :~ name/so id/parse-id-text status/so 'created_at'^(su parse-iso8601) ::region/parse-region + image/(ot name/so ~) ::disk/ni + networks/parse-ip-do + == + =+ buf=`@da`(add ~s10 lat.hid) + :_ +>.$ + =+ lis=(~(tap by insts.vat) *(list ,[@t instance])) + :_ (spam (state-to-json (turn lis |=(a=[@t instance] +.a)))) + [ost %wait /refresh-do buf] + ++ thou |= [[ost=bone him=ship pour-path=path] resp=httr] ^- [(list move) _+>.$] @@ -405,15 +492,15 @@ $% [%diff %json json] %list-do (receive-list-do ost resp) %list-gce - ~& resp - :_ +>.$ - ~ + (receive-list-gce ost resp) +:: :_ +>.$ +:: ~ :: $? %delete %reboot %'power_cycle' %shutdown %'power_off' %'power_on' %'password_reset' %'enable_ipv6' %'enable_private_networking' %snapshot %upgrade :: add retrieve droplet action - %create-do %create-gce + %create-do %create-gce %action-test == ~& resp :_ +>.$ ~ From 3ddaa35c3593ba7a2a48c39c72f9f7f6d2a15bc7 Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Tue, 2 Jun 2015 13:20:16 -0700 Subject: [PATCH 05/11] merging cloud front end --- base/pub/cloud/fab/hymn.hook | 10 ++++------ base/pub/cloud/src/main.js | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/base/pub/cloud/fab/hymn.hook b/base/pub/cloud/fab/hymn.hook index 75735100a6..05b8131d63 100644 --- a/base/pub/cloud/fab/hymn.hook +++ b/base/pub/cloud/fab/hymn.hook @@ -9,7 +9,6 @@ !: ^- manx =+ do=(~(get by qix.gas) %'code') -=+ g=(~(get by qix.gas) %'access_token') ;html ;head @@ -21,11 +20,10 @@ ;title: DO & GCE Manager == ;body - ;* =+ d=?~(do ~ (trip u.do)) - =+ g=?~(g ~ (trip u.g)) - ~& d - :_ ~ - ;script: authcode='{?~(d g d)}'; console.log(authcode) + ;script:""" + var authcode = \{} + authcode.do='{?~(do ~ (trip u.do))}' + """ ;div#container; ;script@"/home/pub/cloud/src/main.js"; == diff --git a/base/pub/cloud/src/main.js b/base/pub/cloud/src/main.js index 7fe39025d2..faade1da3a 100644 --- a/base/pub/cloud/src/main.js +++ b/base/pub/cloud/src/main.js @@ -9,6 +9,18 @@ tr = React.DOM.tr td = React.DOM.td input = React.DOM.input +function HashToJSON() { + var pairs = window.location.hash.slice(1).split('&'); + var result = {}; + pairs.forEach(function(pair) { + pair = pair.split('='); + result[pair[0]] = decodeURIComponent(pair[1] || ''); + }); + + return JSON.parse(JSON.stringify(result)); +} + + DOControls = React.createClass({ createDroplet: function(){ urb.send({appl: "cloud", @@ -114,8 +126,8 @@ Droplet = React.createClass({ dropletAction:function(id, action){ urb.send({ appl:"cloud", - data: {action: action, - id: id}}) + data: {action:action, + id:id}}) }, render: function() { @@ -143,10 +155,11 @@ Page = recl({ handleClick: function(platform){ return function(){ console.log(platform); + console.log(window.authcode.platform) if(window.authcode.length !== ''){ urb.send({ appl: "cloud", - data: {authcode:window.authcode, + data: {authcode:authcode[platform], platform:platform}, mark: "cloud-auth"}) } else { console.log("nocode") } @@ -182,6 +195,8 @@ Page = recl({ } }) +var hash = HashToJSON() //pull out hash of query string for gce authcode +authcode.gce = hash.access_token mounted = React.render(Page({droplets:[]}), $("#container")[0]) urb.bind("/", function(err,d) { From 68f76aecd858c054bc8a121e8d8bad2f2f6cac08 Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Tue, 2 Jun 2015 16:40:53 -0400 Subject: [PATCH 06/11] attempting to fix goning problem --- base/arvo/clay.hoon | 14 +++++++++----- base/arvo/zuse.hoon | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/base/arvo/clay.hoon b/base/arvo/clay.hoon index 3a25db9268..432e31a45b 100644 --- a/base/arvo/clay.hoon +++ b/base/arvo/clay.hoon @@ -2766,8 +2766,10 @@ :: ~& >> [pax %ank-kan-sig] ~ :: ~& >> [pax %ank-sig] - =+ =+ (~(tap by dir.u.kan)) - :: ~& [%dirukan pax=pax (~(run by dir.u.kan) (cury test ~))] + =+ ?~ dir.u.kan + ~ + =+ (~(tap by u.dir.u.kan)) + :: ~& [%dirukan pax=pax (~(run by u.dir.u.kan) (cury test ~))] |- ^- (list (pair path miso)) ?~ +< ~ ?~ q.i $(+< t) @@ -2786,16 +2788,18 @@ - [[(flop pax) %del q.u.q.u.ank] -] :: ~& >> [pax %neither-sig] - =+ %+ weld + =+ ?~ dir.u.kan + ~ + %+ weld =+ (~(tap by r.u.ank)) |- ^- (list ,[p=path q=miso]) ?~ +< ~ - =+ (~(get by dir.u.kan) p.i) + =+ (~(get by u.dir.u.kan) p.i) ?: ?=([~ ~] -) $(+< t) %- weld :_ $(+< t) :: ~& >> [pax %ankhing p.i ?=(~ -)] ^$(pax [p.i pax], ank `q.i, kan ?~(- ~ `u.u.-)) - =+ (~(tap by dir.u.kan)) + =+ (~(tap by u.dir.u.kan)) :: ~& > [%sdirukan pax=pax (~(run by dir.u.kan) (cury test ~))] |- ^- (list ,[p=path q=miso]) ?~ +< ~ diff --git a/base/arvo/zuse.hoon b/base/arvo/zuse.hoon index d54751bcf5..cf0df180c3 100644 --- a/base/arvo/zuse.hoon +++ b/base/arvo/zuse.hoon @@ -2317,7 +2317,7 @@ :: ++ khan :: $: fil=(unit (unit cage)) :: XX see khan-to-soba - dir=(map ,@ta (unit khan)) :: + dir=(unit (map ,@ta (unit khan))) :: == :: ++ mick (list ,[path (unit mime)]) ++ riff ,[p=desk q=(unit rave)] :: request/desist From 2e30e2b5e6faa9d891e2637508fd4fd353fa83fb Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 2 Jun 2015 17:40:34 -0700 Subject: [PATCH 07/11] add +-gas:ju --- base/arvo/hoon.hoon | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/arvo/hoon.hoon b/base/arvo/hoon.hoon index 1a370fc5d2..7c3c860d3b 100644 --- a/base/arvo/hoon.hoon +++ b/base/arvo/hoon.hoon @@ -2051,6 +2051,14 @@ (~(del by a) b) (~(put by a) b e) :: + +- gas :: concatenate + |* b=(list ,[p=* q=*]) + => .(b `(list ,_?>(?=([[* ^] ^] a) [p=p q=n.q]:n.a))`b) + |- ^+ a + ?~ b + a + $(b t.b, a (put(+< a) p.i.b q.i.b)) + :: +- get :: gets set by key |* b=* =+ c=(~(get by a) b) From 2c34ae94da93998205fa1ac0ca9bd222b2e0f539 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 2 Jun 2015 18:05:11 -0700 Subject: [PATCH 08/11] bidirectional translation rc1 --- base/arvo/ford.hoon | 123 ++++++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 40 deletions(-) diff --git a/base/arvo/ford.hoon b/base/arvo/ford.hoon index f5a324be53..c3857477f6 100644 --- a/base/arvo/ford.hoon +++ b/base/arvo/ford.hoon @@ -57,6 +57,7 @@ ++ calx :: concrete cache line $% [%hood p=calm q=(pair beam cage) r=hood] :: compile [%bake p=calm q=(trel mark beam heel) r=(unit vase)]:: load + [%lilt p=calm q=arch r=(jug mark mark)] :: translation graph [%slit p=calm q=[p=type q=type] r=type] :: slam type [%slim p=calm q=[p=type q=twig] r=(pair type nock)]:: mint [%slap p=calm q=[p=vase q=twig] r=vase] :: compute @@ -81,6 +82,7 @@ ?+ sem !! %hood ?>(?=(%hood -.cax) r.cax) %bake ?>(?=(%bake -.cax) r.cax) + %lilt ?>(?=(%lilt -.cax) r.cax) %slap ?>(?=(%slap -.cax) r.cax) %slam ?>(?=(%slam -.cax) r.cax) %slim ?>(?=(%slim -.cax) r.cax) @@ -437,9 +439,9 @@ %+ cope |- ^- (bolt (list (pair gage gage))) ?~ p.gag (fine cof ~) - %+ cope (fret ^$(gag q.i.p.gag)) + %+ cope (fret ^$(gag q.i.p.gag, cof cof)) |= [cof=cafe val=gage] - %+ cope ^$(p.gag t.p.gag) + %+ cope ^$(p.gag t.p.gag, cof cof) |= [cof=cafe rex=(list (pair gage gage))] (fine cof [[p.i.p.gag val] rex]) |= [cof=cafe rex=(list (pair gage gage))] @@ -828,18 +830,24 @@ $(yom t.yom, axe (peg axe 3)) :: ++ lace :: load and check - |= [cof=cafe for=mark bem=beam arg=heel] - ^- (bolt (unit vase)) + |= [cof=cafe for=mark bem=beam] + ^- (bolt (unit (burg heel vase))) %+ cope (lend cof bem) |= [cof=cafe arc=arch] ?^ q.arc - (cope (cope (liar cof bem) (lake for)) (fest (norm ska bem))) - ?: (~(has by r.arc) %hook) - %+ cope (fade cof %hook bem) - |= [cof=cafe hyd=hood] - %+ cope (cope (abut:(meow bem arg) cof hyd) (lake for)) - (fest (norm ska bem)) - (flue cof) + %+ (fest (norm ska bem)) cof + |=([cof=cafe arg=heel] (cope (liar cof bem) (lake for))) + ?. (~(has by r.arc) %hook) + (flue cof) + %+ cope (lend cof bem(s [%hook s.bem])) + |= [cof=cafe arc=arch] + ?~ q.arc + (flue cof) + %+ (fest (norm ska bem(s [%hook s.bem]))) cof + |= [cof=cafe arg=heel] + %+ cope (fade cof %hook bem) + |= [cof=cafe hyd=hood] + (cope (abut:(meow bem arg) cof hyd) (lake for)) :: ++ lake :: check/coerce |= for=mark @@ -912,6 +920,7 @@ ^- (bolt arch) =+ von=(save ~ %cy bem) ?~ von [p=cof q=[%1 [%y bem ~] ~ ~]] + :: %+ flag (norm ska bem) (fine cof ((hard arch) q.q:(need u.von))) :: ++ liar :: load vase @@ -925,40 +934,73 @@ (fine cof q.u.u.von) :: ++ lily :: translation targets - |= [cof=cafe for=mark] - ^- (bolt (list ,@tas)) + |= [cof=cafe for=mark] ^- (bolt (set ,@tas)) + %+ cope (lilt cof) + |= [cof=cafe lil=(jug mark mark)] + (fine cof (~(get ju lil) for)) + :: + ++ lilt + |= cof=cafe ^- (bolt (jug mark mark)) + %+ cope (lend cof [bek /mar]) + |= [cof=cafe arc=arch] + %+ (clef %lilt) (fine cof arc) + |= [cof=cafe arc=arch] + :: =- =+((cope - |=([cafe lil=(jug mark mark)] ~&(lil=lil (flue cof)))) +<) + =+ all=(~(tap by r.arc)) + ~! all + |- ^- (bolt (jug mark mark)) + ?~ all (flue cof) + %+ cope $(cof cof, all t.all) + |= [cof=cafe lil=(jug mark mark)] + =* for p.i.all =+ raf=(fang cof for) - ?: =(%2 -.q.raf) (flue cof) + ?: =(%2 -.q.raf) (fine cof lil) %+ cope raf |= [cof=cafe vax=vase] %+ fine cof + %- ~(gas ju lil) + ~| weg=(jam 3 p.vax) %+ weld - ^- (list ,@tas) - ?. (slob %garb p.vax) ~ - =+ gav=((soft (list ,@tas)) q:(slap vax [%cnzy %garb])) - ?~(gav ~ u.gav) + ^- (list ,[mark mark]) + ?. (slob %grab p.vax) ~ + =+ gab=(slap vax [%cnzy %grab]) + :: =+ opt=(skip (sloe p.gap) |=(fro=mark =(fro %noun))) + (turn (sloe p.gab) |=(fro=mark [fro for])) ?. (slob %grow p.vax) ~ =+ gow=(slap vax [%cnzy %grow]) - (sort (sloe p.gow) aor) + (turn (sloe p.gow) |=(too=mark [for too])) :: ++ lima :: load at depth |= [cof=cafe for=mark bem=beam arg=heel] %+ (clef %bake) [p=cof q=[%0 p=[bem `~] q=[for bem arg]]] |= [cof=cafe for=mark bem=beam arg=heel] ^- (bolt (unit vase)) - %+ cope (lend cof bem) - |= [cof=cafe arc=arch] - ^- (bolt (unit vase)) - ?: (~(has by r.arc) for) - (lace cof for bem(s [for s.bem]) arg) - =+ haz=(turn (~(tap by r.arc) ~) |=([a=@tas b=~] a)) - ?~ haz (flue cof) - %+ cope (lion cof for haz) + %+ cope + %+ cope (lend cof bem) + |= [cof=cafe arc=arch] ^- (bolt (map mark (burg heel vase))) + ?~ r.arc (flue cof) + %+ cope $(r.arc l.r.arc) + |= [cof=cafe lam=(map mark (burg heel vase))] + %+ cope ^$(r.arc r.r.arc, cof cof) + |= [cof=cafe ram=(map mark (burg heel vase))] + =. for p.n.r.arc + %+ cope + ?. ((sane %tas) for) (flue cof) + (lace cof for bem(s [for s.bem])) + |= [cof=cafe nod=(unit (burg heel vase))] + %+ fine cof + ?^(nod [[for u.nod] lam ram] (~(uni by lam) ram)) + |= [cof=cafe mal=(map mark (burg heel vase))] + =+ lit=(~(get by mal) for) + ?^ lit + (cope (u.lit cof arg) (fest bem)) + =+ opt=(sa (turn (~(tap by mal)) head)) :: XX asymptotics + %+ cope (lion cof for opt) |= [cof=cafe wuy=(list ,@tas)] ?~ wuy (flue cof) - %+ cope (cope (make cof %bake i.wuy bem arg) furl) - |= [cof=cafe hoc=cage] - %+ cope (lope cof i.wuy t.wuy q.hoc) + %+ cope ((~(got by mal) i.wuy) cof arg) + |= [cof=cafe hoc=vase] + %+ cope (lope cof i.wuy t.wuy hoc) |= [cof=cafe vax=vase] ((fest bem) cof vax) :: @@ -999,19 +1041,20 @@ (maul cof u.zat vax) :: ++ lion :: translation search - |= [cof=cafe too=mark fro=(list mark)] + |= [cof=cafe too=mark fro=(set mark)] :: ~& lion/[too=too fro=(sa fro)] ^- (bolt (list mark)) =| $: war=(map mark (list mark)) pax=(list mark) won=[p=mark q=(qeu mark)] == %. [cof fro] - |= [cof=cafe fro=(list mark)] ^- (bolt (list mark)) + |= [cof=cafe fro=(set mark)] ^- (bolt (list mark)) ?: =(too p.won) (fine cof (flop pax)) - =. fro (skip fro ~(has by war)) - =: q.won (~(gas to q.won) fro) - war (~(gas by war) (turn fro |=(mark [+< pax]))) + =+ for=(skip (~(tap by fro)) ~(has by war)) + =. for (sort for aor) :: XX useful? + =: q.won (~(gas to q.won) for) + war (~(gas by war) (turn for |=(mark [+< pax]))) == ?: =(~ q.won) (flue cof) @@ -1064,7 +1107,7 @@ == :: %bake - :: ~& [%bake-start (tope q.kas)] + :: ~& > [p.kas (tope q.kas)] %+ cool |.(leaf/"ford: bake {} {<(tope q.kas)>}") %+ cope (lima cof p.kas q.kas r.kas) |= [cof=cafe vux=(unit vase)] @@ -1112,7 +1155,7 @@ |= [cof=cafe cay=cage] ^- (bolt gage) %+ cool |.(leaf/"ford: casting {} to {}") - %+ cope (lion cof p.kas p.cay ~) + %+ cope (lion cof p.kas p.cay `~) |= [cof=cafe wuy=(list ,@tas)] %+ cope ?~ wuy @@ -1180,7 +1223,7 @@ |= [cof=cafe key=gage] %+ cope (fret (make cof q.i.p.kas)) |= [cof=cafe val=gage] - %+ cope ^^$(cof cof, p.kas t.p.kas) + %+ cope ^^$(p.kas t.p.kas, cof cof) |= [cof=cafe rex=(list (pair gage gage))] (fine cof [[key val] rex]) |= [cof=cafe rex=(list (pair gage gage))] @@ -1299,7 +1342,7 @@ ?~ src (fine cof ..body) %+ cope (wilt cof i.src) |= [cof=cafe sel=_..body] - ^$(cof cof, src t.src, ..body sel) + ^$(src t.src, ..body sel, cof cof) :: ++ chad :: atomic list |= [cof=cafe bax=vase doe=term hon=horn] @@ -1369,7 +1412,7 @@ %+ cope |- ^- (bolt (list vase)) ?~ p.hon (flue cof) - %+ cope ^$(hon i.p.hon) + %+ cope ^$(cof cof, hon i.p.hon) |= [cof=cafe vax=vase] %+ cope ^$(cof cof, p.hon t.p.hon) |= [cof=cafe tev=(list vase)] From 7f16f641bd9838272cf65fbfc9eebeab3a70e34c Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Tue, 2 Jun 2015 18:36:23 -0700 Subject: [PATCH 09/11] weird talk bug --- base/ape/cloud/core.hook | 175 +++++++++++++++++-------------------- base/arvo/gall.hoon | 1 + base/pub/cloud/src/main.js | 27 +++--- 3 files changed, 94 insertions(+), 109 deletions(-) diff --git a/base/ape/cloud/core.hook b/base/ape/cloud/core.hook index d9dfe2fe15..5d8c3f8aa8 100644 --- a/base/ape/cloud/core.hook +++ b/base/ape/cloud/core.hook @@ -124,12 +124,12 @@ $% [%diff %json json] == -- !: -|_ [hid=hide vat=axle] +|_ [bowl vat=axle] :: ::++ prep ,_`. :: ++ peer - |= [[ost=bone you=ship] pax=path] + |= pax=path ^- [(list move) _+>.$] :_ +>.$ =+ lis=(~(tap by insts.vat)) @@ -137,12 +137,12 @@ $% [%diff %json json] :: ++ spam |= jon=json - %+ turn (~(tap by sup.hid)) + %+ turn (~(tap by sup)) |= [sub=bone @ pax=path] ^- move [sub %diff %json jon] ++ httpreq - |= $: ost=bone pour-path=wire + |= $: pour-path=wire domain=(list cord) end-point=path req-type=$?(%get %delt [%post json]) headers=math queries=quay @@ -173,7 +173,7 @@ $% [%diff %json json] == :: ++ poke-cloud-auth - |= [[ost=bone you=ship] [cde=cord typ=cord]] + |= [cde=cord typ=cord] ^- [(list move) _+>.$] ?: =(%do typ) =. authc.do.auth.vat @@ -182,11 +182,11 @@ $% [%diff %json json] =. access.gce.toke.vat cde :_ +>.$ - :- (list-instances-gce ost) - ~ + :- list-instances-gce + ~[(publish [%lin & 'successfully authenticated to gce']~)] :: ++ poke-cloud-secret - |= [[ost=bone you=ship] secret=cord typ=cord] + |= [secret=cord typ=cord] ^- [(list move) _+>.$] ?+ typ ~|(missing-platform=typ !!) %do @@ -194,24 +194,14 @@ $% [%diff %json json] [~ secret] :_ +>.$ :_ ~ - %^ httpreq ost /auth-do + %+ httpreq /auth-do :^ ~[%digitalocean %cloud] `path`/v1/oauth/token [%post ~] :- ~ `quay`['client_secret'^secret (auth-queries (need authc.do.auth.vat))] - %gce - =. client-secret.gce.auth.vat - [~ secret] - :_ +>.$ - :_ ~ - %^ httpreq ost /auth-gce - :^ ~[%google %cloud] `path`/v1/oauth/token - [%post ~] - :- (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~) - `quay`['client_secret'^secret %'access_token'^(need authc.gce.auth.vat) ~] ::(auth-queries (need authc.gcp.auth.vat))] == :: ++ receive-auth - |= [ost=bone pour-path=cord resp=httr] + |= [pour-path=cord resp=httr] ^- [(list move) _+>.$] ~| resp =+ body=(rash q:(need r.resp) apex:poja) @@ -223,48 +213,40 @@ $% [%diff %json json] refresh.do.toke.vat re == :_ +>.$ - :~ (list-instances-do ost) - (publish ost our.hid [%lin & 'successfully authenticated']~) + :~ list-instances-do + (publish [%lin & 'successfully authenticated']~) == - %auth-gce - :_ +>.$ - ~ == :: ++ poke-json - |= [[ost=bone you=ship] act=json] + |= act=json ^- [(list move) _+>.$] =+ do=(need ((ot action/so ~):jo act)) :_ +>.$ :_ ~ ?+ do !! %list - (list-instances-do ost) + list-instances-do :: %create-do - (create-do ost act) - :: - %create-gce-disk - (create-gce-disk ost act) + (create-do act) :: %create-gce - (create-gce ost act) + (create-gce-disk act) :: ?(%start %stop %reboot %delete) =+ id=(need ((ot id/so ~):jo act)) - (instance-action ost id do) + (instance-action id do) == :: ++ instance-action - |= $: os=bone id=@t + |= $: id=@t $= action $? %start %stop %reboot %delete == == =+ d=(~(got by insts.vat) id) ~| 'can\'t find id' =+ typ=?~(d !! -.d) - ~& typ - ~! typ ?- typ %do =+ meth=?:(?=(%delete action) %delt [%post (jobe type/s/(convert-do action) ~)]) @@ -272,7 +254,7 @@ $% [%diff %json json] ~& 'do i get here?' =+ ^= req %- httpreq :* - os /action-test + /action-test ~[%digitalocean %api] ?:(?=(%delt meth) /v2/droplets/[id] /v2/droplets/[id]/actions) meth @@ -282,11 +264,20 @@ $% [%diff %json json] == req %gce - !! + ?- action + %start + !! + %stop + !! + %reboot + !! + %delete + !! == + == :: ++ create-do - |= [os=bone act=json] + |= act=json =+ ^- deets=create-req-do %- need %. act @@ -302,7 +293,7 @@ $% [%diff %json json] ipv6.deets private-networking.deets user-data.deets == %- httpreq :* - os /create-do + /create-do ~[%digitalocean %api] /v2/droplets [%post body] %^ mo ['Content-Type' 'application/json; charset=utf-8' ~] @@ -312,70 +303,69 @@ $% [%diff %json json] == :: ++ create-gce-disk - |= [os=bone act=json] :: num=(unit ,@u) - :: =. name ?~(num name ... + |= act=json :: num=(unit ,@u) + =+ :- name=(need ((ot name/so ~):jo act)) + snapshot=(need ((ot 'instance_image'^so ~):jo act)) =+ :- name=(need ((ot name/so ~):jo act)) snap=(need ((ot snap/so ~):jo act)) =+ ^- body=json (jobe name/s/name %'sourceSnapshot'^s/'compute/v1/projects/urbcloud/global/snapshots/snapshot-1' ~) ::^so/snap ~) %- httpreq - :* os /create-gce-disk + :* /create-gce-disk/snapshot/name ~['googleapis' 'www'] /compute/v1/projects/urbcloud/zones/us-central1-b/disks [%post body] %^ mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.gce.toke.vat) ~] ~ - ~ + ~ == +:: ++ ask-disk-status - |= [os=bone pax=path] ^- move - =+ safe=(slav %uv ?~(pax !! -.pax)) + |= pax=path ^- move + ~& 'ask disk status' + =+ :- safe=(slav %uv ?~(pax !! -.pax)) + snap=?.(?=([* ^] pax) !! i.t.pax) =+ link=(need (epur ?~(pax !! safe))) =. r.link ['access_token'^access.gce.toke.vat r.link] - :^ os %them `wire`/disk-status + :^ ost %them `wire`/disk-status/snap `(unit hiss)`[~ [link [%get ~ ~]]] :: ++ disk-status ::receive - |= [ost=bone resp=httr] + |= [ins-img=@t resp=httr] ^- [(list move) _+>.$] + ~& 'disk status called' =+ hcode=p.resp ?: =('200' hcode) ~| 'did not receive 200' !! =+ :-(parsed=(rash q:(need r.resp) apex:poja) jo) + ~& parsed =+ :- status=(need ((ot status/so ~) parsed)) lin=(need ((ot 'selfLink'^so ~) parsed)) =+ link=(scot %uv lin) ?: =('DONE' status) ~& resp ~& 'boot disk now running, now starting instance' - =+ target=(need ((ot 'targetLink'^so ~):jo parsed)) - =+ nam=-:(flop q.q:(need (epur target))) - ~& nam - ::(create-gce-disk ost nam 'tbd') - :- ~ +>.$ + =+ target=(need ((ot 'targetLink'^so ~):jo parsed)) + =+ nam=-:(flop q.q:(need (epur target))) + ~& nam + :_ +>.$ ~[(create-gce nam ins-img)] :_ +>.$ - [ost %wait `path`[%check-status link ~] `@da`(add ~s3 lat.hid)]~ :: refesh every 10 sec + [ost %wait `path`[%check-status link ins-img ~] `@da`(add ~s3 now)]~ :: refesh every 10 sec :: ++ create-gce - |= [os=bone act=json] - =+ ^- deets=create-req-gce - %- need - %. act - => jo - %- ot - :~ project/so zone/so name/so %'machine_type'^so - == - =+ src=(cat 3 'compute/v1/projects/urbcloud/zones/us-central1-b/disks/' name.deets) + |= [name=@t snap=@t] + ~& create-gce-received/snap + =+ src=(cat 3 'compute/v1/projects/urbcloud/zones/us-central1-b/disks/' name) =+ ^- body=json %- jobe - :~ name/s/'name-provided' 'machineType'^s/'zones/us-central1-b/machineTypes/n1-standard-1' + :~ name/s/name 'machineType'^s/'zones/us-central1-b/machineTypes/n1-standard-1' :- %disks :- %a :_ ~ (jobe boot/b/%.y type/s/'persistent' source/s/src ~) :- 'networkInterfaces' :- %a :_ ~ (joba 'network' `json`[%s 'global/networks/default']) == %- httpreq - :* `bone`os `path`/create-gce + :* `path`/create-gce `(list cord)`~['googleapis' 'www'] `path`/compute/v1/projects/urbcloud/zones/us-central1-b/'instances' [%post `json`body] %^ mo ['Content-Type' 'application/json' ~] @@ -385,24 +375,24 @@ $% [%diff %json json] == :: ++ wake - |= [[ost=bone him=ship pour-path=path] ~] + |= [pour-path=path ~] ?+ -.pour-path !! %refresh-do :_ +>.$ - [(list-instances-do ost)]~ + [list-instances-do]~ %refresh-gce :_ +>.$ - [(list-instances-gce ost)]~ + [list-instances-gce]~ %check-status :_ +>.$ - [(ask-disk-status ost +.pour-path)]~ + [(ask-disk-status +.pour-path)]~ == :: ++ list-instances-gce - |= os=bone =+ ^= lis - :* os /list-gce - ~[%googleapis %www] /compute/v1/projects/urbcloud/zones/['us-central1-a']/'instances' + :* + /list-gce + ~[%googleapis %www] /compute/v1/projects/urbcloud/zones/['us-central1-a']/'instances' %get ~ ^- quay [%'access_token' access.gce.toke.vat]~ @@ -410,7 +400,7 @@ $% [%diff %json json] (httpreq lis) :: ++ receive-list-gce - |= [os=bone resp=httr] + |= resp=httr ^- [(list move) _+>.$] =+ parsed=(rash q:(need r.resp) apex:poja) :: body httr to json =+ items=(need ((ot items/(ar some) ~):jo parsed)) @@ -433,16 +423,15 @@ $% [%diff %json json] |=(a=[@t instance] (~(has by insts.vat) id.a)) =. insts.vat (~(gas by insts.vat) new) - =+ buf=`@da`(add ~s10 lat.hid) + =+ buf=`@da`(add ~s10 now) :_ +>.$ =+ lis=(~(tap by insts.vat)) :_ (spam (state-to-json (turn lis |=(a=[@t instance] +.a)))) - [os %wait /refresh-gce buf] + [ost %wait /refresh-gce buf] :: ++ list-instances-do - |= os=bone =+ ^= lis - :~ os /list-do + :~ /list-do ~[%digitalocean %api] /v2/droplets %get (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~) @@ -450,7 +439,7 @@ $% [%diff %json json] (httpreq lis) :: ++ receive-list-do - |= [ost=bone resp=httr] + |= resp=httr ^- [(list move) _+>.$] =+ parsed=(rash q:(need r.resp) apex:poja) :: parse httr to json ~| recieve-list/parsed @@ -473,28 +462,26 @@ $% [%diff %json json] image/(ot name/so ~) ::disk/ni networks/parse-ip-do == - =+ buf=`@da`(add ~s10 lat.hid) + =+ buf=`@da`(add ~s10 now) :_ +>.$ =+ lis=(~(tap by insts.vat) *(list ,[@t instance])) :_ (spam (state-to-json (turn lis |=(a=[@t instance] +.a)))) [ost %wait /refresh-do buf] ++ thou - |= [[ost=bone him=ship pour-path=path] resp=httr] + |= [pour-path=path resp=httr] ^- [(list move) _+>.$] ?+ -.pour-path ~& pour-path !! %auth-do - (receive-auth ost -.pour-path resp) + (receive-auth -.pour-path resp) :: %auth-gce - (receive-auth ost -.pour-path resp) + (receive-auth -.pour-path resp) :: %list-do - (receive-list-do ost resp) + (receive-list-do resp) %list-gce - (receive-list-gce ost resp) -:: :_ +>.$ -:: ~ + (receive-list-gce resp) :: $? %delete %reboot %'power_cycle' %shutdown %'power_off' @@ -506,32 +493,34 @@ $% [%diff %json json] :_ +>.$ ~ :: ?(%create-gce-disk %disk-status) - (disk-status ost resp) + =+ snap=?~(t.pour-path !! i.t.pour-path) + ~& snap/snap + (disk-status snap resp) :: %check-status - :_ +>.$ ~[(ask-disk-status ost +.pour-path)] + :_ +>.$ ~[(ask-disk-status +.pour-path)] :: %pub :_ +>.$ ~ :: == ++ publish - |= [ost=bone you=ship act=(list speech)] + |= [act=(list speech)] ^- move =+ ^= spchz %+ turn act |= sp=speech =+ ^= tail :- ^- audience - :+ :- `partner`[%& our.hid ?+((clan our.hid) !! %czar %court, %duke %porch)] + :+ :- `partner`[%& our ?+((clan our) !! %czar %court, %duke %porch)] ^- (pair envelope delivery) [`envelope`[& ~] %pending] ~ ~ - `statement`[lat.hid ~ sp] + `statement`[now ~ sp] ^- thought - :- `@`(sham eny.hid tail) + :- `@`(sham eny tail) tail =+ mez=[%talk-command [%publish `(list thought)`spchz]] - [ost %send /pub [our.hid %talk] %poke mez] + [ost %send /pub [our %talk] %poke mez] -- diff --git a/base/arvo/gall.hoon b/base/arvo/gall.hoon index 28e13c30dc..53ba30dc32 100644 --- a/base/arvo/gall.hoon +++ b/base/arvo/gall.hoon @@ -1029,6 +1029,7 @@ %merg `%c %plug `%c %them `%e + %wait `%t %want `%a %warp `%c == diff --git a/base/pub/cloud/src/main.js b/base/pub/cloud/src/main.js index faade1da3a..cb4f1747b1 100644 --- a/base/pub/cloud/src/main.js +++ b/base/pub/cloud/src/main.js @@ -74,10 +74,10 @@ GCEControls = React.createClass({ urb.send({ appl: 'cloud', data: {action:'create-gce', - project:$('#project').val(), - zone:$('#zone').val(), - name:$('#gname').val(), - machine_type:$('#machine_type').val() +// project:$('#project').val(), +// zone:$('#zone').val(), +// name:$('#gname').val(), +// machine_type:$('#machine_type').val() / }, mark: 'json'}) }, @@ -85,10 +85,11 @@ GCEControls = React.createClass({ createDisk: function(){ urb.send({ appl: 'cloud', - data: {action:'create-gce-disk', + data: {action:'create-gce', snap:$('#gsnap').val(), number:$('#number').val(), - name:$('#gcpName').val()}, + name:$('#gcpName').val(), + instance_img:$('#instance_image').val()}, mark: 'json'}) }, @@ -100,7 +101,8 @@ GCEControls = React.createClass({ b({onClick:this.createDisk}, 'Create Disk From Image'), input({id:'gcpName',placeholder:'Name for GCE Disk and Instance'}), input({id:'number',placeholder:'Number of instances'}), - input({id:'gsnap',placeholder:'Snapshot'}) + input({id:'gsnap',placeholder:'Snapshot'}), + input({id:'instance_image',placeholder:'Instance Image'}) ]), div({}, [ a({href:ghref},"Get Google Authcode"), @@ -109,16 +111,9 @@ GCEControls = React.createClass({ div({}, [ input({id:"gappsecret"}, b({onClick:this.props.sendSecret('gce','#gappsecret')}, "Send Google Secret")) - ]), - div({}, [ - b({onClick:this.createDroplet}, "Create Droplet"), - input({id:"project",placeholder:"project"}), - input({id:"zone",placeholder:"zone"}), - input({id:"gname",placeholder:"Name of droplet"}), - input({id:"machine_type",placeholder:"Machine Type"}), - //input({id:"image",placeholder:"Image"}), + ]) ]) - ])) + ) } }) From 22062b0b18e73a084a7cfd3455923c0aa2b3ddb4 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 3 Jun 2015 11:04:19 -0700 Subject: [PATCH 10/11] normalized %ford to use ++back wherever %cast --- base/arvo/eyre.hoon | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index eb8cbd41ba..0d4e8dc781 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -53,6 +53,7 @@ ++ whir $| ~ :: wire subset $% [%at p=hole q=whir] :: authenticated [%ay p=span:ship q=span:,@uvH ~] :: remote duct + [%ha p=path:beak] :: GET request [%he p=whir] :: HEAD request [%hi p=mark ~] :: outbound HTTP [%si ~] :: response done @@ -605,10 +606,10 @@ :: kes (~(del by kes) hen) :: == :: ~& eyre-them/(earn p.u.p.kyz) - %+ pass-note hi//[p.kyz] + =+ wir=hi//[p.kyz] ?: ?=(%hiss p.q.kyz) - [%e %meta :(slop !>(%them) !>(~) q.q.kyz)] - (ford-req root-beak [%cast %hiss %done ~ q.kyz]) + (pass-note wir [%e %meta :(slop !>(%them) !>(~) q.q.kyz)]) + (back wir root-beak 0v0 %hiss q.kyz) :: %they :: inbound response =+ kas=(need (~(get by q.ask) p.kyz)) @@ -674,7 +675,7 @@ %ay (ames-gram (slav %p p.tee) got/~ (slav %uv q.tee) |2.sih) %hi =+ cay=[%httr !>(`httr`p.sih)] ?: ?=(%httr p.tee) (give-sigh ~ cay) - (pass-note si/~ (ford-req root-beak [%cast p.tee %done `cay])) + (back si/~ root-beak 0v0 p.tee cay) == :: %unto :: XX horrible @@ -687,7 +688,7 @@ ?> ?=([%of @ ^] tee) ?. ?=(%json p.p.cuf) ::~> %slog.`rose/[" " "[" "]"]^~[>%backing< >p.p.cuf< (sell q.p.cuf)] - (back tee 0v0 %json p.cuf) + (back tee root-beak 0v0 %json p.cuf) (get-rush:(ire-ix p.tee) q.tee ((hard json) q.q.p.cuf)) :: %quit (axom tee [%mean ~]) @@ -716,7 +717,7 @@ =. our (need hov) :: XX |- ^+ ..axon ?- tee - [?(%on %ay) *] ~|(e/ford/lost/-.tee !!) + $|(~ [?(%on %ay) *]) ~|(e/ford/lost/tee !!) [%si ~] (give-sigh q.sih) [%hi ^] ?: ?=(%| -.q.sih) @@ -759,13 +760,14 @@ =^ jon ..ya ~(stat-json ya p.tee cyz) $(tee q.tee, q.q.p.q.sih (add-json jon q.q.cay)) :: - ~ + [%ha *] :: ~& e/ford/hen ?. ?=(%& -.q.sih) (fail 404 p.sih p.q.sih) =* cay p.q.sih ?. ?=(%mime p.cay) - =- (back tee p.sih %mime cay(q.q -)) + =+ bek=-:(need (tome p.tee)) + =- (back tee bek p.sih %mime cay(q.q -)) ?+ p.cay q.q.cay :: inject dependency long-poll %urb =| urb=[[%html ~] [[%head ~] marl] [[%body ~] manx marl] ~] .*(.(urb q.q.cay) !=((add-poll p.sih urb))) @@ -802,9 +804,9 @@ |=([him=ship gam=gram] (pass-note ~ %a %want [our him] [%e -.gam] +.gam)) :: ++ back :: %ford bounce - |= [tea=whir dep=@uvH mar=mark cay=cage] - =+ sil=`silk`[%cast mar %flag dep %done ~ cay] - (pass-note tea (ford-req root-beak sil)) + |= [tea=whir bek=beak dep=@uvH mar=mark cay=cage] + =+ sil=`silk`[%cast mar %done ~ cay] + (pass-note tea (ford-req bek ?~(dep sil [%flag dep sil]))) :: ++ ford-kill (pass-note ~ %f [%exec our *beak ~]) :: XX unused ++ ford-req |=([bek=beak kas=silk] [%f [%exec our bek `kas]]) @@ -812,7 +814,7 @@ ++ fail |= [sas=@ud dep=@uvH mez=tang] ^+ +> - :: (back ~ dep %tang !>(mez)) :: tang->urb chain may be source of failure + :: (back ha/~ dep %tang !>(mez)) ::tang->urb chain may be source of failure (give-html sas ~ (add-poll dep (render-tang mez))) :: ++ give-html @@ -870,6 +872,7 @@ ++ abet ..handle ++ done . ++ teba |*(a=$+(* ..handle) |*(b=* %_(done ..handle (a b)))) + ++ back (teba ^back) ++ give-html (teba ^give-html) ++ give-thou (teba ^give-thou) ++ give-json (teba ^give-json) @@ -1098,7 +1101,8 @@ ?(%beam %spur) =+ ext=(fall p.pok %urb) =+ bem=?-(-.hem %beam p.hem, %spur [root-beak p.hem]) - =+ wir=?+(mef !! %get ~, %head [%he ~]) + =+ wir=`whir`[%ha (tope -.bem ~)] + =. wir ?+(mef !! %get wir, %head [%he wir]) ~| bad-beam/q.bem ?< =([~ 0] (sky %cw (tope bem(+ ~, r [%da now])))) =- ?.(aut [%& %| -] [%| (pass-note -)]) :: XX properly @@ -1124,8 +1128,8 @@ =^ orx ..ya ?:(is-anon new-view:for-client [(need grab-oryx) ..ya]) =+ [vew=(ire-ix (oryx-to-ixor orx)) cay=[%json !>(`json`s.hem)]] ?: ?=(%json q.hem) ((teba new-mess.vew) p.hem r.hem cay) - %+ pass-note [%to (oryx-to-ixor orx) (scot %p p.p.hem) q.p.hem r.hem] - (ford-req root-beak [%cast q.hem %done ~ cay]) + =+ wir=to/[(oryx-to-ixor orx) (scot %p p.p.hem) q.p.hem r.hem] + (back wir root-beak 0v0 q.hem cay) :: %poll ?: ?=([~ %js] p.pok) :: XX treat non-json cases? From 6e86d8efc4aa0d09fb4c5f61f80cbf66d36486d8 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 3 Jun 2015 11:20:25 -0700 Subject: [PATCH 11/11] normalized %eyre* to use ++back for root-beak casting --- base/arvo/eyre.hoon | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index 0d4e8dc781..9d41045d92 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -609,7 +609,7 @@ =+ wir=hi//[p.kyz] ?: ?=(%hiss p.q.kyz) (pass-note wir [%e %meta :(slop !>(%them) !>(~) q.q.kyz)]) - (back wir root-beak 0v0 %hiss q.kyz) + (back wir %hiss q.kyz) :: %they :: inbound response =+ kas=(need (~(get by q.ask) p.kyz)) @@ -674,8 +674,8 @@ ?+ -.tee !! %ay (ames-gram (slav %p p.tee) got/~ (slav %uv q.tee) |2.sih) %hi =+ cay=[%httr !>(`httr`p.sih)] - ?: ?=(%httr p.tee) (give-sigh ~ cay) - (back si/~ root-beak 0v0 p.tee cay) + ?: ?=(%httr p.tee) (give-sigh %& cay) + (back si/~ p.tee cay) == :: %unto :: XX horrible @@ -687,8 +687,8 @@ %diff ?> ?=([%of @ ^] tee) ?. ?=(%json p.p.cuf) - ::~> %slog.`rose/[" " "[" "]"]^~[>%backing< >p.p.cuf< (sell q.p.cuf)] - (back tee root-beak 0v0 %json p.cuf) + ::~> %slog.`%*(. >[%backing p.p.cuf %q-p-cuf]< &3.+> (sell q.p.cuf)) + (back tee %json p.cuf) (get-rush:(ire-ix p.tee) q.tee ((hard json) q.q.p.cuf)) :: %quit (axom tee [%mean ~]) @@ -767,7 +767,8 @@ =* cay p.q.sih ?. ?=(%mime p.cay) =+ bek=-:(need (tome p.tee)) - =- (back tee bek p.sih %mime cay(q.q -)) + =- (pass-note tee (ford-req bek [%flag p.sih -])) + =- `silk`[%cast %mime %done ~ cay(q.q -)] ?+ p.cay q.q.cay :: inject dependency long-poll %urb =| urb=[[%html ~] [[%head ~] marl] [[%body ~] manx marl] ~] .*(.(urb q.q.cay) !=((add-poll p.sih urb))) @@ -804,9 +805,8 @@ |=([him=ship gam=gram] (pass-note ~ %a %want [our him] [%e -.gam] +.gam)) :: ++ back :: %ford bounce - |= [tea=whir bek=beak dep=@uvH mar=mark cay=cage] - =+ sil=`silk`[%cast mar %done ~ cay] - (pass-note tea (ford-req bek ?~(dep sil [%flag dep sil]))) + |= [tea=whir mar=mark cay=cage] + (pass-note tea (ford-req root-beak [%cast mar %done ~ cay])) :: ++ ford-kill (pass-note ~ %f [%exec our *beak ~]) :: XX unused ++ ford-req |=([bek=beak kas=silk] [%f [%exec our bek `kas]]) @@ -1128,8 +1128,8 @@ =^ orx ..ya ?:(is-anon new-view:for-client [(need grab-oryx) ..ya]) =+ [vew=(ire-ix (oryx-to-ixor orx)) cay=[%json !>(`json`s.hem)]] ?: ?=(%json q.hem) ((teba new-mess.vew) p.hem r.hem cay) - =+ wir=to/[(oryx-to-ixor orx) (scot %p p.p.hem) q.p.hem r.hem] - (back wir root-beak 0v0 q.hem cay) + %+ back to/[(oryx-to-ixor orx) (scot %p p.p.hem) q.p.hem r.hem] + [q.hem cay] :: %poll ?: ?=([~ %js] p.pok) :: XX treat non-json cases?