當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。