2015-04-25 21:23:34 +03:00
|
|
|
:: digital ocean fleet management
|
|
|
|
::
|
|
|
|
::::
|
|
|
|
::
|
2015-05-13 16:14:36 +03:00
|
|
|
/? 314
|
|
|
|
/- *talk
|
|
|
|
/+ talk, sole, http
|
|
|
|
|
2015-04-25 21:23:34 +03:00
|
|
|
::
|
|
|
|
::
|
2015-05-21 04:34:45 +03:00
|
|
|
:::: sivtyv-barnel
|
2015-04-25 21:23:34 +03:00
|
|
|
::
|
|
|
|
|
|
|
|
!:
|
|
|
|
|%
|
2015-05-27 03:29:02 +03:00
|
|
|
++ instance
|
2015-06-02 23:15:40 +03:00
|
|
|
$: plat=?(%do %gce) name=@t id=@t status=@t created=@da snapshot=name=@t ::disk=@u region=@t
|
|
|
|
ip=(list ,@if)
|
2015-04-30 05:24:24 +03:00
|
|
|
==
|
2015-06-02 23:15:40 +03:00
|
|
|
++ create-req-do
|
2015-04-30 23:55:10 +03:00
|
|
|
$:
|
2015-06-02 23:15:40 +03:00
|
|
|
name=@t ::region=@t
|
|
|
|
size=@t image=@t ssh=(list cord)
|
2015-05-23 23:45:42 +03:00
|
|
|
backups=(unit ,?) ipv6=(unit ,?)
|
|
|
|
private-networking=(unit ,?) user-data=(unit ,@t)
|
|
|
|
==
|
|
|
|
++ create-req-gce ,[project=@t zone=@t name=@t machine-type=@t]
|
|
|
|
++ axle
|
2015-05-26 05:28:08 +03:00
|
|
|
$: auth=[do=keys gce=keys] toke=[do=tokens gce=tokens]
|
2015-06-02 23:15:40 +03:00
|
|
|
insts=(map ,@t instance)
|
2015-04-30 23:55:10 +03:00
|
|
|
==
|
2015-04-25 21:23:34 +03:00
|
|
|
++ keys ,[authc=(unit ,@t) client-secret=(unit ,@t)]
|
|
|
|
++ tokens ,[access=@t refresh=@t]
|
2015-05-21 04:34:45 +03:00
|
|
|
++ move ,[bone card]
|
|
|
|
++ card
|
|
|
|
$% [%diff %json json]
|
|
|
|
[%wait wire @da]
|
|
|
|
[%send wire [ship term] %poke %talk-command command]
|
|
|
|
[%them wire (unit hiss)]
|
2015-05-13 16:14:36 +03:00
|
|
|
==
|
2015-04-30 00:02:54 +03:00
|
|
|
--
|
2015-04-30 23:55:10 +03:00
|
|
|
!:
|
2015-06-02 23:15:40 +03:00
|
|
|
|% :::
|
|
|
|
++ 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
|
2015-04-30 00:02:54 +03:00
|
|
|
=> jo
|
|
|
|
%- ot
|
2015-06-02 23:15:40 +03:00
|
|
|
:_ ~ 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)))
|
2015-04-30 23:55:10 +03:00
|
|
|
++ parse-region
|
|
|
|
=> jo
|
2015-05-27 03:29:02 +03:00
|
|
|
(ot name/so ~)
|
2015-06-02 23:15:40 +03:00
|
|
|
++ parse-id-text
|
|
|
|
|= jon=json
|
|
|
|
?.(?=([?(%n %s) *] jon) ~ (some p.jon))
|
2015-05-23 23:45:42 +03:00
|
|
|
++ create-do-body
|
2015-06-02 23:15:40 +03:00
|
|
|
|= $: name=@t ::region=@t
|
|
|
|
size=@t image=@t ssh-keys=(list cord)
|
2015-04-30 23:55:10 +03:00
|
|
|
backups=(unit ,?) ipv6=(unit ,?) private-networking=(unit ,?) user-data=(unit ,@t)
|
2015-04-30 05:24:24 +03:00
|
|
|
==
|
|
|
|
%- jobe
|
2015-06-02 23:15:40 +03:00
|
|
|
:~ name/s/name ::region/s/region
|
|
|
|
size/s/size image/s/image ::(jone image)
|
2015-05-13 16:14:36 +03:00
|
|
|
backups/?~(backups ~ b/u.backups) ipv6/?~(ipv6 ~ b/u.ipv6)
|
2015-04-30 23:55:10 +03:00
|
|
|
'user_data'^?~(user-data ~ s/u.user-data) 'private_networking'^?~(private-networking ~ b/u.private-networking)
|
2015-04-30 05:24:24 +03:00
|
|
|
==
|
2015-06-02 23:15:40 +03:00
|
|
|
++ convert-do
|
|
|
|
|= a=?(%start %stop %reboot)
|
|
|
|
?- a
|
|
|
|
%start
|
|
|
|
'power_on'
|
|
|
|
%stop
|
|
|
|
'shutdown'
|
|
|
|
%reboot
|
|
|
|
'power_cycle'
|
|
|
|
==
|
2015-05-01 06:22:05 +03:00
|
|
|
++ state-to-json
|
2015-05-27 03:29:02 +03:00
|
|
|
|= a=(list instance)
|
2015-05-01 06:22:05 +03:00
|
|
|
:- %a
|
|
|
|
%+ turn a
|
2015-05-27 03:29:02 +03:00
|
|
|
|= instance
|
2015-05-01 06:22:05 +03:00
|
|
|
^- json
|
|
|
|
%- jobe
|
2015-05-27 03:29:02 +03:00
|
|
|
:~ name/`json`s/name
|
2015-06-02 23:15:40 +03:00
|
|
|
id/s/id
|
2015-05-01 06:22:05 +03:00
|
|
|
status/s/status
|
2015-06-02 23:15:40 +03:00
|
|
|
created/s/(crip (dust (yore created)))
|
|
|
|
::region/s/region
|
|
|
|
snapshot/s/snapshot
|
|
|
|
:: disk/`json`(jone disk)
|
2015-05-27 03:29:02 +03:00
|
|
|
ip/a/(turn ip |=(a=@if s/(rsh 3 1 (scot %if a))))
|
2015-05-01 06:22:05 +03:00
|
|
|
==
|
2015-04-25 21:23:34 +03:00
|
|
|
--
|
|
|
|
!:
|
2015-06-03 04:36:23 +03:00
|
|
|
|_ [bowl vat=axle]
|
2015-04-30 00:02:54 +03:00
|
|
|
::
|
2015-06-02 23:15:40 +03:00
|
|
|
::++ prep ,_`.
|
|
|
|
::
|
|
|
|
++ peer
|
2015-06-03 04:36:23 +03:00
|
|
|
|= pax=path
|
2015-06-02 23:15:40 +03:00
|
|
|
^- [(list move) _+>.$]
|
|
|
|
:_ +>.$
|
|
|
|
=+ lis=(~(tap by insts.vat))
|
|
|
|
[ost %diff %json (state-to-json (turn lis |=(a=[@t instance] +.a)))]~
|
|
|
|
::
|
2015-05-13 16:14:36 +03:00
|
|
|
++ spam
|
|
|
|
|= jon=json
|
2015-06-03 04:36:23 +03:00
|
|
|
%+ turn (~(tap by sup))
|
2015-05-13 16:14:36 +03:00
|
|
|
|= [sub=bone @ pax=path]
|
|
|
|
^- move
|
2015-05-21 04:34:45 +03:00
|
|
|
[sub %diff %json jon]
|
2015-04-25 21:23:34 +03:00
|
|
|
++ httpreq
|
2015-06-03 04:36:23 +03:00
|
|
|
|= $: pour-path=wire
|
2015-04-25 21:23:34 +03:00
|
|
|
domain=(list cord) end-point=path
|
2015-06-02 23:15:40 +03:00
|
|
|
req-type=$?(%get %delt [%post json]) headers=math
|
2015-04-25 21:23:34 +03:00
|
|
|
queries=quay
|
|
|
|
==
|
|
|
|
^- move
|
|
|
|
=+ ^- parsed-url=purl
|
|
|
|
:+ ^= host-port :: ++hart
|
|
|
|
:+ security=%.y
|
|
|
|
port=~
|
|
|
|
host=[%.y [path=[%com domain]]]
|
|
|
|
endpoint=[extensions=~ point=end-point] :: ++pork,
|
|
|
|
q-strings=queries :: ++quay
|
|
|
|
=+ ^- request=hiss :: cast to hiss
|
|
|
|
:- parsed-url
|
2015-04-30 05:24:24 +03:00
|
|
|
?@ req-type
|
2015-06-02 23:15:40 +03:00
|
|
|
[req-type headers ~]
|
2015-04-30 05:24:24 +03:00
|
|
|
[%post headers ~ (tact (pojo +.req-type))]
|
2015-05-21 04:34:45 +03:00
|
|
|
:^ ost %them pour-path
|
2015-04-25 21:23:34 +03:00
|
|
|
`(unit hiss)`[~ request]
|
|
|
|
::
|
2015-06-02 23:15:40 +03:00
|
|
|
++ auth-queries
|
|
|
|
|= code=cord
|
|
|
|
:~ 'grant_type'^'authorization_code'
|
|
|
|
'code'^code
|
|
|
|
:- 'client_id'
|
|
|
|
'd8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f'
|
|
|
|
'redirect_uri'^'http://localhost:8443/home/pub/cloud/fab'
|
|
|
|
==
|
2015-04-25 21:23:34 +03:00
|
|
|
::
|
2015-05-22 03:22:56 +03:00
|
|
|
++ poke-cloud-auth
|
2015-06-03 04:36:23 +03:00
|
|
|
|= [cde=cord typ=cord]
|
2015-04-25 21:23:34 +03:00
|
|
|
^- [(list move) _+>.$]
|
2015-05-21 04:34:45 +03:00
|
|
|
?: =(%do typ)
|
|
|
|
=. authc.do.auth.vat
|
|
|
|
[~ cde]
|
2015-06-02 23:15:40 +03:00
|
|
|
:_ +>.$ ~
|
2015-05-26 05:28:08 +03:00
|
|
|
=. access.gce.toke.vat
|
2015-05-23 23:45:42 +03:00
|
|
|
cde
|
2015-04-25 21:23:34 +03:00
|
|
|
:_ +>.$
|
2015-06-03 04:36:23 +03:00
|
|
|
:- list-instances-gce
|
|
|
|
~[(publish [%lin & 'successfully authenticated to gce']~)]
|
2015-04-25 21:23:34 +03:00
|
|
|
::
|
2015-05-22 03:22:56 +03:00
|
|
|
++ poke-cloud-secret
|
2015-06-03 04:36:23 +03:00
|
|
|
|= [secret=cord typ=cord]
|
2015-04-25 21:23:34 +03:00
|
|
|
^- [(list move) _+>.$]
|
2015-05-21 04:34:45 +03:00
|
|
|
?+ typ ~|(missing-platform=typ !!)
|
|
|
|
%do
|
|
|
|
=. client-secret.do.auth.vat
|
|
|
|
[~ secret]
|
|
|
|
:_ +>.$
|
|
|
|
:_ ~
|
2015-06-03 04:36:23 +03:00
|
|
|
%+ httpreq /auth-do
|
2015-05-21 04:34:45 +03:00
|
|
|
:^ ~[%digitalocean %cloud] `path`/v1/oauth/token
|
|
|
|
[%post ~]
|
|
|
|
:- ~ `quay`['client_secret'^secret (auth-queries (need authc.do.auth.vat))]
|
|
|
|
==
|
2015-04-25 21:23:34 +03:00
|
|
|
::
|
2015-04-30 00:02:54 +03:00
|
|
|
++ receive-auth
|
2015-06-03 04:36:23 +03:00
|
|
|
|= [pour-path=cord resp=httr]
|
2015-05-13 16:14:36 +03:00
|
|
|
^- [(list move) _+>.$]
|
|
|
|
~| resp
|
2015-05-21 04:34:45 +03:00
|
|
|
=+ body=(rash q:(need r.resp) apex:poja)
|
|
|
|
~| recieve-auth/resp(r body)
|
2015-05-23 23:45:42 +03:00
|
|
|
?+ pour-path !!
|
|
|
|
%auth-do
|
2015-04-30 00:02:54 +03:00
|
|
|
=+ [ac re]=(need ((ot 'access_token'^so 'refresh_token'^so ~):jo body))
|
2015-05-23 23:45:42 +03:00
|
|
|
=: access.do.toke.vat ac
|
|
|
|
refresh.do.toke.vat re
|
2015-04-30 00:02:54 +03:00
|
|
|
==
|
|
|
|
:_ +>.$
|
2015-06-03 04:36:23 +03:00
|
|
|
:~ list-instances-do
|
|
|
|
(publish [%lin & 'successfully authenticated']~)
|
2015-05-13 16:14:36 +03:00
|
|
|
==
|
2015-05-23 23:45:42 +03:00
|
|
|
==
|
2015-04-30 00:02:54 +03:00
|
|
|
::
|
|
|
|
++ poke-json
|
2015-06-03 04:36:23 +03:00
|
|
|
|= act=json
|
2015-05-01 22:05:16 +03:00
|
|
|
^- [(list move) _+>.$]
|
2015-04-30 05:24:24 +03:00
|
|
|
=+ do=(need ((ot action/so ~):jo act))
|
2015-05-27 03:29:02 +03:00
|
|
|
:_ +>.$
|
|
|
|
:_ ~
|
2015-04-30 00:02:54 +03:00
|
|
|
?+ do !!
|
2015-05-13 16:14:36 +03:00
|
|
|
%list
|
2015-06-03 04:36:23 +03:00
|
|
|
list-instances-do
|
2015-05-13 16:14:36 +03:00
|
|
|
::
|
2015-05-23 23:45:42 +03:00
|
|
|
%create-do
|
2015-06-03 04:36:23 +03:00
|
|
|
(create-do act)
|
2015-05-23 23:45:42 +03:00
|
|
|
::
|
|
|
|
%create-gce
|
2015-06-03 04:36:23 +03:00
|
|
|
(create-gce-disk act)
|
2015-05-13 16:14:36 +03:00
|
|
|
::
|
2015-06-02 23:15:40 +03:00
|
|
|
?(%start %stop %reboot %delete)
|
|
|
|
=+ id=(need ((ot id/so ~):jo act))
|
2015-06-03 04:36:23 +03:00
|
|
|
(instance-action id do)
|
2015-04-25 21:23:34 +03:00
|
|
|
==
|
2015-05-13 16:14:36 +03:00
|
|
|
::
|
2015-05-27 03:29:02 +03:00
|
|
|
++ instance-action
|
2015-06-03 04:36:23 +03:00
|
|
|
|= $: id=@t
|
2015-05-13 16:14:36 +03:00
|
|
|
$= action $?
|
2015-05-27 03:29:02 +03:00
|
|
|
%start %stop %reboot %delete
|
2015-05-13 16:14:36 +03:00
|
|
|
== ==
|
2015-06-02 23:15:40 +03:00
|
|
|
=+ d=(~(got by insts.vat) id)
|
|
|
|
~| 'can\'t find id'
|
|
|
|
=+ typ=?~(d !! -.d)
|
|
|
|
?- typ
|
|
|
|
%do
|
|
|
|
=+ meth=?:(?=(%delete action) %delt [%post (jobe type/s/(convert-do action) ~)])
|
2015-05-27 03:29:02 +03:00
|
|
|
^- move
|
2015-06-02 23:15:40 +03:00
|
|
|
~& 'do i get here?'
|
2015-05-13 16:14:36 +03:00
|
|
|
=+ ^= req
|
2015-05-01 22:05:16 +03:00
|
|
|
%- httpreq :*
|
2015-06-03 04:36:23 +03:00
|
|
|
/action-test
|
2015-06-02 23:15:40 +03:00
|
|
|
~[%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) ~] ~
|
2015-05-01 22:05:16 +03:00
|
|
|
*quay
|
|
|
|
==
|
2015-05-13 16:14:36 +03:00
|
|
|
req
|
2015-06-02 23:15:40 +03:00
|
|
|
%gce
|
2015-06-03 04:36:23 +03:00
|
|
|
?- action
|
|
|
|
%start
|
|
|
|
!!
|
|
|
|
%stop
|
|
|
|
!!
|
|
|
|
%reboot
|
|
|
|
!!
|
|
|
|
%delete
|
|
|
|
!!
|
2015-06-02 23:15:40 +03:00
|
|
|
==
|
2015-06-03 04:36:23 +03:00
|
|
|
==
|
2015-04-30 00:02:54 +03:00
|
|
|
::
|
2015-05-23 23:45:42 +03:00
|
|
|
++ create-do
|
2015-06-03 04:36:23 +03:00
|
|
|
|= act=json
|
2015-05-27 03:29:02 +03:00
|
|
|
=+ ^- deets=create-req-do
|
|
|
|
%- need
|
|
|
|
%. act
|
|
|
|
=> jo
|
|
|
|
%- ot
|
2015-06-02 23:15:40 +03:00
|
|
|
:~ name/so size/so image/so :: id key:img object region/so
|
2015-05-27 03:29:02 +03:00
|
|
|
ssh/(ar so) backups/(mu bo)
|
|
|
|
'ipv6'^(mu bo) 'priv_networking'^(mu bo) 'user_data'^(mu so)
|
|
|
|
==
|
2015-05-21 04:34:45 +03:00
|
|
|
=+ ^- body=json
|
2015-05-23 23:45:42 +03:00
|
|
|
%- create-do-body :*
|
2015-06-02 23:15:40 +03:00
|
|
|
name.deets size.deets image.deets ssh.deets backups.deets ::region.deets
|
2015-05-27 03:29:02 +03:00
|
|
|
ipv6.deets private-networking.deets user-data.deets
|
2015-04-30 23:55:10 +03:00
|
|
|
==
|
2015-05-21 04:34:45 +03:00
|
|
|
%- httpreq :*
|
2015-06-03 04:36:23 +03:00
|
|
|
/create-do
|
2015-05-21 04:34:45 +03:00
|
|
|
~[%digitalocean %api] /v2/droplets
|
|
|
|
[%post body]
|
2015-05-26 05:28:08 +03:00
|
|
|
%^ mo ['Content-Type' 'application/json; charset=utf-8' ~]
|
2015-05-23 23:45:42 +03:00
|
|
|
['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~]
|
2015-05-21 04:34:45 +03:00
|
|
|
~
|
|
|
|
~
|
|
|
|
==
|
2015-06-02 23:15:40 +03:00
|
|
|
::
|
2015-05-26 05:28:08 +03:00
|
|
|
++ create-gce-disk
|
2015-06-03 04:36:23 +03:00
|
|
|
|= act=json :: num=(unit ,@u)
|
|
|
|
=+ :- name=(need ((ot name/so ~):jo act))
|
|
|
|
snapshot=(need ((ot 'instance_image'^so ~):jo act))
|
2015-05-27 03:29:02 +03:00
|
|
|
=+ :- name=(need ((ot name/so ~):jo act))
|
|
|
|
snap=(need ((ot snap/so ~):jo act))
|
2015-05-26 05:28:08 +03:00
|
|
|
=+ ^- body=json
|
|
|
|
(jobe name/s/name %'sourceSnapshot'^s/'compute/v1/projects/urbcloud/global/snapshots/snapshot-1' ~) ::^so/snap ~)
|
|
|
|
%- httpreq
|
2015-06-03 04:36:23 +03:00
|
|
|
:* /create-gce-disk/snapshot/name
|
2015-05-26 05:28:08 +03:00
|
|
|
~['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) ~]
|
|
|
|
~
|
2015-06-03 04:36:23 +03:00
|
|
|
~
|
2015-05-26 05:28:08 +03:00
|
|
|
==
|
2015-06-03 04:36:23 +03:00
|
|
|
::
|
2015-05-26 05:28:08 +03:00
|
|
|
++ ask-disk-status
|
2015-06-03 04:36:23 +03:00
|
|
|
|= pax=path ^- move
|
|
|
|
~& 'ask disk status'
|
|
|
|
=+ :- safe=(slav %uv ?~(pax !! -.pax))
|
|
|
|
snap=?.(?=([* ^] pax) !! i.t.pax)
|
2015-05-26 05:28:08 +03:00
|
|
|
=+ link=(need (epur ?~(pax !! safe)))
|
|
|
|
=. r.link ['access_token'^access.gce.toke.vat r.link]
|
2015-06-03 04:36:23 +03:00
|
|
|
:^ ost %them `wire`/disk-status/snap
|
2015-05-26 05:28:08 +03:00
|
|
|
`(unit hiss)`[~ [link [%get ~ ~]]]
|
2015-06-02 23:15:40 +03:00
|
|
|
::
|
2015-05-26 05:28:08 +03:00
|
|
|
++ disk-status ::receive
|
2015-06-03 04:36:23 +03:00
|
|
|
|= [ins-img=@t resp=httr]
|
2015-05-26 05:28:08 +03:00
|
|
|
^- [(list move) _+>.$]
|
2015-06-03 04:36:23 +03:00
|
|
|
~& 'disk status called'
|
2015-05-26 23:47:57 +03:00
|
|
|
=+ hcode=p.resp
|
|
|
|
?: =('200' hcode)
|
|
|
|
~| 'did not receive 200' !!
|
|
|
|
=+ :-(parsed=(rash q:(need r.resp) apex:poja) jo)
|
2015-06-03 04:36:23 +03:00
|
|
|
~& parsed
|
2015-05-26 23:47:57 +03:00
|
|
|
=+ :- 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'
|
2015-06-03 04:36:23 +03:00
|
|
|
=+ target=(need ((ot 'targetLink'^so ~):jo parsed))
|
|
|
|
=+ nam=-:(flop q.q:(need (epur target)))
|
|
|
|
~& nam
|
|
|
|
:_ +>.$ ~[(create-gce nam ins-img)]
|
2015-05-26 05:28:08 +03:00
|
|
|
:_ +>.$
|
2015-06-03 04:36:23 +03:00
|
|
|
[ost %wait `path`[%check-status link ins-img ~] `@da`(add ~s3 now)]~ :: refesh every 10 sec
|
2015-06-02 23:15:40 +03:00
|
|
|
::
|
2015-05-23 23:45:42 +03:00
|
|
|
++ create-gce
|
2015-06-03 04:36:23 +03:00
|
|
|
|= [name=@t snap=@t]
|
|
|
|
~& create-gce-received/snap
|
|
|
|
=+ src=(cat 3 'compute/v1/projects/urbcloud/zones/us-central1-b/disks/' name)
|
2015-05-23 23:45:42 +03:00
|
|
|
=+ ^- body=json
|
|
|
|
%- jobe
|
2015-06-03 04:36:23 +03:00
|
|
|
:~ name/s/name 'machineType'^s/'zones/us-central1-b/machineTypes/n1-standard-1'
|
2015-05-26 05:28:08 +03:00
|
|
|
:- %disks :- %a :_ ~
|
|
|
|
(jobe boot/b/%.y type/s/'persistent' source/s/src ~)
|
|
|
|
:- 'networkInterfaces' :- %a :_ ~
|
|
|
|
(joba 'network' `json`[%s 'global/networks/default'])
|
|
|
|
==
|
2015-05-23 23:45:42 +03:00
|
|
|
%- httpreq
|
2015-06-03 04:36:23 +03:00
|
|
|
:* `path`/create-gce
|
2015-05-26 05:28:08 +03:00
|
|
|
`(list cord)`~['googleapis' 'www'] `path`/compute/v1/projects/urbcloud/zones/us-central1-b/'instances'
|
2015-05-23 23:45:42 +03:00
|
|
|
[%post `json`body]
|
2015-05-24 00:40:20 +03:00
|
|
|
%^ mo ['Content-Type' 'application/json' ~]
|
2015-05-26 05:28:08 +03:00
|
|
|
['Authorization' (cat 3 'Bearer ' access.gce.toke.vat) ~]
|
2015-05-24 00:40:20 +03:00
|
|
|
~
|
2015-05-26 05:28:08 +03:00
|
|
|
`quay`[%key access.gce.toke.vat]~
|
2015-05-23 23:45:42 +03:00
|
|
|
==
|
2015-06-02 23:15:40 +03:00
|
|
|
::
|
2015-05-21 04:34:45 +03:00
|
|
|
++ wake
|
2015-06-03 04:36:23 +03:00
|
|
|
|= [pour-path=path ~]
|
2015-05-21 04:34:45 +03:00
|
|
|
?+ -.pour-path !!
|
2015-05-26 05:28:08 +03:00
|
|
|
%refresh-do
|
2015-05-21 04:34:45 +03:00
|
|
|
:_ +>.$
|
2015-06-03 04:36:23 +03:00
|
|
|
[list-instances-do]~
|
2015-06-02 23:15:40 +03:00
|
|
|
%refresh-gce
|
|
|
|
:_ +>.$
|
2015-06-03 04:36:23 +03:00
|
|
|
[list-instances-gce]~
|
2015-05-26 05:28:08 +03:00
|
|
|
%check-status
|
|
|
|
:_ +>.$
|
2015-06-03 04:36:23 +03:00
|
|
|
[(ask-disk-status +.pour-path)]~
|
2015-05-21 04:34:45 +03:00
|
|
|
==
|
2015-06-02 23:15:40 +03:00
|
|
|
::
|
|
|
|
++ list-instances-gce
|
|
|
|
=+ ^= lis
|
2015-06-03 04:36:23 +03:00
|
|
|
:*
|
|
|
|
/list-gce
|
|
|
|
~[%googleapis %www] /compute/v1/projects/urbcloud/zones/['us-central1-a']/'instances'
|
2015-06-02 23:15:40 +03:00
|
|
|
%get ~
|
|
|
|
^- quay
|
|
|
|
[%'access_token' access.gce.toke.vat]~
|
|
|
|
==
|
|
|
|
(httpreq lis)
|
|
|
|
::
|
|
|
|
++ receive-list-gce
|
2015-06-03 04:36:23 +03:00
|
|
|
|= resp=httr
|
2015-06-02 23:15:40 +03:00
|
|
|
^- [(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)
|
2015-06-03 04:36:23 +03:00
|
|
|
=+ buf=`@da`(add ~s10 now)
|
2015-06-02 23:15:40 +03:00
|
|
|
:_ +>.$
|
|
|
|
=+ lis=(~(tap by insts.vat))
|
|
|
|
:_ (spam (state-to-json (turn lis |=(a=[@t instance] +.a))))
|
2015-06-03 04:36:23 +03:00
|
|
|
[ost %wait /refresh-gce buf]
|
2015-06-02 23:15:40 +03:00
|
|
|
::
|
|
|
|
++ list-instances-do
|
|
|
|
=+ ^= lis
|
2015-06-03 04:36:23 +03:00
|
|
|
:~ /list-do
|
2015-06-02 23:15:40 +03:00
|
|
|
~[%digitalocean %api] /v2/droplets
|
|
|
|
%get
|
|
|
|
(mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~)
|
|
|
|
==
|
|
|
|
(httpreq lis)
|
|
|
|
::
|
|
|
|
++ receive-list-do
|
2015-06-03 04:36:23 +03:00
|
|
|
|= resp=httr
|
2015-06-02 23:15:40 +03:00
|
|
|
^- [(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
|
|
|
|
==
|
2015-06-03 04:36:23 +03:00
|
|
|
=+ buf=`@da`(add ~s10 now)
|
2015-06-02 23:15:40 +03:00
|
|
|
:_ +>.$
|
|
|
|
=+ lis=(~(tap by insts.vat) *(list ,[@t instance]))
|
|
|
|
:_ (spam (state-to-json (turn lis |=(a=[@t instance] +.a))))
|
|
|
|
[ost %wait /refresh-do buf]
|
|
|
|
|
2015-05-21 04:34:45 +03:00
|
|
|
++ thou
|
2015-06-03 04:36:23 +03:00
|
|
|
|= [pour-path=path resp=httr]
|
2015-04-30 00:02:54 +03:00
|
|
|
^- [(list move) _+>.$]
|
2015-05-26 05:28:08 +03:00
|
|
|
?+ -.pour-path ~& pour-path !!
|
2015-05-23 23:45:42 +03:00
|
|
|
%auth-do
|
2015-06-03 04:36:23 +03:00
|
|
|
(receive-auth -.pour-path resp)
|
2015-05-23 23:45:42 +03:00
|
|
|
::
|
|
|
|
%auth-gce
|
2015-06-03 04:36:23 +03:00
|
|
|
(receive-auth -.pour-path resp)
|
2015-04-30 00:02:54 +03:00
|
|
|
::
|
2015-05-26 05:28:08 +03:00
|
|
|
%list-do
|
2015-06-03 04:36:23 +03:00
|
|
|
(receive-list-do resp)
|
2015-05-26 05:28:08 +03:00
|
|
|
%list-gce
|
2015-06-03 04:36:23 +03:00
|
|
|
(receive-list-gce resp)
|
2015-04-30 23:55:10 +03:00
|
|
|
::
|
2015-05-13 16:14:36 +03:00
|
|
|
$?
|
|
|
|
%delete %reboot %'power_cycle' %shutdown %'power_off'
|
|
|
|
%'power_on' %'password_reset' %'enable_ipv6' %'enable_private_networking'
|
|
|
|
%snapshot %upgrade :: add retrieve droplet action
|
2015-06-02 23:15:40 +03:00
|
|
|
%create-do %create-gce %action-test
|
2015-05-13 16:14:36 +03:00
|
|
|
==
|
|
|
|
~& resp
|
|
|
|
:_ +>.$ ~
|
2015-05-26 05:28:08 +03:00
|
|
|
::
|
|
|
|
?(%create-gce-disk %disk-status)
|
2015-06-03 04:36:23 +03:00
|
|
|
=+ snap=?~(t.pour-path !! i.t.pour-path)
|
|
|
|
~& snap/snap
|
|
|
|
(disk-status snap resp)
|
2015-05-26 05:28:08 +03:00
|
|
|
::
|
|
|
|
%check-status
|
2015-06-03 04:36:23 +03:00
|
|
|
:_ +>.$ ~[(ask-disk-status +.pour-path)]
|
2015-05-01 06:22:05 +03:00
|
|
|
::
|
2015-05-13 16:14:36 +03:00
|
|
|
%pub
|
|
|
|
:_ +>.$ ~
|
|
|
|
::
|
2015-04-30 00:02:54 +03:00
|
|
|
==
|
2015-05-13 16:14:36 +03:00
|
|
|
++ publish
|
2015-06-03 04:36:23 +03:00
|
|
|
|= [act=(list speech)]
|
2015-05-13 16:14:36 +03:00
|
|
|
^- move
|
|
|
|
=+ ^= spchz
|
|
|
|
%+ turn act
|
|
|
|
|= sp=speech
|
|
|
|
=+ ^= tail
|
|
|
|
:- ^- audience
|
2015-06-03 04:36:23 +03:00
|
|
|
:+ :- `partner`[%& our ?+((clan our) !! %czar %court, %duke %porch)]
|
2015-05-13 16:14:36 +03:00
|
|
|
^- (pair envelope delivery)
|
|
|
|
[`envelope`[& ~] %pending]
|
|
|
|
~
|
|
|
|
~
|
2015-06-03 04:36:23 +03:00
|
|
|
`statement`[now ~ sp]
|
2015-05-13 16:14:36 +03:00
|
|
|
^- thought
|
2015-06-03 04:36:23 +03:00
|
|
|
:- `@`(sham eny tail)
|
2015-05-13 16:14:36 +03:00
|
|
|
tail
|
2015-05-21 04:34:45 +03:00
|
|
|
=+ mez=[%talk-command [%publish `(list thought)`spchz]]
|
2015-06-03 04:36:23 +03:00
|
|
|
[ost %send /pub [our %talk] %poke mez]
|
2015-04-25 21:23:34 +03:00
|
|
|
--
|