PageRenderTime 56ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/github.com/gophercloud/gophercloud/acceptance/openstack/sharedfilesystems/v2/sharetypes.go

https://gitlab.com/unofficial-mirrors/openshift-origin
Go | 56 lines | 40 code | 11 blank | 5 comment | 5 complexity | 2bb48c11dae3b88513545db22c1f47bc MD5 | raw file
  1. package v2
  2. import (
  3. "testing"
  4. "github.com/gophercloud/gophercloud"
  5. "github.com/gophercloud/gophercloud/acceptance/tools"
  6. "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/sharetypes"
  7. )
  8. // CreateShareType will create a share type with a random name. An
  9. // error will be returned if the share type was unable to be created.
  10. func CreateShareType(t *testing.T, client *gophercloud.ServiceClient) (*sharetypes.ShareType, error) {
  11. if testing.Short() {
  12. t.Skip("Skipping test that requires share type creation in short mode.")
  13. }
  14. shareTypeName := tools.RandomString("ACPTTEST", 16)
  15. t.Logf("Attempting to create share type: %s", shareTypeName)
  16. extraSpecsOps := sharetypes.ExtraSpecsOpts{
  17. DriverHandlesShareServers: true,
  18. }
  19. createOpts := sharetypes.CreateOpts{
  20. Name: shareTypeName,
  21. IsPublic: false,
  22. ExtraSpecs: extraSpecsOps,
  23. }
  24. shareType, err := sharetypes.Create(client, createOpts).Extract()
  25. if err != nil {
  26. return shareType, err
  27. }
  28. return shareType, nil
  29. }
  30. // DeleteShareType will delete a share type. An error will occur if
  31. // the share type was unable to be deleted.
  32. func DeleteShareType(t *testing.T, client *gophercloud.ServiceClient, shareType *sharetypes.ShareType) {
  33. err := sharetypes.Delete(client, shareType.ID).ExtractErr()
  34. if err != nil {
  35. t.Fatalf("Failed to delete share type %s: %v", shareType.ID, err)
  36. }
  37. t.Logf("Deleted share type: %s", shareType.ID)
  38. }
  39. // PrintShareType will print a share type and all of its attributes.
  40. func PrintShareType(t *testing.T, shareType *sharetypes.ShareType) {
  41. t.Logf("Name: %s", shareType.Name)
  42. t.Logf("ID: %s", shareType.ID)
  43. t.Logf("OS share type access is public: %t", shareType.IsPublic)
  44. t.Logf("Extra specs: %#v", shareType.ExtraSpecs)
  45. }