yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/remotefile/vpc.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 remotefile 16 17 import ( 18 "yunion.io/x/pkg/utils" 19 20 "yunion.io/x/cloudmux/pkg/cloudprovider" 21 "yunion.io/x/cloudmux/pkg/multicloud" 22 ) 23 24 type SVpc struct { 25 multicloud.SVpc 26 SResourceBase 27 28 region *SRegion 29 30 RegionId string 31 CidrBlock string 32 IsDefault bool 33 } 34 35 func (self *SVpc) Delete() error { 36 return cloudprovider.ErrNotSupported 37 } 38 39 func (self *SVpc) GetCidrBlock() string { 40 return self.CidrBlock 41 } 42 43 func (self *SVpc) GetIRouteTableById(id string) (cloudprovider.ICloudRouteTable, error) { 44 return nil, cloudprovider.ErrNotSupported 45 } 46 47 func (self *SVpc) GetIRouteTables() ([]cloudprovider.ICloudRouteTable, error) { 48 return nil, cloudprovider.ErrNotSupported 49 } 50 51 func (self *SVpc) GetIWires() ([]cloudprovider.ICloudWire, error) { 52 wires, err := self.region.client.GetWires() 53 if err != nil { 54 return nil, err 55 } 56 zones, err := self.region.client.GetZones() 57 if err != nil { 58 return nil, err 59 } 60 zoneIds := []string{} 61 for i := range zones { 62 zoneIds = append(zoneIds, zones[i].Id) 63 } 64 ret := []cloudprovider.ICloudWire{} 65 for i := range wires { 66 if wires[i].VpcId != self.GetId() || !utils.IsInStringArray(wires[i].ZoneId, zoneIds) { 67 continue 68 } 69 wires[i].region = self.region 70 ret = append(ret, &wires[i]) 71 } 72 return ret, nil 73 } 74 75 func (self *SVpc) CreateIWire(opts *cloudprovider.SWireCreateOptions) (cloudprovider.ICloudWire, error) { 76 return nil, cloudprovider.ErrNotSupported 77 } 78 79 func (self *SVpc) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) { 80 secgroups, err := self.region.client.GetSecgroups() 81 if err != nil { 82 return nil, err 83 } 84 ret := []cloudprovider.ICloudSecurityGroup{} 85 for i := range secgroups { 86 if secgroups[i].VpcId != self.GetId() { 87 continue 88 } 89 ret = append(ret, &secgroups[i]) 90 } 91 return nil, cloudprovider.ErrNotFound 92 } 93 94 func (self *SVpc) GetIWireById(id string) (cloudprovider.ICloudWire, error) { 95 wires, err := self.GetIWires() 96 if err != nil { 97 return nil, err 98 } 99 for i := range wires { 100 if wires[i].GetGlobalId() == id { 101 return wires[i], nil 102 } 103 } 104 return nil, cloudprovider.ErrNotFound 105 } 106 107 func (self *SVpc) GetINatGateways() ([]cloudprovider.ICloudNatGateway, error) { 108 return nil, cloudprovider.ErrNotSupported 109 } 110 111 func (self *SVpc) CreateINatGateway(opts *cloudprovider.NatGatewayCreateOptions) (cloudprovider.ICloudNatGateway, error) { 112 return nil, cloudprovider.ErrNotSupported 113 } 114 115 func (self *SVpc) GetICloudVpcPeeringConnections() ([]cloudprovider.ICloudVpcPeeringConnection, error) { 116 return nil, cloudprovider.ErrNotSupported 117 } 118 119 func (self *SVpc) GetICloudAccepterVpcPeeringConnections() ([]cloudprovider.ICloudVpcPeeringConnection, error) { 120 return nil, cloudprovider.ErrNotSupported 121 } 122 123 func (self *SVpc) GetICloudVpcPeeringConnectionById(id string) (cloudprovider.ICloudVpcPeeringConnection, error) { 124 return nil, cloudprovider.ErrNotSupported 125 } 126 127 func (self *SVpc) CreateICloudVpcPeeringConnection(opts *cloudprovider.VpcPeeringConnectionCreateOptions) (cloudprovider.ICloudVpcPeeringConnection, error) { 128 return nil, cloudprovider.ErrNotSupported 129 } 130 131 func (self *SVpc) AcceptICloudVpcPeeringConnection(id string) error { 132 return cloudprovider.ErrNotSupported 133 } 134 135 func (self *SVpc) GetAuthorityOwnerId() string { 136 return "" 137 } 138 139 func (self *SVpc) ProposeJoinICloudInterVpcNetwork(opts *cloudprovider.SVpcJointInterVpcNetworkOption) error { 140 return cloudprovider.ErrNotSupported 141 } 142 143 func (self *SVpc) GetICloudIPv6Gateways() ([]cloudprovider.ICloudIPv6Gateway, error) { 144 return nil, cloudprovider.ErrNotSupported 145 } 146 147 func (self *SVpc) GetIsDefault() bool { 148 return self.IsDefault 149 } 150 151 func (self *SVpc) GetRegion() cloudprovider.ICloudRegion { 152 return self.region 153 }