當前位置: 首頁>>代碼示例>>Golang>>正文


Golang types.Client類代碼示例

本文整理匯總了Golang中github.com/codedellemc/libstorage/api/types.Client的典型用法代碼示例。如果您正苦於以下問題:Golang Client類的具體用法?Golang Client怎麽用?Golang Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Client類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: volumeCreate

///////////////////////////////////////////////////////////////////////
/////////        PRIVATE TESTS FOR VOLUME FUNCTIONALITY       /////////
///////////////////////////////////////////////////////////////////////
// Test volume creation specifying size and volume name
func volumeCreate(
	t *testing.T, client types.Client, volumeName, tag string) *types.Volume {
	log.WithField("volumeName", volumeName).Info("creating volume")
	// Prepare request for storage driver call to create volume
	size := int64(1)

	opts := map[string]interface{}{
		"priority": 2,
		"owner":    "[email protected]",
	}

	volumeCreateRequest := &types.VolumeCreateRequest{
		Name: volumeName,
		Size: &size,
		Opts: opts,
	}

	// Send request and retrieve created libStorage types.Volume
	reply, err := client.API().VolumeCreate(nil, ebs.Name, volumeCreateRequest)
	assert.NoError(t, err)
	if err != nil {
		t.FailNow()
		t.Error("failed volumeCreate")
	}
	apitests.LogAsJSON(reply, t)

	// If tag is set, then add tag to expected volumeName
	if tag != "" {
		volumeName = tag + ebs.TagDelimiter + volumeName
	}
	// Check if name and size are same
	assert.Equal(t, volumeName, reply.Name)
	assert.Equal(t, size, reply.Size)
	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:39,代碼來源:ebs_test.go

示例2: volumeCopy

func volumeCopy(
	t *testing.T, client types.Client,
	volumeID, volumeName string) *types.Volume {
	fields := map[string]interface{}{
		"volumeID":   volumeID,
		"volumeName": volumeName,
	}
	log.WithFields(fields).Info("copying volume")

	volumeCopyRequest := &types.VolumeCopyRequest{
		VolumeName: volumeName,
	}

	reply, err := client.API().VolumeCopy(nil,
		rackspace.Name, volumeID, volumeCopyRequest)
	assert.NoError(t, err)
	if err != nil {
		t.FailNow()
		t.Error("failed volumeCopy")
	}
	apitests.LogAsJSON(reply, t)

	assert.Equal(t, volumeName, reply.Name)

	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:26,代碼來源:rackspace_test.go

示例3: volumeCreate

func volumeCreate(
	t *testing.T, client types.Client, volumeName string) *types.Volume {
	log.WithField("volumeName", volumeName).Info("creating volume")
	size := int64(8)

	opts := map[string]interface{}{
		"priority": 2,
		"owner":    "[email protected]",
	}

	volumeCreateRequest := &types.VolumeCreateRequest{
		Name: volumeName,
		Size: &size,
		Opts: opts,
	}

	reply, err := client.API().VolumeCreate(nil, rackspace.Name, volumeCreateRequest)

	assert.NoError(t, err)
	if err != nil {
		t.FailNow()
		t.Error("failed volumeCreate")
	}

	apitests.LogAsJSON(reply, t)
	assert.Equal(t, volumeName, reply.Name)
	assert.Equal(t, int64(75), reply.Size)
	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:29,代碼來源:rackspace_test.go

示例4: volumeByName

// Test volume retrieval by volume name using Volumes, which retrieves all volumes
// from the storage driver without filtering, and filters the volumes externally.
func volumeByName(
	t *testing.T, client types.Client, volumeName, tag string) *types.Volume {
	log.WithField("volumeName", volumeName).Info("get volume by ebs.Name")
	// Retrieve all volumes
	vols, err := client.API().Volumes(nil, 0)
	assert.NoError(t, err)
	if err != nil {
		t.FailNow()
	}
	// If tag is set, then add tag to expected volumeName
	if tag != "" {
		volumeName = tag + ebs.TagDelimiter + volumeName
	}
	// Filter volumes to those under the ec2 service,
	// and find a volume matching inputted volume name
	assert.Contains(t, vols, ebs.Name)
	for _, vol := range vols[ebs.Name] {
		if vol.Name == volumeName {
			return vol
		}
	}
	// No matching volumes found
	t.FailNow()
	t.Error("failed volumeByName")
	return nil
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:28,代碼來源:ebs_test.go

示例5: volumeAttach

// Test volume attachment by volume ID
func volumeAttach(
	t *testing.T, client types.Client, volumeID string) *types.Volume {
	log.WithField("volumeID", volumeID).Info("attaching volume")
	// Get next device name from executor
	nextDevice, err := client.Executor().NextDevice(context.Background().WithValue(context.ServiceKey, ebs.Name),
		utils.NewStore())
	assert.NoError(t, err)
	if err != nil {
		t.Error("error getting next device name from executor")
		t.FailNow()
	}

	reply, token, err := client.API().VolumeAttach(
		nil, ebs.Name, volumeID, &types.VolumeAttachRequest{
			NextDeviceName: &nextDevice,
		})

	assert.NoError(t, err)
	if err != nil {
		t.Error("failed volumeAttach")
		t.FailNow()
	}
	apitests.LogAsJSON(reply, t)
	assert.NotEqual(t, token, "")

	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:28,代碼來源:ebs_test.go

示例6: volumeSnapshot

func volumeSnapshot(
	t *testing.T, client types.Client,
	volumeID, snapshotName string) *types.Snapshot {
	log.WithField("snapshotName", snapshotName).Info("creating snapshot")

	/*
		opts := map[string]interface{}{
			"priority": 2,
			"owner":    "[email protected]",
		}*/

	volumeSnapshotRequest := &types.VolumeSnapshotRequest{
		SnapshotName: snapshotName,
		//	Opts: opts,
	}

	reply, err := client.API().VolumeSnapshot(nil, rackspace.Name,
		volumeID, volumeSnapshotRequest)
	assert.NoError(t, err)
	if err != nil {
		t.FailNow()
		t.Error("failed snapshotCreate")
	}
	apitests.LogAsJSON(reply, t)

	assert.Equal(t, snapshotName, reply.Name)
	assert.Equal(t, volumeID, reply.VolumeID)
	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:29,代碼來源:rackspace_test.go

示例7: volumeRemove

func volumeRemove(t *testing.T, client types.Client, volumeID string) {
	log.WithField("volumeID", volumeID).Info("removing volume")
	err := client.API().VolumeRemove(
		nil, rackspace.Name, volumeID)
	assert.NoError(t, err)
	if err != nil {
		t.Error("failed volumeRemove")
		t.FailNow()
	}
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:10,代碼來源:rackspace_test.go

示例8: Test

// Test is the APITestFunc for the NextDeviceTest.
func (tt *NextDeviceTest) Test(
	config gofig.Config,
	client types.Client,
	t *testing.T) {

	ctx := context.Background().WithValue(context.ServiceKey, tt.Driver)
	val, err := client.Executor().NextDevice(ctx, utils.NewStore())
	assert.NoError(t, err)
	assert.Equal(t, tt.Expected, val)
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:11,代碼來源:tests_std.go

示例9: snapshotRemove

func snapshotRemove(t *testing.T, client types.Client, snapshotID string) {
	log.WithField("snapshotID", snapshotID).Info("removing snapshot")
	err := client.API().SnapshotRemove(
		nil, rackspace.Name, snapshotID)
	assert.NoError(t, err)

	if err != nil {
		t.Error("failed snapshotRemove")
		t.FailNow()
	}
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:11,代碼來源:rackspace_test.go

示例10: snapshotInspect

func snapshotInspect(
	t *testing.T, client types.Client, snapshotID string) *types.Snapshot {
	log.WithField("snapshotID", snapshotID).Info("inspecting snapshot")
	reply, err := client.API().SnapshotInspect(nil, rackspace.Name, snapshotID)
	assert.NoError(t, err)

	if err != nil {
		t.Error("failed snapshotInspect")
		t.FailNow()
	}
	apitests.LogAsJSON(reply, t)
	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:13,代碼來源:rackspace_test.go

示例11: volumeInspect

// Test volume retrieval by volume ID using VolumeInspect, which directly
// retrieves matching volumes from the storage driver. Contrast with
// volumeByID, which uses Volumes to retrieve all volumes from the storage
// driver without filtering, and filters the volumes externally.
func volumeInspect(
	t *testing.T, client types.Client, volumeID string) *types.Volume {
	log.WithField("volumeID", volumeID).Info("inspecting volume")
	reply, err := client.API().VolumeInspect(nil, ebs.Name, volumeID, 0)
	assert.NoError(t, err)

	if err != nil {
		t.Error("failed volumeInspect")
		t.FailNow()
	}
	apitests.LogAsJSON(reply, t)
	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:17,代碼來源:ebs_test.go

示例12: volumeDetach

// Test detaching volume by volume ID
func volumeDetach(
	t *testing.T, client types.Client, volumeID string) *types.Volume {
	log.WithField("volumeID", volumeID).Info("detaching volume")
	reply, err := client.API().VolumeDetach(
		nil, ebs.Name, volumeID, &types.VolumeDetachRequest{})
	assert.NoError(t, err)
	if err != nil {
		t.Error("failed volumeDetach")
		t.FailNow()
	}
	apitests.LogAsJSON(reply, t)
	assert.Len(t, reply.Attachments, 0)
	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:15,代碼來源:ebs_test.go

示例13: volumeInspectDetachedFail

func volumeInspectDetachedFail(
	t *testing.T, client types.Client, volumeID string) *types.Volume {

	log.WithField("volumeID", volumeID).Info("inspecting volume")
	reply, err := client.API().VolumeInspect(nil, rackspace.Name, volumeID, 0)
	assert.NoError(t, err)

	if err != nil {
		t.Error("failed volumeInspectDetachedFail")
		t.FailNow()
	}
	apitests.LogAsJSON(reply, t)
	assert.Len(t, reply.Attachments, 1)
	apitests.LogAsJSON(reply, t)
	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:16,代碼來源:rackspace_test.go

示例14: volumeInspectAttached

func volumeInspectAttached(
	t *testing.T, client types.Client, volumeID string) *types.Volume {

	log.WithField("volumeID", volumeID).Info("inspecting volume")
	reply, err := client.API().VolumeInspect(
		nil, isilon.Name, volumeID, types.VolAttReqTrue)
	assert.NoError(t, err)

	if err != nil {
		t.Error("failed volumeInspectAttached")
		t.FailNow()
	}
	apitests.LogAsJSON(reply, t)
	assert.Len(t, reply.Attachments, 1)
	// assert.NotEqual(t, "", reply.Attachments[0].DeviceName)
	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:17,代碼來源:isilon_test.go

示例15: volumeAttach

func volumeAttach(
	t *testing.T, client types.Client, volumeID string) *types.Volume {

	log.WithField("volumeID", volumeID).Info("attaching volume")
	reply, token, err := client.API().VolumeAttach(
		nil, rackspace.Name, volumeID, &types.VolumeAttachRequest{})

	assert.NoError(t, err)
	if err != nil {
		t.Error("failed volumeAttach")
		t.FailNow()
	}
	apitests.LogAsJSON(reply, t)
	assert.NotEqual(t, token, "")

	return reply
}
開發者ID:emccode,項目名稱:libstorage,代碼行數:17,代碼來源:rackspace_test.go


注:本文中的github.com/codedellemc/libstorage/api/types.Client類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。