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/openstack/sharedfilesystems/v2/sharenetworks/requests.go b/openstack/sharedfilesystems/v2/sharenetworks/requests.go
new file mode 100644
index 0000000..f551861
--- /dev/null
+++ b/openstack/sharedfilesystems/v2/sharenetworks/requests.go
@@ -0,0 +1,46 @@
+package sharenetworks
+
+import "github.com/gophercloud/gophercloud"
+
+// CreateOptsBuilder allows extensions to add additional parameters to the
+// Create request.
+type CreateOptsBuilder interface {
+ ToShareNetworkCreateMap() (map[string]interface{}, error)
+}
+
+// CreateOpts contains options for creating a ShareNetwork. This object is
+// passed to the sharenetworks.Create function. For more information about
+// these parameters, see the ShareNetwork object.
+type CreateOpts struct {
+ // The UUID of the Neutron network to set up for share servers
+ NeutronNetID string `json:"neutron_net_id,omitempty"`
+ // The UUID of the Neutron subnet to set up for share servers
+ NeutronSubnetID string `json:"neutron_subnet_id,omitempty"`
+ // The UUID of the nova network to set up for share servers
+ NovaNetID string `json:"nova_net_id,omitempty"`
+ // The share network name
+ Name string `json:"name"`
+ // The share network description
+ Description string `json:"description"`
+}
+
+// ToShareNetworkCreateMap assembles a request body based on the contents of a
+// CreateOpts.
+func (opts CreateOpts) ToShareNetworkCreateMap() (map[string]interface{}, error) {
+ return gophercloud.BuildRequestBody(opts, "share_network")
+}
+
+// Create will create a new ShareNetwork based on the values in CreateOpts. To
+// extract the ShareNetwork object from the response, call the Extract method
+// on the CreateResult.
+func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
+ b, err := opts.ToShareNetworkCreateMap()
+ if err != nil {
+ r.Err = err
+ return
+ }
+ _, r.Err = client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200, 202},
+ })
+ return
+}