当前位置: 首页>>代码示例>>Golang>>正文


Golang minilog.Info函数代码示例

本文整理汇总了Golang中minilog.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: sshClientActivity

func sshClientActivity(index int) {
	sc := sshConns[index]

	s := rand.NewSource(time.Now().UnixNano())
	r := rand.New(s)

	// generate a random byte slice
	l := r.Intn(128)
	b := make([]byte, l)
	for i, _ := range b {
		b[i] = byte(r.Int())
	}

	data := base64.StdEncoding.EncodeToString(b)
	log.Debug("ssh activity to %v with %v", sc.Host, data)

	start := time.Now().UnixNano()

	sc.Stdin.Write([]byte(data))
	sc.Stdin.Write([]byte{'\r', '\n'})
	sshReportChan <- uint64(len(data))

	expected := fmt.Sprintf("> %v\r\n%v\r\n> ", data, data)
	for i := 0; i < 10 && sc.StdoutBuf.String() != expected; i++ {
		time.Sleep(100 * time.Millisecond)
	}

	stop := time.Now().UnixNano()
	log.Info("ssh %v %vns", sc.Host, uint64(stop-start))

	log.Debugln("ssh: ", sc.StdoutBuf.String())

	sc.StdoutBuf.Reset()
}
开发者ID:cdshann,项目名称:minimega,代码行数:34,代码来源:ssh.go

示例2: cliPreprocessor

// cliPreprocessor allows modifying commands post-compile but pre-process.
// Current preprocessors "file:", "http://", and "https://".
//
// Note: we don't run preprocessors when we're not running the `local` behavior
// (see wrapBroadcastCLI) to avoid expanding files before we're running the
// command on the correct machine.
func cliPreprocessor(c *minicli.Command) error {
	if c.Source != GetNamespaceName() {
		return nil
	}

	for k, v := range c.StringArgs {
		v2, err := cliPreprocess(v)
		if err != nil {
			return err
		}

		if v != v2 {
			log.Info("cliPreprocess: [%v] %v -> %v", k, v, v2)
		}
		c.StringArgs[k] = v2
	}

	for k := range c.ListArgs {
		for k2, v := range c.ListArgs[k] {
			v2, err := cliPreprocess(v)
			if err != nil {
				return err
			}

			if v != v2 {
				log.Info("cliPreprocessor: [%v][%v] %v -> %v", k, k2, v, v2)
			}
			c.ListArgs[k][k2] = v2
		}
	}

	return nil
}
开发者ID:cdshann,项目名称:minimega,代码行数:39,代码来源:cli.go

示例3: Kill

// Kill VMs matching target.
func (vms VMs) Kill(target string) []error {
	vmLock.Lock()
	defer vmLock.Unlock()

	killedVms := map[int]bool{}

	// For each VM, kill it if it's in a killable state. Should not be run in
	// parallel because we record the IDs of the VMs we kill in killedVms.
	applyFunc := func(vm VM, _ bool) (bool, error) {
		if vm.GetState()&VM_KILLABLE == 0 {
			return false, nil
		}

		if err := vm.Kill(); err != nil {
			log.Error("unleash the zombie VM: %v", err)
		} else {
			killedVms[vm.GetID()] = true
		}
		return true, nil
	}

	errs := vms.apply(target, false, applyFunc)

	for len(killedVms) > 0 {
		id := <-killAck
		log.Info("VM %v killed", id)
		delete(killedVms, id)
	}

	for id := range killedVms {
		log.Info("VM %d failed to acknowledge kill", id)
	}

	return errs
}
开发者ID:cdshann,项目名称:minimega,代码行数:36,代码来源:vmlist.go

示例4: addTap

