interface.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 raid
  15. import (
  16. "io"
  17. api "yunion.io/x/onecloud/pkg/apis/compute"
  18. "yunion.io/x/onecloud/pkg/compute/baremetal"
  19. )
  20. type IRaidDriver interface {
  21. ParsePhyDevs() error
  22. GetName() string
  23. GetAdapters() []IRaidAdapter
  24. PreBuildRaid(confs []*api.BaremetalDiskConfig, adapterIdx int) error
  25. CleanRaid() error
  26. }
  27. type IRaidAdapter interface {
  28. GetIndex() int
  29. PreBuildRaid(confs []*api.BaremetalDiskConfig) error
  30. GetLogicVolumes() ([]*RaidLogicalVolume, error)
  31. RemoveLogicVolumes() error
  32. GetDevices() []*baremetal.BaremetalStorage
  33. BuildRaid0(devs []*baremetal.BaremetalStorage, conf *api.BaremetalDiskConfig) error
  34. BuildRaid1(devs []*baremetal.BaremetalStorage, conf *api.BaremetalDiskConfig) error
  35. BuildRaid5(devs []*baremetal.BaremetalStorage, conf *api.BaremetalDiskConfig) error
  36. BuildRaid10(devs []*baremetal.BaremetalStorage, conf *api.BaremetalDiskConfig) error
  37. BuildNoneRaid(devs []*baremetal.BaremetalStorage) error
  38. PostBuildRaid() error
  39. }
  40. type IRaidDeviceSetter interface {
  41. SetDevicesForAdapter(int, []*baremetal.BaremetalStorage)
  42. }
  43. type IExecTerm interface {
  44. Run(cmds ...string) ([]string, error)
  45. RunWithInput(input io.Reader, cmds ...string) ([]string, error)
  46. }