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

Golang disk.Disk类代码示例

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

本文整理汇总了Golang中github.com/cloudfoundry/bosh-init/deployment/disk.Disk的典型用法代码示例。如果您正苦于以下问题:Golang Disk类的具体用法?Golang Disk怎么用?Golang Disk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: DetachDisk

func (vm *FakeVM) DetachDisk(disk bidisk.Disk) error {
	vm.DetachDiskInputs = append(vm.DetachDiskInputs, DetachDiskInput{
		Disk: disk,
	})

	return vm.detachDiskBehavior[disk.CID()]
}
开发者ID:vestel,项目名称:bosh-init,代码行数:7,代码来源:fake_vm.go


示例2: attachDisk

func (d *diskDeployer) attachDisk(disk bidisk.Disk, vm VM, stage biui.Stage) error {
	stageName := fmt.Sprintf("Attaching disk '%s' to VM '%s'", disk.CID(), vm.CID())
	err := stage.Perform(stageName, func() error {
		return vm.AttachDisk(disk)
	})

	return err
}
开发者ID:vestel,项目名称:bosh-init,代码行数:8,代码来源:disk_deployer.go


示例3: DetachDisk

func (vm *vm) DetachDisk(disk bidisk.Disk) error {
	err := vm.cloud.DetachDisk(vm.cid, disk.CID())
	if err != nil {
		return bosherr.WrapError(err, "Detaching disk in the cloud")
	}

	return nil
}
开发者ID:vestel,项目名称:bosh-init,代码行数:8,代码来源:vm.go


示例4: migrateDisk

func (d *diskDeployer) migrateDisk(
	originalDisk bidisk.Disk,
	diskPool bideplmanifest.DiskPool,
	vm VM,
	stage biui.Stage,
) (newDisk bidisk.Disk, err error) {
	d.logger.Debug(d.logTag, "Migrating disk '%s'", originalDisk.CID())

	err = stage.Perform("Creating disk", func() error {
		newDisk, err = d.diskManager.Create(diskPool, vm.CID())
		return err
	})
	if err != nil {
		return newDisk, err
	}

	stageName := fmt.Sprintf("Attaching disk '%s' to VM '%s'", newDisk.CID(), vm.CID())
	err = stage.Perform(stageName, func() error {
		return vm.AttachDisk(newDisk)
	})
	if err != nil {
		return newDisk, err
	}

	stageName = fmt.Sprintf("Migrating disk content from '%s' to '%s'", originalDisk.CID(), newDisk.CID())
	err = stage.Perform(stageName, func() error {
		return vm.MigrateDisk()
	})
	if err != nil {
		return newDisk, err
	}

	err = d.updateCurrentDiskRecord(newDisk)
	if err != nil {
		return newDisk, err
	}

	stageName = fmt.Sprintf("Detaching disk '%s'", originalDisk.CID())
	err = stage.Perform(stageName, func() error {
		return vm.DetachDisk(originalDisk)
	})
	if err != nil {
		return newDisk, err
	}

	stageName = fmt.Sprintf("Deleting disk '%s'", originalDisk.CID())
	err = stage.Perform(stageName, func() error {
		return originalDisk.Delete()
	})
	if err != nil {
		return newDisk, err
	}

	return newDisk, nil
}
开发者ID:vestel,项目名称:bosh-init,代码行数:55,代码来源:disk_deployer.go


示例5: deleteDisk

func (d *deployment) deleteDisk(deleteStage biui.Stage, disk bidisk.Disk) error {
	stepName := fmt.Sprintf("Deleting disk '%s'", disk.CID())
	return deleteStage.Perform(stepName, func() error {
		err := disk.Delete()
		cloudErr, ok := err.(bicloud.Error)
		if ok && cloudErr.Type() == bicloud.DiskNotFoundError {
			return biui.NewSkipStageError(cloudErr, "Disk not found")
		}
		return err
	})
}
开发者ID:vestel,项目名称:bosh-init,代码行数:11,代码来源:deployment.go


示例6: AttachDisk

func (vm *vm) AttachDisk(disk bidisk.Disk) error {
	err := vm.cloud.AttachDisk(vm.cid, disk.CID())
	if err != nil {
		return bosherr.WrapError(err, "Attaching disk in the cloud")
	}

	err = vm.agentClient.MountDisk(disk.CID())
	if err != nil {
		return bosherr.WrapError(err, "Mounting disk")
	}

	return nil
}
开发者ID:vestel,项目名称:bosh-init,代码行数:13,代码来源:vm.go


示例7: updateCurrentDiskRecord

func (d *diskDeployer) updateCurrentDiskRecord(disk bidisk.Disk) error {
	savedDiskRecord, found, err := d.diskRepo.Find(disk.CID())
	if err != nil {
		return bosherr.WrapError(err, "Finding disk record")
	}

	if !found {
		return bosherr.Error("Failed to find disk record for new disk")
	}

	err = d.diskRepo.UpdateCurrent(savedDiskRecord.ID)
	if err != nil {
		return bosherr.WrapError(err, "Updating current disk record")
	}

	return nil
}
开发者ID:vestel,项目名称:bosh-init,代码行数:17,代码来源:disk_deployer.go


示例8: deployExistingDisk

func (d *diskDeployer) deployExistingDisk(disk bidisk.Disk, diskPool bideplmanifest.DiskPool, vm VM, stage biui.Stage) ([]bidisk.Disk, error) {
	disks := []bidisk.Disk{}

	// the disk is already part of the deployment, and should already be attached
	disks = append(disks, disk)

	// attach is idempotent
	err := d.attachDisk(disk, vm, stage)
	if err != nil {
		return disks, err
	}

	if disk.NeedsMigration(diskPool.DiskSize, diskPool.CloudProperties) {
		disk, err = d.migrateDisk(disk, diskPool, vm, stage)
		if err != nil {
			return disks, err
		}

		// after migration, only the new disk is part of the deployment
		disks[0] = disk
	}

	return disks, nil
}
开发者ID:vestel,项目名称:bosh-init,代码行数:24,代码来源:disk_deployer.go


示例9: UnmountDisk

func (vm *vm) UnmountDisk(disk bidisk.Disk) error {
	return vm.agentClient.UnmountDisk(disk.CID())
}
开发者ID:vestel,项目名称:bosh-init,代码行数:3,代码来源:vm.go


示例10: SetDetachDiskBehavior

func (vm *FakeVM) SetDetachDiskBehavior(disk bidisk.Disk, err error) {
	vm.detachDiskBehavior[disk.CID()] = err
}
开发者ID:vestel,项目名称:bosh-init,代码行数:3,代码来源:fake_vm.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang mocks.MockBuilder类代码示例发布时间:2022-05-23
下一篇:
Golang fakes.FakeSha1Calculator类代码示例发布时间: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