func (b *Bridge) addTap(tap, mac string, lan int, host bool) error {
	log.Info("adding tap on bridge: %v %v %v %v %v", b.Name, tap, mac, lan, host)

	// reap taps before adding to avoid someone killing/restarting a vm faster
	// than the periodic tap reaper
	b.reapTaps()

	if _, ok := b.taps[tap]; ok {
		return fmt.Errorf("tap already on bridge")
	}

	err := ovsAddPort(b.Name, tap, lan, host)
	if err == errAlreadyExists {
		// Special case -- tap is already on bridge... try to remove it first
		// and then add it again.
		log.Info("tap %v is already on bridge, adding again", tap)
		if err = ovsDelPort(b.Name, tap); err == nil {
			err = ovsAddPort(b.Name, tap, lan, host)
		}
	}

	if err != nil {
		return err
	}

	b.taps[tap] = &Tap{
		Name:   tap,
		Bridge: b.Name,
		VLAN:   lan,
		MAC:    mac,
		Host:   host,
	}

	return nil
}
开发者ID:cdshann,项目名称:minimega,代码行数:35,代码来源:tap.go

示例5: Start

func (vm *ContainerVM) Start() (err error) {
	vm.lock.Lock()
	defer vm.lock.Unlock()

	if vm.State&VM_RUNNING != 0 {
		return nil
	}

	if vm.State == VM_QUIT || vm.State == VM_ERROR {
		log.Info("relaunching VM: %v", vm.ID)

		// Create a new channel since we closed the other one to indicate that
		// the VM should quit.
		vm.kill = make(chan bool)

		// Launch handles setting the VM to error state
		if err := vm.launch(); err != nil {
			return err
		}
	}

	log.Info("starting VM: %v", vm.ID)
	if err := vm.thaw(); err != nil {
		log.Errorln(err)
		vm.setError(err)
		return err
	}

	vm.setState(VM_RUNNING)

	return nil
}
开发者ID:cdshann,项目名称:minimega,代码行数:32,代码来源:container.go

示例6: kill

func (vms VMs) kill(target string) []error {
	killedVms := map[int]bool{}

	errs := expandVmTargets(target, false, func(vm VM, _ bool) (bool, error) {
		if vm.State()&(VM_QUIT|VM_ERROR) != 0 {
			return false, nil
		}

		vm.Kill()
		killedVms[vm.ID()] = true
		return true, nil
	})

outer:
	for len(killedVms) > 0 {
		select {
		case id := <-killAck:
			log.Info("VM %v killed", id)
			delete(killedVms, id)
		case <-time.After(COMMAND_TIMEOUT * time.Second):
			log.Error("vm kill timeout")
			break outer
		}
	}

	for id := range killedVms {
		log.Info("VM %d failed to acknowledge kill", id)
	}

	return errs
}
开发者ID:summits,项目名称:minimega,代码行数:31,代码来源:vmlist.go

示例7: kill

func kill(pid int) {
	Client.Lock()
	defer Client.Unlock()

	if pid == -1 {
		// Wildcard
		log.Info("killing all processes")
		for _, p := range Client.Processes {
			if err := p.process.Kill(); err != nil {
				log.Errorln(err)
			}
		}

		return
	}

	log.Info("killing PID %v", pid)
	if p, ok := Client.Processes[pid]; ok {
		if err := p.process.Kill(); err != nil {
			log.Errorln(err)
		}

		return
	}

	log.Error("no such process: %v", pid)
}
开发者ID:cdshann,项目名称:minimega,代码行数:27,代码来源:commands.go

示例8: Start

func (vm *vmKVM) Start() error {
	s := vm.State()

	stateMask := VM_PAUSED | VM_BUILDING | VM_QUIT | VM_ERROR
	if s&stateMask == 0 {
		return nil
	}

	if s == VM_QUIT || s == VM_ERROR {
		log.Info("restarting VM: %v", vm.id)
		ack := make(chan int)
		go vm.launch(ack)
		log.Debug("ack restarted VM %v", <-ack)
	}

	log.Info("starting VM: %v", vm.id)
	err := vm.q.Start()
	if err != nil {
		log.Errorln(err)
		if err != qmp.ERR_READY {
			vm.setState(VM_ERROR)
		}
	} else {
		vm.setState(VM_RUNNING)
	}

	return err
}
开发者ID:summits,项目名称:minimega,代码行数:28,代码来源:kvm.go

