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


Golang chaos.Now函数代码示例

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


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

示例1: Snapshot

func (d *Driver) Snapshot(volumeID string, readonly bool, locator *api.VolumeLocator) (string, error) {
	dryRun := false
	vols, err := d.DefaultEnumerator.Inspect([]string{volumeID})
	if err != nil {
		return "", err
	}
	if len(vols) != 1 {
		return "", fmt.Errorf("Failed to inspect %v len %v", volumeID, len(vols))
	}
	awsID := volumeID
	request := &ec2.CreateSnapshotInput{
		VolumeId: &awsID,
		DryRun:   &dryRun,
	}
	snap, err := d.ec2.CreateSnapshot(request)
	chaos.Now(koStrayCreate)
	vols[0].Id = *snap.SnapshotId
	vols[0].Source = &api.Source{Parent: volumeID}
	vols[0].Locator = locator
	vols[0].Ctime = prototime.Now()

	chaos.Now(koStrayCreate)
	err = d.CreateVol(vols[0])
	if err != nil {
		return "", err
	}
	return vols[0].Id, nil
}
开发者ID:ModelRocket,项目名称:openstorage,代码行数:28,代码来源:aws.go

示例2: Snapshot

func (d *Driver) Snapshot(volumeID api.VolumeID, readonly bool, locator api.VolumeLocator) (api.VolumeID, error) {
	dryRun := false
	vols, err := d.DefaultEnumerator.Inspect([]api.VolumeID{volumeID})
	if err != nil {
		return api.BadVolumeID, err
	}
	if len(vols) != 1 {
		return api.BadVolumeID, fmt.Errorf("Failed to inspect %v len %v", volumeID, len(vols))
	}
	awsID := string(volumeID)
	request := &ec2.CreateSnapshotInput{
		VolumeID: &awsID,
		DryRun:   &dryRun,
	}
	snap, err := d.ec2.CreateSnapshot(request)
	chaos.Now(koStrayCreate)
	vols[0].ID = api.VolumeID(*snap.SnapshotID)
	vols[0].Parent = volumeID
	vols[0].Locator = locator
	vols[0].Ctime = time.Now()

	chaos.Now(koStrayCreate)
	err = d.CreateVol(&vols[0])
	if err != nil {
		return api.BadVolumeID, err
	}
	return vols[0].ID, nil
}
开发者ID:phoenix-io,项目名称:openstorage,代码行数:28,代码来源:aws.go

示例3: Snapshot

// Snapshot create new subvolume from volume
func (d *driver) Snapshot(volumeID api.VolumeID, readonly bool, locator api.VolumeLocator) (api.VolumeID, error) {
	vols, err := d.Inspect([]api.VolumeID{volumeID})
	if err != nil {
		return api.BadVolumeID, err
	}
	if len(vols) != 1 {
		return api.BadVolumeID, fmt.Errorf("Failed to inspect %v len %v", volumeID, len(vols))
	}
	snapID := uuid.New()
	vols[0].ID = api.VolumeID(snapID)
	vols[0].Parent = volumeID
	vols[0].Locator = locator
	vols[0].Ctime = time.Now()

	err = d.CreateVol(&vols[0])
	if err != nil {
		return api.BadVolumeID, err
	}
	chaos.Now(koStrayCreate)
	err = d.btrfs.Create(snapID, string(volumeID))
	if err != nil {
		return api.BadVolumeID, err
	}
	return vols[0].ID, nil
}
开发者ID:phoenix-io,项目名称:openstorage,代码行数:26,代码来源:btrfs.go

示例4: Delete

// Delete subvolume
func (d *driver) Delete(volumeID string) error {
	if err := d.DeleteVol(volumeID); err != nil {
		return err
	}
	chaos.Now(koStrayDelete)
	return d.btrfs.Remove(volumeID)
}
开发者ID:ModelRocket,项目名称:openstorage,代码行数:8,代码来源:btrfs.go

示例5: SnapDelete

