fixes for formatting

This commit is contained in:
2024-12-31 11:00:02 +01:00
parent 8400bfc4ee
commit 92335f8828
39 changed files with 699 additions and 752 deletions

View File

@@ -1,40 +1,45 @@
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
struct DeploymentStateDB{
secret ... //to encrypt symmetric
//...
struct DeploymentStateDB {
secret string // to encrypt symmetric
data map[string]string
}
struct DeploymentState{
name ...
vms []VMDeployed
struct DeploymentState {
name string
vms []VMDeployed
zdbs []ZDBDeployed
...
}
pub fn (db DeploymentStateDB) set(deployment_name string, key string, val string)! {
//store e.g. \n separated list of all keys per deployment_name
//encrypt
pub fn (mut db DeploymentStateDB) set(deployment_name string, key string, val string)! {
// store e.g. \n separated list of all keys per deployment_name
// encrypt
db.data['${deployment_name}_${key}'] = val
}
pub fn (db DeploymentStateDB) get(deployment_name string, key string)!string {
return db.data['${deployment_name}_${key}'] or { return error('key not found') }
}
pub fn (db DeploymentStateDB) delete(deployment_name string, key string)! {
pub fn (mut db DeploymentStateDB) delete(deployment_name string, key string)! {
db.data.delete('${deployment_name}_${key}')
}
pub fn (db DeploymentStateDB) keys(deployment_name string)![]string {
mut keys := []string{}
for k, _ in db.data {
if k.starts_with('${deployment_name}_') {
keys << k.all_after('${deployment_name}_')
}
}
return keys
}
pub fn (db DeploymentStateDB) load(deployment_name string)!DeploymentState {
}
mut state := DeploymentState{
name: deployment_name
}
// Implementation would need to load VMs and ZDBs based on stored data
return state
}

View File

@@ -1,41 +1,35 @@
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
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)
}

View File

@@ -1,39 +1,40 @@
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
struct NodeQuery{
location string //how to define location
struct NodeQuery {
location string // how to define location
capacity_available_hdd_gb int
capacity_available_ssd_gb int
capacity_available_mem_gb int
capacity_available_vcpu int //vcpu core's
capacity_free_hdd_gb int
capacity_free_ssd_gb int
capacity_free_mem_gb int
capacity_free_vcpu int //vcpu core's
uptime_min int = 70 //0..99
bw_min_mb_sec int = 0 //bandwith in mbit per second, min
capacity_available_mem_gb int
capacity_available_vcpu int // vcpu core's
capacity_free_hdd_gb int
capacity_free_ssd_gb int
capacity_free_mem_gb int
capacity_free_vcpu int // vcpu core's
uptime_min int = 70 // 0..99
bw_min_mb_sec int = 0 // bandwith in mbit per second, min
}
struct NodeInfo{
location string //how to define location
struct NodeInfo {
location string // how to define location
capacity_available_hdd_gb int
capacity_available_ssd_gb int
capacity_available_mem_gb int
capacity_available_vcpu int //vcpu core's
capacity_free_hdd_gb int
capacity_free_ssd_gb int
capacity_free_mem_gb int
capacity_free_vcpu int //vcpu core's
uptime_min int = 70 //0..99
bw_min_mb_sec int = 0 //bandwith in mbit per second, min
guid str
...
capacity_available_mem_gb int
capacity_available_vcpu int // vcpu core's
capacity_free_hdd_gb int
capacity_free_ssd_gb int
capacity_free_mem_gb int
capacity_free_vcpu int // vcpu core's
uptime_min int = 70 // 0..99
bw_min_mb_sec int = 0 // bandwith in mbit per second, min
guid string
status string
last_update i64 // unix timestamp
}
fn node_find(args_ NodeQuery) []NodeInfo{
}
fn node_find(args NodeQuery) []NodeInfo {
// Implementation would need to:
// 1. Query nodes based on the criteria in args
// 2. Filter nodes that match the requirements
// 3. Return array of matching NodeInfo
return []NodeInfo{}
}

View File

@@ -1,19 +1,10 @@
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
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 {
}

View File

@@ -1,31 +1,48 @@
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.core.redisclient { RedisClient }
struct ZDBSpecs{
struct ZDBSpecs {
deployment_name string
nodeid string
nodeid string
namespace string
secret string
}
struct ZDBDeployed {
nodeid string
namespace string
secret string
secret string
host string
port int
}
struct ZDBDeployed{
nodeid string
namespace string
secret string
// test zdb is answering
pub fn (zdb ZDBDeployed) ping() !bool {
mut client := zdb.redisclient()!
return client.ping()!
}
//test zdb is answering
pub fn (vm ZDBDeployed) ping() bool {
pub fn (zdb ZDBDeployed) redisclient() !RedisClient {
return RedisClient.new(
host: zdb.host
port: zdb.port
password: zdb.secret
db: 0
)!
}
pub fn (vm ZDBDeployed) redisclient() redisclient... {
// only connect to yggdrasil and mycelium
fn zdb_deploy(args ZDBSpecs) !ZDBDeployed {
// Implementation would need to:
// 1. Deploy ZDB on the specified node
// 2. Configure namespace and security
// 3. Return connection details
return ZDBDeployed{
nodeid: args.nodeid
namespace: args.namespace
secret: args.secret
host: '' // Would be set to actual host
port: 0 // Would be set to actual port
}
}
//only connect to yggdrasil and mycelium
//
fn zdb_deploy(args_ ZDBSpecs) ZDBDeployed{
}