示例9: mux

// mux to handle i/o over the transport. Data on channel out will be sent over
// the transport. Data coming in over the transport will be routed to the
// incoming channel as tagged be the message's TID. This allows us to trunk
// multiple tunnels over a single transport.
func (t *Tunnel) mux() {
	var err error

	log.Info("starting minitunnel mux")

	for {
		var m tunnelMessage
		if err = t.dec.Decode(&m); err != nil {
			break
		}

		log.Debug("new message: %v", m.Type)

		// create new session if necessary
		if m.Type == CONNECT {
			t.handleRemote(&m)
		} else if m.Type == FORWARD {
			t.handleReverse(&m)
		} else if c := t.chans.get(m.TID); c != nil {
			// route the message to the handler by TID
			c <- &m
		} else {
			log.Info("invalid TID: %v", m.TID)
		}
	}

	close(t.quit) // signal to all listeners that this tunnel is outa here
	t.transport.Close()

	for _, ch := range t.chans.dropAll() {
		close(ch)
	}

	log.Info("mux exit: %v", err)
}
开发者ID:cdshann,项目名称:minimega,代码行数:39,代码来源:mux.go

示例10: webStart

func webStart(port int, root string) {
	// Initialize templates
	templates := filepath.Join(root, "templates")
	log.Info("compiling templates from %s", templates)

	web.Templates = template.New("minimega-templates")
	filepath.Walk(templates, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			log.Error("failed to load template from %s", path)
			return nil
		}

		if !info.IsDir() && strings.HasSuffix(path, ".html") {
			web.Templates.ParseFiles(path)
		}

		return nil
	})

	mux := http.NewServeMux()
	for _, v := range []string{"novnc", "libs", "include"} {
		path := fmt.Sprintf("/%s/", v)
		dir := http.Dir(filepath.Join(root, v))
		mux.Handle(path, http.StripPrefix(path, http.FileServer(dir)))
	}

	mux.HandleFunc("/", webVMs)
	mux.HandleFunc("/map", webMapVMs)
	mux.HandleFunc("/screenshot/", webScreenshot)
	mux.HandleFunc("/hosts", webHosts)
	mux.HandleFunc("/tags", webVMTags)
	mux.HandleFunc("/tiles", webTileVMs)
	mux.HandleFunc("/graph", webGraph)
	mux.HandleFunc("/json", webJSON)
	mux.HandleFunc("/vnc/", webVNC)
	mux.HandleFunc("/ws/", vncWsHandler)

	if web.Server == nil {
		web.Server = &http.Server{
			Addr:    fmt.Sprintf(":%d", port),
			Handler: mux,
		}

		err := web.Server.ListenAndServe()
		if err != nil {
			log.Error("web: %v", err)
			web.Server = nil
		} else {
			web.Port = port
			web.Running = true
		}
	} else {
		log.Info("web: changing web root to: %s", root)
		if port != web.Port && port != defaultWebPort {
			log.Error("web: changing web's port is not supported")
		}
		// just update the mux
		web.Server.Handler = mux
	}
}
开发者ID:npe9,项目名称:minimega,代码行数:60,代码来源:web.go

示例11: updateClient

// updateClient updates the client fields and pushes the VM tags state
func (s *Server) updateClient(cin *Client) {
	s.clientLock.Lock()
	defer s.clientLock.Unlock()

	c, ok := s.clients[cin.UUID]
	if !ok {
		// the client probably disconnected between sending the heartbeat and
		// us processing it. We'll still process any command responses.
		log.Info("unknown client %v", cin.UUID)
		return
	}

	c.Client = cin
	c.Checkin = time.Now()

	vm, ok := s.vms[cin.UUID]
	if !ok {
		// see above
		log.Info("unregistered client %v", cin.UUID)
		return
	}

	for k, v := range cin.Tags {
		vm.SetTag(k, v)
	}
}
开发者ID:cdshann,项目名称:minimega,代码行数:27,代码来源:server.go

