diff --git a/conf/agent/config.exemple.yml b/conf/agent/config.exemple.yml index 5bd1dfd..bc1d437 100644 --- a/conf/agent/config.exemple.yml +++ b/conf/agent/config.exemple.yml @@ -1,7 +1,9 @@ database: path: "/var/lib/two/data/" +default_interface: br-000000 + interfaces: vms: br-000000 internet: br-000000 - admin: br-000000 \ No newline at end of file + admin: br-000000 diff --git a/internal/config/agent/struct.go b/internal/config/agent/struct.go index 21dde0d..1c9fc9f 100644 --- a/internal/config/agent/struct.go +++ b/internal/config/agent/struct.go @@ -20,7 +20,8 @@ type Config struct { Count int `mapstructure:"count"` BufferSize int `mapstructure:"buffer_size"` } `mapstructure:"worker"` - Interfaces map[string]string `mapstructure:"interfaces"` + DefaultInterface string `mapstructure:"default_interface"` + Interfaces map[string]string `mapstructure:"interfaces"` } func LoadConfig(path string) (*Config, error) { @@ -35,6 +36,7 @@ func LoadConfig(path string) (*Config, error) { v.SetDefault("prometheus.port", 9090) v.SetDefault("worker.count", 4) v.SetDefault("worker.buffer_size", 100) + v.SetDefault("default_interface", "br-000000") v.ReadInConfig() diff --git a/internal/dispatcher/subnet_commands.go b/internal/dispatcher/subnet_commands.go index c2a0cff..0d471c3 100644 --- a/internal/dispatcher/subnet_commands.go +++ b/internal/dispatcher/subnet_commands.go @@ -23,7 +23,7 @@ type CreateSubnetCommand struct { func (c CreateSubnetCommand) Execute(db *badger.DB, cfg *configuration.Config) error { localIface, ok := cfg.Interfaces[c.IfaceType] if !ok { - return fmt.Errorf("unknown iface_type %q: not found in config", c.IfaceType) + localIface = cfg.DefaultInterface } kv.AddInDB(db, "subnet/"+c.Name+"/state", "creating") kv.AddInDB(db, "subnet/"+c.Name+"/vpc", c.VPC)