• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang log.Warnf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getOrCreateHostOnlyNetwork

func getOrCreateHostOnlyNetwork(hostIP net.IP, netmask net.IPMask, nets map[string]*hostOnlyNetwork, vbox VBoxManager) (*hostOnlyNetwork, error) {
	// Search for an existing host-only adapter.
	hostOnlyAdapter := getHostOnlyAdapter(nets, hostIP, netmask)
	if hostOnlyAdapter != nil {
		return hostOnlyAdapter, nil
	}

	// No existing host-only adapter found. Create a new one.
	_, err := createHostonlyAdapter(vbox)
	if err != nil {
		// Sometimes the host-only adapter fails to create. See https://www.virtualbox.org/ticket/14040
		// BUT, it is created in fact! So let's wait until it appears last in the list
		log.Warnf("Creating a new host-only adapter produced an error: %s", err)
		log.Warn("This is a known VirtualBox bug. Let's try to recover anyway...")
	}

	// It can take some time for an adapter to appear. Let's poll.
	hostOnlyAdapter, err = waitForNewHostOnlyNetwork(nets, vbox)
	if err != nil {
		// Sometimes, Vbox says it created it but then it cannot be found...
		return nil, errNewHostOnlyAdapterNotVisible
	}

	log.Warnf("Found a new host-only adapter: %q", hostOnlyAdapter.Name)

	hostOnlyAdapter.IPv4.IP = hostIP
	hostOnlyAdapter.IPv4.Mask = netmask
	if err := hostOnlyAdapter.Save(vbox); err != nil {
		return nil, err
	}

	return hostOnlyAdapter, nil
}
开发者ID:tsuru,项目名称:tsuru,代码行数:33,代码来源:network.go


示例2: Start

func (d *Driver) Start() error {
	log.Debugf("Starting VM %s", d.MachineName)
	d.validateVMRef()
	err := d.VM.Create()
	if err != nil {
		log.Warnf("Failed to start: %s", err)
		return err
	}

	// They wont start immediately
	time.Sleep(5 * time.Second)

	for i := 0; i < 90; i++ {
		time.Sleep(time.Second)
		ip, _ := d.GetIP()
		if ip != "" {
			// Add a second to let things settle
			time.Sleep(time.Second)
			return nil
		}
		log.Debugf("Waiting for the VM to come up... %d", i)
	}
	log.Warnf("Unable to determine VM's IP address, did it fail to boot?")
	return err
}
开发者ID:b0d0nne11,项目名称:docker-machine-kvm,代码行数:25,代码来源:kvm.go


示例3: getIPByMacFromSettings

func (d *Driver) getIPByMacFromSettings(mac string) (string, error) {
	network, err := d.conn.LookupNetworkByName(d.PrivateNetwork)
	if err != nil {
		log.Warnf("Failed to find network: %s", err)
		return "", err
	}
	bridge_name, err := network.GetBridgeName()
	if err != nil {
		log.Warnf("Failed to get network bridge: %s", err)
		return "", err
	}
	statusFile := fmt.Sprintf(dnsmasqStatus, bridge_name)
	data, err := ioutil.ReadFile(statusFile)
	type Lease struct {
		Ip_address  string `json:"ip-address"`
		Mac_address string `json:"mac-address"`
		// Other unused fields omitted
	}
	var s []Lease

	err = json.Unmarshal(data, &s)
	if err != nil {
		log.Warnf("Failed to decode dnsmasq lease status: %s", err)
		return "", err
	}
	for _, value := range s {
		if strings.ToLower(value.Mac_address) == strings.ToLower(mac) {
			log.Debugf("IP address: %s", value.Ip_address)
			return value.Ip_address, nil
		}
	}
	return "", nil
}
开发者ID:b0d0nne11,项目名称:docker-machine-kvm,代码行数:33,代码来源:kvm.go


示例4: closeAll

// closeAll - cleanup sessions on the OV and ICSP appliances
func closeAll(d *Driver) {
	err := d.ClientOV.SessionLogout()
	if err != nil {
		log.Warnf("OV Session Logout : %s", err)
	}
	err = d.ClientICSP.SessionLogout()
	if err != nil {
		log.Warnf("ICSP Session Logout : %s", err)
	}
}
开发者ID:JohnKDay,项目名称:docker-machine-oneview,代码行数:11,代码来源:oneview.go


