Example #1
0
// LoadDefaultScopes loads default scope configs for scopes which
// doesn't have explicit user specified configs.
func (c *Config) LoadDefaultScopes(dataDir string) {
	for k, v := range datastore.DefaultScopes(dataDir) {
		if _, ok := c.Scopes[k]; !ok {
			c.Scopes[k] = v
		}
	}
}
Example #2
0
func main() {
	kingpin.Parse()
	if *debug {
		logrus.SetLevel(logrus.DebugLevel)
	}

	dc := &driverCallback{}
	driverOptions := options.Generic{
		"EnableIPTables":     *iptables,
		"EnableIPForwarding": *ipForward,
	}
	genericOption := make(map[string]interface{})
	genericOption[netlabel.GenericData] = driverOptions
	for k, v := range datastore.DefaultScopes("") {
		if !v.IsValid() {
			continue
		}

		genericOption[netlabel.MakeKVProvider(k)] = v.Client.Provider
		genericOption[netlabel.MakeKVProviderURL(k)] = v.Client.Address
		genericOption[netlabel.MakeKVProviderConfig(k)] = v.Client.Config
	}

	err := bridge.Init(dc, genericOption)
	if err != nil {
		logrus.Fatalf("Failed to initialize the bridge: %v", err)
	}

	h := network.NewHandler(dc.driver)
	h.ServeUnix("", pluginName)
}
Example #3
0
func TestBoltdbBackend(t *testing.T) {
	defer os.Remove(datastore.DefaultScopes("")[datastore.LocalScope].Client.Address)
	testLocalBackend(t, "", "", nil)
	defer os.Remove("/tmp/boltdb.db")
	config := &store.Config{Bucket: "testBackend"}
	testLocalBackend(t, "boltdb", "/tmp/boltdb.db", config)

}
Example #4
0
func createController() error {
	var err error

	// Cleanup local datastore file
	os.Remove(datastore.DefaultScopes("")[datastore.LocalScope].Client.Address)

	option := options.Generic{
		"EnableIPForwarding": true,
	}

	genericOption := make(map[string]interface{})
	genericOption[netlabel.GenericData] = option

	cfgOptions, err := libnetwork.OptionBoltdbWithRandomDBFile()
	if err != nil {
		return err
	}
	controller, err = libnetwork.New(append(cfgOptions, config.OptionDriverConfig(bridgeNetType, genericOption))...)
	if err != nil {
		return err
	}

	return nil
}