wire.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 options
  15. import "yunion.io/x/jsonutils"
  16. type WireListOptions struct {
  17. BaseListOptions
  18. Bandwidth *int `help:"List wires by bandwidth"`
  19. Region string `help:"List wires in region"`
  20. Zone string `help:"list wires in zone" json:"-"`
  21. Vpc string `help:"List wires in vpc"`
  22. Host string `help:"List wires attached to a host"`
  23. HostType string `help:"List wires attached to host with HostType"`
  24. OrderByNetworkCount string
  25. }
  26. func (wo *WireListOptions) GetContextId() string {
  27. return wo.Vpc
  28. }
  29. func (wo *WireListOptions) Params() (jsonutils.JSONObject, error) {
  30. return ListStructToParams(wo)
  31. }
  32. type WireOptions struct {
  33. ID string `help:"Id or Name of wire to update"`
  34. }
  35. func (wo *WireOptions) GetId() string {
  36. return wo.ID
  37. }
  38. func (wo *WireOptions) Params() (jsonutils.JSONObject, error) {
  39. return nil, nil
  40. }
  41. type WireUpdateOptions struct {
  42. WireOptions
  43. SwireupdateOptions
  44. }
  45. type SwireupdateOptions struct {
  46. Name string `help:"Name of wire" json:"name"`
  47. Desc string `metavar:"<DESCRIPTION>" help:"Description" json:"description"`
  48. Bw int64 `help:"Bandwidth in mbps" json:"bandwidth"`
  49. Mtu int64 `help:"mtu in bytes" json:"mtu"`
  50. }
  51. func (wo *WireUpdateOptions) Params() (jsonutils.JSONObject, error) {
  52. return jsonutils.Marshal(wo.SwireupdateOptions), nil
  53. }
  54. type WireCreateOptions struct {
  55. ZONE string `help:"Zone ID or Name"`
  56. Vpc string `help:"VPC ID or Name" default:"default"`
  57. NAME string `help:"Name of wire"`
  58. BW int64 `help:"Bandwidth in mbps"`
  59. Mtu int64 `help:"mtu in bytes"`
  60. Desc string `metavar:"<DESCRIPTION>" help:"Description"`
  61. }
  62. func (wo *WireCreateOptions) Params() (jsonutils.JSONObject, error) {
  63. return jsonutils.Marshal(wo), nil
  64. }
  65. type SwirePublicOptions struct {
  66. Scope string `help:"sharing scope" choices:"system|domain"`
  67. SharedDomains []string `help:"share to domains"`
  68. }
  69. type WirePublicOptions struct {
  70. WireOptions
  71. SwirePublicOptions
  72. }
  73. func (wo *WirePublicOptions) Params() (jsonutils.JSONObject, error) {
  74. return jsonutils.Marshal(wo.SwirePublicOptions), nil
  75. }
  76. type WireMergeOptions struct {
  77. Froms []string `help:"IDs or names of merge wire from" json:"sources"`
  78. TARGET string `help:"ID or name of merge wire target"`
  79. MergeNetwork bool `help:"whether to merge network under wire"`
  80. }
  81. func (wo *WireMergeOptions) GetId() string {
  82. return wo.TARGET
  83. }
  84. func (wo *WireMergeOptions) Params() (jsonutils.JSONObject, error) {
  85. return jsonutils.Marshal(wo), nil
  86. }