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

Golang log.Errorf函数代码示例

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

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



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

示例1: cmdRm

func cmdRm(c *cli.Context) {
	if len(c.Args()) == 0 {
		cli.ShowCommandHelp(c, "rm")
		fatal("You must specify a machine name")
	}

	force := c.Bool("force")
	store := getStore(c)

	for _, hostName := range c.Args() {
		h, err := loadHost(store, hostName)
		if err != nil {
			fatalf("Error removing host %q: %s", hostName, err)
		}
		if err := h.Driver.Remove(); err != nil {
			if !force {
				log.Errorf("Provider error removing machine %q: %s", hostName, err)
				continue
			}
		}

		if err := store.Remove(hostName); err != nil {
			log.Errorf("Error removing machine %q from store: %s", hostName, err)
		} else {
			log.Infof("Successfully removed %s", hostName)
		}
	}
}
开发者ID:rhendric,项目名称:machine,代码行数:28,代码来源:rm.go


示例2: Remove

func (d *Driver) Remove() error {
	s, err := d.GetState()
	if err != nil {
		if err == ErrMachineNotExist {
			log.Infof("machine does not exist, assuming it has been removed already")
			return nil
		}
		return err
	}
	if s == state.Running {
		if err := d.Stop(); err != nil {
			return err
		}
	}

	if err := d.removeDiskImage(); err != nil {
		return err
	}

	if d.NFSShare {
		log.Infof("Remove NFS share folder must be root. Please insert root password.")
		if _, err := nfsexports.Remove("", d.nfsExportIdentifier()); err != nil {
			log.Errorf("failed removing nfs share: %s", err.Error())
		}

		if err := nfsexports.ReloadDaemon(); err != nil {
			log.Errorf("failed reload nfs daemon: %s", err.Error())
		}
	}
	return nil
}
开发者ID:johanneswuerbach,项目名称:docker-machine-xhyve,代码行数:31,代码来源:xhyve.go


示例3: SubmitDeploymentJobs

// SubmitDeploymentJobs api call to deployment jobs
func (c *ICSPClient) SubmitDeploymentJobs(dj DeploymentJobs) (jt *JobTask, err error) {
	log.Info("Applying OS Build plan for ICSP")
	var (
		uri  = "/rest/os-deployment-jobs"
		juri ODSUri
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	jt = jt.NewJobTask(c)
	jt.Reset()
	data, err := c.RestAPICall(rest.POST, uri, dj)
	if err != nil {
		jt.IsDone = true
		log.Errorf("Error submitting new build request: %s", err)
		return jt, err
	}

	log.Debugf("Response submit new os build plan job %s", data)
	if err := json.Unmarshal([]byte(data), &juri); err != nil {
		jt.IsDone = true
		jt.JobURI = juri
		log.Errorf("Error with task un-marshal: %s", err)
		return jt, err
	}
	jt.JobURI = juri

	return jt, err
}
开发者ID:HewlettPackard,项目名称:oneview-golang,代码行数:31,代码来源:deploymentjobs.go


示例4: UpdateGoldenImage

func (c *I3SClient) UpdateGoldenImage(goldenImage GoldenImage) error {
	log.Infof("Initializing update of golden image for %s.", goldenImage.Name)
	var (
		uri = goldenImage.URI.String()
		t   *Task
	)

	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, goldenImage)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.PUT, uri, goldenImage)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting update golden image request: %s", err)
		return err
	}

	log.Debugf("Response update Golden Image %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
开发者ID:HewlettPackard,项目名称:oneview-golang,代码行数:34,代码来源:golden_image.go


示例5: UpdateProfileTemplate

func (c *OVClient) UpdateProfileTemplate(serverProfileTemplate ServerProfile) error {
	log.Infof("Initializing update of server profile template for %s.", serverProfileTemplate.Name)
	var (
		uri = serverProfileTemplate.URI.String()
		t   *Task
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, serverProfileTemplate)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.PUT, uri, serverProfileTemplate)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting update server profile template request: %s", err)
		return err
	}

	log.Debugf("Response update ServerProfileTemplate %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
开发者ID:wenlock,项目名称:oneview-golang,代码行数:35,代码来源:profile_templates.go


示例6: SubmitDeleteProfile

// submit new profile template
func (c *OVClient) SubmitDeleteProfile(p ServerProfile) (t *Task, err error) {
	var (
		uri = p.URI.String()
	// 	task = rest_api(:oneview, :post, '/rest/server-profiles', { 'body' => new_template_profile })
	)
	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, p)
	log.Debugf("task -> %+v", t)
	if uri == "" {
		log.Warn("Unable to post delete, no uri found.")
		t.TaskIsDone = true
		return t, err
	}
	data, err := c.RestAPICall(rest.DELETE, uri, nil)
	if err != nil {
		log.Errorf("Error submitting new profile request: %s", err)
		t.TaskIsDone = true
		return t, err
	}

	log.Debugf("Response delete profile %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return t, err
	}

	return t, err
}
开发者ID:wenlock,项目名称:oneview-golang,代码行数:31,代码来源:profiles.go


