isolated_devices.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 compute
  15. import (
  16. "yunion.io/x/jsonutils"
  17. "yunion.io/x/onecloud/pkg/mcclient/options"
  18. )
  19. type DeviceListOptions struct {
  20. options.BaseListOptions
  21. Unused bool `help:"Only show unused devices"`
  22. Gpu bool `help:"Only show gpu devices"`
  23. Host string `help:"Host ID or Name"`
  24. Region string `help:"Cloudregion ID or Name"`
  25. Zone string `help:"Zone ID or Name"`
  26. Server string `help:"Server ID or Name"`
  27. DevType []string `help:"filter by dev_type"`
  28. Model []string `help:"filter by model"`
  29. Addr []string `help:"filter by addr"`
  30. DevicePath []string `help:"filter by device path"`
  31. VendorDeviceId []string `help:"filter by vendor device id(PCIID)"`
  32. NumaNode []uint8 `help:"fitler by numa node index"`
  33. Index *int `help:"filter by index"`
  34. DeviceMinor *int `help:"filter by device minor"`
  35. }
  36. func (o *DeviceListOptions) Params() (jsonutils.JSONObject, error) {
  37. return options.ListStructToParams(o)
  38. }
  39. type DeviceShowOptions struct {
  40. options.BaseIdOptions
  41. }
  42. type DeviceDeleteOptions struct {
  43. options.BaseIdsOptions
  44. }
  45. type DeviceUpdateOptions struct {
  46. options.BaseIdOptions
  47. ReservedCpu *int `help:"reserved cpu for isolated device"`
  48. ReservedMem *int `help:"reserved mem for isolated device"`
  49. ReservedStorage *int `help:"reserved storage for isolated device"`
  50. DevType string `help:"Device type"`
  51. }
  52. func (o *DeviceUpdateOptions) Params() (jsonutils.JSONObject, error) {
  53. return jsonutils.Marshal(o), nil
  54. }
  55. type DevicePurgeOptions struct {
  56. options.BaseIdsOptions
  57. Purge bool `help:"purge devices when attached to guest"`
  58. }
  59. func (o *DevicePurgeOptions) Params() (jsonutils.JSONObject, error) {
  60. return jsonutils.Marshal(map[string]interface{}{
  61. "purge": o.Purge,
  62. }), nil
  63. }