blob: 8a43d7ab798f324dde45c354d878c2aedd272d97 [file] [log] [blame]
ehdou10f1f852016-10-14 20:58:23 +03001package v2
2
3import (
4 "testing"
5
Krzysztof Szukiełojć3f41d082017-05-07 14:43:06 +02006 "gerrit.mcp.mirantis.net/debian/gophercloud.git"
Krzysztof Szukiełojć24a29ce2017-05-07 14:24:02 +02007 "gerrit.mcp.mirantis.net/debian/gophercloud.git/acceptance/tools"
8 "gerrit.mcp.mirantis.net/debian/gophercloud.git/openstack/sharedfilesystems/v2/sharenetworks"
ehdou10f1f852016-10-14 20:58:23 +03009)
10
11// CreateShareNetwork will create a share network with a random name. An
12// error will be returned if the share network was unable to be created.
13func CreateShareNetwork(t *testing.T, client *gophercloud.ServiceClient) (*sharenetworks.ShareNetwork, error) {
14 if testing.Short() {
15 t.Skip("Skipping test that requires share network creation in short mode.")
16 }
17
18 shareNetworkName := tools.RandomString("ACPTTEST", 16)
19 t.Logf("Attempting to create share network: %s", shareNetworkName)
20
21 createOpts := sharenetworks.CreateOpts{
22 Name: shareNetworkName,
23 Description: "This is a shared network",
24 }
25
26 shareNetwork, err := sharenetworks.Create(client, createOpts).Extract()
27 if err != nil {
28 return shareNetwork, err
29 }
30
31 return shareNetwork, nil
32}
33
ehdou53687252016-10-14 22:10:13 +030034// DeleteShareNetwork will delete a share network. An error will occur if
35// the share network was unable to be deleted.
36func DeleteShareNetwork(t *testing.T, client *gophercloud.ServiceClient, shareNetwork *sharenetworks.ShareNetwork) {
37 err := sharenetworks.Delete(client, shareNetwork.ID).ExtractErr()
38 if err != nil {
39 t.Fatalf("Failed to delete share network %s: %v", shareNetwork.ID, err)
40 }
41
42 t.Logf("Deleted share network: %s", shareNetwork.ID)
43}
44
ehdou10f1f852016-10-14 20:58:23 +030045// PrintShareNetwork will print a share network and all of its attributes.
46func PrintShareNetwork(t *testing.T, sharenetwork *sharenetworks.ShareNetwork) {
47 t.Logf("ID: %s", sharenetwork.ID)
48 t.Logf("Project ID: %s", sharenetwork.ProjectID)
49 t.Logf("Neutron network ID: %s", sharenetwork.NeutronNetID)
50 t.Logf("Neutron sub-network ID: %s", sharenetwork.NeutronSubnetID)
51 t.Logf("Nova network ID: %s", sharenetwork.NovaNetID)
52 t.Logf("Network type: %s", sharenetwork.NetworkType)
53 t.Logf("Segmentation ID: %d", sharenetwork.SegmentationID)
54 t.Logf("CIDR: %s", sharenetwork.CIDR)
55 t.Logf("IP version: %d", sharenetwork.IPVersion)
56 t.Logf("Name: %s", sharenetwork.Name)
57 t.Logf("Description: %s", sharenetwork.Description)
ehdou07943332016-10-24 21:21:58 +030058 t.Logf("Created at: %v", sharenetwork.CreatedAt)
59 t.Logf("Updated at: %v", sharenetwork.UpdatedAt)
ehdou10f1f852016-10-14 20:58:23 +030060}