baremetalagents.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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/cmd/climc/shell"
  18. modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
  19. "yunion.io/x/onecloud/pkg/mcclient/options"
  20. )
  21. type AgentListOptions struct {
  22. options.BaseListOptions
  23. }
  24. func (o AgentListOptions) Params() (jsonutils.JSONObject, error) {
  25. return o.BaseListOptions.Params()
  26. }
  27. func (o AgentListOptions) Description() string {
  28. return "List all agent"
  29. }
  30. type AgentOpsOperations struct {
  31. ID string `help:"ID or name of agent"`
  32. }
  33. func (o AgentOpsOperations) GetId() string {
  34. return o.ID
  35. }
  36. func (o AgentOpsOperations) Params() (jsonutils.JSONObject, error) {
  37. return nil, nil
  38. }
  39. type AgentShowOpt struct {
  40. AgentOpsOperations
  41. }
  42. func (o AgentShowOpt) Description() string {
  43. return "Show details of an agent"
  44. }
  45. type AgentEnableOpt struct {
  46. AgentOpsOperations
  47. }
  48. func (o AgentEnableOpt) Description() string {
  49. return "Enable agent"
  50. }
  51. type AgentDisableOpt struct {
  52. AgentOpsOperations
  53. }
  54. func (o AgentDisableOpt) Description() string {
  55. return "Disable agent"
  56. }
  57. type AgentDeleteOpt struct {
  58. AgentOpsOperations
  59. }
  60. func (o AgentDeleteOpt) Description() string {
  61. return "Delete agent"
  62. }
  63. type AgentEnableImageCacheOpt struct {
  64. AgentOpsOperations
  65. }
  66. func (o AgentEnableImageCacheOpt) Description() string {
  67. return "Enable cache image of a agent"
  68. }
  69. type AgentDisableImageCacheOpt struct {
  70. AgentOpsOperations
  71. }
  72. func (o AgentDisableImageCacheOpt) Description() string {
  73. return "Disable cache image of a agent"
  74. }
  75. func init() {
  76. cmd := shell.NewResourceCmd(&modules.Baremetalagents).WithKeyword("agent")
  77. cmd.List(new(AgentListOptions))
  78. cmd.Show(new(AgentShowOpt))
  79. cmd.Perform("enable", new(AgentEnableOpt))
  80. cmd.Perform("disable", new(AgentDisableOpt))
  81. cmd.Perform("enable-image-cache", new(AgentEnableImageCacheOpt))
  82. cmd.Perform("disable-image-cache", new(AgentDisableImageCacheOpt))
  83. cmd.Delete(new(AgentDeleteOpt))
  84. }