formatting
This commit is contained in:
@@ -4,15 +4,14 @@ import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.installers.base
|
||||
|
||||
fn do() ! {
|
||||
//base.uninstall_brew()!
|
||||
//println("something")
|
||||
// base.uninstall_brew()!
|
||||
// println("something")
|
||||
if osal.is_osx() {
|
||||
println('IS OSX')
|
||||
}
|
||||
|
||||
// mut job2 := osal.exec(cmd: 'ls /')!
|
||||
// println(job2)
|
||||
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -4,7 +4,6 @@ import freeflowuniverse.herolib.builder
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import os
|
||||
|
||||
|
||||
fn do1() ! {
|
||||
mut b := builder.new()!
|
||||
mut n := b.node_new(ipaddr: 'root@195.192.213.2')!
|
||||
|
||||
@@ -10,7 +10,7 @@ mut n := b.node_new(ipaddr: 'root@51.195.61.5')!
|
||||
|
||||
println(n)
|
||||
|
||||
r:=n.exec(cmd:"ls /")!
|
||||
r := n.exec(cmd: 'ls /')!
|
||||
println(r)
|
||||
|
||||
// n.upload(source: myexamplepath, dest: '/tmp/myexamplepath2')!
|
||||
|
||||
@@ -7,7 +7,7 @@ import os
|
||||
mut b := builder.new()!
|
||||
mut n := b.node_new(ipaddr: 'root@302:1d81:cef8:3049:ad01:796d:a5da:9c6')!
|
||||
|
||||
r:=n.exec(cmd:"ls /")!
|
||||
r := n.exec(cmd: 'ls /')!
|
||||
println(r)
|
||||
|
||||
// n.upload(source: myexamplepath, dest: '/tmp/myexamplepath2')!
|
||||
|
||||
@@ -14,7 +14,7 @@ mut:
|
||||
_, privkey := ed25519.generate_key()!
|
||||
mut a := AStruct{
|
||||
items: ['a', 'b']
|
||||
nr: 10
|
||||
nr: 10
|
||||
// privkey: []u8{len: 5, init: u8(0xf8)}
|
||||
privkey: privkey
|
||||
}
|
||||
@@ -36,10 +36,9 @@ aa.privkey = d.get_bytes()
|
||||
|
||||
assert a == aa
|
||||
|
||||
|
||||
a = AStruct{
|
||||
items: ['a', 'b']
|
||||
nr: 10
|
||||
items: ['a', 'b']
|
||||
nr: 10
|
||||
privkey: []u8{len: 5, init: u8(0xf8)}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.data.encoderhero
|
||||
import freeflowuniverse.herolib.core.base
|
||||
|
||||
//this is docu at top
|
||||
@[name:"teststruct " ; params]
|
||||
// this is docu at top
|
||||
@[name: 'teststruct ']
|
||||
@[params]
|
||||
pub struct TestStruct {
|
||||
//this is docu at mid
|
||||
// this is docu at mid
|
||||
pub mut:
|
||||
id int @[hi]
|
||||
descr string
|
||||
secret string @[secret]
|
||||
number int = 1 @[min:1 ;max:10]
|
||||
id int @[hi]
|
||||
descr string
|
||||
secret string @[secret]
|
||||
number int = 1 @[max: 10; min: 1]
|
||||
yesno bool
|
||||
liststr []string
|
||||
listint []int
|
||||
ss SubStruct
|
||||
ss2 []SubStruct
|
||||
ss SubStruct
|
||||
ss2 []SubStruct
|
||||
}
|
||||
|
||||
pub struct SubStruct {
|
||||
pub mut:
|
||||
color string
|
||||
size int
|
||||
size int
|
||||
}
|
||||
|
||||
fn (self TestStruct) heroscript()!string {
|
||||
mut out:=""
|
||||
fn (self TestStruct) heroscript() !string {
|
||||
mut out := ''
|
||||
mut p := encoderhero.encode[TestStruct](self)!
|
||||
// out += "!!hr.teststruct_define " + p.heroscript() + "\n"
|
||||
// p = paramsparser.encode[SubStruct](self.ss)!
|
||||
@@ -39,10 +41,9 @@ fn (self TestStruct) heroscript()!string {
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
mut t := TestStruct{
|
||||
id:100
|
||||
descr: '
|
||||
id: 100
|
||||
descr: '
|
||||
test
|
||||
muliline
|
||||
s
|
||||
@@ -50,15 +51,24 @@ mut t := TestStruct{
|
||||
muliline
|
||||
test
|
||||
muliline
|
||||
'
|
||||
number: 2
|
||||
yesno: true
|
||||
'
|
||||
number: 2
|
||||
yesno: true
|
||||
liststr: ['one', 'two+two']
|
||||
listint: [1, 2]
|
||||
ss:SubStruct{color:"red",size:10}
|
||||
ss: SubStruct{
|
||||
color: 'red'
|
||||
size: 10
|
||||
}
|
||||
}
|
||||
t.ss2 << SubStruct{
|
||||
color: 'red1'
|
||||
size: 11
|
||||
}
|
||||
t.ss2 << SubStruct{
|
||||
color: 'red2'
|
||||
size: 12
|
||||
}
|
||||
t.ss2<< SubStruct{color:"red1",size:11}
|
||||
t.ss2<< SubStruct{color:"red2",size:12}
|
||||
|
||||
println(t.heroscript()!)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.data.paramsparser { Params, parse }
|
||||
import time { Duration, sleep }
|
||||
import time
|
||||
|
||||
totalnr := 1000000
|
||||
|
||||
|
||||
@@ -8,17 +8,19 @@ mut silent := false
|
||||
|
||||
coderoot := if 'CODEROOT' in os.environ() {
|
||||
os.environ()['CODEROOT']
|
||||
} else {os.join_path(os.home_dir(), 'code')}
|
||||
} else {
|
||||
os.join_path(os.home_dir(), 'code')
|
||||
}
|
||||
|
||||
mut gs := gittools.get()!
|
||||
if coderoot.len > 0 {
|
||||
//is a hack for now
|
||||
// is a hack for now
|
||||
gs = gittools.new(coderoot: coderoot)!
|
||||
}
|
||||
|
||||
mypath := gs.do(
|
||||
recursive: true
|
||||
cmd: 'list'
|
||||
cmd: 'list'
|
||||
)!
|
||||
|
||||
timer := performance.new('gittools')
|
||||
|
||||
@@ -4,7 +4,6 @@ import freeflowuniverse.herolib.develop.gittools
|
||||
import freeflowuniverse.herolib.osal
|
||||
import time
|
||||
|
||||
|
||||
mut gs_default := gittools.new()!
|
||||
|
||||
println(gs_default)
|
||||
|
||||
@@ -5,7 +5,7 @@ import freeflowuniverse.herolib.osal
|
||||
import time
|
||||
|
||||
// Creates a new file in the specified repository path and returns its name.
|
||||
fn create_new_file(repo_path string, runtime i64)! string {
|
||||
fn create_new_file(repo_path string, runtime i64) !string {
|
||||
coded_now := time.now().unix()
|
||||
file_name := 'hello_world_${coded_now}.py'
|
||||
println('Creating a new ${file_name} file.')
|
||||
@@ -29,8 +29,8 @@ mut repo := gs_default.get_repo(name: 'repo3')!
|
||||
// mut repo := gs_default.get_repo(name: 'repo3' clone: true, url: 'https://github.com/Mahmoud-Emad/repo2.git')!
|
||||
|
||||
runtime := time.now().unix()
|
||||
branch_name := "branch_${runtime}"
|
||||
tag_name := "tag_${runtime}"
|
||||
branch_name := 'branch_${runtime}'
|
||||
tag_name := 'tag_${runtime}'
|
||||
repo_path := repo.get_path()!
|
||||
mut file_name := create_new_file(repo_path, runtime)!
|
||||
|
||||
@@ -51,36 +51,28 @@ repo.checkout(branch_name: branch_name, pull: false) or {
|
||||
// Check for changes and stage them if present.
|
||||
if repo.has_changes()! {
|
||||
println('Adding the changes...')
|
||||
repo.add_changes() or {
|
||||
error('Cannot add the changes due to: ${err}')
|
||||
}
|
||||
repo.add_changes() or { error('Cannot add the changes due to: ${err}') }
|
||||
}
|
||||
|
||||
// Check if a commit is needed and commit changes if necessary.
|
||||
if repo.need_commit()! {
|
||||
commit_msg := 'feat: Added ${file_name} file.'
|
||||
println('Committing the changes, Commit message: ${commit_msg}.')
|
||||
repo.commit(msg: commit_msg) or {
|
||||
error('Cannot commit the changes due to: ${err}')
|
||||
}
|
||||
repo.commit(msg: commit_msg) or { error('Cannot commit the changes due to: ${err}') }
|
||||
}
|
||||
|
||||
// Push changes to the remote repository if necessary.
|
||||
if repo.need_push()! {
|
||||
println('Pushing the changes...')
|
||||
repo.push() or {
|
||||
error('Cannot push the changes due to: ${err}')
|
||||
}
|
||||
repo.push() or { error('Cannot push the changes due to: ${err}') }
|
||||
}
|
||||
|
||||
if repo.need_pull()! {
|
||||
println('Pulling the changes.')
|
||||
repo.pull() or {
|
||||
error('Cannot pull the changes due to: ${err}')
|
||||
}
|
||||
repo.pull() or { error('Cannot pull the changes due to: ${err}') }
|
||||
}
|
||||
|
||||
// Checkout to the base branch
|
||||
// Checkout to the base branch
|
||||
repo.checkout(checkout_to_base_branch: true, pull: true) or {
|
||||
error("Couldn't checkout to branch ${branch_name} due to: ${err}")
|
||||
}
|
||||
@@ -93,12 +85,8 @@ repo.create_tag(tag_name: tag_name, checkout: false) or {
|
||||
|
||||
// Push the created tag.
|
||||
println('Pushing the tag...')
|
||||
repo.push(push_tag: true) or {
|
||||
error('Cannot push the tag due to: ${err}')
|
||||
}
|
||||
repo.push(push_tag: true) or { error('Cannot push the tag due to: ${err}') }
|
||||
|
||||
// Check if the created tag exists.
|
||||
println('Check if the created tag exists...')
|
||||
repo.is_tag_exists(tag_name: tag_name) or {
|
||||
println("Tag isn't exists.")
|
||||
}
|
||||
repo.is_tag_exists(tag_name: tag_name) or { println("Tag isn't exists.") }
|
||||
|
||||
@@ -8,16 +8,16 @@ import veb
|
||||
osal.load_env_file('${os.dir(@FILE)}/.env')!
|
||||
|
||||
mut j := juggler.configure(
|
||||
url: 'https://git.ourworld.tf/projectmycelium/itenv'
|
||||
url: 'https://git.ourworld.tf/projectmycelium/itenv'
|
||||
username: os.getenv('JUGGLER_USERNAME')
|
||||
password: os.getenv('JUGGLER_PASSWORD')
|
||||
reset: true
|
||||
reset: true
|
||||
)!
|
||||
|
||||
spawn j.run(8000)
|
||||
println(j.info())
|
||||
|
||||
for{}
|
||||
for {}
|
||||
|
||||
// TODO
|
||||
// - automate caddy install/start
|
||||
|
||||
@@ -5,11 +5,13 @@ import os
|
||||
|
||||
mut sm := startupmanager.get()!
|
||||
sm.start(
|
||||
name: 'juggler'
|
||||
cmd: 'hero juggler -secret planetfirst -u https://git.ourworld.tf/projectmycelium/itenv -reset true'
|
||||
env: {'HOME': os.home_dir()}
|
||||
name: 'juggler'
|
||||
cmd: 'hero juggler -secret planetfirst -u https://git.ourworld.tf/projectmycelium/itenv -reset true'
|
||||
env: {
|
||||
'HOME': os.home_dir()
|
||||
}
|
||||
restart: true
|
||||
) or {panic('failed to start sm ${err}')}
|
||||
) or { panic('failed to start sm ${err}') }
|
||||
|
||||
// TODO
|
||||
// - automate caddy install/start
|
||||
|
||||
@@ -3,26 +3,26 @@
|
||||
import freeflowuniverse.herolib.develop.luadns
|
||||
|
||||
fn main() {
|
||||
mut lua_dns := luadns.load('https://github.com/Incubaid/dns') or {
|
||||
eprintln('Failed to parse LuaDNS files: $err')
|
||||
return
|
||||
}
|
||||
mut lua_dns := luadns.load('https://github.com/Incubaid/dns') or {
|
||||
eprintln('Failed to parse LuaDNS files: ${err}')
|
||||
return
|
||||
}
|
||||
|
||||
lua_dns.set_domain('test.protocol.me', '65.21.132.119') or {
|
||||
eprintln('Failed to set domain: $err')
|
||||
return
|
||||
}
|
||||
lua_dns.set_domain('test.protocol.me', '65.21.132.119') or {
|
||||
eprintln('Failed to set domain: ${err}')
|
||||
return
|
||||
}
|
||||
|
||||
lua_dns.set_domain('example.protocol.me', '65.21.132.119') or {
|
||||
eprintln('Failed to set domain: $err')
|
||||
return
|
||||
}
|
||||
|
||||
for config in lua_dns.configs {
|
||||
println(config)
|
||||
}
|
||||
|
||||
for config in lua_dns.configs {
|
||||
println(config)
|
||||
}
|
||||
lua_dns.set_domain('example.protocol.me', '65.21.132.119') or {
|
||||
eprintln('Failed to set domain: ${err}')
|
||||
return
|
||||
}
|
||||
|
||||
for config in lua_dns.configs {
|
||||
println(config)
|
||||
}
|
||||
|
||||
for config in lua_dns.configs {
|
||||
println(config)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import freeflowuniverse.herolib.clients.openai as op
|
||||
mut ai_cli := op.new()!
|
||||
mut msg := []op.Message{}
|
||||
msg << op.Message{
|
||||
role: op.RoleType.user
|
||||
role: op.RoleType.user
|
||||
content: 'Say this is a test!'
|
||||
}
|
||||
mut msgs := op.Messages{
|
||||
@@ -19,26 +19,26 @@ models := ai_cli.list_models()!
|
||||
model := ai_cli.get_model(models.data[0].id)!
|
||||
print(model)
|
||||
images_created := ai_cli.create_image(op.ImageCreateArgs{
|
||||
prompt: 'Calm weather'
|
||||
prompt: 'Calm weather'
|
||||
num_images: 2
|
||||
size: op.ImageSize.size_512_512
|
||||
format: op.ImageRespType.url
|
||||
size: op.ImageSize.size_512_512
|
||||
format: op.ImageRespType.url
|
||||
})!
|
||||
print(images_created)
|
||||
images_updated := ai_cli.create_edit_image(op.ImageEditArgs{
|
||||
image_path: '/path/to/image.png'
|
||||
mask_path: '/path/to/mask.png'
|
||||
prompt: 'Calm weather'
|
||||
mask_path: '/path/to/mask.png'
|
||||
prompt: 'Calm weather'
|
||||
num_images: 2
|
||||
size: op.ImageSize.size_512_512
|
||||
format: op.ImageRespType.url
|
||||
size: op.ImageSize.size_512_512
|
||||
format: op.ImageRespType.url
|
||||
})!
|
||||
print(images_updated)
|
||||
images_variatons := ai_cli.create_variation_image(op.ImageVariationArgs{
|
||||
image_path: '/path/to/image.png'
|
||||
num_images: 2
|
||||
size: op.ImageSize.size_512_512
|
||||
format: op.ImageRespType.url
|
||||
size: op.ImageSize.size_512_512
|
||||
format: op.ImageRespType.url
|
||||
})!
|
||||
print(images_variatons)
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
|
||||
import freeflowuniverse.herolib.hero.bootstrap
|
||||
|
||||
mut al:=bootstrap.new_alpine_loader()
|
||||
mut al := bootstrap.new_alpine_loader()
|
||||
|
||||
al.start()!
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
import freeflowuniverse.herolib.hero.generation
|
||||
|
||||
generation.generate_actor(
|
||||
name: 'Example'
|
||||
name: 'Example'
|
||||
interfaces: []
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module example_actor
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.hero.baobab.actor {IActor, RunParams}
|
||||
import freeflowuniverse.herolib.hero.baobab.actor { IActor, RunParams }
|
||||
import freeflowuniverse.herolib.web.openapi
|
||||
import time
|
||||
|
||||
@@ -10,27 +10,25 @@ const openapi_spec_json = os.read_file(openapi_spec_path) or { panic(err) }
|
||||
const openapi_specification = openapi.json_decode(openapi_spec_json)!
|
||||
|
||||
struct ExampleActor {
|
||||
actor.Actor
|
||||
actor.Actor
|
||||
}
|
||||
|
||||
fn new() !ExampleActor {
|
||||
return ExampleActor{
|
||||
actor.new('example')
|
||||
}
|
||||
return ExampleActor{actor.new('example')}
|
||||
}
|
||||
|
||||
pub fn run() ! {
|
||||
mut a_ := new()!
|
||||
mut a := IActor(a_)
|
||||
a.run()!
|
||||
mut a_ := new()!
|
||||
mut a := IActor(a_)
|
||||
a.run()!
|
||||
}
|
||||
|
||||
pub fn run_server(params RunParams) ! {
|
||||
mut a := new()!
|
||||
mut server := actor.new_server(
|
||||
redis_url: 'localhost:6379'
|
||||
redis_queue: a.name
|
||||
openapi_spec: openapi_specification
|
||||
)!
|
||||
server.run(params)
|
||||
}
|
||||
mut a := new()!
|
||||
mut server := actor.new_server(
|
||||
redis_url: 'localhost:6379'
|
||||
redis_queue: a.name
|
||||
openapi_spec: openapi_specification
|
||||
)!
|
||||
server.run(params)
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@ module example_actor
|
||||
const test_port = 8101
|
||||
|
||||
pub fn test_new() ! {
|
||||
new() or {
|
||||
return error('Failed to create actor:\n${err}')
|
||||
}
|
||||
new() or { return error('Failed to create actor:\n${err}') }
|
||||
}
|
||||
|
||||
pub fn test_run() ! {
|
||||
@@ -14,4 +12,4 @@ pub fn test_run() ! {
|
||||
|
||||
pub fn test_run_server() ! {
|
||||
spawn run_server(port: test_port)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module example_actor
|
||||
|
||||
pub fn (mut a ExampleActor) handle(method string, data string) !string {
|
||||
return data
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -6,210 +6,229 @@ import veb
|
||||
import json
|
||||
import x.json2
|
||||
import net.http
|
||||
import freeflowuniverse.herolib.web.openapi {Server, Context, Request, Response}
|
||||
import freeflowuniverse.herolib.hero.processor {Processor, ProcedureCall, ProcedureResponse, ProcessParams}
|
||||
import freeflowuniverse.herolib.web.openapi
|
||||
import freeflowuniverse.herolib.hero.processor
|
||||
import freeflowuniverse.herolib.clients.redisclient
|
||||
|
||||
@[heap]
|
||||
struct Actor {
|
||||
mut:
|
||||
rpc redisclient.RedisRpc
|
||||
data_store DataStore
|
||||
rpc redisclient.RedisRpc
|
||||
data_store DataStore
|
||||
}
|
||||
|
||||
pub struct DataStore {
|
||||
mut:
|
||||
pets map[int]Pet
|
||||
orders map[int]Order
|
||||
users map[int]User
|
||||
pets map[int]Pet
|
||||
orders map[int]Order
|
||||
users map[int]User
|
||||
}
|
||||
|
||||
struct Pet {
|
||||
id int
|
||||
name string
|
||||
tag string
|
||||
id int
|
||||
name string
|
||||
tag string
|
||||
}
|
||||
|
||||
struct Order {
|
||||
id int
|
||||
pet_id int
|
||||
quantity int
|
||||
ship_date string
|
||||
status string
|
||||
complete bool
|
||||
id int
|
||||
pet_id int
|
||||
quantity int
|
||||
ship_date string
|
||||
status string
|
||||
complete bool
|
||||
}
|
||||
|
||||
struct User {
|
||||
id int
|
||||
username string
|
||||
email string
|
||||
phone string
|
||||
id int
|
||||
username string
|
||||
email string
|
||||
phone string
|
||||
}
|
||||
|
||||
// Entry point for the actor
|
||||
fn main() {
|
||||
mut redis := redisclient.new('localhost:6379') or {panic(err)}
|
||||
mut rpc := redis.rpc_get('procedure_queue')
|
||||
mut redis := redisclient.new('localhost:6379') or { panic(err) }
|
||||
mut rpc := redis.rpc_get('procedure_queue')
|
||||
|
||||
mut actor := Actor{
|
||||
rpc: rpc
|
||||
data_store: DataStore{}
|
||||
}
|
||||
mut actor := Actor{
|
||||
rpc: rpc
|
||||
data_store: DataStore{}
|
||||
}
|
||||
|
||||
actor.listen() or {panic(err)}
|
||||
actor.listen() or { panic(err) }
|
||||
}
|
||||
|
||||
// Actor listens to the Redis queue for method invocations
|
||||
fn (mut actor Actor) listen() ! {
|
||||
println('Actor started and listening for tasks...')
|
||||
for {
|
||||
actor.rpc.process(actor.handle_method)!
|
||||
time.sleep(time.millisecond * 100) // Prevent CPU spinning
|
||||
}
|
||||
println('Actor started and listening for tasks...')
|
||||
for {
|
||||
actor.rpc.process(actor.handle_method)!
|
||||
time.sleep(time.millisecond * 100) // Prevent CPU spinning
|
||||
}
|
||||
}
|
||||
|
||||
// Handle method invocations
|
||||
fn (mut actor Actor) handle_method(cmd string, data string) !string {
|
||||
println('debugzo received rpc ${cmd}:${data}')
|
||||
param_anys := json2.raw_decode(data)!.arr()
|
||||
match cmd {
|
||||
'listPets' {
|
||||
pets := if param_anys.len == 0 {
|
||||
actor.data_store.list_pets()
|
||||
} else {
|
||||
params := json.decode(ListPetParams, param_anys[0].str())!
|
||||
actor.data_store.list_pets(params)
|
||||
}
|
||||
return json.encode(pets)
|
||||
}
|
||||
'createPet' {
|
||||
response := if param_anys.len == 0 {
|
||||
return error('at least data expected')
|
||||
} else if param_anys.len == 1 {
|
||||
payload := json.decode(NewPet, param_anys[0].str())!
|
||||
actor.data_store.create_pet(payload)
|
||||
} else {
|
||||
return error('expected 1 param, found too many')
|
||||
}
|
||||
// data := json.decode(NewPet, data) or { return error('Invalid pet data: $err') }
|
||||
// created_pet := actor.data_store.create_pet(pet)
|
||||
return json.encode(response)
|
||||
}
|
||||
'getPet' {
|
||||
response := if param_anys.len == 0 {
|
||||
return error('at least data expected')
|
||||
} else if param_anys.len == 1 {
|
||||
payload := param_anys[0].int()
|
||||
actor.data_store.get_pet(payload)!
|
||||
} else {
|
||||
return error('expected 1 param, found too many')
|
||||
}
|
||||
|
||||
return json.encode(response)
|
||||
}
|
||||
'deletePet' {
|
||||
params := json.decode(map[string]int, data) or { return error('Invalid params: $err') }
|
||||
actor.data_store.delete_pet(params['petId']) or { return error('Pet not found: $err') }
|
||||
return json.encode({'message': 'Pet deleted'})
|
||||
}
|
||||
'listOrders' {
|
||||
orders := actor.data_store.list_orders()
|
||||
return json.encode(orders)
|
||||
}
|
||||
'getOrder' {
|
||||
params := json.decode(map[string]int, data) or { return error('Invalid params: $err') }
|
||||
order := actor.data_store.get_order(params['orderId']) or {
|
||||
return error('Order not found: $err')
|
||||
}
|
||||
return json.encode(order)
|
||||
}
|
||||
'deleteOrder' {
|
||||
params := json.decode(map[string]int, data) or { return error('Invalid params: $err') }
|
||||
actor.data_store.delete_order(params['orderId']) or {
|
||||
return error('Order not found: $err')
|
||||
}
|
||||
return json.encode({'message': 'Order deleted'})
|
||||
}
|
||||
'createUser' {
|
||||
user := json.decode(NewUser, data) or { return error('Invalid user data: $err') }
|
||||
created_user := actor.data_store.create_user(user)
|
||||
return json.encode(created_user)
|
||||
}
|
||||
else {
|
||||
return error('Unknown method: $cmd')
|
||||
}
|
||||
}
|
||||
println('debugzo received rpc ${cmd}:${data}')
|
||||
param_anys := json2.raw_decode(data)!.arr()
|
||||
match cmd {
|
||||
'listPets' {
|
||||
pets := if param_anys.len == 0 {
|
||||
actor.data_store.list_pets()
|
||||
} else {
|
||||
params := json.decode(ListPetParams, param_anys[0].str())!
|
||||
actor.data_store.list_pets(params)
|
||||
}
|
||||
return json.encode(pets)
|
||||
}
|
||||
'createPet' {
|
||||
response := if param_anys.len == 0 {
|
||||
return error('at least data expected')
|
||||
} else if param_anys.len == 1 {
|
||||
payload := json.decode(NewPet, param_anys[0].str())!
|
||||
actor.data_store.create_pet(payload)
|
||||
} else {
|
||||
return error('expected 1 param, found too many')
|
||||
}
|
||||
// data := json.decode(NewPet, data) or { return error('Invalid pet data: $err') }
|
||||
// created_pet := actor.data_store.create_pet(pet)
|
||||
return json.encode(response)
|
||||
}
|
||||
'getPet' {
|
||||
response := if param_anys.len == 0 {
|
||||
return error('at least data expected')
|
||||
} else if param_anys.len == 1 {
|
||||
payload := param_anys[0].int()
|
||||
actor.data_store.get_pet(payload)!
|
||||
} else {
|
||||
return error('expected 1 param, found too many')
|
||||
}
|
||||
|
||||
return json.encode(response)
|
||||
}
|
||||
'deletePet' {
|
||||
params := json.decode(map[string]int, data) or {
|
||||
return error('Invalid params: ${err}')
|
||||
}
|
||||
actor.data_store.delete_pet(params['petId']) or {
|
||||
return error('Pet not found: ${err}')
|
||||
}
|
||||
return json.encode({
|
||||
'message': 'Pet deleted'
|
||||
})
|
||||
}
|
||||
'listOrders' {
|
||||
orders := actor.data_store.list_orders()
|
||||
return json.encode(orders)
|
||||
}
|
||||
'getOrder' {
|
||||
params := json.decode(map[string]int, data) or {
|
||||
return error('Invalid params: ${err}')
|
||||
}
|
||||
order := actor.data_store.get_order(params['orderId']) or {
|
||||
return error('Order not found: ${err}')
|
||||
}
|
||||
return json.encode(order)
|
||||
}
|
||||
'deleteOrder' {
|
||||
params := json.decode(map[string]int, data) or {
|
||||
return error('Invalid params: ${err}')
|
||||
}
|
||||
actor.data_store.delete_order(params['orderId']) or {
|
||||
return error('Order not found: ${err}')
|
||||
}
|
||||
return json.encode({
|
||||
'message': 'Order deleted'
|
||||
})
|
||||
}
|
||||
'createUser' {
|
||||
user := json.decode(NewUser, data) or { return error('Invalid user data: ${err}') }
|
||||
created_user := actor.data_store.create_user(user)
|
||||
return json.encode(created_user)
|
||||
}
|
||||
else {
|
||||
return error('Unknown method: ${cmd}')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@[params]
|
||||
pub struct ListPetParams {
|
||||
limit u32
|
||||
limit u32
|
||||
}
|
||||
|
||||
// DataStore methods for managing data
|
||||
fn (mut store DataStore) list_pets(params ListPetParams) []Pet {
|
||||
if params.limit > 0 {
|
||||
if params.limit >= store.pets.values().len {
|
||||
return store.pets.values()
|
||||
}
|
||||
return store.pets.values()[..params.limit]
|
||||
}
|
||||
return store.pets.values()
|
||||
if params.limit > 0 {
|
||||
if params.limit >= store.pets.values().len {
|
||||
return store.pets.values()
|
||||
}
|
||||
return store.pets.values()[..params.limit]
|
||||
}
|
||||
return store.pets.values()
|
||||
}
|
||||
|
||||
fn (mut store DataStore) create_pet(new_pet NewPet) Pet {
|
||||
id := store.pets.keys().len + 1
|
||||
pet := Pet{id: id, name: new_pet.name, tag: new_pet.tag}
|
||||
store.pets[id] = pet
|
||||
return pet
|
||||
id := store.pets.keys().len + 1
|
||||
pet := Pet{
|
||||
id: id
|
||||
name: new_pet.name
|
||||
tag: new_pet.tag
|
||||
}
|
||||
store.pets[id] = pet
|
||||
return pet
|
||||
}
|
||||
|
||||
fn (mut store DataStore) get_pet(id int) !Pet {
|
||||
return store.pets[id] or {
|
||||
return error('Pet with id ${id} not found.')
|
||||
}
|
||||
return store.pets[id] or { return error('Pet with id ${id} not found.') }
|
||||
}
|
||||
|
||||
fn (mut store DataStore) delete_pet(id int) ! {
|
||||
if id in store.pets {
|
||||
store.pets.delete(id)
|
||||
return
|
||||
}
|
||||
return error('Pet not found')
|
||||
if id in store.pets {
|
||||
store.pets.delete(id)
|
||||
return
|
||||
}
|
||||
return error('Pet not found')
|
||||
}
|
||||
|
||||
fn (mut store DataStore) list_orders() []Order {
|
||||
return store.orders.values()
|
||||
return store.orders.values()
|
||||
}
|
||||
|
||||
fn (mut store DataStore) get_order(id int) !Order {
|
||||
return store.orders[id] or { none }
|
||||
return store.orders[id] or { none }
|
||||
}
|
||||
|
||||
fn (mut store DataStore) delete_order(id int) ! {
|
||||
if id in store.orders {
|
||||
store.orders.delete(id)
|
||||
return
|
||||
}
|
||||
return error('Order not found')
|
||||
if id in store.orders {
|
||||
store.orders.delete(id)
|
||||
return
|
||||
}
|
||||
return error('Order not found')
|
||||
}
|
||||
|
||||
fn (mut store DataStore) create_user(new_user NewUser) User {
|
||||
id := store.users.keys().len + 1
|
||||
user := User{id: id, username: new_user.username, email: new_user.email, phone: new_user.phone}
|
||||
store.users[id] = user
|
||||
return user
|
||||
id := store.users.keys().len + 1
|
||||
user := User{
|
||||
id: id
|
||||
username: new_user.username
|
||||
email: new_user.email
|
||||
phone: new_user.phone
|
||||
}
|
||||
store.users[id] = user
|
||||
return user
|
||||
}
|
||||
|
||||
// NewPet struct for creating a pet
|
||||
struct NewPet {
|
||||
name string
|
||||
tag string
|
||||
name string
|
||||
tag string
|
||||
}
|
||||
|
||||
// NewUser struct for creating a user
|
||||
struct NewUser {
|
||||
username string
|
||||
email string
|
||||
phone string
|
||||
username string
|
||||
email string
|
||||
phone string
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import os
|
||||
import time
|
||||
import veb
|
||||
import json
|
||||
import x.json2 {Any}
|
||||
import x.json2 { Any }
|
||||
import net.http
|
||||
import freeflowuniverse.herolib.data.jsonschema {Schema}
|
||||
import freeflowuniverse.herolib.web.openapi {Server, Context, Request, Response}
|
||||
import freeflowuniverse.herolib.hero.processor {Processor, ProcedureCall, ProcedureResponse, ProcessParams}
|
||||
import freeflowuniverse.herolib.data.jsonschema { Schema }
|
||||
import freeflowuniverse.herolib.web.openapi { Context, Request, Response, Server }
|
||||
import freeflowuniverse.herolib.hero.processor { ProcedureCall, ProcessParams, Processor }
|
||||
import freeflowuniverse.herolib.clients.redisclient
|
||||
|
||||
const spec_path = '${os.dir(@FILE)}/data/openapi.json'
|
||||
@@ -16,126 +16,123 @@ const spec_json = os.read_file(spec_path) or { panic(err) }
|
||||
|
||||
// Main function to start the server
|
||||
fn main() {
|
||||
// Initialize the Redis client and RPC mechanism
|
||||
mut redis := redisclient.new('localhost:6379')!
|
||||
mut rpc := redis.rpc_get('procedure_queue')
|
||||
// Initialize the Redis client and RPC mechanism
|
||||
mut redis := redisclient.new('localhost:6379')!
|
||||
mut rpc := redis.rpc_get('procedure_queue')
|
||||
|
||||
// Initialize the server
|
||||
mut server := &Server{
|
||||
specification: openapi.json_decode(spec_json)!
|
||||
handler: Handler{
|
||||
processor: Processor{
|
||||
rpc: rpc
|
||||
}
|
||||
}
|
||||
}
|
||||
// Initialize the server
|
||||
mut server := &Server{
|
||||
specification: openapi.json_decode(spec_json)!
|
||||
handler: Handler{
|
||||
processor: Processor{
|
||||
rpc: rpc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start the server
|
||||
veb.run[Server, Context](mut server, 8080)
|
||||
// Start the server
|
||||
veb.run[Server, Context](mut server, 8080)
|
||||
}
|
||||
|
||||
pub struct Handler {
|
||||
mut:
|
||||
processor Processor
|
||||
mut:
|
||||
processor Processor
|
||||
}
|
||||
|
||||
fn (mut handler Handler) handle(request Request) !Response {
|
||||
// Convert incoming OpenAPI request to a procedure call
|
||||
mut params := []string{}
|
||||
// Convert incoming OpenAPI request to a procedure call
|
||||
mut params := []string{}
|
||||
|
||||
if request.arguments.len > 0 {
|
||||
params = request.arguments.values().map(it.str()).clone()
|
||||
}
|
||||
if request.arguments.len > 0 {
|
||||
params = request.arguments.values().map(it.str()).clone()
|
||||
}
|
||||
|
||||
if request.body != '' {
|
||||
params << request.body
|
||||
}
|
||||
if request.body != '' {
|
||||
params << request.body
|
||||
}
|
||||
|
||||
if request.parameters.len != 0 {
|
||||
mut param_map := map[string]Any{} // Store parameters with correct types
|
||||
if request.parameters.len != 0 {
|
||||
mut param_map := map[string]Any{} // Store parameters with correct types
|
||||
|
||||
for param_name, param_value in request.parameters {
|
||||
operation_param := request.operation.parameters.filter(it.name == param_name)
|
||||
if operation_param.len > 0 {
|
||||
param_schema := operation_param[0].schema as Schema
|
||||
param_type := param_schema.typ
|
||||
param_format := param_schema.format
|
||||
for param_name, param_value in request.parameters {
|
||||
operation_param := request.operation.parameters.filter(it.name == param_name)
|
||||
if operation_param.len > 0 {
|
||||
param_schema := operation_param[0].schema as Schema
|
||||
param_type := param_schema.typ
|
||||
param_format := param_schema.format
|
||||
|
||||
// Convert parameter value to corresponding type
|
||||
match param_type {
|
||||
'integer' {
|
||||
match param_format {
|
||||
'int32' {
|
||||
param_map[param_name] = param_value.int() // Convert to int
|
||||
}
|
||||
'int64' {
|
||||
param_map[param_name] = param_value.i64() // Convert to i64
|
||||
}
|
||||
else {
|
||||
param_map[param_name] = param_value.int() // Default to int
|
||||
}
|
||||
}
|
||||
}
|
||||
'string' {
|
||||
param_map[param_name] = param_value // Already a string
|
||||
}
|
||||
'boolean' {
|
||||
param_map[param_name] = param_value.bool() // Convert to bool
|
||||
}
|
||||
'number' {
|
||||
match param_format {
|
||||
'float' {
|
||||
param_map[param_name] = param_value.f32() // Convert to float
|
||||
}
|
||||
'double' {
|
||||
param_map[param_name] = param_value.f64() // Convert to double
|
||||
}
|
||||
else {
|
||||
param_map[param_name] = param_value.f64() // Default to double
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
param_map[param_name] = param_value // Leave as string for unknown types
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If the parameter is not defined in the OpenAPI operation, skip or log it
|
||||
println('Unknown parameter: $param_name')
|
||||
}
|
||||
}
|
||||
// Convert parameter value to corresponding type
|
||||
match param_type {
|
||||
'integer' {
|
||||
match param_format {
|
||||
'int32' {
|
||||
param_map[param_name] = param_value.int() // Convert to int
|
||||
}
|
||||
'int64' {
|
||||
param_map[param_name] = param_value.i64() // Convert to i64
|
||||
}
|
||||
else {
|
||||
param_map[param_name] = param_value.int() // Default to int
|
||||
}
|
||||
}
|
||||
}
|
||||
'string' {
|
||||
param_map[param_name] = param_value // Already a string
|
||||
}
|
||||
'boolean' {
|
||||
param_map[param_name] = param_value.bool() // Convert to bool
|
||||
}
|
||||
'number' {
|
||||
match param_format {
|
||||
'float' {
|
||||
param_map[param_name] = param_value.f32() // Convert to float
|
||||
}
|
||||
'double' {
|
||||
param_map[param_name] = param_value.f64() // Convert to double
|
||||
}
|
||||
else {
|
||||
param_map[param_name] = param_value.f64() // Default to double
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
param_map[param_name] = param_value // Leave as string for unknown types
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If the parameter is not defined in the OpenAPI operation, skip or log it
|
||||
println('Unknown parameter: ${param_name}')
|
||||
}
|
||||
}
|
||||
|
||||
// Encode the parameter map to JSON if needed
|
||||
params << json.encode(param_map.str())
|
||||
}
|
||||
// Encode the parameter map to JSON if needed
|
||||
params << json.encode(param_map.str())
|
||||
}
|
||||
|
||||
call := ProcedureCall{
|
||||
method: request.operation.operation_id
|
||||
params: "[${params.join(',')}]" // Keep as a string since ProcedureCall expects a string
|
||||
}
|
||||
call := ProcedureCall{
|
||||
method: request.operation.operation_id
|
||||
params: '[${params.join(',')}]' // Keep as a string since ProcedureCall expects a string
|
||||
}
|
||||
|
||||
// Process the procedure call
|
||||
procedure_response := handler.processor.process(
|
||||
call,
|
||||
ProcessParams{
|
||||
timeout: 30 // Set timeout in seconds
|
||||
}
|
||||
) or {
|
||||
// Handle ProcedureError
|
||||
if err is processor.ProcedureError {
|
||||
return Response{
|
||||
status: http.status_from_int(err.code()) // Map ProcedureError reason to HTTP status code
|
||||
body: json.encode({
|
||||
'error': err.msg()
|
||||
})
|
||||
}
|
||||
}
|
||||
return error('Unexpected error: $err')
|
||||
}
|
||||
// Process the procedure call
|
||||
procedure_response := handler.processor.process(call, ProcessParams{
|
||||
timeout: 30 // Set timeout in seconds
|
||||
}) or {
|
||||
// Handle ProcedureError
|
||||
if err is processor.ProcedureError {
|
||||
return Response{
|
||||
status: http.status_from_int(err.code()) // Map ProcedureError reason to HTTP status code
|
||||
body: json.encode({
|
||||
'error': err.msg()
|
||||
})
|
||||
}
|
||||
}
|
||||
return error('Unexpected error: ${err}')
|
||||
}
|
||||
|
||||
// Convert returned procedure response to OpenAPI response
|
||||
return Response{
|
||||
status: http.Status.ok // Assuming success if no error
|
||||
body: procedure_response.result
|
||||
}
|
||||
// Convert returned procedure response to OpenAPI response
|
||||
return Response{
|
||||
status: http.Status.ok // Assuming success if no error
|
||||
body: procedure_response.result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,4 +4,4 @@ import freeflowuniverse.herolib.installers.sysadmintools.actrunner
|
||||
import freeflowuniverse.herolib.installers.virt.herocontainers
|
||||
|
||||
actrunner.install()!
|
||||
//herocontainers.start()!
|
||||
// herocontainers.start()!
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
|
||||
import freeflowuniverse.herolib.installers.infra.coredns as coredns_installer
|
||||
|
||||
|
||||
coredns_installer.install()!
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import freeflowuniverse.herolib.installers.sysadmintools.daguserver
|
||||
import freeflowuniverse.herolib.installers.infra.zinit
|
||||
|
||||
//make sure zinit is there and running, will restart it if needed
|
||||
mut z:=zinit.get()!
|
||||
// make sure zinit is there and running, will restart it if needed
|
||||
mut z := zinit.get()!
|
||||
z.destroy()!
|
||||
z.start()!
|
||||
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
|
||||
import freeflowuniverse.herolib.installers.sysadmintools.daguserver
|
||||
|
||||
//will call the installer underneith
|
||||
// will call the installer underneith
|
||||
|
||||
mut dserver:=daguserver.new()!
|
||||
mut dserver := daguserver.new()!
|
||||
dserver.install()!
|
||||
dserver.restart()!
|
||||
|
||||
println("DAGU installed & running")
|
||||
|
||||
mut dagucl:=dserver.client()!
|
||||
println('DAGU installed & running')
|
||||
|
||||
mut dagucl := dserver.client()!
|
||||
|
||||
// name string // The name of the DAG, which is optional. The default name is the name of the file.
|
||||
// description ?string // A brief description of the DAG.
|
||||
@@ -23,9 +22,8 @@ mut dagucl:=dserver.client()!
|
||||
// max_active_runs ?int // The maximum number of parallel running steps.
|
||||
// max_cleanup_time_sec ?int // The maximum time to wait after sending a TERM signal to running steps before killing them.
|
||||
|
||||
|
||||
mut mydag:=dagucl.dag_new(
|
||||
nameswhere:"test11"
|
||||
mut mydag := dagucl.dag_new(
|
||||
nameswhere: 'test11'
|
||||
)
|
||||
|
||||
// nr int @[required]
|
||||
@@ -43,19 +41,18 @@ mut mydag:=dagucl.dag_new(
|
||||
// retry_interval int = 5
|
||||
|
||||
mydag.step_add(
|
||||
script : "ls /tmp"
|
||||
retry_interval:1
|
||||
retry_nr:3
|
||||
)!
|
||||
script: 'ls /tmp'
|
||||
retry_interval: 1
|
||||
retry_nr: 3
|
||||
)!
|
||||
|
||||
mydag.step_add(
|
||||
script : "ls /root"
|
||||
retry_interval:1
|
||||
retry_nr:3
|
||||
)!
|
||||
script: 'ls /root'
|
||||
retry_interval: 1
|
||||
retry_nr: 3
|
||||
)!
|
||||
|
||||
|
||||
dagresult:=dagucl.dag_register(mydag,start:true)!
|
||||
dagresult := dagucl.dag_register(mydag, start: true)!
|
||||
println(dagresult)
|
||||
|
||||
println("DAGU should have new steps")
|
||||
println('DAGU should have new steps')
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
import freeflowuniverse.herolib.installers.gitea
|
||||
|
||||
mut g := gitea.new(
|
||||
passwd: '123'
|
||||
postgresql_path: '/tmp/db'
|
||||
passwd: '123'
|
||||
postgresql_path: '/tmp/db'
|
||||
postgresql_reset: true
|
||||
domain: 'git.meet.tf'
|
||||
appname: 'ourworld'
|
||||
domain: 'git.meet.tf'
|
||||
appname: 'ourworld'
|
||||
)!
|
||||
// postgresql will be same passwd
|
||||
g.restart()!
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.installers.threefold.griddriver
|
||||
|
||||
mut griddriver_installer := griddriver.get()!
|
||||
griddriver_installer.install()!
|
||||
|
||||
@@ -5,4 +5,4 @@ import freeflowuniverse.herolib.installers.sysadmintools.daguserver
|
||||
import freeflowuniverse.herolib.installers.sysadmintools.b2 as b2_installer
|
||||
|
||||
vlang.v_analyzer_install()!
|
||||
daguserver.new()! //will install & start a daguserver
|
||||
daguserver.new()! // will install & start a daguserver
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
|
||||
import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.installers.lang.golang
|
||||
|
||||
import freeflowuniverse.herolib.installers.virt.podman as podman_installer
|
||||
import freeflowuniverse.herolib.installers.virt.buildah as buildah_installer
|
||||
|
||||
mut podman_installer0:= podman_installer.get()!
|
||||
mut buildah_installer0:= buildah_installer.get()!
|
||||
mut podman_installer0 := podman_installer.get()!
|
||||
mut buildah_installer0 := buildah_installer.get()!
|
||||
|
||||
//podman_installer0.destroy()! //will remove all
|
||||
// podman_installer0.destroy()! //will remove all
|
||||
|
||||
podman_installer0.install()!
|
||||
buildah_installer0.install()!
|
||||
|
||||
@@ -20,10 +20,8 @@ mycelium_installer.install()!
|
||||
// mut screens:=screen.new()!
|
||||
// println(screens)
|
||||
|
||||
|
||||
// dagu_installer.check(secret:"1234")!
|
||||
|
||||
|
||||
vlang.v_analyzer_install()!
|
||||
|
||||
// b2_installer.install()!
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.installers.net.mycelium as mycelium_installer
|
||||
|
||||
mycelium_installer.start()!
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
|
||||
import time
|
||||
|
||||
import freeflowuniverse.herolib.installers.db.postgresql
|
||||
|
||||
mut db:= postgresql.get()!
|
||||
mut db := postgresql.get()!
|
||||
|
||||
// db.destroy()!
|
||||
db.start()!
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
|
||||
import freeflowuniverse.herolib.installers.virt.youki
|
||||
|
||||
mut youki_installer:= youki.get()!
|
||||
mut youki_installer := youki.get()!
|
||||
|
||||
youki_installer.install()!
|
||||
|
||||
@@ -1,33 +1,28 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
|
||||
import freeflowuniverse.herolib.lang.python
|
||||
import json
|
||||
|
||||
import json
|
||||
|
||||
pub struct Person {
|
||||
name string
|
||||
age int
|
||||
is_member bool
|
||||
skills []string
|
||||
name string
|
||||
age int
|
||||
is_member bool
|
||||
skills []string
|
||||
}
|
||||
|
||||
mut py := python.new(name: 'test')! // a python env with name test
|
||||
// py.update()!
|
||||
py.pip('ipython')!
|
||||
|
||||
mut py:=python.new(name:'test')! //a python env with name test
|
||||
//py.update()!
|
||||
py.pip("ipython")!
|
||||
nrcount := 5
|
||||
cmd := $tmpl('pythonexample.py')
|
||||
|
||||
|
||||
nrcount:=5
|
||||
cmd:=$tmpl("pythonexample.py")
|
||||
|
||||
mut res:=""
|
||||
for i in 0..5{
|
||||
mut res := ''
|
||||
for i in 0 .. 5 {
|
||||
println(i)
|
||||
res=py.exec(cmd:cmd)!
|
||||
|
||||
res = py.exec(cmd: cmd)!
|
||||
}
|
||||
//res:=py.exec(cmd:cmd)!
|
||||
// res:=py.exec(cmd:cmd)!
|
||||
|
||||
person:=json.decode(Person,res)!
|
||||
person := json.decode(Person, res)!
|
||||
println(person)
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
import freeflowuniverse.herolib.osal { download }
|
||||
|
||||
mut p := download(
|
||||
url: 'https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.3/@name'
|
||||
name: 'echarts.min.js'
|
||||
reset: false
|
||||
dest: '/tmp/@name'
|
||||
url: 'https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.3/@name'
|
||||
name: 'echarts.min.js'
|
||||
reset: false
|
||||
dest: '/tmp/@name'
|
||||
minsize_kb: 1000
|
||||
maxsize_kb: 5000
|
||||
)!
|
||||
|
||||
@@ -6,6 +6,18 @@ import freeflowuniverse.herolib.builder
|
||||
// address string @[required]
|
||||
// remote_port int @[required]
|
||||
|
||||
builder.portforward_to_local(name:"holo1",address:"[302:1d81:cef8:3049:fbe1:69ba:bd8c:52ec]",remote_port:45579)!
|
||||
builder.portforward_to_local(name:"holo2",address:"[302:1d81:cef8:3049:fbe1:69ba:bd8c:52ec]",remote_port:34639)!
|
||||
builder.portforward_to_local(name:"holoui",address:"[302:1d81:cef8:3049:fbe1:69ba:bd8c:52ec]",remote_port:8282)!
|
||||
builder.portforward_to_local(
|
||||
name: 'holo1'
|
||||
address: '[302:1d81:cef8:3049:fbe1:69ba:bd8c:52ec]'
|
||||
remote_port: 45579
|
||||
)!
|
||||
builder.portforward_to_local(
|
||||
name: 'holo2'
|
||||
address: '[302:1d81:cef8:3049:fbe1:69ba:bd8c:52ec]'
|
||||
remote_port: 34639
|
||||
)!
|
||||
builder.portforward_to_local(
|
||||
name: 'holoui'
|
||||
address: '[302:1d81:cef8:3049:fbe1:69ba:bd8c:52ec]'
|
||||
remote_port: 8282
|
||||
)!
|
||||
|
||||
@@ -8,9 +8,8 @@ fn main() {
|
||||
}
|
||||
|
||||
fn do1() ! {
|
||||
|
||||
mut p := os.new_process("/bin/bash")
|
||||
p.set_work_folder("/tmp")
|
||||
mut p := os.new_process('/bin/bash')
|
||||
p.set_work_folder('/tmp')
|
||||
p.set_redirect_stdio()
|
||||
p.use_stdio_ctl = true
|
||||
p.use_pgroup = true
|
||||
@@ -18,9 +17,9 @@ fn do1() ! {
|
||||
p.run()
|
||||
// p.set_args("")
|
||||
// time.sleep(100 * time.millisecond)
|
||||
println( "alive: ${p.is_alive()}")
|
||||
println('alive: ${p.is_alive()}')
|
||||
assert p.is_alive()
|
||||
|
||||
|
||||
defer {
|
||||
p.wait()
|
||||
p.close()
|
||||
@@ -33,32 +32,28 @@ fn do1() ! {
|
||||
// println(p.stderr_slurp())
|
||||
// println(3)
|
||||
// }
|
||||
mut counter:=0
|
||||
mut counter := 0
|
||||
for {
|
||||
counter+=1
|
||||
counter += 1
|
||||
println(counter)
|
||||
out:=p.pipe_read(.stdout) or {""}
|
||||
if out.len>0{
|
||||
println("o")
|
||||
out := p.pipe_read(.stdout) or { '' }
|
||||
if out.len > 0 {
|
||||
println('o')
|
||||
println(out)
|
||||
}
|
||||
err:=p.pipe_read(.stderr) or {""}
|
||||
if err.len>0{
|
||||
println("e")
|
||||
err := p.pipe_read(.stderr) or { '' }
|
||||
if err.len > 0 {
|
||||
println('e')
|
||||
println(err)
|
||||
}
|
||||
time.sleep(100 * time.millisecond)
|
||||
if counter==2{
|
||||
if counter == 2 {
|
||||
p.stdin_write("echo '111'\n")
|
||||
// os.fd_close(p.stdio_fd[0])
|
||||
}
|
||||
if counter==20{
|
||||
if counter == 20 {
|
||||
p.stdin_write("echo '2222'\n")
|
||||
// os.fd_close(p.stdio_fd[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,19 +8,18 @@ fn main() {
|
||||
}
|
||||
|
||||
fn do1() ! {
|
||||
|
||||
mut p := os.new_process("/opt/homebrew/bin/python3")
|
||||
p.set_work_folder("/tmp")
|
||||
mut p := os.new_process('/opt/homebrew/bin/python3')
|
||||
p.set_work_folder('/tmp')
|
||||
p.set_redirect_stdio()
|
||||
p.use_stdio_ctl = true
|
||||
p.use_pgroup = true
|
||||
p.set_args(['-i','-q'])
|
||||
p.set_args(['-i', '-q'])
|
||||
p.run()
|
||||
// p.set_args("")
|
||||
// time.sleep(100 * time.millisecond)
|
||||
println( "alive: ${p.is_alive()}")
|
||||
println('alive: ${p.is_alive()}')
|
||||
assert p.is_alive()
|
||||
|
||||
|
||||
defer {
|
||||
p.wait()
|
||||
p.close()
|
||||
@@ -33,99 +32,88 @@ fn do1() ! {
|
||||
// println(p.stderr_slurp())
|
||||
// println(3)
|
||||
// }
|
||||
mut counter:=0
|
||||
mut counter := 0
|
||||
for {
|
||||
counter+=1
|
||||
counter += 1
|
||||
println(counter)
|
||||
out:=p.pipe_read(.stdout) or {""}
|
||||
if out.len>0{
|
||||
println("o")
|
||||
out := p.pipe_read(.stdout) or { '' }
|
||||
if out.len > 0 {
|
||||
println('o')
|
||||
println(out)
|
||||
}
|
||||
err:=p.pipe_read(.stderr) or {""}
|
||||
if err.len>0{
|
||||
println("e")
|
||||
err := p.pipe_read(.stderr) or { '' }
|
||||
if err.len > 0 {
|
||||
println('e')
|
||||
println(err)
|
||||
}
|
||||
time.sleep(100 * time.millisecond)
|
||||
if counter==2{
|
||||
if counter == 2 {
|
||||
p.stdin_write("print('something')\n\n\n")
|
||||
// os.fd_close(p.stdio_fd[0])
|
||||
}
|
||||
if counter==20{
|
||||
if counter == 20 {
|
||||
p.stdin_write("print('something else')\n\n\n")
|
||||
// os.fd_close(p.stdio_fd[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
fn do2() ! {
|
||||
|
||||
mut p := os.new_process("/opt/homebrew/bin/python3")
|
||||
p.set_work_folder("/tmp")
|
||||
mut p := os.new_process('/opt/homebrew/bin/python3')
|
||||
p.set_work_folder('/tmp')
|
||||
p.set_redirect_stdio()
|
||||
p.use_stdio_ctl = true
|
||||
p.use_pgroup = true
|
||||
p.run()
|
||||
// p.set_args("")
|
||||
// time.sleep(100 * time.millisecond)
|
||||
println( "alive: ${p.is_alive()}")
|
||||
println('alive: ${p.is_alive()}')
|
||||
assert p.is_alive()
|
||||
|
||||
|
||||
defer {
|
||||
p.wait()
|
||||
p.close()
|
||||
}
|
||||
|
||||
for {
|
||||
fdi:=p.stdio_fd[0]
|
||||
fdo:=p.stdio_fd[1]
|
||||
fde:=p.stdio_fd[2]
|
||||
fdi := p.stdio_fd[0]
|
||||
fdo := p.stdio_fd[1]
|
||||
fde := p.stdio_fd[2]
|
||||
println(1)
|
||||
if os.fd_is_pending(fdo){
|
||||
if os.fd_is_pending(fdo) {
|
||||
println(1.1)
|
||||
println(os.fd_slurp(fdo))
|
||||
}
|
||||
println(2)
|
||||
if os.fd_is_pending(fde){
|
||||
if os.fd_is_pending(fde) {
|
||||
println(2.1)
|
||||
println(os.fd_slurp(fde))
|
||||
}
|
||||
}
|
||||
println(3)
|
||||
time.sleep(100 * time.millisecond)
|
||||
}
|
||||
mut counter:=0
|
||||
mut counter := 0
|
||||
for {
|
||||
counter+=1
|
||||
counter += 1
|
||||
println(counter)
|
||||
out:=p.pipe_read(.stdout) or {""}
|
||||
if out.len>0{
|
||||
println("o")
|
||||
out := p.pipe_read(.stdout) or { '' }
|
||||
if out.len > 0 {
|
||||
println('o')
|
||||
println(out)
|
||||
}
|
||||
err:=p.pipe_read(.stderr) or {""}
|
||||
if err.len>0{
|
||||
println("e")
|
||||
err := p.pipe_read(.stderr) or { '' }
|
||||
if err.len > 0 {
|
||||
println('e')
|
||||
println(err)
|
||||
}
|
||||
time.sleep(100 * time.millisecond)
|
||||
if counter==2{
|
||||
if counter == 2 {
|
||||
p.stdin_write("print('something')\n\n\n")
|
||||
os.fd_close(p.stdio_fd[0])
|
||||
}
|
||||
if counter==20{
|
||||
if counter == 20 {
|
||||
p.stdin_write("print('something else')\n\n\n")
|
||||
os.fd_close(p.stdio_fd[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ fn do() ! {
|
||||
// get 2 bootstraps to work from
|
||||
f.debootstrap(imagename: 'debian', reset: false)! // if reset then will download again
|
||||
f.debootstrap(
|
||||
imagename: 'ubuntu22'
|
||||
imagename: 'ubuntu22'
|
||||
repository: 'http://de.archive.ubuntu.com/ubuntu'
|
||||
release: 'jammy'
|
||||
reset: false
|
||||
release: 'jammy'
|
||||
reset: false
|
||||
)!
|
||||
|
||||
// mut c := f.container_new(startcmd: ["ls", "/", "/proc"])!
|
||||
|
||||
@@ -3,12 +3,12 @@ module main
|
||||
import freeflowuniverse.herolib.osal.sshagent
|
||||
|
||||
fn do1() ! {
|
||||
mut agent:=sshagent.new()!
|
||||
mut agent := sshagent.new()!
|
||||
println(agent)
|
||||
k:=agent.get(name:"kds") or {panic("notgound")}
|
||||
k := agent.get(name: 'kds') or { panic('notgound') }
|
||||
println(k)
|
||||
|
||||
mut k2:=agent.get(name:"books") or {panic("notgound")}
|
||||
mut k2 := agent.get(name: 'books') or { panic('notgound') }
|
||||
k2.load()!
|
||||
println(k2.agent)
|
||||
|
||||
@@ -18,11 +18,8 @@ fn do1() ! {
|
||||
println(k2.agent)
|
||||
|
||||
// println(agent)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn main() {
|
||||
do1() or { panic(err) }
|
||||
}
|
||||
|
||||
@@ -3,21 +3,21 @@
|
||||
import freeflowuniverse.herolib.installers.infra.zinit as zinitinstaller
|
||||
import freeflowuniverse.herolib.sysadmin.startupmanager
|
||||
|
||||
mut z:=zinitinstaller.get()!
|
||||
mut z := zinitinstaller.get()!
|
||||
z.destroy()!
|
||||
z.install()!
|
||||
|
||||
println("zinit installed")
|
||||
println('zinit installed')
|
||||
|
||||
cmd:= '/usr/local/bin/zinit init'
|
||||
name:= 'zinit'
|
||||
cmd := '/usr/local/bin/zinit init'
|
||||
name := 'zinit'
|
||||
|
||||
mut sm := startupmanager.get()!
|
||||
println(sm.list()!)
|
||||
sm.new(
|
||||
name: name
|
||||
cmd: cmd
|
||||
start:false
|
||||
name: name
|
||||
cmd: cmd
|
||||
start: false
|
||||
)!
|
||||
|
||||
println(sm.list()!)
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
|
||||
import freeflowuniverse.herolib.osal.systemd
|
||||
|
||||
|
||||
mut systemdfactory := systemd.new()!
|
||||
// mut systemdprocess := systemdfactory.new(
|
||||
// cmd: '/usr/local/bin/zinit init'
|
||||
// name: 'zinit'
|
||||
// description: 'a super easy to use startup manager.'
|
||||
// )!
|
||||
l:=systemd.process_list()!
|
||||
l := systemd.process_list()!
|
||||
println(l)
|
||||
systemdfactory.destroy("zinit")!
|
||||
systemdfactory.destroy('zinit')!
|
||||
|
||||
@@ -29,8 +29,8 @@ ruleset.deny(
|
||||
ruleset.deny(
|
||||
port: 21
|
||||
from: '2001:db8::1'
|
||||
udp: true
|
||||
tcp: false
|
||||
udp: true
|
||||
tcp: false
|
||||
ipv6: true
|
||||
)
|
||||
|
||||
|
||||
@@ -35,5 +35,5 @@ heroscript := "
|
||||
"
|
||||
|
||||
mut plbook := playbook.new(text: heroscript)!
|
||||
rs:=ufw.play(mut plbook)!
|
||||
rs := ufw.play(mut plbook)!
|
||||
println(rs)
|
||||
|
||||
@@ -18,7 +18,7 @@ mut z := zinit.new()!
|
||||
|
||||
p := z.process_new(
|
||||
name: 'test'
|
||||
cmd: '/bin/bash'
|
||||
cmd: '/bin/bash'
|
||||
)!
|
||||
|
||||
println(p)
|
||||
|
||||
@@ -17,23 +17,23 @@ fn test_create_and_update_deployment() ! {
|
||||
twin_id := deployer.client.get_user_twin()!
|
||||
println('your wireguard privatekey is ${user_privkey[0]}')
|
||||
mut network := models.Znet{
|
||||
ip_range: '10.1.0.0/16'
|
||||
subnet: '10.1.1.0/24'
|
||||
ip_range: '10.1.0.0/16'
|
||||
subnet: '10.1.1.0/24'
|
||||
wireguard_private_key: node_privkey[0] // node private key
|
||||
wireguard_listen_port: 3012
|
||||
peers: [
|
||||
peers: [
|
||||
models.Peer{
|
||||
subnet: '10.1.2.0/24'
|
||||
subnet: '10.1.2.0/24'
|
||||
wireguard_public_key: user_privkey[1] // user public key
|
||||
allowed_ips: ['10.1.2.0/24', '100.64.1.2/32']
|
||||
allowed_ips: ['10.1.2.0/24', '100.64.1.2/32']
|
||||
},
|
||||
]
|
||||
}
|
||||
mut znet_workload := models.Workload{
|
||||
version: 0
|
||||
name: 'networkaa'
|
||||
type_: models.workload_types.network
|
||||
data: json.encode_pretty(network)
|
||||
version: 0
|
||||
name: 'networkaa'
|
||||
type_: models.workload_types.network
|
||||
data: json.encode_pretty(network)
|
||||
description: 'test network2'
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ fn test_create_and_update_deployment() ! {
|
||||
zmount_workload := zmount.to_workload(name: disk_name)
|
||||
|
||||
mount := models.Mount{
|
||||
name: disk_name
|
||||
name: disk_name
|
||||
mountpoint: '/disk1'
|
||||
}
|
||||
|
||||
@@ -55,39 +55,39 @@ fn test_create_and_update_deployment() ! {
|
||||
ip_workload := ip.to_workload(name: public_ip_name)
|
||||
|
||||
zmachine := models.Zmachine{
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/base:latest.flist'
|
||||
entrypoint: '/sbin/zinit init'
|
||||
network: models.ZmachineNetwork{
|
||||
public_ip: public_ip_name
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/base:latest.flist'
|
||||
entrypoint: '/sbin/zinit init'
|
||||
network: models.ZmachineNetwork{
|
||||
public_ip: public_ip_name
|
||||
interfaces: [
|
||||
models.ZNetworkInterface{
|
||||
network: 'networkaa'
|
||||
ip: '10.1.1.3'
|
||||
ip: '10.1.1.3'
|
||||
},
|
||||
]
|
||||
planetary: true
|
||||
planetary: true
|
||||
}
|
||||
compute_capacity: models.ComputeCapacity{
|
||||
cpu: 1
|
||||
cpu: 1
|
||||
memory: i64(1024) * 1024 * 1024 * 2
|
||||
}
|
||||
env: {
|
||||
env: {
|
||||
'SSH_KEY': pubkey
|
||||
}
|
||||
mounts: [mount]
|
||||
mounts: [mount]
|
||||
}
|
||||
|
||||
mut zmachine_workload := models.Workload{
|
||||
version: 0
|
||||
name: 'vm2'
|
||||
type_: models.workload_types.zmachine
|
||||
data: json.encode(zmachine)
|
||||
version: 0
|
||||
name: 'vm2'
|
||||
type_: models.workload_types.zmachine
|
||||
data: json.encode(zmachine)
|
||||
description: 'zmachine test'
|
||||
}
|
||||
|
||||
zlogs := models.ZLogs{
|
||||
zmachine: 'vm2'
|
||||
output: 'wss://example_ip.com:9000'
|
||||
output: 'wss://example_ip.com:9000'
|
||||
}
|
||||
zlogs_workload := zlogs.to_workload(name: 'myzlogswl')
|
||||
|
||||
@@ -98,17 +98,17 @@ fn test_create_and_update_deployment() ! {
|
||||
zdb_workload := zdb.to_workload(name: 'myzdb')
|
||||
|
||||
mut deployment := models.Deployment{
|
||||
version: 0
|
||||
twin_id: twin_id
|
||||
description: 'zm kjasdf1nafvbeaf1234t21'
|
||||
workloads: [znet_workload, zmount_workload, zmachine_workload, zlogs_workload, zdb_workload,
|
||||
ip_workload]
|
||||
version: 0
|
||||
twin_id: twin_id
|
||||
description: 'zm kjasdf1nafvbeaf1234t21'
|
||||
workloads: [znet_workload, zmount_workload, zmachine_workload, zlogs_workload,
|
||||
zdb_workload, ip_workload]
|
||||
signature_requirement: models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -133,7 +133,7 @@ fn test_create_and_update_deployment() ! {
|
||||
}
|
||||
|
||||
gw_name := models.GatewayNameProxy{
|
||||
name: 'mygwname1'
|
||||
name: 'mygwname1'
|
||||
backends: ['http://[${zmachine_planetary_ip}]:9000']
|
||||
}
|
||||
gw_name_wl := gw_name.to_workload(name: 'mygwname1')
|
||||
|
||||
@@ -17,8 +17,8 @@ fn main() {
|
||||
|
||||
gw := models.GatewayFQDNProxy{
|
||||
tls_passthrough: false
|
||||
backends: ['http://1.1.1.1:9000']
|
||||
fqdn: 'domaind.gridtesting.xyz'
|
||||
backends: ['http://1.1.1.1:9000']
|
||||
fqdn: 'domaind.gridtesting.xyz'
|
||||
}
|
||||
wl := gw.to_workload(name: 'mywlname')
|
||||
node_id := u32(14)
|
||||
@@ -30,16 +30,16 @@ fn main() {
|
||||
logger.info('preparing the deployment..')
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ fn main() {
|
||||
|
||||
gw := models.GatewayNameProxy{
|
||||
tls_passthrough: false
|
||||
backends: ['http://1.1.1.1']
|
||||
name: 'hamada_gw'
|
||||
backends: ['http://1.1.1.1']
|
||||
name: 'hamada_gw'
|
||||
}
|
||||
|
||||
wl := gw.to_workload(name: 'hamada_gw')
|
||||
@@ -28,17 +28,17 @@ fn main() {
|
||||
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
|
||||
|
||||
@@ -17,38 +17,38 @@ fn main() {
|
||||
network_name := 'network1'
|
||||
wg_port := deployer.assign_wg_port(node_id)!
|
||||
mut network := models.Znet{
|
||||
ip_range: '10.1.0.0/16'
|
||||
subnet: '10.1.1.0/24'
|
||||
ip_range: '10.1.0.0/16'
|
||||
subnet: '10.1.1.0/24'
|
||||
wireguard_private_key: 'GDU+cjKrHNJS9fodzjFDzNFl5su3kJXTZ3ipPgUjOUE='
|
||||
wireguard_listen_port: wg_port
|
||||
peers: [
|
||||
peers: [
|
||||
models.Peer{
|
||||
subnet: '10.1.2.0/24'
|
||||
subnet: '10.1.2.0/24'
|
||||
wireguard_public_key: '4KTvZS2KPWYfMr+GbiUUly0ANVg8jBC7xP9Bl79Z8zM='
|
||||
allowed_ips: ['10.1.2.0/24', '100.64.1.2/32']
|
||||
allowed_ips: ['10.1.2.0/24', '100.64.1.2/32']
|
||||
},
|
||||
]
|
||||
}
|
||||
mut znet_workload := network.to_workload(name: network_name, description: 'test_network1')
|
||||
|
||||
zmachine := models.Zmachine{
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/threefoldtech-ubuntu-22.04.flist'
|
||||
network: models.ZmachineNetwork{
|
||||
public_ip: ''
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/threefoldtech-ubuntu-22.04.flist'
|
||||
network: models.ZmachineNetwork{
|
||||
public_ip: ''
|
||||
interfaces: [
|
||||
models.ZNetworkInterface{
|
||||
network: network_name
|
||||
ip: '10.1.1.3'
|
||||
ip: '10.1.1.3'
|
||||
},
|
||||
]
|
||||
planetary: true
|
||||
planetary: true
|
||||
}
|
||||
entrypoint: '/sbin/zinit init'
|
||||
entrypoint: '/sbin/zinit init'
|
||||
compute_capacity: models.ComputeCapacity{
|
||||
cpu: 1
|
||||
cpu: 1
|
||||
memory: i64(1024) * 1024 * 1024 * 2
|
||||
}
|
||||
env: {
|
||||
env: {
|
||||
'SSH_KEY': 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTwULSsUubOq3VPWL6cdrDvexDmjfznGydFPyaNcn7gAL9lRxwFbCDPMj7MbhNSpxxHV2+/iJPQOTVJu4oc1N7bPP3gBCnF51rPrhTpGCt5pBbTzeyNweanhedkKDsCO2mIEh/92Od5Hg512dX4j7Zw6ipRWYSaepapfyoRnNSriW/s3DH/uewezVtL5EuypMdfNngV/u2KZYWoeiwhrY/yEUykQVUwDysW/xUJNP5o+KSTAvNSJatr3FbuCFuCjBSvageOLHePTeUwu6qjqe+Xs4piF1ByO/6cOJ8bt5Vcx0bAtI8/MPApplUU/JWevsPNApvnA/ntffI+u8DCwgP'
|
||||
}
|
||||
}
|
||||
@@ -56,18 +56,18 @@ fn main() {
|
||||
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
description: 'test deployment'
|
||||
workloads: [znet_workload, zmachine_workload]
|
||||
twin_id: deployer.twin_id
|
||||
description: 'test deployment'
|
||||
workloads: [znet_workload, zmachine_workload]
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
deployment.add_metadata('vm', 'SimpleVM')
|
||||
|
||||
@@ -15,7 +15,7 @@ fn test_deploy_vm_hight_level(node_id u32) ! {
|
||||
mut deployer := tfgrid.new_deployer(mnemonics, chain_network, mut logger)!
|
||||
|
||||
vm := models.VM{
|
||||
name: 'vm1'
|
||||
name: 'vm1'
|
||||
env_vars: {
|
||||
'SSH_KEY': 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTwULSsUubOq3VPWL6cdrDvexDmjfznGydFPyaNcn7gAL9lRxwFbCDPMj7MbhNSpxxHV2+/iJPQOTVJu4oc1N7bPP3gBCnF51rPrhTpGCt5pBbTzeyNweanhedkKDsCO2mIEh/92Od5Hg512dX4j7Zw6ipRWYSaepapfyoRnNSriW/s3DH/uewezVtL5EuypMdfNngV/u2KZYWoeiwhrY/yEUykQVUwDysW/xUJNP5o+KSTAvNSJatr3FbuCFuCjBSvageOLHePTeUwu6qjqe+Xs4piF1ByO/6cOJ8bt5Vcx0bAtI8/MPApplUU/JWevsPNApvnA/ntffI+u8DCwgP'
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ fn main() {
|
||||
mut deployer := tfgrid.new_deployer(mnemonics, chain_network, mut logger)!
|
||||
|
||||
zdb := models.Zdb{
|
||||
size: u64(2) * 1024 * 1024
|
||||
mode: 'user'
|
||||
size: u64(2) * 1024 * 1024
|
||||
mode: 'user'
|
||||
password: 'pass'
|
||||
}
|
||||
|
||||
@@ -25,17 +25,17 @@ fn main() {
|
||||
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ fn main() {
|
||||
|
||||
chain_net_enum := get_chain_network(chain_network)!
|
||||
mut deployer := tfgrid.new_deployer(mnemonics, chain_net_enum, mut logger)!
|
||||
|
||||
|
||||
mut workloads := []models.Workload{}
|
||||
node_id := get_node_id(chain_net_enum, memory, disk, cpu, public_ip)!
|
||||
// node_id := u32(150)
|
||||
@@ -38,20 +38,19 @@ fn main() {
|
||||
network_name := 'net_${rand.string(5).to_lower()}' // autocreate a network
|
||||
wg_port := deployer.assign_wg_port(node_id)!
|
||||
mut network := models.Znet{
|
||||
ip_range: '10.1.0.0/16' // auto-assign
|
||||
subnet: '10.1.1.0/24' // auto-assign
|
||||
ip_range: '10.1.0.0/16' // auto-assign
|
||||
subnet: '10.1.1.0/24' // auto-assign
|
||||
wireguard_private_key: 'GDU+cjKrHNJS9fodzjFDzNFl5su3kJXTZ3ipPgUjOUE=' // autocreate
|
||||
wireguard_listen_port: wg_port
|
||||
mycelium: models.Mycelium{
|
||||
mycelium: models.Mycelium{
|
||||
hex_key: rand.string(32).bytes().hex()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
workloads << network.to_workload(name: network_name, description: 'test_network1')
|
||||
|
||||
mut public_ip_name := ''
|
||||
if public_ip{
|
||||
if public_ip {
|
||||
public_ip_name = rand.string(5).to_lower()
|
||||
workloads << models.PublicIP{
|
||||
v4: true
|
||||
@@ -59,52 +58,52 @@ fn main() {
|
||||
}
|
||||
|
||||
zmachine := models.Zmachine{
|
||||
flist: 'https://hub.grid.tf/mariobassem1.3bot/threefolddev-holochain-latest.flist' // from user or default to ubuntu
|
||||
network: models.ZmachineNetwork{
|
||||
flist: 'https://hub.grid.tf/mariobassem1.3bot/threefolddev-holochain-latest.flist' // from user or default to ubuntu
|
||||
network: models.ZmachineNetwork{
|
||||
interfaces: [
|
||||
models.ZNetworkInterface{
|
||||
network: network_name
|
||||
ip: '10.1.1.3'
|
||||
ip: '10.1.1.3'
|
||||
},
|
||||
]
|
||||
public_ip: public_ip_name
|
||||
planetary: true
|
||||
mycelium: models.MyceliumIP{
|
||||
network: network_name
|
||||
public_ip: public_ip_name
|
||||
planetary: true
|
||||
mycelium: models.MyceliumIP{
|
||||
network: network_name
|
||||
hex_seed: rand.string(6).bytes().hex()
|
||||
}
|
||||
}
|
||||
entrypoint: '/sbin/zinit init' // from user or default
|
||||
entrypoint: '/sbin/zinit init' // from user or default
|
||||
compute_capacity: models.ComputeCapacity{
|
||||
cpu: u8(cpu)
|
||||
cpu: u8(cpu)
|
||||
memory: i64(memory) * 1024 * 1024 * 1024
|
||||
}
|
||||
size: u64(disk) * 1024 * 1024 * 1024
|
||||
env: {
|
||||
size: u64(disk) * 1024 * 1024 * 1024
|
||||
env: {
|
||||
'SSH_KEY': ssh_key
|
||||
'CODE_SERVER_PASSWORD': code_server_pass
|
||||
}
|
||||
}
|
||||
|
||||
workloads << zmachine.to_workload(
|
||||
name: 'vm_${rand.string(5).to_lower()}'
|
||||
name: 'vm_${rand.string(5).to_lower()}'
|
||||
description: 'zmachine_test'
|
||||
)
|
||||
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
description: 'holochain deployment'
|
||||
workloads: workloads
|
||||
twin_id: deployer.twin_id
|
||||
description: 'holochain deployment'
|
||||
workloads: workloads
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
deployment.add_metadata('vm', 'SimpleVM')
|
||||
@@ -147,7 +146,7 @@ fn get_chain_network(network string) !tfgrid.ChainNetwork {
|
||||
return chain_net_enum
|
||||
}
|
||||
|
||||
fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, public_ip bool) !u32{
|
||||
fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, public_ip bool) !u32 {
|
||||
gp_net := match network {
|
||||
.dev { gridproxy.TFGridNet.dev }
|
||||
.qa { gridproxy.TFGridNet.qa }
|
||||
@@ -157,15 +156,15 @@ fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, publi
|
||||
|
||||
mut gridproxy_client := gridproxy.get(gp_net, false)!
|
||||
mut free_ips := u64(0)
|
||||
if public_ip{
|
||||
if public_ip {
|
||||
free_ips = 1
|
||||
}
|
||||
|
||||
mut node_it := gridproxy_client.get_nodes_has_resources(
|
||||
free_mru_gb: u64(memory)
|
||||
free_sru_gb: u64(disk)
|
||||
free_cpu: u64(cpu)
|
||||
free_ips: free_ips
|
||||
free_cpu: u64(cpu)
|
||||
free_ips: free_ips
|
||||
)
|
||||
nodes := node_it.next()
|
||||
mut node_id := u32(0) // get from user or use gridproxy to get nodeid
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.gridproxy.model {NodeFilter}
|
||||
import freeflowuniverse.herolib.threefold.gridproxy.model { NodeFilter }
|
||||
import rand
|
||||
import log
|
||||
import os
|
||||
@@ -44,7 +44,7 @@ fn get_chain_network(network string) !tfgrid.ChainNetwork {
|
||||
return chain_net_enum
|
||||
}
|
||||
|
||||
fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, public_ip bool, has_domain bool, available_for u64) !u32{
|
||||
fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, public_ip bool, has_domain bool, available_for u64) !u32 {
|
||||
gp_net := match network {
|
||||
.dev { gridproxy.TFGridNet.dev }
|
||||
.qa { gridproxy.TFGridNet.qa }
|
||||
@@ -54,24 +54,24 @@ fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, publi
|
||||
|
||||
mut gridproxy_client := gridproxy.get(gp_net, false)!
|
||||
mut free_ips := u64(0)
|
||||
if public_ip{
|
||||
if public_ip {
|
||||
free_ips = 1
|
||||
}
|
||||
|
||||
mut filter_ := NodeFilter{
|
||||
free_ips: free_ips
|
||||
free_mru: u64(memory) * (1204 * 1204 * 1204)
|
||||
free_sru: u64(disk) * (1204 * 1204 * 1204)
|
||||
total_cru: u64(cpu)
|
||||
domain: has_domain
|
||||
free_ips: free_ips
|
||||
free_mru: u64(memory) * (1204 * 1204 * 1204)
|
||||
free_sru: u64(disk) * (1204 * 1204 * 1204)
|
||||
total_cru: u64(cpu)
|
||||
domain: has_domain
|
||||
available_for: available_for
|
||||
status: 'up'
|
||||
randomize: true
|
||||
size: u64(1)
|
||||
status: 'up'
|
||||
randomize: true
|
||||
size: u64(1)
|
||||
}
|
||||
|
||||
nodes := gridproxy_client.get_nodes(filter_)!
|
||||
if nodes.len != 1{
|
||||
if nodes.len != 1 {
|
||||
return error('cannot find a suitable node matching your specs')
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ logger.info('deploying on node: ${node_id}')
|
||||
network_name := 'net_${rand.string(5).to_lower()}' // autocreate a network
|
||||
wg_port := deployer.assign_wg_port(node_id)!
|
||||
mut network := models.Znet{
|
||||
ip_range: '10.1.0.0/16' // auto-assign
|
||||
subnet: '10.1.1.0/24' // auto-assign
|
||||
ip_range: '10.1.0.0/16' // auto-assign
|
||||
subnet: '10.1.1.0/24' // auto-assign
|
||||
wireguard_private_key: 'GDU+cjKrHNJS9fodzjFDzNFl5su3kJXTZ3ipPgUjOUE=' // autocreate
|
||||
wireguard_listen_port: wg_port
|
||||
// mycelium: models.Mycelium{
|
||||
@@ -117,7 +117,7 @@ mut network := models.Znet{
|
||||
workloads << network.to_workload(name: network_name, description: 'test_network1')
|
||||
|
||||
mut public_ip_name := ''
|
||||
if public_ip{
|
||||
if public_ip {
|
||||
public_ip_name = rand.string(5).to_lower()
|
||||
workloads << models.PublicIP{
|
||||
v4: true
|
||||
@@ -125,51 +125,51 @@ if public_ip{
|
||||
}
|
||||
|
||||
zmachine := models.Zmachine{
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/base:latest.flist'
|
||||
network: models.ZmachineNetwork{
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/base:latest.flist'
|
||||
network: models.ZmachineNetwork{
|
||||
interfaces: [
|
||||
models.ZNetworkInterface{
|
||||
network: network_name
|
||||
ip: '10.1.1.3'
|
||||
ip: '10.1.1.3'
|
||||
},
|
||||
]
|
||||
public_ip: public_ip_name
|
||||
planetary: true
|
||||
public_ip: public_ip_name
|
||||
planetary: true
|
||||
// mycelium: models.MyceliumIP{
|
||||
// network: network_name
|
||||
// hex_seed: rand.string(6).bytes().hex()
|
||||
// }
|
||||
}
|
||||
entrypoint: '/sbin/zinit init' // from user or default
|
||||
entrypoint: '/sbin/zinit init' // from user or default
|
||||
compute_capacity: models.ComputeCapacity{
|
||||
cpu: u8(cpu)
|
||||
cpu: u8(cpu)
|
||||
memory: i64(memory) * 1024 * 1024 * 1024
|
||||
}
|
||||
size: u64(disk) * 1024 * 1024 * 1024
|
||||
env: {
|
||||
'SSH_KEY': ssh_key
|
||||
size: u64(disk) * 1024 * 1024 * 1024
|
||||
env: {
|
||||
'SSH_KEY': ssh_key
|
||||
}
|
||||
}
|
||||
|
||||
workloads << zmachine.to_workload(
|
||||
name: 'vm_${rand.string(5).to_lower()}'
|
||||
name: 'vm_${rand.string(5).to_lower()}'
|
||||
description: 'zmachine_test'
|
||||
)
|
||||
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
description: 'vm with gateway'
|
||||
workloads: workloads
|
||||
twin_id: deployer.twin_id
|
||||
description: 'vm with gateway'
|
||||
workloads: workloads
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
deployment.add_metadata('vm', 'SimpleVM')
|
||||
@@ -187,11 +187,11 @@ dl := deployer.get_deployment(contract_id, node_id) or {
|
||||
machine_res := get_machine_result(dl)!
|
||||
logger.info('zmachine result: ${machine_res}')
|
||||
|
||||
gw_name := rand.string(5).to_lower()
|
||||
gw_name := rand.string(5).to_lower()
|
||||
gw := models.GatewayNameProxy{
|
||||
tls_passthrough: false
|
||||
backends: ['http://[${machine_res.planetary_ip}]:9000']
|
||||
name: gw_name
|
||||
backends: ['http://[${machine_res.planetary_ip}]:9000']
|
||||
name: gw_name
|
||||
}
|
||||
|
||||
gw_workload := gw.to_workload(name: gw_name)
|
||||
@@ -200,8 +200,8 @@ name_contract_id := deployer.client.create_name_contract(gw_name)!
|
||||
logger.info('name contract ${gw_workload.name} created with id ${name_contract_id}')
|
||||
|
||||
mut gw_deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [gw_workload]
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [gw_workload]
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
|
||||
|
||||
@@ -5,22 +5,22 @@ import log
|
||||
// Mock implementation for testing
|
||||
struct MockDeployer {
|
||||
mut:
|
||||
logger &log.Log
|
||||
logger &log.Log
|
||||
}
|
||||
|
||||
fn (mut d MockDeployer) cancel_contract(contract_id u64) ! {
|
||||
d.logger.info('Mock: Canceling contract ${contract_id}')
|
||||
d.logger.info('Mock: Canceling contract ${contract_id}')
|
||||
}
|
||||
|
||||
fn test_cancel_contract(contract_id u64) ! {
|
||||
mut logger := &log.Log{}
|
||||
logger.set_level(.debug)
|
||||
mut deployer := MockDeployer{
|
||||
logger: logger
|
||||
}
|
||||
deployer.cancel_contract(contract_id)!
|
||||
mut logger := &log.Log{}
|
||||
logger.set_level(.debug)
|
||||
mut deployer := MockDeployer{
|
||||
logger: logger
|
||||
}
|
||||
deployer.cancel_contract(contract_id)!
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test_cancel_contract(u64(119497)) or { println('error happened: ${err}') }
|
||||
test_cancel_contract(u64(119497)) or { println('error happened: ${err}') }
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
|
||||
mut cl := tfgrid.get("my_config")!
|
||||
mut cl := tfgrid.get('my_config')!
|
||||
mut cfg := cl.config()!
|
||||
|
||||
println(cl.instance)
|
||||
cfg = cl.config()!
|
||||
println(cfg)
|
||||
|
||||
if cfg.mnemonics == "" {
|
||||
if cfg.mnemonics == '' {
|
||||
// will ask questions if not filled in yet
|
||||
cl.config_interactive()!
|
||||
}
|
||||
@@ -27,11 +27,11 @@ println(cl.instance)
|
||||
cfg = cl.config()!
|
||||
println(cfg)
|
||||
|
||||
cl = tfgrid.get("empty_config")!
|
||||
cl = tfgrid.get('empty_config')!
|
||||
|
||||
println(cl.instance)
|
||||
cfg = cl.config()!
|
||||
println(cfg)
|
||||
|
||||
// TO CONFIGURE NEW
|
||||
// TO CONFIGURE NEW
|
||||
// cl.config_delete()!
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import freeflowuniverse.herolib.threefold.griddriver { Client }
|
||||
import freeflowuniverse.herolib.threefold.griddriver
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import log
|
||||
|
||||
|
||||
@@ -1,40 +1,33 @@
|
||||
|
||||
|
||||
struct VMSpecs{
|
||||
struct VMSpecs {
|
||||
deployment_name string
|
||||
name string
|
||||
nodeid string
|
||||
pub_sshkeys []string
|
||||
flist string //if any, if used then ostype not used
|
||||
ostype OSType
|
||||
name string
|
||||
nodeid string
|
||||
pub_sshkeys []string
|
||||
flist string // if any, if used then ostype not used
|
||||
ostype OSType
|
||||
}
|
||||
|
||||
enum OSType{
|
||||
enum OSType {
|
||||
ubuntu_22_04
|
||||
ubuntu_24_04
|
||||
arch
|
||||
alpine
|
||||
}
|
||||
|
||||
struct VMDeployed{
|
||||
name string
|
||||
struct VMDeployed {
|
||||
name string
|
||||
nodeid string
|
||||
//size ..
|
||||
guid string
|
||||
// size ..
|
||||
guid string
|
||||
yggdrasil_ip string
|
||||
mycelium_ip string
|
||||
|
||||
mycelium_ip string
|
||||
}
|
||||
|
||||
|
||||
pub fn (vm VMDeployed) builder_node() builder.Node {
|
||||
|
||||
}
|
||||
|
||||
//only connect to yggdrasil and mycelium
|
||||
// only connect to yggdrasil and mycelium
|
||||
//
|
||||
fn vm_deploy(args_ VMSpecs) VMDeployed{
|
||||
|
||||
deploymentstate_db.set(args.deployment_name,"vm_${args.name}",VMDeployed.json)
|
||||
|
||||
}
|
||||
fn vm_deploy(args_ VMSpecs) VMDeployed {
|
||||
deploymentstate_db.set(args.deployment_name, 'vm_${args.name}', VMDeployed.json)
|
||||
}
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct WebGWArgs{
|
||||
struct WebGWArgs {
|
||||
deployment_name string
|
||||
//...
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//connect domain name, or exising to it
|
||||
fn webgateway_rule_deploy(args_ WebGWArgs) []VMDeployed{
|
||||
|
||||
}
|
||||
// connect domain name, or exising to it
|
||||
fn webgateway_rule_deploy(args_ WebGWArgs) []VMDeployed {
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
contract_id := u64(119450)
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:false)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: false)!
|
||||
bills := gp_client.get_contract_hourly_bill(contract_id)!
|
||||
|
||||
console.print_debug("${bills}")
|
||||
console.print_debug('${bills}')
|
||||
|
||||
@@ -11,10 +11,10 @@ fn get_contracts_example() ! {
|
||||
myfilter.contract_type = 'node'
|
||||
myfilter.twin_id = u64(5191)
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mycontracts := gp_client.get_contracts(myfilter)!
|
||||
|
||||
console.print_debug("${mycontracts}")
|
||||
console.print_debug('${mycontracts}')
|
||||
}
|
||||
|
||||
fn get_contract_by_id_example(contract_id u64) ! {
|
||||
@@ -22,10 +22,10 @@ fn get_contract_by_id_example(contract_id u64) ! {
|
||||
|
||||
myfilter.contract_id = contract_id
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mycontracts := gp_client.get_contracts(myfilter)!
|
||||
|
||||
console.print_debug("${mycontracts}")
|
||||
console.print_debug('${mycontracts}')
|
||||
}
|
||||
|
||||
fn get_my_contracts_example() ! {
|
||||
@@ -37,7 +37,7 @@ fn get_my_contracts_example() ! {
|
||||
myfilter.twin_id = u64(deployer.twin_id)
|
||||
myfilter.state = 'created'
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:false)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: false)!
|
||||
mycontracts := gp_client.get_contracts(myfilter)!
|
||||
|
||||
console.print_debug('${mycontracts}')
|
||||
|
||||
@@ -9,10 +9,10 @@ fn get_farms_example() ! {
|
||||
myfilter.country = 'Egypt'
|
||||
myfilter.total_ips = u64(10)
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
myfarms := gp_client.get_farms(myfilter)!
|
||||
|
||||
console.print_debug("${myfarms}")
|
||||
console.print_debug('${myfarms}')
|
||||
}
|
||||
|
||||
fn get_farm_by_name_example(farm_name string) ! {
|
||||
@@ -20,11 +20,11 @@ fn get_farm_by_name_example(farm_name string) ! {
|
||||
|
||||
myfilter.name = farm_name
|
||||
|
||||
mut gp_client := gridproxy.new(net:.main, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .main, cache: true)!
|
||||
myfarms := gp_client.get_farms(myfilter)!
|
||||
|
||||
console.print_debug("${myfarms}")
|
||||
console.print_debug('${myfarms}')
|
||||
}
|
||||
|
||||
get_farms_example()!
|
||||
get_farm_by_name_example("freefarm")!
|
||||
get_farm_by_name_example('freefarm')!
|
||||
|
||||
@@ -8,11 +8,11 @@ fn get_gateway_nodes_example() ! {
|
||||
|
||||
myfilter.status = 'up'
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mygateways := gp_client.get_gateways(myfilter)!
|
||||
|
||||
console.print_debug("${mygateways}")
|
||||
console.print_debug("${mygateways.len}")
|
||||
|
||||
console.print_debug('${mygateways}')
|
||||
console.print_debug('${mygateways.len}')
|
||||
}
|
||||
|
||||
fn get_gateway_by_id_example(node_id u64) ! {
|
||||
@@ -20,10 +20,10 @@ fn get_gateway_by_id_example(node_id u64) ! {
|
||||
|
||||
myfilter.node_id = node_id
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mygateways := gp_client.get_gateways(myfilter)!
|
||||
|
||||
console.print_debug("${mygateways}")
|
||||
console.print_debug('${mygateways}')
|
||||
}
|
||||
|
||||
get_gateway_nodes_example()!
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
mut gp_client := gridproxy.new(net:.test, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .test, cache: true)!
|
||||
|
||||
// get twin list
|
||||
twins := gp_client.get_twins()!
|
||||
|
||||
@@ -9,10 +9,10 @@ fn get_nodes_example() ! {
|
||||
myfilter.status = 'up'
|
||||
myfilter.country = 'belgium'
|
||||
|
||||
mut gp_client := gridproxy.new(net:.main, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .main, cache: true)!
|
||||
mynodes := gp_client.get_nodes(myfilter)!
|
||||
|
||||
console.print_debug("${mynodes}")
|
||||
console.print_debug('${mynodes}')
|
||||
}
|
||||
|
||||
fn get_node_by_id_example(node_id u64) ! {
|
||||
@@ -20,22 +20,22 @@ fn get_node_by_id_example(node_id u64) ! {
|
||||
|
||||
myfilter.node_id = node_id
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mynodes := gp_client.get_nodes(myfilter)!
|
||||
|
||||
console.print_debug("${mynodes}")
|
||||
console.print_debug('${mynodes}')
|
||||
|
||||
// get node available resources
|
||||
node_available_resources := mynodes[0].calc_available_resources()
|
||||
console.print_debug("${node_available_resources}")
|
||||
console.print_debug('${node_available_resources}')
|
||||
}
|
||||
|
||||
fn get_node_stats_by_id_example(node_id u64) ! {
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
|
||||
node_stats := gp_client.get_node_stats_by_id(node_id)!
|
||||
|
||||
console.print_debug("${node_stats}")
|
||||
console.print_debug('${node_stats}')
|
||||
}
|
||||
|
||||
fn get_node_by_available_capacity_example() ! {
|
||||
@@ -43,15 +43,15 @@ fn get_node_by_available_capacity_example() ! {
|
||||
|
||||
// minimum free capacity
|
||||
myfilter.free_mru = u64(0)
|
||||
myfilter.free_sru = u64(1024) // 1 tb
|
||||
myfilter.free_sru = u64(1024) // 1 tb
|
||||
myfilter.free_hru = u64(0)
|
||||
myfilter.free_ips = u64(1)
|
||||
|
||||
// init gridproxy client on devnet with redis cash
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mynodes := gp_client.get_nodes(myfilter)!
|
||||
|
||||
console.print_debug("${mynodes}")
|
||||
console.print_debug('${mynodes}')
|
||||
}
|
||||
|
||||
fn get_node_by_city_country_example() ! {
|
||||
@@ -60,10 +60,10 @@ fn get_node_by_city_country_example() ! {
|
||||
myfilter.city = 'Rio de Janeiro'
|
||||
myfilter.country = 'Brazil'
|
||||
|
||||
mut gp_client := gridproxy.new(net:.main, cache:false)!
|
||||
mut gp_client := gridproxy.new(net: .main, cache: false)!
|
||||
mynodes := gp_client.get_nodes(myfilter)!
|
||||
|
||||
console.print_debug("${mynodes}")
|
||||
console.print_debug('${mynodes}')
|
||||
}
|
||||
|
||||
fn get_node_box_poc_example() ! {
|
||||
@@ -71,10 +71,10 @@ fn get_node_box_poc_example() ! {
|
||||
|
||||
myfilter.status = 'up'
|
||||
|
||||
mut gp_client := gridproxy.new(net:.main, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .main, cache: true)!
|
||||
mynodes := gp_client.get_nodes(myfilter)!
|
||||
|
||||
for node in mynodes{
|
||||
for node in mynodes {
|
||||
console.print_debug('${node}')
|
||||
console.print_debug('${node.capacity.total_resources.hru.to_gigabytes()}')
|
||||
|
||||
@@ -83,7 +83,6 @@ fn get_node_box_poc_example() ! {
|
||||
|
||||
node_stats := gp_client.get_node_stats_by_id(node.node_id)!
|
||||
console.print_debug('${node_stats}')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ fn get_online_grid_stats_example() ! {
|
||||
|
||||
myfilter.status = NodeStatus.online
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mystats := gp_client.get_stats(myfilter)!
|
||||
|
||||
console.print_debug("${mystats}")
|
||||
console.print_debug('${mystats}')
|
||||
}
|
||||
|
||||
fn get_all_grid_stats_example() ! {
|
||||
@@ -20,10 +20,10 @@ fn get_all_grid_stats_example() ! {
|
||||
|
||||
myfilter.status = NodeStatus.all
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mystats := gp_client.get_stats(myfilter)!
|
||||
|
||||
console.print_debug("${mystats}")
|
||||
console.print_debug('${mystats}')
|
||||
}
|
||||
|
||||
get_online_grid_stats_example()!
|
||||
|
||||
@@ -4,10 +4,10 @@ import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
fn get_all_twins_example() ! {
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mytwins := gp_client.get_twins()!
|
||||
|
||||
console.print_debug("${mytwins}")
|
||||
console.print_debug('${mytwins}')
|
||||
}
|
||||
|
||||
fn get_twin_by_id_example(twin_id u64) ! {
|
||||
@@ -15,10 +15,10 @@ fn get_twin_by_id_example(twin_id u64) ! {
|
||||
|
||||
myfilter.twin_id = twin_id
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mytwins := gp_client.get_twins(myfilter)!
|
||||
|
||||
console.print_debug("${mytwins}")
|
||||
console.print_debug('${mytwins}')
|
||||
}
|
||||
|
||||
get_all_twins_example()!
|
||||
|
||||
@@ -4,60 +4,59 @@ import freeflowuniverse.herolib.threefold.tfrobot
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.clients.dagu
|
||||
|
||||
console.print_header("Deploy test of vmachines on TFGrid using TFRobot.")
|
||||
console.print_header('Deploy test of vmachines on TFGrid using TFRobot.')
|
||||
|
||||
mut bot := tfrobot.new()!
|
||||
|
||||
mut deploy_config := tfrobot.DeployConfig{
|
||||
name: 'holotest2'
|
||||
network: .main
|
||||
debug: true
|
||||
name: 'holotest2'
|
||||
network: .main
|
||||
debug: true
|
||||
node_groups: [
|
||||
tfrobot.NodeGroup{
|
||||
name: 'hologroup2'
|
||||
name: 'hologroup2'
|
||||
nodes_count: 20
|
||||
free_cpu: 8
|
||||
free_mru: 8
|
||||
free_ssd: 100
|
||||
free_cpu: 8
|
||||
free_mru: 8
|
||||
free_ssd: 100
|
||||
// region:"europe"
|
||||
},
|
||||
]
|
||||
vms: [
|
||||
vms: [
|
||||
tfrobot.VMConfig{
|
||||
name: 'myvm'
|
||||
vms_count: 5
|
||||
cpu: 1
|
||||
mem: 1
|
||||
name: 'myvm'
|
||||
vms_count: 5
|
||||
cpu: 1
|
||||
mem: 1
|
||||
entry_point: '/sbin/zinit init'
|
||||
// flist: 'https://hub.grid.tf/mariobassem1.3bot/threefolddev-holochain-latest.flist'
|
||||
flist: 'https://hub.grid.tf/ashraf.3bot/threefolddev-holochain-latest.flist'
|
||||
env_vars: {
|
||||
'CODE_SERVER_PASSWORD': 'planetfirst'
|
||||
flist: 'https://hub.grid.tf/ashraf.3bot/threefolddev-holochain-latest.flist'
|
||||
env_vars: {
|
||||
'CODE_SERVER_PASSWORD': 'planetfirst'
|
||||
'DAGU_BASICAUTH_USERNAME': 'admin'
|
||||
'DAGU_BASICAUTH_PASSWORD': 'planetfirst'
|
||||
}
|
||||
public_ip4: false
|
||||
root_size: 50
|
||||
planetary: true
|
||||
root_size: 50
|
||||
planetary: true
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
//ssh-key is not specified, first key will be chosen
|
||||
// ssh-key is not specified, first key will be chosen
|
||||
|
||||
//DEAL WITH SSH KEYS
|
||||
// DEAL WITH SSH KEYS
|
||||
tfrobot.sshagent_keys_add(mut deploy_config)!
|
||||
|
||||
console.print_header("nr of ssh keys in ssh-agent:${deploy_config.ssh_keys.len}")
|
||||
console.print_header('nr of ssh keys in ssh-agent:${deploy_config.ssh_keys.len}')
|
||||
|
||||
res := bot.deploy(deploy_config)!
|
||||
|
||||
|
||||
console.print_header("Get VM's and ssh into it.")
|
||||
|
||||
for vm in tfrobot.vms_get('holotest')!{
|
||||
for vm in tfrobot.vms_get('holotest')! {
|
||||
console.print_debug(vm.str())
|
||||
mut node:=vm.node()!
|
||||
r:=node.exec(cmd:"ls /")!
|
||||
mut node := vm.node()!
|
||||
r := node.exec(cmd: 'ls /')!
|
||||
println(r)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import freeflowuniverse.herolib.ui.console
|
||||
|
||||
console.print_header("Get VM's.")
|
||||
|
||||
for vm in tfrobot.vms_get('holotest2')!{
|
||||
for vm in tfrobot.vms_get('holotest2')! {
|
||||
console.print_debug(vm.str())
|
||||
mut node:=vm.node()!
|
||||
r:=node.exec(cmd:"ls /")!
|
||||
mut node := vm.node()!
|
||||
r := node.exec(cmd: 'ls /')!
|
||||
println(r)
|
||||
}
|
||||
|
||||
@@ -3,44 +3,43 @@
|
||||
import freeflowuniverse.herolib.threefold.tfrobot
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
console.print_header("Tasker Example.")
|
||||
console.print_header('Tasker Example.')
|
||||
|
||||
mut vm := tfrobot.vm_get('holotest','test2')!
|
||||
mut vm := tfrobot.vm_get('holotest', 'test2')!
|
||||
|
||||
//get a set of tasks as we want to execute on the vm
|
||||
mut tasks:=vm.tasks_new(name:'holochain_scaffold')
|
||||
// get a set of tasks as we want to execute on the vm
|
||||
mut tasks := vm.tasks_new(name: 'holochain_scaffold')
|
||||
|
||||
tasks.step_add(
|
||||
nr:1
|
||||
name: 'Verify installation'
|
||||
command: 'nix run --refresh -j0 -v github:holochain/holochain#hc-scaffold -- --version'
|
||||
)!
|
||||
nr: 1
|
||||
name: 'Verify installation'
|
||||
command: 'nix run --refresh -j0 -v github:holochain/holochain#hc-scaffold -- --version'
|
||||
)!
|
||||
|
||||
tasks.step_add(
|
||||
nr:2
|
||||
name: 'Create working directory'
|
||||
command: 'mkdir -p /root/Holochain'
|
||||
depends: "1"
|
||||
)!
|
||||
nr: 2
|
||||
name: 'Create working directory'
|
||||
command: 'mkdir -p /root/Holochain'
|
||||
depends: '1'
|
||||
)!
|
||||
|
||||
tasks.step_add(
|
||||
nr:3
|
||||
name: 'Scaffold application'
|
||||
description: 'Scaffold a simple "Hello, World!" Holochain application'
|
||||
dir: '/root/Holochain'
|
||||
script: 'nix run github:holochain/holochain#hc-scaffold -- example hello-world || true'
|
||||
depends: "2"
|
||||
continue_on_error: true
|
||||
)!
|
||||
nr: 3
|
||||
name: 'Scaffold application'
|
||||
description: 'Scaffold a simple "Hello, World!" Holochain application'
|
||||
dir: '/root/Holochain'
|
||||
script: 'nix run github:holochain/holochain#hc-scaffold -- example hello-world || true'
|
||||
depends: '2'
|
||||
continue_on_error: true
|
||||
)!
|
||||
|
||||
tasks.step_add(
|
||||
nr:4
|
||||
name: 'Run Application'
|
||||
dir: '/root/Holochain/hello-world'
|
||||
command: 'nix develop --command bash -c "npm install && npm run start" && exit'
|
||||
depends: "3"
|
||||
)!
|
||||
|
||||
nr: 4
|
||||
name: 'Run Application'
|
||||
dir: '/root/Holochain/hello-world'
|
||||
command: 'nix develop --command bash -c "npm install && npm run start" && exit'
|
||||
depends: '3'
|
||||
)!
|
||||
|
||||
vm.tasks_run(tasks)!
|
||||
vm.tasks_see(tasks)!
|
||||
|
||||
@@ -3,26 +3,25 @@
|
||||
import freeflowuniverse.herolib.threefold.tfrobot
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
console.print_header("Tasker Example 2.")
|
||||
console.print_header('Tasker Example 2.')
|
||||
|
||||
mut vm := tfrobot.vm_get('holotest','test1')!
|
||||
mut vm := tfrobot.vm_get('holotest', 'test1')!
|
||||
|
||||
//get a set of tasks as we want to execute on the vm
|
||||
mut tasks:=vm.tasks_new(name:'sysadmin')
|
||||
// get a set of tasks as we want to execute on the vm
|
||||
mut tasks := vm.tasks_new(name: 'sysadmin')
|
||||
|
||||
tasks.step_add(
|
||||
nr:1
|
||||
name: 'ls'
|
||||
command: 'ls /'
|
||||
)!
|
||||
nr: 1
|
||||
name: 'ls'
|
||||
command: 'ls /'
|
||||
)!
|
||||
|
||||
tasks.step_add(
|
||||
nr:2
|
||||
name: 'install something'
|
||||
command: 'nix-env --install mc'
|
||||
depends: "1"
|
||||
)!
|
||||
|
||||
nr: 2
|
||||
name: 'install something'
|
||||
command: 'nix-env --install mc'
|
||||
depends: '1'
|
||||
)!
|
||||
|
||||
vm.tasks_run(tasks)!
|
||||
vm.tasks_see(tasks)!
|
||||
|
||||
@@ -5,9 +5,8 @@ import freeflowuniverse.herolib.threefold.tfgrid3deployer
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.installers.threefold.griddriver
|
||||
|
||||
|
||||
fn main(){
|
||||
mut installer:= griddriver.get()!
|
||||
fn main() {
|
||||
mut installer := griddriver.get()!
|
||||
installer.install()!
|
||||
|
||||
// v := tfgrid3deployer.get()!
|
||||
@@ -52,7 +51,7 @@ fn main(){
|
||||
// vm1 := deployment.vm_get("my_vm1")!
|
||||
// reachable := vm1.healthcheck()!
|
||||
// println("vm reachable: ${reachable}")
|
||||
|
||||
|
||||
// if !reachable {
|
||||
// deployment.vm_delete()!
|
||||
// deployment.vm_deploy()!
|
||||
@@ -63,7 +62,6 @@ fn main(){
|
||||
// vm1.deploy()!
|
||||
// }
|
||||
|
||||
|
||||
/*
|
||||
TODO: Agreed on
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ pub mut:
|
||||
fn (mut f RoomOrderFlow) room_choice() ! {
|
||||
i := f.ui.ask_dropdown(
|
||||
description: 'Which type of room do you want?'
|
||||
items: ['penthouse', 'normal', 'single', 'appartment_room']
|
||||
warning: 'Please select your right type of room'
|
||||
items: ['penthouse', 'normal', 'single', 'appartment_room']
|
||||
warning: 'Please select your right type of room'
|
||||
)!
|
||||
|
||||
println(i)
|
||||
|
||||
@@ -10,9 +10,9 @@ struct RoomOrderFlow {
|
||||
fn (mut f RoomOrderFlow) room_select() ! {
|
||||
i := f.ui.ask_dropdown_int(
|
||||
description: 'Which type of room do you want?'
|
||||
items: ['penthouse', 'normal', 'single', 'appartment_room']
|
||||
warning: 'Please select your right type of room'
|
||||
reset: true
|
||||
items: ['penthouse', 'normal', 'single', 'appartment_room']
|
||||
warning: 'Please select your right type of room'
|
||||
reset: true
|
||||
)
|
||||
// match
|
||||
smoker := f.ui.ask_yesno(description: 'Are you a smoker?')
|
||||
|
||||
@@ -4,10 +4,10 @@ import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
console.silent_set()
|
||||
mut job2 := osal.exec(cmd: 'ls /',debug:true)!
|
||||
println("I got nothing above")
|
||||
mut job2 := osal.exec(cmd: 'ls /', debug: true)!
|
||||
println('I got nothing above')
|
||||
|
||||
console.silent_unset()
|
||||
println("now I will get output")
|
||||
println('now I will get output')
|
||||
|
||||
osal.exec(cmd: 'ls /',debug:true)!
|
||||
osal.exec(cmd: 'ls /', debug: true)!
|
||||
|
||||
@@ -10,9 +10,9 @@ struct RoomOrderFlow {
|
||||
fn (mut f RoomOrderFlow) room_choice() ! {
|
||||
i := ui.ask_dropdown(
|
||||
description: 'Which type of room do you want?'
|
||||
items: ['penthouse', 'normal', 'single', 'appartment_room']
|
||||
warning: 'Please select your right type of room'
|
||||
reset: true
|
||||
items: ['penthouse', 'normal', 'single', 'appartment_room']
|
||||
warning: 'Please select your right type of room'
|
||||
reset: true
|
||||
)
|
||||
|
||||
// match
|
||||
|
||||
@@ -18,7 +18,7 @@ presearch_node.volume_add('/presearch-node-storage', '/app/node')!
|
||||
presearch_node.env_add('REGISTRATION_CODE', '${registration_code}')
|
||||
|
||||
mut presearch_updater := recipe.service_new(
|
||||
name: 'presearch_updater'
|
||||
name: 'presearch_updater'
|
||||
image: 'presearch/auto-updater'
|
||||
)!
|
||||
presearch_updater.volume_add('/var/run/docker.sock', '/var/run/docker.sock')!
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.virt.docker
|
||||
|
||||
mut engine := docker.new(prefix: '', localonly: true)!
|
||||
|
||||
@@ -5,24 +5,23 @@ import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.base
|
||||
import freeflowuniverse.herolib.builder
|
||||
import time
|
||||
|
||||
import os
|
||||
|
||||
console.print_header("Hetzner login.")
|
||||
console.print_header('Hetzner login.')
|
||||
|
||||
//USE IF YOU WANT TO CONFIGURE THE HETZNER, ONLY DO THIS ONCE
|
||||
//hetzner.configure("test")!
|
||||
// USE IF YOU WANT TO CONFIGURE THE HETZNER, ONLY DO THIS ONCE
|
||||
// hetzner.configure("test")!
|
||||
|
||||
mut cl:=hetzner.get("test")!
|
||||
mut cl := hetzner.get('test')!
|
||||
|
||||
for i in 0..5{
|
||||
println("test cache, first time slow then fast")
|
||||
for i in 0 .. 5 {
|
||||
println('test cache, first time slow then fast')
|
||||
cl.servers_list()!
|
||||
}
|
||||
|
||||
println(cl.servers_list()!)
|
||||
|
||||
mut serverinfo:= cl.server_info_get(name:"kristof2")!
|
||||
mut serverinfo := cl.server_info_get(name: 'kristof2')!
|
||||
|
||||
println(serverinfo)
|
||||
|
||||
@@ -30,13 +29,12 @@ println(serverinfo)
|
||||
|
||||
// cl.server_rescue(name:"kristof2",wait:true)!
|
||||
|
||||
console.print_header("SSH login")
|
||||
console.print_header('SSH login')
|
||||
mut b := builder.new()!
|
||||
mut n := b.node_new(ipaddr: serverinfo.server_ip)!
|
||||
|
||||
// n.hero_install()!
|
||||
// n.hero_compile_debug()!
|
||||
|
||||
|
||||
// mut ks:=cl.keys_get()!
|
||||
// println(ks)
|
||||
|
||||
@@ -8,17 +8,16 @@ import os
|
||||
|
||||
limainstaller.install()!
|
||||
|
||||
mut virtmanager:=lima.new()!
|
||||
mut virtmanager := lima.new()!
|
||||
|
||||
virtmanager.vm_delete_all()!
|
||||
|
||||
// virtmanager.vm_new(reset:true,template:.alpine,name:'alpine',install_hero:false)!
|
||||
|
||||
// virtmanager.vm_new(reset:true,template:.arch,name:'arch',install_hero:true)!
|
||||
|
||||
//virtmanager.vm_new(reset:true,template:.arch,name:'arch',install_hero:true)!
|
||||
|
||||
virtmanager.vm_new(reset:true,template:.ubuntucloud,name:'hero',install_hero:false)!
|
||||
mut vm:=virtmanager.vm_get('hero')!
|
||||
virtmanager.vm_new(reset: true, template: .ubuntucloud, name: 'hero', install_hero: false)!
|
||||
mut vm := virtmanager.vm_get('hero')!
|
||||
|
||||
println(vm)
|
||||
|
||||
|
||||
@@ -4,30 +4,26 @@ import freeflowuniverse.herolib.virt.herocontainers
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.base
|
||||
import freeflowuniverse.herolib.osal
|
||||
|
||||
import freeflowuniverse.herolib.installers.virt.pacman
|
||||
|
||||
mut installer := pacman.get()!
|
||||
|
||||
mut installer:= pacman.get()!
|
||||
// installer.destroy()!
|
||||
// installer.install()!
|
||||
|
||||
//installer.destroy()!
|
||||
//installer.install()!
|
||||
// exit(0)
|
||||
|
||||
//exit(0)
|
||||
// interative means will ask for login/passwd
|
||||
|
||||
//interative means will ask for login/passwd
|
||||
|
||||
mut engine:=herocontainers.new(install:true,herocompile:false)!
|
||||
mut engine := herocontainers.new(install: true, herocompile: false)!
|
||||
|
||||
engine.reset_all()!
|
||||
|
||||
mut builder_gorust := engine.builder_go_rust()!
|
||||
|
||||
//will build nodejs, python build & herolib, hero
|
||||
//mut builder_hero := engine.builder_hero(reset:true)!
|
||||
|
||||
//mut builder_web := engine.builder_heroweb(reset:true)!
|
||||
|
||||
// will build nodejs, python build & herolib, hero
|
||||
// mut builder_hero := engine.builder_hero(reset:true)!
|
||||
|
||||
// mut builder_web := engine.builder_heroweb(reset:true)!
|
||||
|
||||
builder_gorust.shell()!
|
||||
|
||||
@@ -5,20 +5,16 @@ import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.base
|
||||
// import freeflowuniverse.herolib.builder
|
||||
import time
|
||||
|
||||
import os
|
||||
|
||||
mut pm := herocontainers.new(herocompile: true, install: false)!
|
||||
|
||||
mut pm:=herocontainers.new(herocompile:true,install:false)!
|
||||
|
||||
mut mybuildcontainer := pm.builder_get("builder_heroweb")!
|
||||
|
||||
//bash & python can be executed directly in build container
|
||||
|
||||
//any of the herocommands can be executed like this
|
||||
mybuildcontainer.run(cmd:"installers -n heroweb",runtime:.herocmd)!
|
||||
mut mybuildcontainer := pm.builder_get('builder_heroweb')!
|
||||
|
||||
// bash & python can be executed directly in build container
|
||||
|
||||
// any of the herocommands can be executed like this
|
||||
mybuildcontainer.run(cmd: 'installers -n heroweb', runtime: .herocmd)!
|
||||
|
||||
// //following will execute heroscript in the buildcontainer
|
||||
// mybuildcontainer.run(
|
||||
@@ -31,11 +27,10 @@ mybuildcontainer.run(cmd:"installers -n heroweb",runtime:.herocmd)!
|
||||
// ",
|
||||
// runtime:.heroscript)!
|
||||
|
||||
//there are also shortcuts for this
|
||||
// there are also shortcuts for this
|
||||
|
||||
//mybuildcontainer.hero_copy()!
|
||||
//mybuildcontainer.shell()!
|
||||
// mybuildcontainer.hero_copy()!
|
||||
// mybuildcontainer.shell()!
|
||||
|
||||
|
||||
//mut b2:=pm.builder_get("builderv")!
|
||||
//b2.shell()!
|
||||
// mut b2:=pm.builder_get("builderv")!
|
||||
// b2.shell()!
|
||||
|
||||
@@ -5,13 +5,11 @@ import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.base
|
||||
// import freeflowuniverse.herolib.builder
|
||||
import time
|
||||
|
||||
import os
|
||||
|
||||
mut pm := herocontainers.new(herocompile: false)!
|
||||
|
||||
mut pm:=herocontainers.new(herocompile:false)!
|
||||
|
||||
mut b:=pm.builder_new()!
|
||||
mut b := pm.builder_new()!
|
||||
|
||||
println(b)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import os
|
||||
import flag
|
||||
|
||||
import freeflowuniverse.herolib.virt.herocontainers
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.base
|
||||
@@ -21,13 +20,13 @@ additional_args := fp.finalize() or {
|
||||
return
|
||||
}
|
||||
|
||||
mut pm:=herocontainers.new(herocompile:true,install:false)!
|
||||
mut pm := herocontainers.new(herocompile: true, install: false)!
|
||||
|
||||
mut mybuildcontainer := pm.builder_get("builder_heroweb")!
|
||||
mut mybuildcontainer := pm.builder_get('builder_heroweb')!
|
||||
|
||||
// //bash & python can be executed directly in build container
|
||||
|
||||
// //any of the herocommands can be executed like this
|
||||
mybuildcontainer.run(cmd:"installers -n heroweb",runtime:.herocmd)!
|
||||
mybuildcontainer.run(cmd: 'installers -n heroweb', runtime: .herocmd)!
|
||||
|
||||
mybuildcontainer.run(cmd: 'hero mdbook -u ${url} -o', runtime: .bash)!
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.installers.virt.cloudhypervisor as cloudhypervisor_installer
|
||||
|
||||
import freeflowuniverse.herolib.virt.cloudhypervisor
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import os
|
||||
|
||||
mut ci:=cloudhypervisor_installer.get()!
|
||||
ci.install(reset:true)!
|
||||
mut ci := cloudhypervisor_installer.get()!
|
||||
ci.install(reset: true)!
|
||||
|
||||
//mut vmm:=cloudhypervisor.new()!
|
||||
// mut vmm:=cloudhypervisor.new()!
|
||||
|
||||
// virtmanager.vm_delete_all()!
|
||||
// virtmanager.vm_new(reset:true,template:.alpine,name:'alpine',install_hero:true)!
|
||||
|
||||
@@ -9,8 +9,8 @@ import encoding.base64
|
||||
file_name := 'newfile.txt'
|
||||
root_dir := '/tmp/webdav'
|
||||
|
||||
username := "omda"
|
||||
password := "password"
|
||||
username := 'omda'
|
||||
password := 'password'
|
||||
hashed_password := base64.encode_str('${username}:${password}')
|
||||
|
||||
mut app := webdav.new_app(root_dir: root_dir, username: username, password: password) or {
|
||||
@@ -24,6 +24,7 @@ time.sleep(1 * time.second)
|
||||
mut p := pathlib.get_file(path: '${root_dir}/${file_name}', create: true)!
|
||||
p.write('my new file')!
|
||||
|
||||
mut req := http.new_request(.get, 'http://localhost:${app.server_port}/${file_name}', '')
|
||||
mut req := http.new_request(.get, 'http://localhost:${app.server_port}/${file_name}',
|
||||
'')
|
||||
req.add_custom_header('Authorization', 'Basic ${hashed_password}')!
|
||||
req.do()!
|
||||
|
||||
@@ -56,9 +56,9 @@ pub fn (mut node Node) upgrade() ! {
|
||||
install_base_content := install_base_content_.to_string()
|
||||
cmd := '${install_base_content}\n'
|
||||
node.exec_cmd(
|
||||
cmd: cmd
|
||||
period: 48 * 3600
|
||||
reset: false
|
||||
cmd: cmd
|
||||
period: 48 * 3600
|
||||
reset: false
|
||||
description: 'upgrade operating system packages'
|
||||
)!
|
||||
}
|
||||
@@ -100,45 +100,45 @@ pub mut:
|
||||
reset bool
|
||||
}
|
||||
|
||||
pub fn (mut node Node) hero_install(args HeroInstallArgs) ! {
|
||||
mut bs := bootstrapper()
|
||||
install_base_content_ := bs.embedded_files['install_base.sh'] or { panic('bug') }
|
||||
install_base_content := install_base_content_.to_string()
|
||||
// pub fn (mut node Node) hero_install(args HeroInstallArgs) ! {
|
||||
// mut bs := bootstrapper()
|
||||
// install_base_content_ := bs.embedded_files['install_base.sh'] or { panic('bug') }
|
||||
// install_base_content := install_base_content_.to_string()
|
||||
|
||||
if args.reset {
|
||||
console.clear()
|
||||
console.print_debug('')
|
||||
console.print_stderr('will remove: .vmodules, hero lib code and ~/hero')
|
||||
console.print_debug('')
|
||||
mut myui := ui.new()!
|
||||
toinstall := myui.ask_yesno(
|
||||
question: 'Ok to reset?'
|
||||
default: true
|
||||
)!
|
||||
if !toinstall {
|
||||
exit(1)
|
||||
}
|
||||
os.rmdir_all('${os.home_dir()}/.vmodules')!
|
||||
os.rmdir_all('${os.home_dir()}/hero')!
|
||||
os.rmdir_all('${os.home_dir()}/code/github/freeflowuniverse/herolib')!
|
||||
os.rmdir_all('${os.home_dir()}/code/github/freeflowuniverse/webcomponents')!
|
||||
}
|
||||
// if args.reset {
|
||||
// console.clear()
|
||||
// console.print_debug('')
|
||||
// console.print_stderr('will remove: .vmodules, hero lib code and ~/hero')
|
||||
// console.print_debug('')
|
||||
// mut myui := ui.new()!
|
||||
// toinstall := myui.ask_yesno(
|
||||
// question: 'Ok to reset?'
|
||||
// default: true
|
||||
// )!
|
||||
// if !toinstall {
|
||||
// exit(1)
|
||||
// }
|
||||
// os.rmdir_all('${os.home_dir()}/.vmodules')!
|
||||
// os.rmdir_all('${os.home_dir()}/hero')!
|
||||
// os.rmdir_all('${os.home_dir()}/code/github/freeflowuniverse/herolib')!
|
||||
// os.rmdir_all('${os.home_dir()}/code/github/freeflowuniverse/webcomponents')!
|
||||
// }
|
||||
|
||||
cmd := '
|
||||
${install_base_content}
|
||||
|
||||
rm -f /usr/local/bin/hero
|
||||
freeflow_dev_env_install
|
||||
// cmd := '
|
||||
// ${install_base_content}
|
||||
|
||||
~/code/github/freeflowuniverse/herolib/install.sh
|
||||
|
||||
echo HERO, V, CRYSTAL ALL INSTALL OK
|
||||
echo WE ARE READY TO HERO...
|
||||
|
||||
'
|
||||
console.print_debug('executing cmd ${cmd}')
|
||||
node.exec_cmd(cmd: cmd)!
|
||||
}
|
||||
// rm -f /usr/local/bin/hero
|
||||
// freeflow_dev_env_install
|
||||
|
||||
// ~/code/github/freeflowuniverse/herolib/install.sh
|
||||
|
||||
// echo HERO, V, CRYSTAL ALL INSTALL OK
|
||||
// echo WE ARE READY TO HERO...
|
||||
|
||||
// '
|
||||
// console.print_debug('executing cmd ${cmd}')
|
||||
// node.exec_cmd(cmd: cmd)!
|
||||
// }
|
||||
|
||||
@[params]
|
||||
pub struct HeroUpdateArgs {
|
||||
@@ -162,10 +162,10 @@ pub fn (mut node Node) hero_update(args_ HeroUpdateArgs) ! {
|
||||
|
||||
if args.sync_from_local {
|
||||
if args.sync_full {
|
||||
node.sync_code('hero', builder.heropath_ + '/..', '~/code/github/freeflowuniverse/herolib',
|
||||
node.sync_code('hero', heropath_ + '/..', '~/code/github/freeflowuniverse/herolib',
|
||||
args.sync_fast)!
|
||||
} else {
|
||||
node.sync_code('hero_lib', builder.heropath_, '~/code/github/freeflowuniverse/herolib/herolib',
|
||||
node.sync_code('hero_lib', heropath_, '~/code/github/freeflowuniverse/herolib/herolib',
|
||||
args.sync_fast)!
|
||||
}
|
||||
return
|
||||
@@ -202,15 +202,15 @@ pub fn (mut node Node) hero_update(args_ HeroUpdateArgs) ! {
|
||||
pub fn (mut node Node) sync_code(name string, src_ string, dest string, fast_rsync bool) ! {
|
||||
mut src := pathlib.get_dir(path: os.abs_path(src_), create: false)!
|
||||
node.upload(
|
||||
source: src.path
|
||||
dest: dest
|
||||
ignore: [
|
||||
source: src.path
|
||||
dest: dest
|
||||
ignore: [
|
||||
'.git/*',
|
||||
'_archive',
|
||||
'.vscode',
|
||||
'examples',
|
||||
]
|
||||
delete: true
|
||||
delete: true
|
||||
fast_rsync: fast_rsync
|
||||
)!
|
||||
}
|
||||
@@ -254,9 +254,9 @@ pub fn (mut node Node) vscript(args_ VScriptArgs) ! {
|
||||
mut args := args_
|
||||
node.hero_update(
|
||||
sync_from_local: args.sync_from_local
|
||||
git_reset: args.git_reset
|
||||
git_pull: args.git_pull
|
||||
branch: args.branch
|
||||
git_reset: args.git_reset
|
||||
git_pull: args.git_pull
|
||||
branch: args.branch
|
||||
)!
|
||||
mut p := pathlib.get_file(path: args.path, create: false)!
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ fn executor_new(args_ ExecutorNewArguments) !Executor {
|
||||
}
|
||||
mut e := ExecutorSSH{
|
||||
ipaddr: ipaddr
|
||||
user: args.user
|
||||
debug: args.debug
|
||||
user: args.user
|
||||
debug: args.debug
|
||||
}
|
||||
e.init()!
|
||||
return e
|
||||
|
||||
@@ -75,12 +75,12 @@ pub fn (mut executor ExecutorLocal) info() map[string]string {
|
||||
// upload from local FS to executor FS
|
||||
pub fn (mut executor ExecutorLocal) upload(args SyncArgs) ! {
|
||||
mut rsargs := rsync.RsyncArgs{
|
||||
source: args.source
|
||||
dest: args.dest
|
||||
delete: args.delete
|
||||
ignore: args.ignore
|
||||
source: args.source
|
||||
dest: args.dest
|
||||
delete: args.delete
|
||||
ignore: args.ignore
|
||||
ignore_default: args.ignore_default
|
||||
stdout: args.stdout
|
||||
stdout: args.stdout
|
||||
}
|
||||
rsync.rsync(rsargs)!
|
||||
}
|
||||
@@ -88,12 +88,12 @@ pub fn (mut executor ExecutorLocal) upload(args SyncArgs) ! {
|
||||
// download from executor FS to local FS
|
||||
pub fn (mut executor ExecutorLocal) download(args SyncArgs) ! {
|
||||
mut rsargs := rsync.RsyncArgs{
|
||||
source: args.source
|
||||
dest: args.dest
|
||||
delete: args.delete
|
||||
ignore: args.ignore
|
||||
source: args.source
|
||||
dest: args.dest
|
||||
delete: args.delete
|
||||
ignore: args.ignore
|
||||
ignore_default: args.ignore_default
|
||||
stdout: args.stdout
|
||||
stdout: args.stdout
|
||||
}
|
||||
rsync.rsync(rsargs)!
|
||||
}
|
||||
|
||||
@@ -125,13 +125,13 @@ pub fn (mut executor ExecutorSSH) download(args SyncArgs) ! {
|
||||
addr = '\'${executor.user}@[${executor.ipaddr.addr}]\':${executor.ipaddr.port}'
|
||||
}
|
||||
mut rsargs := rsync.RsyncArgs{
|
||||
source: args.source
|
||||
dest: args.dest
|
||||
delete: args.delete
|
||||
ipaddr_src: addr
|
||||
ignore: args.ignore
|
||||
source: args.source
|
||||
dest: args.dest
|
||||
delete: args.delete
|
||||
ipaddr_src: addr
|
||||
ignore: args.ignore
|
||||
ignore_default: args.ignore_default
|
||||
stdout: args.stdout
|
||||
stdout: args.stdout
|
||||
}
|
||||
rsync.rsync(rsargs)!
|
||||
}
|
||||
@@ -173,14 +173,14 @@ pub fn (mut executor ExecutorSSH) upload(args SyncArgs) ! {
|
||||
}
|
||||
|
||||
mut rsargs := rsync.RsyncArgs{
|
||||
source: args.source
|
||||
dest: args.dest
|
||||
delete: args.delete
|
||||
ipaddr_dst: addr
|
||||
ignore: args.ignore
|
||||
source: args.source
|
||||
dest: args.dest
|
||||
delete: args.delete
|
||||
ipaddr_dst: addr
|
||||
ignore: args.ignore
|
||||
ignore_default: args.ignore_default
|
||||
stdout: args.stdout
|
||||
fast_rsync: args.fast_rsync
|
||||
stdout: args.stdout
|
||||
fast_rsync: args.fast_rsync
|
||||
}
|
||||
rsync.rsync(rsargs)!
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ fn test_file_operations() {
|
||||
e.ipaddr = IPAddress{
|
||||
addr: '127.0.0.1'
|
||||
port: 22
|
||||
cat: .ipv4
|
||||
cat: .ipv4
|
||||
}
|
||||
mut filepath := '/tmp/${rand.uuid_v4()}'
|
||||
e.file_write(filepath, 'ssh')!
|
||||
@@ -54,7 +54,7 @@ fn test_environ_get() {
|
||||
e.ipaddr = IPAddress{
|
||||
addr: '127.0.0.1'
|
||||
port: 22
|
||||
cat: .ipv4
|
||||
cat: .ipv4
|
||||
}
|
||||
mut env := e.environ_get()!
|
||||
console.print_debug(env)
|
||||
|
||||
@@ -28,7 +28,7 @@ mut:
|
||||
factory &BuilderFactory @[skip; str: skip]
|
||||
pub mut:
|
||||
name string = 'unknown'
|
||||
executor Executor @[skip; str: skip]
|
||||
executor Executor @[skip; str: skip]
|
||||
platform PlatformType
|
||||
cputype CPUType
|
||||
done map[string]string
|
||||
|
||||
@@ -16,7 +16,7 @@ pub struct NodeExecCmd {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
cmd string
|
||||
period int // period in which we check when this was done last, if 0 then period is indefinite
|
||||
period int // period in which we check when this was done last, if 0 then period is indefinite
|
||||
reset bool = true // means do again or not
|
||||
remove_installer bool = true // delete the installer
|
||||
description string
|
||||
|
||||
@@ -44,9 +44,9 @@ pub fn (mut node Node) exec(args ExecArgs) !string {
|
||||
pub struct ExecRetryArgs {
|
||||
pub:
|
||||
cmd string
|
||||
retrymax int = 10 // how may times maximum to retry
|
||||
retrymax int = 10 // how may times maximum to retry
|
||||
period_milli int = 100 // sleep in between retry in milliseconds
|
||||
timeout int = 2 // timeout for al the tries together
|
||||
timeout int = 2 // timeout for al the tries together
|
||||
stdout bool = true
|
||||
}
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ pub fn (mut bldr BuilderFactory) node_new(args_ NodeArguments) !&Node {
|
||||
|
||||
eargs := ExecutorNewArguments{
|
||||
ipaddr: args.ipaddr
|
||||
user: args.user
|
||||
debug: args.debug
|
||||
user: args.user
|
||||
debug: args.debug
|
||||
}
|
||||
mut executor := executor_new(eargs)!
|
||||
mut node := Node{
|
||||
name: args.name
|
||||
name: args.name
|
||||
executor: executor
|
||||
factory: &bldr
|
||||
factory: &bldr
|
||||
}
|
||||
|
||||
if node.name == '' {
|
||||
|
||||
@@ -18,7 +18,6 @@ pub fn heroscript_default() !string {
|
||||
return heroscript
|
||||
}
|
||||
|
||||
|
||||
pub struct MeilisearchClient {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
|
||||
@@ -19,7 +19,7 @@ const configfile = '${os.home_dir()}/.config/rclone/rclone.conf'
|
||||
//```
|
||||
pub fn configure() ! {
|
||||
mut plbook := playbook.new(
|
||||
path: rclone.configfile
|
||||
path: configfile
|
||||
// actor_filter: ['config']
|
||||
// action_filter: [
|
||||
// 's3server_define',
|
||||
|
||||
@@ -34,7 +34,7 @@ pub fn heroscript_default() !string {
|
||||
pub struct RCloneClient {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
type_ string = 's3' // remote type (s3, sftp, etc)
|
||||
type_ string = 's3' // remote type (s3, sftp, etc)
|
||||
provider string = 'aws' // provider for s3 (aws, minio, etc)
|
||||
access_key string // access key for authentication
|
||||
secret_key string // secret key for authentication
|
||||
@@ -44,13 +44,13 @@ pub mut:
|
||||
|
||||
fn cfg_play(p paramsparser.Params) ! {
|
||||
mut mycfg := RCloneClient{
|
||||
name: p.get_default('name', 'default')!
|
||||
type_: p.get_default('type', 's3')!
|
||||
provider: p.get_default('provider', 'aws')!
|
||||
name: p.get_default('name', 'default')!
|
||||
type_: p.get_default('type', 's3')!
|
||||
provider: p.get_default('provider', 'aws')!
|
||||
access_key: p.get('access_key')!
|
||||
secret_key: p.get('secret_key')!
|
||||
region: p.get_default('region', 'us-east-1')!
|
||||
endpoint: p.get_default('endpoint', '')!
|
||||
region: p.get_default('region', 'us-east-1')!
|
||||
endpoint: p.get_default('endpoint', '')!
|
||||
}
|
||||
set(mycfg)!
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ pub fn play_juggler(mut plbook playbook.PlayBook) ! {
|
||||
port := p.get_int_default('port', 8000)!
|
||||
|
||||
j = juggler.configure(
|
||||
url: 'https://git.ourworld.tf/projectmycelium/itenv'
|
||||
url: 'https://git.ourworld.tf/projectmycelium/itenv'
|
||||
username: username
|
||||
password: password
|
||||
reset: true
|
||||
reset: true
|
||||
)!
|
||||
config_actions[0].done = true
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ module playcmds
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.virt.hetzner
|
||||
//import freeflowuniverse.herolib.clients.b2
|
||||
// import freeflowuniverse.herolib.clients.b2
|
||||
import freeflowuniverse.herolib.biz.bizmodel
|
||||
import freeflowuniverse.herolib.hero.publishing
|
||||
import freeflowuniverse.herolib.threefold.grid4.gridsimulator
|
||||
//import freeflowuniverse.herolib.installers.sysadmintools.daguserver
|
||||
// import freeflowuniverse.herolib.installers.sysadmintools.daguserver
|
||||
import freeflowuniverse.herolib.threefold.grid4.farmingsimulator
|
||||
import freeflowuniverse.herolib.web.components.slides
|
||||
// import freeflowuniverse.herolib.installers.base as base_install
|
||||
@@ -22,12 +22,12 @@ pub fn run(mut plbook playbook.PlayBook, dagu bool) ! {
|
||||
play_core(mut plbook)!
|
||||
play_ssh(mut plbook)!
|
||||
play_git(mut plbook)!
|
||||
//play_zola(mut plbook)!
|
||||
//play_caddy(mut plbook)!
|
||||
//play_juggler(mut plbook)!
|
||||
//play_luadns(mut plbook)!
|
||||
// play_zola(mut plbook)!
|
||||
// play_caddy(mut plbook)!
|
||||
// play_juggler(mut plbook)!
|
||||
// play_luadns(mut plbook)!
|
||||
hetzner.heroplay(mut plbook)!
|
||||
//b2.heroplay(mut plbook)!
|
||||
// b2.heroplay(mut plbook)!
|
||||
|
||||
farmingsimulator.play(mut plbook)!
|
||||
gridsimulator.play(mut plbook)!
|
||||
@@ -38,7 +38,7 @@ pub fn run(mut plbook playbook.PlayBook, dagu bool) ! {
|
||||
|
||||
publishing.play(mut plbook)!
|
||||
|
||||
//plbook.empty_check()!
|
||||
// plbook.empty_check()!
|
||||
|
||||
console.print_header('Actions concluded succesfully.')
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ const dagu_script = "
|
||||
"
|
||||
|
||||
fn test_play_dagu() ! {
|
||||
mut plbook := playbook.new(text: playcmds.dagu_script)!
|
||||
mut plbook := playbook.new(text: dagu_script)!
|
||||
play_dagu(mut plbook)!
|
||||
panic('s')
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user