示例5: removeOrphanDHCPServers

// removeOrphanDHCPServers removed the DHCP servers linked to no host-only adapter
func removeOrphanDHCPServers(vbox VBoxManager) error {
	dhcps, err := listDHCPServers(vbox)
	if err != nil {
		return err
	}

	if len(dhcps) == 0 {
		return nil
	}

	nets, err := listHostOnlyAdapters(vbox)
	if err != nil {
		return err
	}

	for name := range dhcps {
		if strings.HasPrefix(name, dhcpPrefix) {
			if _, present := nets[name]; !present {
				if err := vbox.vbm("dhcpserver", "remove", "--netname", name); err != nil {
					log.Warnf("Unable to remove orphan dhcp server %q: %s", name, err)
				}
			}
		}
	}

	return nil
}
开发者ID:webchip,项目名称:machine,代码行数:28,代码来源:network.go


示例6: PowerExecutor

// Submit desired power state and wait
// Most of our concurrency will happen in PowerExecutor
func (pt *PowerTask) PowerExecutor(s PowerState) error {
	currenttime := 0
	pt.State = P_UKNOWN
	pt.ResetTask()
	go pt.SubmitPowerState(s)
	for !pt.TaskIsDone && (currenttime < pt.Timeout) {
		if err := pt.GetCurrentTaskStatus(); err != nil {
			return err
		}
		if pt.URI != "" && T_COMPLETED.Equal(pt.TaskState) {
			pt.TaskIsDone = true
		}
		if pt.URI != "" {
			log.Debugf("Waiting to set power state %s for blade %s, %s", s, pt.Blade.Name)
			log.Infof("Working on power state,%d%%, %s.", pt.ComputedPercentComplete, pt.TaskStatus)
		} else {
			log.Info("Working on power state.")
		}

		// wait time before next check
		time.Sleep(time.Millisecond * (1000 * pt.WaitTime)) // wait 10sec before checking the status again
		currenttime++
	}
	if !(currenttime < pt.Timeout) {
		log.Warnf("Power %s state timed out for %s.", s, pt.Blade.Name)
	}
	log.Infof("Power Task Execution Completed")
	return nil
}
开发者ID:wenlock,项目名称:oneview-golang,代码行数:31,代码来源:power_state.go


示例7: GetCurrentPowerState

// get current power state
func (pt *PowerTask) GetCurrentPowerState() error {
	// Quick check to make sure we have a proper hardware blade
	if pt.Blade.URI.IsNil() {
		pt.State = P_UKNOWN
		return errors.New("Can't get power on blade without hardware")
	}

	// get the latest state based on current blade uri
	b, err := pt.Blade.Client.GetServerHardware(pt.Blade.URI)
	if err != nil {
		return err
	}
	log.Debugf("GetCurrentPowerState() blade -> %+v", b)
	// Set the current state of the blade as a constant
	if P_OFF.Equal(b.PowerState) {
		pt.State = P_OFF
	} else if P_ON.Equal(b.PowerState) {
		pt.State = P_ON
	} else {
		log.Warnf("Un-known power state detected %s, for %s.", b.PowerState, b.Name)
		pt.State = P_UKNOWN
	}
	// Reassign the current blade and state of that blade
	pt.Blade = b
	return nil
}
开发者ID:wenlock,项目名称:oneview-golang,代码行数:27,代码来源:power_state.go


示例8: GetSSHPassword

func (c *RPCClientDriver) GetSSHPassword() string {
	sshPassword, err := c.rpcStringCall(GetSSHPasswordMethod)
	if err != nil {
		log.Warnf("Error attempting call to get SSH password: %s", err)
	}
	return sshPassword
}
开发者ID:containerx,项目名称:machine,代码行数:7,代码来源:client_driver.go


示例9: GetOS

func (c *RPCClientDriver) GetOS() string {
	OS, err := c.rpcStringCall(GetOSMethod)
	if err != nil {
		log.Warnf("Error attempting call to get OS: %s", err)
	}
	return OS
}
开发者ID:containerx,项目名称:machine,代码行数:7,代码来源:client_driver.go


