loadbalancers.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/onecloud/cmd/climc/shell"
  17. "yunion.io/x/onecloud/pkg/mcclient"
  18. modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute"
  19. baseoptions "yunion.io/x/onecloud/pkg/mcclient/options"
  20. options "yunion.io/x/onecloud/pkg/mcclient/options/compute"
  21. )
  22. func init() {
  23. cmd := shell.NewResourceCmd(&modules.Loadbalancers).WithKeyword("lb")
  24. cmd.Create(&options.LoadbalancerCreateOptions{})
  25. cmd.Show(&options.LoadbalancerIdOptions{})
  26. cmd.List(&options.LoadbalancerListOptions{})
  27. cmd.Update(&options.LoadbalancerUpdateOptions{})
  28. cmd.Delete(&options.LoadbalancerIdOptions{})
  29. cmd.Perform("purge", &options.LoadbalancerIdOptions{})
  30. cmd.Perform("status", &options.LoadbalancerActionStatusOptions{})
  31. cmd.Perform("syncstatus", &options.LoadbalancerIdOptions{})
  32. cmd.Perform("remote-update", &options.LoadbalancerRemoteUpdateOptions{})
  33. cmd.Get("change-owner-candidate-domains", &options.LoadbalancerIdOptions{})
  34. cmd.Perform("associate-eip", &options.LoadbalancerAssociateEipOptions{})
  35. cmd.Perform("create-eip", &options.LoadbalancerCreateEipOptions{})
  36. cmd.Perform("dissociate-eip", &options.LoadbalancerDissociateEipOptions{})
  37. R(&baseoptions.ResourceMetadataOptions{}, "lb-add-tag", "Set tag of a lb", func(s *mcclient.ClientSession, opts *baseoptions.ResourceMetadataOptions) error {
  38. params, err := opts.Params()
  39. if err != nil {
  40. return err
  41. }
  42. result, err := modules.Loadbalancers.PerformAction(s, opts.ID, "user-metadata", params)
  43. if err != nil {
  44. return err
  45. }
  46. printObject(result)
  47. return nil
  48. })
  49. R(&baseoptions.ResourceMetadataOptions{}, "lb-set-tag", "Set tag of a lb", func(s *mcclient.ClientSession, opts *baseoptions.ResourceMetadataOptions) error {
  50. params, err := opts.Params()
  51. if err != nil {
  52. return err
  53. }
  54. result, err := modules.Loadbalancers.PerformAction(s, opts.ID, "set-user-metadata", params)
  55. if err != nil {
  56. return err
  57. }
  58. printObject(result)
  59. return nil
  60. })
  61. }