f-11: code: move start and stop metadata #11

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-01-07 23:16:58 +01:00
commit a8ffeebb72
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
9 changed files with 46 additions and 30 deletions

View file

@ -5,9 +5,8 @@ import (
"fmt"
configuration "git.g3e.fr/syonad/two/internal/config/agent"
"git.g3e.fr/syonad/two/internal/load_db/nocloud"
"git.g3e.fr/syonad/two/internal/metadata"
"git.g3e.fr/syonad/two/pkg/db/kv"
"git.g3e.fr/syonad/two/pkg/systemd"
)
func main() {
@ -24,8 +23,6 @@ func main() {
flag.Parse()
service, _ := systemd.New()
conf, err := configuration.LoadConfig(*conf_file)
if err != nil {
fmt.Println(err)
@ -38,21 +35,15 @@ func main() {
defer db.Close()
if *start {
nocloud.LoadNcCloudInDB(nocloud.Config{
metadata.StartMetadata(metadata.NoCloudConfig{
VpcName: *vpc,
Name: *vm_name,
BindIP: *bind_ip,
BindPort: *bind_port,
Password: *password,
SSHKEY: *ssh_key,
}, db)
if !*dryrun {
service.Start("metadata@" + *vm_name)
}
}, db, *dryrun)
} else if *stop {
nocloud.UnLoadNoCloudInDB(*vm_name, db)
if !*dryrun {
service.Stop("metadata@" + *vm_name)
}
metadata.StopMetadata(*vm_name, db, *dryrun)
}
}