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