vpcs.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.Vpcs).WithContextManager(&modules.Cloudregions)
  24. cmd.List(&options.VpcListOptions{})
  25. cmd.Create(&options.VpcCreateOptions{})
  26. cmd.Show(&options.VpcIdOptions{})
  27. cmd.Delete(&options.VpcIdOptions{})
  28. cmd.Update(&options.VpcUpdateOptions{})
  29. cmd.Perform("status", &options.VpcStatusOptions{})
  30. cmd.Perform("purge", &options.VpcIdOptions{})
  31. cmd.Perform("sync", &options.VpcIdOptions{})
  32. cmd.Perform("syncstatus", &options.VpcIdOptions{})
  33. cmd.Perform("private", &options.VpcIdOptions{})
  34. cmd.Perform("public", &baseoptions.BasePublicOptions{})
  35. cmd.Perform("change-owner", &options.VpcChangeOwnerOptions{})
  36. cmd.Get("vpc-change-owner-candidate-domains", &options.VpcIdOptions{})
  37. cmd.Get("topology", &options.VpcIdOptions{})
  38. R(&baseoptions.ResourceMetadataOptions{}, "vpc-set-user-metadata", "Set metadata of a vpc", func(s *mcclient.ClientSession, opts *baseoptions.ResourceMetadataOptions) error {
  39. params, err := opts.Params()
  40. if err != nil {
  41. return err
  42. }
  43. result, err := modules.Vpcs.PerformAction(s, opts.ID, "user-metadata", params)
  44. if err != nil {
  45. return err
  46. }
  47. printObject(result)
  48. return nil
  49. })
  50. }