本文整理汇总了Golang中github.com/codedellemc/libstorage/api/types.Client类的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: snapshotByName
func snapshotByName(
t *testing.T, client types.Client, snapshotName string) *types.Snapshot {
log.WithField("snapshotName", snapshotName).Info("get snapshot by rackspace.Name")
snapshots, err := client.API().Snapshots(nil)
assert.NoError(t, err)
if err != nil {
t.FailNow()
}
assert.Contains(t, snapshots, rackspace.Name)
for _, vol := range snapshots[rackspace.Name] {
if vol.Name == snapshotName {
return vol
}
}
t.FailNow()
t.Error("failed snapshotByName")
return nil
}
开发者ID:emccode,项目名称:libstorage,代码行数:18,代码来源:rackspace_test.go
示例17: volumeByName
func volumeByName(
t *testing.T, client types.Client, volumeName string) *types.Volume {
log.WithField("volumeName", volumeName).Info("get volume byrackspace.Name")
vols, err := client.API().Volumes(nil, 0)
assert.NoError(t, err)
if err != nil {
t.FailNow()
}
assert.Contains(t, vols, rackspace.Name)
for _, vol := range vols[rackspace.Name] {
if vol.Name == volumeName {
return vol
}
}
t.FailNow()
t.Error("failed volumeByName")
return nil
}
开发者ID:emccode,项目名称:libstorage,代码行数:19,代码来源:rackspace_test.go
示例18: snapshotCopy
func snapshotCopy(
t *testing.T, client types.Client,
snapshotID, snapshotName, destinationID string) *types.Snapshot {
log.WithField("snapshotName", snapshotName).Info("copying snapshot")
snapshotCopyRequest := &types.SnapshotCopyRequest{
SnapshotName: snapshotName,
}
reply, err := client.API().SnapshotCopy(nil, rackspace.Name,
snapshotID, snapshotCopyRequest)
assert.NoError(t, err)
if err != nil {
t.FailNow()
t.Error("failed snapshotCopy")
}
apitests.LogAsJSON(reply, t)
assert.Equal(t, snapshotName, reply.Name)
return reply
}
开发者ID:emccode,项目名称:libstorage,代码行数:21,代码来源:rackspace_test.go
示例19: volumeByID
// Test volume retrieval by volume ID using Volumes, which retrieves all
// volumes from the storage driver without filtering, and filters the volumes
// externally. Contrast with volumeInspect, which directly retrieves matching
// volumes from the storage driver.
func volumeByID(
t *testing.T, client types.Client, volumeID string) *types.Volume {
log.WithField("volumeID", volumeID).Info("get volume by ebs.Name using ID")
// Retrieve all volumes
vols, err := client.API().Volumes(nil, 0)
assert.NoError(t, err)
if err != nil {
t.FailNow()
}
// Filter volumes to those under the ec2 service,
// and find a volume matching inputted volume ID
assert.Contains(t, vols, ebs.Name)
for _, vol := range vols[ebs.Name] {
if vol.ID == volumeID {
return vol
}
}
// No matching volumes found
t.FailNow()
t.Error("failed volumeByID")
return nil
}
开发者ID:emccode,项目名称:libstorage,代码行数:26,代码来源:ebs_test.go
示例20: volumeCreateFromSnapshot
func volumeCreateFromSnapshot(
t *testing.T, client types.Client,
snapshotID, volumeName string) *types.Volume {
fields := map[string]interface{}{
"snapshotID": snapshotID,
"volumeName": volumeName,
}
log.WithFields(fields).Info("creating volume from snapshot")
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().VolumeCreateFromSnapshot(nil,
rackspace.Name, snapshotID, volumeCreateRequest)
assert.NoError(t, err)
if err != nil {
t.FailNow()
t.Error("failed volumeCreateFromSnapshot")
}
apitests.LogAsJSON(reply, t)
assert.Equal(t, volumeName, reply.Name)
assert.Equal(t, size, reply.Size)
assert.Equal(t, opts["priority"], 2)
assert.Equal(t, opts["owner"], "[email protected]")
return reply
}
开发者ID:emccode,项目名称:libstorage,代码行数:37,代码来源:rackspace_test.go
注:本文中的github.com/codedellemc/libstorage/api/types.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论