Sync baremetal openstack with upstream
Change-Id: I125fc08e2cc4433aeaa470de48823dd4434c2030
Related-PROD: PROD-33018
diff --git a/openstack/baremetal/noauth/doc.go b/openstack/baremetal/noauth/doc.go
new file mode 100644
index 0000000..9f83357
--- /dev/null
+++ b/openstack/baremetal/noauth/doc.go
@@ -0,0 +1,17 @@
+/*
+Package noauth provides support for noauth bare metal endpoints.
+
+Example of obtaining and using a client:
+
+ client, err := noauth.NewBareMetalNoAuth(noauth.EndpointOpts{
+ IronicEndpoint: "http://localhost:6385/v1/",
+ })
+ if err != nil {
+ panic(err)
+ }
+
+ client.Microversion = "1.50"
+
+ nodes.ListDetail(client, nodes.ListOpts{})
+*/
+package noauth
diff --git a/openstack/baremetal/noauth/requests.go b/openstack/baremetal/noauth/requests.go
new file mode 100644
index 0000000..0b956e4
--- /dev/null
+++ b/openstack/baremetal/noauth/requests.go
@@ -0,0 +1,36 @@
+package noauth
+
+import (
+ "fmt"
+
+ "gerrit.mcp.mirantis.net/debian/gophercloud.git"
+)
+
+// EndpointOpts specifies a "noauth" Ironic Endpoint.
+type EndpointOpts struct {
+ // IronicEndpoint [required] is currently only used with "noauth" Ironic.
+ // An Ironic endpoint with "auth_strategy=noauth" is necessary, for example:
+ // http://ironic.example.com:6385/v1.
+ IronicEndpoint string
+}
+
+func initClientOpts(client *gophercloud.ProviderClient, eo EndpointOpts) (*gophercloud.ServiceClient, error) {
+ sc := new(gophercloud.ServiceClient)
+ if eo.IronicEndpoint == "" {
+ return nil, fmt.Errorf("IronicEndpoint is required")
+ }
+
+ sc.Endpoint = gophercloud.NormalizeURL(eo.IronicEndpoint)
+ sc.ProviderClient = client
+ return sc, nil
+}
+
+// NewBareMetalNoAuth creates a ServiceClient that may be used to access a
+// "noauth" bare metal service.
+func NewBareMetalNoAuth(eo EndpointOpts) (*gophercloud.ServiceClient, error) {
+ sc, err := initClientOpts(&gophercloud.ProviderClient{}, eo)
+
+ // sc.Type = "baremetal"
+
+ return sc, err
+}
diff --git a/openstack/baremetal/noauth/testing/requests_test.go b/openstack/baremetal/noauth/testing/requests_test.go
new file mode 100644
index 0000000..a2181eb
--- /dev/null
+++ b/openstack/baremetal/noauth/testing/requests_test.go
@@ -0,0 +1,16 @@
+package testing
+
+import (
+ "testing"
+
+ "gerrit.mcp.mirantis.net/debian/gophercloud.git/openstack/baremetal/noauth"
+ th "gerrit.mcp.mirantis.net/debian/gophercloud.git/testhelper"
+)
+
+func TestNoAuth(t *testing.T) {
+ noauthClient, err := noauth.NewBareMetalNoAuth(noauth.EndpointOpts{
+ IronicEndpoint: "http://ironic:6385/v1",
+ })
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, "", noauthClient.TokenID)
+}