wire.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 proxmox
  15. import (
  16. api "yunion.io/x/cloudmux/pkg/apis/compute"
  17. "yunion.io/x/cloudmux/pkg/cloudprovider"
  18. "yunion.io/x/cloudmux/pkg/multicloud"
  19. )
  20. type SWire struct {
  21. multicloud.SResourceBase
  22. ProxmoxTags
  23. region *SRegion
  24. }
  25. func (self *SWire) GetId() string {
  26. return self.region.GetId()
  27. }
  28. func (self *SWire) GetName() string {
  29. return "Default"
  30. }
  31. func (self *SWire) GetGlobalId() string {
  32. return self.GetId()
  33. }
  34. func (self *SWire) CreateINetwork(opts *cloudprovider.SNetworkCreateOptions) (cloudprovider.ICloudNetwork, error) {
  35. return nil, cloudprovider.ErrNotSupported
  36. }
  37. func (self *SWire) GetBandwidth() int {
  38. return 10000
  39. }
  40. func (self *SWire) GetINetworks() ([]cloudprovider.ICloudNetwork, error) {
  41. nets, err := self.region.GetNetworks()
  42. if err != nil {
  43. return nil, err
  44. }
  45. ret := []cloudprovider.ICloudNetwork{}
  46. for i := range nets {
  47. nets[i].wire = self
  48. ret = append(ret, &nets[i])
  49. }
  50. return ret, nil
  51. }
  52. func (self *SWire) GetINetworkById(id string) (cloudprovider.ICloudNetwork, error) {
  53. net, err := self.region.GetNetwork(id)
  54. if err != nil {
  55. return nil, err
  56. }
  57. net.wire = self
  58. return net, nil
  59. }
  60. func (self *SWire) GetIVpc() cloudprovider.ICloudVpc {
  61. return self.region.getVpc()
  62. }
  63. func (self *SWire) GetIZone() cloudprovider.ICloudZone {
  64. zone, _ := self.region.GetZone()
  65. return zone
  66. }
  67. func (self *SWire) GetStatus() string {
  68. return api.WIRE_STATUS_AVAILABLE
  69. }
  70. func (self *SRegion) GetWires() ([]SWire, error) {
  71. ret := []SWire{}
  72. wire := &SWire{region: self}
  73. ret = append(ret, *wire)
  74. return ret, nil
  75. }
  76. func (self *SRegion) GetWire() (*SWire, error) {
  77. ret := &SWire{region: self}
  78. return ret, nil
  79. }