示例12: Unlock

func (m *loggingMutex) Unlock() {
	_, file, line, _ := runtime.Caller(1)

	log.Info("unlocking: %v:%v", file, line)
	m.Mutex.Unlock()
	log.Info("unlocked: %v:%v", file, line)
}
开发者ID:cdshann,项目名称:minimega,代码行数:7,代码来源:misc.go

示例13: kill

func (vms VMs) kill(target string) []error {
	killedVms := map[int]bool{}

	errs := expandVmTargets(target, false, func(vm VM, _ bool) (bool, error) {
		if vm.GetState()&VM_KILLABLE == 0 {
			return false, nil
		}

		if err := vm.Kill(); err != nil {
			log.Error("unleash the zombie VM: %v", err)
		} else {
			killedVms[vm.GetID()] = true
		}
		return true, nil
	})

outer:
	for len(killedVms) > 0 {
		select {
		case id := <-killAck:
			log.Info("VM %v killed", id)
			delete(killedVms, id)
		case <-time.After(COMMAND_TIMEOUT * time.Second):
			log.Error("vm kill timeout")
			break outer
		}
	}

	for id := range killedVms {
		log.Info("VM %d failed to acknowledge kill", id)
	}

	return errs
}
开发者ID:postfix,项目名称:minimega,代码行数:34,代码来源:vmlist.go

示例14: Start

func (vm *ContainerVM) Start() error {
	if vm.State&VM_RUNNING != 0 {
		return nil
	}

	if vm.State == VM_QUIT || vm.State == VM_ERROR {
		log.Info("restarting VM: %v", vm.ID)
		ack := make(chan int)
		vm.kill = make(chan bool)
		go vm.launch(ack)
		log.Debug("ack restarted VM %v", <-ack)
	}

	log.Info("starting VM: %v", vm.ID)

	freezer := filepath.Join(CGROUP_PATH, fmt.Sprintf("%v", vm.ID), "freezer.state")
	err := ioutil.WriteFile(freezer, []byte("THAWED"), 0644)
	if err != nil {
		return err
	}

	vm.setState(VM_RUNNING)

	return nil
}
开发者ID:seedubb,项目名称:minimega,代码行数:25,代码来源:container.go

示例15: recvFiles

// recvFiles retrieves a list of files from the ron server by requesting each
// one individually.
func recvFiles(files []*ron.File) {
	start := time.Now()
	var size int64

	for _, v := range files {
		log.Info("requesting file %v", v)

		dst := filepath.Join(*f_path, "files", v.Name)

		if _, err := os.Stat(dst); err == nil {
			// file exists (TODO: overwrite?)
			log.Info("skipping %v -- already exists")
			continue
		}

		m := &ron.Message{
			Type:     ron.MESSAGE_FILE,
			UUID:     Client.UUID,
			Filename: v.Name,
		}

		if err := sendMessage(m); err != nil {
			log.Error("send failed: %v", err)
			return
		}

		resp := <-Client.fileChan
		if resp.Filename != v.Name {
			log.Error("filename mismatch: %v != %v", resp.Filename, v.Name)
			continue
		}

		if resp.Error != "" {
			log.Error("%v", resp.Error)
			continue
		}

		dir := filepath.Dir(dst)

		if err := os.MkdirAll(dir, os.FileMode(0770)); err != nil {
			log.Errorln(err)
			continue
		}

		if err := ioutil.WriteFile(dst, resp.File, v.Perm); err != nil {
			log.Errorln(err)
			continue
		}

		size += int64(len(resp.File))
	}

	d := time.Since(start)
	rate := (float64(size) / 1024 / d.Seconds())

	log.Debug("received %v bytes in %v (%v KBps)", size, d, rate)

	return
}
开发者ID:cdshann,项目名称:minimega,代码行数:61,代码来源:files.go


注:本文中的minilog.Info函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。