Esempio n. 1
0
func NewFromConfigs(kernel, initrd string, configs []FactoryConfig) Factory {
	bases := make([]base.Factory, len(configs))
	for i, c := range configs {
		var b base.Factory
		b = direct.New(c.Cpu, c.Memory, kernel, initrd)
		bases[i] = cache.New(c.Cache, b)
	}

	if len(bases) == 0 {
		// skip GetVm from the base factory
		return single.New(direct.New(1000000, 1000000, kernel, initrd))
	} else if len(bases) == 1 {
		return single.New(bases[0])
	} else {
		return multi.New(bases)
	}
}
Esempio n. 2
0
			}
		} else if kernel == "" || initrd == "" {
			glog.Infof("argument kernel and initrd must be set")
			os.Exit(1)
		}

		hypervisor.InterfaceCount = 0
		var err error
		if hypervisor.HDriver, err = driverloader.Probe(driver); err != nil {
			glog.V(1).Infof("%s\n", err.Error())
			os.Exit(1)
		}

		var f factory.Factory
		if template != "" {
			f = singlefactory.New(templatefactory.NewFromExisted(tconfig))
		} else {
			f = factory.NewFromConfigs(kernel, initrd, nil)
		}
		sv, err := supervisor.New(stateDir, containerdDir, f,
			context.GlobalInt("default_cpus"), context.GlobalInt("default_memory"))
		if err != nil {
			glog.Infof("%v", err)
			os.Exit(1)
		}

		if context.Bool("solo-namespaced") {
			go namespaceShare(sv, containerdDir, stateDir)
		}

		if err = daemon(sv, context.String("listen")); err != nil {