示例7: CreatePlanScript

func (c *I3SClient) CreatePlanScript(planScript PlanScript) error {
	log.Infof("Initializing creation of plan script for %s.", planScript.Name)
	var (
		uri                 = "/rest/plan-scripts"
		attemptedPlanScript *PlanScript
	)

	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	data, err := c.RestAPICall(rest.POST, uri, planScript)
	if err != nil {
		log.Errorf("Error submitting new plan script request: %s", err)
		return err
	}

	log.Debugf("Response New Plan Script %s", data)
	if err := json.Unmarshal([]byte(data), &attemptedPlanScript); err != nil {
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	if attemptedPlanScript.URI == "" {
		return fmt.Errorf("PlanScript not succesfully created")
	}

	return nil
}
开发者ID:HewlettPackard,项目名称:oneview-golang,代码行数:27,代码来源:plan_script.go


示例8: CreateEnclosureGroup

func (c *OVClient) CreateEnclosureGroup(eGroup EnclosureGroup) error {
	log.Infof("Initializing creation of enclosure group for %s.", eGroup.Name)
	var (
		uri = "/rest/enclosure-groups"
		t   *Task
	)

	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewProfileTask(c)
	t.ResetTask()
	data, err := c.RestAPICall(rest.POST, uri, eGroup)
	if err != nil {
		log.Errorf("Error submitting new enclosure group request: %s", err)
		return err
	}

	log.Debugf("Response New EnclosureGroup %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	return nil
}
开发者ID:HewlettPackard,项目名称:oneview-golang,代码行数:28,代码来源:enclosure_group.go


示例9: isActive

// IsActive provides a single function for determining if a host is active
// based on both the url and if the host is stopped.
func isActive(h *host.Host) (bool, error) {
	currentState, err := h.Driver.GetState()

	if err != nil {
		log.Errorf("error getting state for host %s: %s", h.Name, err)
		return false, err
	}

	url, err := h.GetURL()

	if err != nil {
		if err == drivers.ErrHostIsNotRunning {
			url = ""
		} else {
			log.Errorf("error getting URL for host %s: %s", h.Name, err)
			return false, err
		}
	}

	dockerHost := os.Getenv("DOCKER_HOST")

	notStopped := currentState != state.Stopped
	correctURL := url == dockerHost

	isActive := notStopped && correctURL

	return isActive, nil
}
开发者ID:rominirani,项目名称:machine,代码行数:30,代码来源:ls.go


示例10: CreateFCNetwork

func (c *OVClient) CreateFCNetwork(fcNet FCNetwork) error {
	log.Infof("Initializing creation of fc network for %s.", fcNet.Name)
	var (
		uri = "/rest/fc-networks"
		t   *Task
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, fcNet)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.POST, uri, fcNet)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting new fc network request: %s", err)
		return err
	}

	log.Debugf("Response New fcNetwork %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
开发者ID:wenlock,项目名称:oneview-golang,代码行数:35,代码来源:fc_network.go


示例11: attemptGetHostState

func attemptGetHostState(h *host.Host, stateQueryChan chan<- HostListItem) {
	currentState, err := h.Driver.GetState()
	if err != nil {
		log.Errorf("error getting state for host %s: %s", h.Name, err)
	}

	url, err := h.GetURL()
	if err != nil {
		if err == drivers.ErrHostIsNotRunning {
			url = ""
		} else {
			log.Errorf("error getting URL for host %s: %s", h.Name, err)
		}
	}

	active, err := isActive(h)
	if err != nil {
		log.Errorf("error determining if host is active for host %s: %s",
			h.Name, err)
	}

	stateQueryChan <- HostListItem{
		Name:         h.Name,
		Active:       active,
		DriverName:   h.Driver.DriverName(),
		State:        currentState,
		URL:          url,
		SwarmOptions: h.HostOptions.SwarmOptions,
	}
}
开发者ID:rominirani,项目名称:machine,代码行数:30,代码来源:ls.go


示例12: CreateArtifactsBundle

func (c *I3SClient) CreateArtifactsBundle(artifactsBundle InputArtifactsBundle) error {
	log.Infof("Initializing creation of artifactsBundle for %s.", artifactsBundle.Name)
	var (
		uri = "/rest/artifact-bundles"
		t   *Task
	)

	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, artifactsBundle)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.POST, uri, artifactsBundle)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting new artifacts bundle request: %s", err)
		return err
	}

	log.Debugf("Response New ArtifactsBundle %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
开发者ID:HewlettPackard,项目名称:oneview-golang,代码行数:34,代码来源:artifacts_bundle.go


示例13: cmdRm

func cmdRm(c CommandLine) error {
	if len(c.Args()) == 0 {
		c.ShowHelp()
		return errors.New("You must specify a machine name")
	}

	force := c.Bool("force")
	store := getStore(c)

	for _, hostName := range c.Args() {
		h, err := loadHost(store, hostName)
		if err != nil {
			return fmt.Errorf("Error removing host %q: %s", hostName, err)
		}

		if err := h.Driver.Remove(); err != nil {
			if !force {
				log.Errorf("Provider error removing machine %q: %s", hostName, err)
				continue
			}
		}

		if err := store.Remove(hostName); err != nil {
			log.Errorf("Error removing machine %q from store: %s", hostName, err)
		} else {
			log.Infof("Successfully removed %s", hostName)
		}
	}

	return nil
}
开发者ID:mschygulla,项目名称:machine,代码行数:31,代码来源:rm.go


示例14: CreateDeploymentPlan

func (c *I3SClient) CreateDeploymentPlan(deploymentPlan DeploymentPlan) error {
	log.Infof("Initializing creation of deploymentPlan for %s.", deploymentPlan.Name)
	var (
		uri = "/rest/deployment-plans"
		t   *Task
	)

	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, deploymentPlan)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.POST, uri, deploymentPlan)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting new deployment plan request: %s", err)
		return err
	}

	log.Debugf("Response New DeploymentPlan %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
开发者ID:HewlettPackard,项目名称:oneview-golang,代码行数:34,代码来源:deployment_plan.go


示例15: SubmitNewServer

// SubmitNewServer submit new profile template
func (c *ICSPClient) SubmitNewServer(sc ServerCreate) (jt *JobTask, err error) {
	log.Infof("Initializing creation of server for ICSP, %s.", sc.IPAddress)
	var (
		uri = "/rest/os-deployment-servers"
		// uri  = "/rest/os-deployment-ilos" //TODO: implement hidden api for server deploy that works in Houston
		juri ODSUri
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())
	// c.SetAuthHeaderOptions(c.GetAuthHeaderMapNoVer()) //TODO: only needed when using os-deployment-ilos

	jt = jt.NewJobTask(c)
	jt.Reset()
	data, err := c.RestAPICall(rest.POST, uri, sc)
	if err != nil {
		jt.IsDone = true
		log.Errorf("Error submitting new server request: %s", err)
		return jt, err
	}

	log.Debugf("Response submit new server %s", data)
	if err := json.Unmarshal([]byte(data), &juri); err != nil {
		jt.IsDone = true
		jt.JobURI = juri
		log.Errorf("Error with task un-marshal: %s", err)
		return jt, err
	}
	jt.JobURI = juri

	return jt, err
}
开发者ID:HewlettPackard,项目名称:oneview-golang,代码行数:33,代码来源:servers.go


示例16: UpdateEnclosureGroup

func (c *OVClient) UpdateEnclosureGroup(enclosureGroup EnclosureGroup) error {
	log.Infof("Initializing update of enclosure group for %s.", enclosureGroup.Name)
	var (
		uri = enclosureGroup.URI.String()
		t   *Task
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, enclosureGroup)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.PUT, uri, enclosureGroup)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting update enclosure group request: %s", err)
		return err
	}

	log.Debugf("Response update EnclosureGroup %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	return nil
}
开发者ID:HewlettPackard,项目名称:oneview-golang,代码行数:30,代码来源:enclosure_group.go