示例10: PreCreateCheck

func (d *Driver) PreCreateCheck() error {
	conn, err := d.getConn()
	if err != nil {
		return err
	}

	// TODO We could look at conn.GetCapabilities()
	// parse the XML, and look for kvm
	log.Debug("About to check libvirt version")

	// TODO might want to check minimum version
	_, err = conn.GetLibVersion()
	if err != nil {
		log.Warnf("Unable to get libvirt version")
		return err
	}
	err = d.validatePrivateNetwork()
	if err != nil {
		return err
	}
	err = d.validateNetwork(d.Network)
	if err != nil {
		return err
	}
	// Others...?
	return nil
}
开发者ID:dhiltgen,项目名称:docker-machine-kvm,代码行数:27,代码来源:kvm.go


示例11: configureTags

func (d *Driver) configureTags(tagGroups string) error {

	tags := []*ec2.Tag{}
	tags = append(tags, &ec2.Tag{
		Key:   aws.String("Name"),
		Value: &d.MachineName,
	})

	if tagGroups != "" {
		t := strings.Split(tagGroups, ",")
		if len(t) > 0 && len(t)%2 != 0 {
			log.Warnf("Tags are not key value in pairs. %d elements found", len(t))
		}
		for i := 0; i < len(t)-1; i += 2 {
			tags = append(tags, &ec2.Tag{
				Key:   &t[i],
				Value: &t[i+1],
			})
		}
	}

	_, err := d.getClient().CreateTags(&ec2.CreateTagsInput{
		Resources: []*string{&d.InstanceId},
		Tags:      tags,
	})

	if err != nil {
		return err
	}

	return nil
}
开发者ID:robertjustjones,项目名称:machine,代码行数:32,代码来源:amazonec2.go


示例12: Stop

func (d *Driver) Stop() error {
	log.Debugf("Stopping VM %s", d.MachineName)
	d.validateVMRef()
	s, err := d.GetState()
	if err != nil {
		return err
	}

	if s != state.Stopped {
		err := d.VM.DestroyFlags(libvirt.VIR_DOMAIN_DESTROY_GRACEFUL)
		if err != nil {
			log.Warnf("Failed to gracefully shutdown VM")
			return err
		}
		for i := 0; i < 90; i++ {
			time.Sleep(time.Second)
			s, _ := d.GetState()
			log.Debugf("VM state: %s", s)
			if s == state.Stopped {
				return nil
			}
		}
		return errors.New("VM Failed to gracefully shutdown, try the kill command")
	}
	return nil
}
开发者ID:b0d0nne11,项目名称:docker-machine-kvm,代码行数:26,代码来源:kvm.go


示例13: UpdateISOCache

func (b *B2dUtils) UpdateISOCache(isoURL string) error {
	// recreate the cache dir if it has been manually deleted
	if _, err := os.Stat(b.imgCachePath); os.IsNotExist(err) {
		log.Infof("Image cache directory does not exist, creating it at %s...", b.imgCachePath)
		if err := os.Mkdir(b.imgCachePath, 0700); err != nil {
			return err
		}
	}

	exists := b.exists()

	if isoURL != "" {
		if exists {
			// Warn that the b2d iso won't be updated if isoURL is set
			log.Warnf("Boot2Docker URL was explicitly set to %q at create time, so Docker Machine cannot upgrade this machine to the latest version.", isoURL)
		}
		// Non-default B2D are not cached
		return nil
	}

	if !exists {
		log.Info("No default Boot2Docker ISO found locally, downloading the latest release...")
		return b.DownloadLatestBoot2Docker("")
	}

	latest := b.isLatest()
	if !latest {
		log.Info("Default Boot2Docker ISO is out-of-date, downloading the latest release...")
		return b.DownloadLatestBoot2Docker("")
	}

	return nil
}
开发者ID:RaulKite,项目名称:machine,代码行数:33,代码来源:b2d.go


示例14: NewRpcClientDriver