// SnapDelete Delete subvolume
func (d *driver) SnapDelete(snapID api.SnapID) error {
	err := d.DeleteSnap(snapID)
	chaos.Now(koStrayDelete)
	if err == nil {
		err = d.btrfs.Remove(string(snapID))
	}
	return err
}
开发者ID:gourao,项目名称:openstorage,代码行数:9,代码来源:btrfs.go

示例6: Delete

// Delete subvolume
func (d *btrfsDriver) Delete(volumeID api.VolumeID) error {
	err := d.DeleteVol(volumeID)
	chaos.Now(koStrayDelete)
	if err == nil {
		err = d.btrfs.Remove(string(volumeID))
	}
	return err
}
开发者ID:portworx,项目名称:openstorage,代码行数:9,代码来源:btrfs.go

示例7: Delete

// Delete subvolume
func (d *driver) Delete(volumeID api.VolumeID) error {
	err := d.DeleteVol(volumeID)
	if err != nil {
		log.Println(err)
		return err
	}

	chaos.Now(koStrayDelete)
	if err == nil {
		err = d.btrfs.Remove(string(volumeID))
	}
	return err
}
开发者ID:phoenix-io,项目名称:openstorage,代码行数:14,代码来源:btrfs.go

示例8: Snapshot

func (d *Driver) Snapshot(volumeID api.VolumeID, labels api.Labels) (api.SnapID, error) {
	dryRun := false
	awsID := string(volumeID)
	request := &ec2.CreateSnapshotInput{
		VolumeID: &awsID,
		DryRun:   &dryRun,
	}
	snap, err := d.ec2.CreateSnapshot(request)
	chaos.Now(koStrayCreate)
	volSnap := &api.VolumeSnap{
		ID:         api.SnapID(*snap.SnapshotID),
		VolumeID:   volumeID,
		SnapLabels: labels,
		Ctime:      time.Now(),
	}
	chaos.Now(koStrayCreate)
	err = d.CreateSnap(volSnap)
	if err != nil {
		return api.BadSnapID, err
	}
	return volSnap.ID, nil
}
开发者ID:gourao,项目名称:openstorage,代码行数:22,代码来源:aws.go

示例9: Snapshot

// Snapshot create new subvolume from volume
func (d *driver) Snapshot(volumeID api.VolumeID, labels api.Labels) (api.SnapID, error) {
	snapID := uuid.New()

	snap := &api.VolumeSnap{
		ID:         api.SnapID(snapID),
		VolumeID:   volumeID,
		SnapLabels: labels,
		Ctime:      time.Now(),
	}
	err := d.CreateSnap(snap)
	if err != nil {
		return api.BadSnapID, err
	}
	chaos.Now(koStrayCreate)
	err = d.btrfs.Create(snapID, string(volumeID))
	if err != nil {
		return api.BadSnapID, err
	}
	return snap.ID, nil
}
开发者ID:gourao,项目名称:openstorage,代码行数:21,代码来源:btrfs.go

示例10: Snapshot

// Snapshot create new subvolume from volume
func (d *driver) Snapshot(volumeID string, readonly bool, locator *api.VolumeLocator) (string, error) {
	vols, err := d.Inspect([]string{volumeID})
	if err != nil {
		return "", err
	}
	if len(vols) != 1 {
		return "", fmt.Errorf("Failed to inspect %v len %v", volumeID, len(vols))
	}
	snapID := uuid.New()
	vols[0].Id = snapID
	vols[0].Source = &api.Source{Parent: volumeID}
	vols[0].Locator = locator
	vols[0].Ctime = prototime.Now()

	if err := d.CreateVol(vols[0]); err != nil {
		return "", err
	}
	chaos.Now(koStrayCreate)
	err = d.btrfs.Create(snapID, volumeID, "")
	if err != nil {
		return "", err
	}
	return vols[0].Id, nil
}
开发者ID:ModelRocket,项目名称:openstorage,代码行数:25,代码来源:btrfs.go


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