示例17: SubmitNewProfile

// SubmitNewProfile - submit new profile template
func (c *OVClient) SubmitNewProfile(p ServerProfile) (t *Task, err error) {
	log.Infof("Initializing creation of server profile for %s.", p.Name)
	var (
		uri = "/rest/server-profiles"
	// 	task = rest_api(:oneview, :post, '/rest/server-profiles', { 'body' => new_template_profile })
	)
	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, p)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.POST, uri, p)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting new profile request: %s", err)
		return t, err
	}

	log.Debugf("Response NewProfile %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return t, err
	}

	return t, err
}
开发者ID:wenlock,项目名称:oneview-golang,代码行数:27,代码来源:profiles.go


示例18: SubmitPowerState

// Submit desired power state
func (pt *PowerTask) SubmitPowerState(s PowerState) {
	if err := pt.GetCurrentPowerState(); err != nil {
		pt.TaskIsDone = true
		log.Errorf("Error getting current power state: %s", err)
		return
	}
	if s != pt.State {
		log.Infof("Powering %s server %s for %s.", s, pt.Blade.Name, pt.Blade.SerialNumber)
		var (
			body = PowerRequest{PowerState: s.String(), PowerControl: P_PRESSANDHOLD.String()}
			uri  = strings.Join([]string{pt.Blade.URI.String(),
				"/powerState"}, "")
		)
		log.Debugf("REST : %s \n %+v\n", uri, body)
		log.Debugf("pt -> %+v", pt)
		data, err := pt.Blade.Client.RestAPICall(rest.PUT, uri, body)
		if err != nil {
			pt.TaskIsDone = true
			log.Errorf("Error with power state request: %s", err)
			return
		}

		log.Debugf("SubmitPowerState %s", data)
		if err := json.Unmarshal([]byte(data), &pt); err != nil {
			pt.TaskIsDone = true
			log.Errorf("Error with power state un-marshal: %s", err)
			return
		}
	} else {
		log.Infof("Desired Power State already set -> %s", pt.State)
		pt.TaskIsDone = true
	}

	return
}
开发者ID:wenlock,项目名称:oneview-golang,代码行数:36,代码来源:power_state.go


