Feature/filestorage sharenetworks create (#118)
* sfs: Add support for share networks Create
* sfs: Add Manila to acceptance test environment
* sfs: Add acceptance tests for share networks Create
* sfs: Remove unused urls
Some url functions were introduced but they belong to other
PRs. Will be repushed with in the correct PRs
* sfs: Make name and descr required for creating share network
* sfs: Remove required parameters
After taking a close look at the code it appeared that 'name'
and 'description' are not required parameters
diff --git a/acceptance/openstack/sharedfilesystems/v2/pkg.go b/acceptance/openstack/sharedfilesystems/v2/pkg.go
new file mode 100644
index 0000000..5a5cd2b
--- /dev/null
+++ b/acceptance/openstack/sharedfilesystems/v2/pkg.go
@@ -0,0 +1,3 @@
+// The v2 package contains acceptance tests for the Openstack Manila V2 service.
+
+package v2
diff --git a/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go b/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go
new file mode 100644
index 0000000..a964515
--- /dev/null
+++ b/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go
@@ -0,0 +1,49 @@
+package v2
+
+import (
+ "testing"
+
+ "github.com/gophercloud/gophercloud"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
+ "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/sharenetworks"
+)
+
+// CreateShareNetwork will create a share network with a random name. An
+// error will be returned if the share network was unable to be created.
+func CreateShareNetwork(t *testing.T, client *gophercloud.ServiceClient) (*sharenetworks.ShareNetwork, error) {
+ if testing.Short() {
+ t.Skip("Skipping test that requires share network creation in short mode.")
+ }
+
+ shareNetworkName := tools.RandomString("ACPTTEST", 16)
+ t.Logf("Attempting to create share network: %s", shareNetworkName)
+
+ createOpts := sharenetworks.CreateOpts{
+ Name: shareNetworkName,
+ Description: "This is a shared network",
+ }
+
+ shareNetwork, err := sharenetworks.Create(client, createOpts).Extract()
+ if err != nil {
+ return shareNetwork, err
+ }
+
+ return shareNetwork, nil
+}
+
+// PrintShareNetwork will print a share network and all of its attributes.
+func PrintShareNetwork(t *testing.T, sharenetwork *sharenetworks.ShareNetwork) {
+ t.Logf("ID: %s", sharenetwork.ID)
+ t.Logf("Project ID: %s", sharenetwork.ProjectID)
+ t.Logf("Neutron network ID: %s", sharenetwork.NeutronNetID)
+ t.Logf("Neutron sub-network ID: %s", sharenetwork.NeutronSubnetID)
+ t.Logf("Nova network ID: %s", sharenetwork.NovaNetID)
+ t.Logf("Network type: %s", sharenetwork.NetworkType)
+ t.Logf("Segmentation ID: %d", sharenetwork.SegmentationID)
+ t.Logf("CIDR: %s", sharenetwork.CIDR)
+ t.Logf("IP version: %d", sharenetwork.IPVersion)
+ t.Logf("Name: %s", sharenetwork.Name)
+ t.Logf("Description: %s", sharenetwork.Description)
+ t.Logf("Created at: %s", sharenetwork.CreatedAt)
+ t.Logf("Updated at: %s", sharenetwork.UpdatedAt)
+}
diff --git a/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go b/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go
new file mode 100644
index 0000000..6b74007
--- /dev/null
+++ b/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go
@@ -0,0 +1,23 @@
+package v2
+
+import (
+ "testing"
+
+ "github.com/gophercloud/gophercloud/acceptance/clients"
+)
+
+func TestShareNetworkCreate(t *testing.T) {
+ client, err := clients.NewSharedFileSystemV2Client()
+ if err != nil {
+ t.Fatalf("Unable to create shared file system client: %v", err)
+ }
+
+ shareNetwork, err := CreateShareNetwork(t, client)
+ if err != nil {
+ t.Fatalf("Unable to create share network: %v", err)
+ }
+
+ // TODO: delete the share network when the delete is implemented
+
+ PrintShareNetwork(t, shareNetwork)
+}