summaryrefslogtreecommitdiffhomepage
path: root/test/scenario_test/quagga-rsconfig.go
diff options
context:
space:
mode:
authorNaoto Hanaue <hanaue.naoto@po.ntts.co.jp>2015-03-05 16:45:41 +0900
committerNaoto Hanaue <hanaue.naoto@po.ntts.co.jp>2015-03-05 16:45:41 +0900
commit3abf440d5e0cf0493e179b19eebcfc7ebae32777 (patch)
tree1fa54ffd3c5cc1966ca8492f29d737425f6821d9 /test/scenario_test/quagga-rsconfig.go
parent97e54711515e579b77586ed1aa90e8bf5b5349c0 (diff)
scenario_test: change generated by the program the configuration file of malformed test
Diffstat (limited to 'test/scenario_test/quagga-rsconfig.go')
-rw-r--r--test/scenario_test/quagga-rsconfig.go61
1 files changed, 32 insertions, 29 deletions
diff --git a/test/scenario_test/quagga-rsconfig.go b/test/scenario_test/quagga-rsconfig.go
index 83b6e663..49fd24ea 100644
--- a/test/scenario_test/quagga-rsconfig.go
+++ b/test/scenario_test/quagga-rsconfig.go
@@ -80,7 +80,7 @@ func (qt *QuaggaConfig) IPv6Config() *bytes.Buffer {
return buf
}
-func create_config_files(nr int, outputDir string, IPVersion string) {
+func create_config_files(nr int, outputDir string, IPVersion string, nonePeer bool) {
quaggaConfigList := make([]*QuaggaConfig, 0)
gobgpConf := config.Bgp{
@@ -100,17 +100,19 @@ func create_config_files(nr int, outputDir string, IPVersion string) {
Timers: config.Timers{HoldTime: 30, KeepaliveInterval: 10, IdleHoldTimeAfterReset: 10},
}
gobgpConf.NeighborList = append(gobgpConf.NeighborList, c)
- q := NewQuaggaConfig(i, &gobgpConf.Global, &c, net.ParseIP(serverAddress[IPVersion]))
- quaggaConfigList = append(quaggaConfigList, q)
- os.Mkdir(fmt.Sprintf("%s/q%d", outputDir, i), 0755)
- var err error
- if IPVersion == "IPv6" {
- err = ioutil.WriteFile(fmt.Sprintf("%s/q%d/bgpd.conf", outputDir, i), q.IPv6Config().Bytes(), 0644)
- } else {
- err = ioutil.WriteFile(fmt.Sprintf("%s/q%d/bgpd.conf", outputDir, i), q.IPv4Config().Bytes(), 0644)
- }
- if err != nil {
- log.Fatal(err)
+ if !nonePeer {
+ q := NewQuaggaConfig(i, &gobgpConf.Global, &c, net.ParseIP(serverAddress[IPVersion]))
+ quaggaConfigList = append(quaggaConfigList, q)
+ os.Mkdir(fmt.Sprintf("%s/q%d", outputDir, i), 0755)
+ var err error
+ if IPVersion == "IPv6" {
+ err = ioutil.WriteFile(fmt.Sprintf("%s/q%d/bgpd.conf", outputDir, i), q.IPv6Config().Bytes(), 0644)
+ } else {
+ err = ioutil.WriteFile(fmt.Sprintf("%s/q%d/bgpd.conf", outputDir, i), q.IPv4Config().Bytes(), 0644)
+ }
+ if err != nil {
+ log.Fatal(err)
+ }
}
}
@@ -124,7 +126,7 @@ func create_config_files(nr int, outputDir string, IPVersion string) {
}
}
-func append_config_files(ar int, outputDir string, IPVersion string) {
+func append_config_files(ar int, outputDir string, IPVersion string, nonePeer bool) {
gobgpConf := config.Bgp{
Global: config.Global{
@@ -140,21 +142,23 @@ func append_config_files(ar int, outputDir string, IPVersion string) {
TransportOptions: config.TransportOptions{PassiveMode: true},
Timers: config.Timers{HoldTime: 30, KeepaliveInterval: 10, IdleHoldTimeAfterReset: 10},
}
- q := NewQuaggaConfig(ar, &gobgpConf.Global, &c, net.ParseIP(serverAddress[IPVersion]))
- os.Mkdir(fmt.Sprintf("%s/q%d", outputDir, ar), 0755)
- var err error
- if IPVersion == "IPv6" {
- err = ioutil.WriteFile(fmt.Sprintf("%s/q%d/bgpd.conf", outputDir, ar), q.IPv6Config().Bytes(), 0644)
- } else {
- err = ioutil.WriteFile(fmt.Sprintf("%s/q%d/bgpd.conf", outputDir, ar), q.IPv4Config().Bytes(), 0644)
- }
- if err != nil {
- log.Fatal(err)
+ if !nonePeer {
+ q := NewQuaggaConfig(ar, &gobgpConf.Global, &c, net.ParseIP(serverAddress[IPVersion]))
+ os.Mkdir(fmt.Sprintf("%s/q%d", outputDir, ar), 0755)
+ var err error
+ if IPVersion == "IPv6" {
+ err = ioutil.WriteFile(fmt.Sprintf("%s/q%d/bgpd.conf", outputDir, ar), q.IPv6Config().Bytes(), 0644)
+ } else {
+ err = ioutil.WriteFile(fmt.Sprintf("%s/q%d/bgpd.conf", outputDir, ar), q.IPv4Config().Bytes(), 0644)
+ }
+ if err != nil {
+ log.Fatal(err)
+ }
}
newConf := config.Bgp{}
_, d_err := toml.DecodeFile(fmt.Sprintf("%s/gobgpd.conf", outputDir), &newConf)
if d_err != nil {
- log.Fatal(err)
+ log.Fatal(d_err)
}
newConf.NeighborList = append(newConf.NeighborList, c)
var buffer bytes.Buffer
@@ -162,7 +166,7 @@ func append_config_files(ar int, outputDir string, IPVersion string) {
encoder.Encode(newConf)
e_err := ioutil.WriteFile(fmt.Sprintf("%s/gobgpd.conf", outputDir), buffer.Bytes(), 0644)
if e_err != nil {
- log.Fatal(err)
+ log.Fatal(e_err)
}
}
@@ -173,15 +177,14 @@ func main() {
AppendClient int `short:"a" long:"append" description:"specifing the add client number" default:"0"`
IPVersion string `short:"v" long:"ip-version" description:"specifing the use ip version" default:"IPv4"`
NetIdentifier int `short:"i" long:"net-identifer" description:"specifing the use network identifier" default:"0"`
+ NonePeer bool `long:"none-peer" description:"disable make quagga config"`
}
parser := flags.NewParser(&opts, flags.Default)
-
_, err := parser.Parse()
if err != nil {
fmt.Print(err)
os.Exit(1)
}
-
if opts.OutputDir == "" {
opts.OutputDir, _ = filepath.Abs(".")
} else {
@@ -204,11 +207,11 @@ func main() {
}
if opts.AppendClient == 0 {
- create_config_files(opts.ClientNumber, opts.OutputDir, opts.IPVersion)
+ create_config_files(opts.ClientNumber, opts.OutputDir, opts.IPVersion, opts.NonePeer)
} else {
if _, err := os.Stat(fmt.Sprintf("%s/gobgpd.conf", opts.OutputDir)); os.IsNotExist(err) {
log.Fatal(err)
}
- append_config_files(opts.AppendClient, opts.OutputDir, opts.IPVersion)
+ append_config_files(opts.AppendClient, opts.OutputDir, opts.IPVersion, opts.NonePeer)
}
}