func NewRpcClientDriver(rawDriverData []byte, driverName string) (*RpcClientDriver, error) {
	mcnName := ""

	p := localbinary.NewLocalBinaryPlugin(driverName)

	go func() {
		if err := p.Serve(); err != nil {
			// If we can't safely load the server, best to just
			// bail.
			log.Fatal(err)
		}
	}()

	addr, err := p.Address()
	if err != nil {
		return nil, fmt.Errorf("Error attempting to get plugin server address for RPC: %s", err)
	}

	rpcclient, err := rpc.DialHTTP("tcp", addr)
	if err != nil {
		return nil, err
	}

	c := &RpcClientDriver{
		Client:          NewInternalClient(rpcclient),
		heartbeatDoneCh: make(chan bool),
	}

	go func(heartbeatDoneCh <-chan bool) {
		for {
			select {
			case <-heartbeatDoneCh:
				return
			default:
				if err := c.Client.Call("RpcServerDriver.Heartbeat", struct{}{}, nil); err != nil {
					log.Warnf("Error attempting heartbeat call to plugin server: %s", err)
				}
				time.Sleep(heartbeatInterval)
			}
		}
	}(c.heartbeatDoneCh)

	var version int
	if err := c.Client.Call("RpcServerDriver.GetVersion", struct{}{}, &version); err != nil {
		return nil, err
	}
	log.Debug("Using API Version ", version)

	if err := c.SetConfigRaw(rawDriverData); err != nil {
		return nil, err
	}

	mcnName = c.GetMachineName()
	p.MachineName = mcnName
	c.Client.MachineName = mcnName
	c.plugin = p

	return c, nil
}
开发者ID:rhendric,项目名称:machine,代码行数:59,代码来源:client_driver.go


示例15: GetSSHPassword

func (c *RpcClientDriver) GetSSHPassword() string {
	password, err := c.rpcStringCall("RpcServerDriver.GetSSHPassword")
	if err != nil {
		log.Warnf("Error attempting call to get SSH password: %s", err)
	}

	return password
}
开发者ID:pdxjohnny,项目名称:machine,代码行数:8,代码来源:client_driver.go


示例16: GlobalArtifactPath

func (c *RPCClientDriver) GlobalArtifactPath() string {
	globalArtifactPath, err := c.rpcStringCall("RPCServerDriver.GlobalArtifactPath")
	if err != nil {
		log.Warnf("Error attempting call to get GlobalArtifactPath: %s", err)
	}

	return globalArtifactPath
}
开发者ID:rowancarr,项目名称:machine,代码行数:8,代码来源:client_driver.go


示例17: GetSSHUsername

func (c *RPCClientDriver) GetSSHUsername() string {
	username, err := c.rpcStringCall("RPCServerDriver.GetSSHUsername")
	if err != nil {
		log.Warnf("Error attempting call to get SSH username: %s", err)
	}

	return username
}
开发者ID:rowancarr,项目名称:machine,代码行数:8,代码来源:client_driver.go


示例18: GetSSHKeyPath

// GetSSHKeyPath returns the key path
// TODO:  This method doesn't even make sense to have with RPC.
func (c *RPCClientDriver) GetSSHKeyPath() string {
	path, err := c.rpcStringCall("RPCServerDriver.GetSSHKeyPath")
	if err != nil {
		log.Warnf("Error attempting call to get SSH key path: %s", err)
	}

	return path
}
开发者ID:rowancarr,项目名称:machine,代码行数:10,代码来源:client_driver.go


示例19: GetMachineName

func (c *RPCClientDriver) GetMachineName() string {
	name, err := c.rpcStringCall("RPCServerDriver.GetMachineName")
	if err != nil {
		log.Warnf("Error attempting call to get machine name: %s", err)
	}

	return name
}
开发者ID:rowancarr,项目名称:machine,代码行数:8,代码来源:client_driver.go


示例20: DriverName

// DriverName returns the name of the driver
func (c *RPCClientDriver) DriverName() string {
	driverName, err := c.rpcStringCall("RPCServerDriver.DriverName")
	if err != nil {
		log.Warnf("Error attempting call to get driver name: %s", err)
	}

	return driverName
}
开发者ID:rowancarr,项目名称:machine,代码行数:9,代码来源:client_driver.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang log.WithField函数代码示例发布时间:2022-05-23
下一篇:
Golang log.Warn函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap