generic.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package generic
  15. import (
  16. "yunion.io/x/jsonutils"
  17. "yunion.io/x/onecloud/pkg/util/redfish"
  18. )
  19. const (
  20. basePath = "/redfish/v1"
  21. linkKey = "@odata.id"
  22. memberKey = "Members"
  23. versionKey = "RedfishVersion"
  24. )
  25. type SGenericRedfishApiFactory struct {
  26. }
  27. func (f *SGenericRedfishApiFactory) Name() string {
  28. return "Redfish"
  29. }
  30. func (f *SGenericRedfishApiFactory) NewApi(endpoint, username, password string, debug bool) redfish.IRedfishDriver {
  31. return NewGenericRedfishApi(endpoint, username, password, debug)
  32. }
  33. func init() {
  34. redfish.RegisterDefaultApiFactory(&SGenericRedfishApiFactory{})
  35. }
  36. type SGenericRefishApi struct {
  37. redfish.SBaseRedfishClient
  38. }
  39. func NewGenericRedfishApi(endpoint, username, password string, debug bool) redfish.IRedfishDriver {
  40. api := &SGenericRefishApi{
  41. SBaseRedfishClient: redfish.NewBaseRedfishClient(endpoint, username, password, debug),
  42. }
  43. api.SetVirtualObject(api)
  44. return api
  45. }
  46. func (r *SGenericRefishApi) BasePath() string {
  47. return basePath
  48. }
  49. func (r *SGenericRefishApi) GetParent(parent jsonutils.JSONObject) jsonutils.JSONObject {
  50. return parent
  51. }
  52. func (r *SGenericRefishApi) VersionKey() string {
  53. return versionKey
  54. }
  55. func (r *SGenericRefishApi) LinkKey() string {
  56. return linkKey
  57. }
  58. func (r *SGenericRefishApi) MemberKey() string {
  59. return memberKey
  60. }
  61. func (r *SGenericRefishApi) LogItemsKey() string {
  62. return memberKey
  63. }