コード例 #1
0
ファイル: clone.go プロジェクト: ibmendoza/dgtk
func (action *Clone) Run() error {
	out := fmt.Sprintf("cloning vm %q", action.VmName)
	if action.SnapshotName != "" {
		out += fmt.Sprintf(" and snapshot=%q", action.SnapshotName)
	}
	logger.Printf(out)
	vms, e := vmware.AllWithTemplates()
	if e != nil {
		return e
	}
	vm := vms.FindFirst(action.VmName)
	clone, e := vmware.Create(vm, action.SnapshotName)
	if e != nil {
		return e
	}
	logger.Printf("using %d cpus", action.Cpus)
	e = clone.ModifyCpu(action.Cpus)
	if e != nil {
		return e
	}
	logger.Printf("using %d memory", action.Memory)
	e = clone.ModifyMemory(action.Memory)
	if e != nil {
		return e
	}
	started := time.Now()
	e = clone.Start()
	logger.Printf("started in %.3f", time.Since(started).Seconds())
	if e != nil {
		return e
	}

	if action.Name != "" {
		return vmware.UpdateTag(&vmware.Tag{VmId: clone.Id(), Key: "Name", Value: action.Name})
	}
	return nil
}
コード例 #2
0
ファイル: tags_create.go プロジェクト: ibmendoza/dgtk
func (r *TagsCreate) Run() error {
	tag := &vmware.Tag{VmId: r.VmId, Key: r.Key, Value: r.Value}
	return vmware.UpdateTag(tag)
}
コード例 #3
0
ファイル: tags_delete.go プロジェクト: ibmendoza/dgtk
func (r *TagsDelete) Run() error {
	tag := &vmware.Tag{VmId: r.VmId, Key: r.Key}
	return vmware.UpdateTag(tag)
}