49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
|
|
configuration "git.g3e.fr/syonad/two/internal/config/agent"
|
|
"git.g3e.fr/syonad/two/internal/load_db/nocloud"
|
|
"git.g3e.fr/syonad/two/pkg/db/kv"
|
|
)
|
|
|
|
func main() {
|
|
conf_file := flag.String("conf", "/etc/two/agent.yml", "configuration file")
|
|
vm_name := flag.String("vm_name", "", "Nom de la vm")
|
|
vpc := flag.String("vpc_name", "", "vpc name")
|
|
bind_ip := flag.String("ip", "", "bind ip")
|
|
bind_port := flag.String("port", "", "bind port")
|
|
ssh_key := flag.String("key", "", "Clef ssh")
|
|
password := flag.String("pass", "", "password user")
|
|
start := flag.Bool("start", false, "start metadata server")
|
|
stop := flag.Bool("stop", false, "stop metadata server")
|
|
|
|
flag.Parse()
|
|
|
|
conf, err := configuration.LoadConfig(*conf_file)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Print(conf)
|
|
|
|
db := kv.InitDB(kv.Config{
|
|
Path: conf.Database.Path,
|
|
})
|
|
defer db.Close()
|
|
|
|
if *start {
|
|
nocloud.LoadNcCloudInDB(nocloud.Config{
|
|
VpcName: *vpc,
|
|
Name: *vm_name,
|
|
BindIP: *bind_ip,
|
|
BindPort: *bind_port,
|
|
Password: *password,
|
|
SSHKEY: *ssh_key,
|
|
}, db)
|
|
} else if *stop {
|
|
nocloud.UnLoadNoCloudInDB(*vm_name, db)
|
|
}
|
|
}
|