示例19: CreateStorageVolume

func (c *OVClient) CreateStorageVolume(sVol StorageVolumeV3) error {
	log.Infof("Initializing creation of storage volume for %s.", sVol.Name)
	var (
		uri = "/rest/storage-volumes"
		t   *Task
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, sVol)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.POST, uri, sVol)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting new storage volume request: %s", err)
		return err
	}

	log.Debugf("Response New StorageVolume %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
开发者ID:HewlettPackard,项目名称:oneview-golang,代码行数:35,代码来源:storage_volume.go


示例20: importVdi

func (d *Driver) importVdi(vdi *xsclient.VDI, filename string, timeout time.Duration) error {
	f, err := os.Open(filename)
	if err != nil {
		log.Errorf("Unable to open disk image '%s': %v", filename, err)
		return err
	}

	// Get file length
	fi, err := f.Stat()
	if err != nil {
		log.Errorf("Unable to stat disk image '%s': %v", filename, err)
		return err
	}

	task, err := vdi.Client.CreateTask()
	if err != nil {
		return fmt.Errorf("Unable to create task: %v", err)
	}
	urlStr := fmt.Sprintf("https://%s/import_raw_vdi?vdi=%s&session_id=%s&task_id=%s",
		vdi.Client.Host, vdi.Ref, vdi.Client.Session.(string), task.Ref)

	// Define a new http Transport which allows self-signed certs
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}

	req, err := http.NewRequest("PUT", urlStr, f)
	if err != nil {
		return err
	}
	req.ContentLength = fi.Size()

	resp, err := tr.RoundTrip(req)
	if err != nil {
		log.Errorf("Unable to upload VDI: %v", err)
		return err
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		msg, _ := ioutil.ReadAll(resp.Body)
		err = fmt.Errorf("xenserver reply %s: %v", resp.Status, string(msg))
		log.Errorf("Unable to upload VDI: %v", err)
		return err
	}

	log.Infof("Waiting Upload VDI task(%v) to complete...", task.Ref)
	if err = d.waitTask(task, timeout); err != nil {
		return err
	}
	return nil
}
开发者ID:jonludlam,项目名称:docker-machine-xenserver,代码行数:52,代码来源:xenserver.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang log.Fatal函数代码示例发布时间:2022-05-23
下一篇:
Golang log.Error函数代码示例发布时间: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