f-14: code: add db usage in vpc creation #14
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
44f01c2373
commit
f9c1cd7d32
2 changed files with 62 additions and 37 deletions
|
|
@ -5,21 +5,39 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
configuration "git.g3e.fr/syonad/two/internal/config/agent"
|
||||
"git.g3e.fr/syonad/two/internal/vpc"
|
||||
"git.g3e.fr/syonad/two/pkg/db/kv"
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
)
|
||||
|
||||
var (
|
||||
netns = flag.String("netns", "", "Network namespace à faire")
|
||||
name = flag.String("name", "", "interface name")
|
||||
action = flag.String("action", "", "Action a faire")
|
||||
netns = flag.String("netns", "", "Network namespace à faire")
|
||||
name = flag.String("name", "", "interface name")
|
||||
action = flag.String("action", "", "Action a faire")
|
||||
conf_file = flag.String("conf", "/etc/two/agent.yml", "configuration file")
|
||||
)
|
||||
|
||||
var DB *badger.DB
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
conf, err := configuration.LoadConfig(*conf_file)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
DB = kv.InitDB(kv.Config{
|
||||
Path: conf.Database.Path,
|
||||
}, false)
|
||||
defer DB.Close()
|
||||
|
||||
switch *action {
|
||||
case "create":
|
||||
if err := vpc.CreateVPC(*name); err != nil {
|
||||
kv.AddInDB(DB, "vpc/"+*name+"/state", "creating")
|
||||
if err := vpc.CreateVPC(DB, *name); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
case "delete":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue