yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/proxmox/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 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 SVpc struct {
    24  	multicloud.SVpc
    25  	ProxmoxTags
    26  
    27  	region *SRegion
    28  }
    29  
    30  func (self *SVpc) GetName() string {
    31  	return "Default"
    32  }
    33  
    34  func (self *SVpc) GetId() string {
    35  	return self.region.GetId()
    36  }
    37  
    38  func (self *SVpc) GetGlobalId() string {
    39  	return self.GetId()
    40  }
    41  
    42  func (self *SVpc) Delete() error {
    43  	return cloudprovider.ErrNotSupported
    44  }
    45  
    46  func (self *SVpc) IsEmulated() bool {
    47  	return true
    48  }
    49  
    50  func (self *SVpc) GetCidrBlock() string {
    51  	return "0.0.0.0/0"
    52  }
    53  
    54  func (self *SVpc) GetIRouteTables() ([]cloudprovider.ICloudRouteTable, error) {
    55  	return []cloudprovider.ICloudRouteTable{}, nil
    56  }
    57  
    58  func (self *SVpc) GetIRouteTableById(routeTableId string) (cloudprovider.ICloudRouteTable, error) {
    59  	return nil, cloudprovider.ErrNotFound
    60  }
    61  
    62  func (self *SVpc) GetISecurityGroups() ([]cloudprovider.ICloudSecurityGroup, error) {
    63  	return []cloudprovider.ICloudSecurityGroup{}, nil
    64  }
    65  
    66  func (self *SVpc) GetIWires() ([]cloudprovider.ICloudWire, error) {
    67  	wires, err := self.region.GetWires()
    68  	if err != nil {
    69  		return nil, err
    70  	}
    71  	ret := []cloudprovider.ICloudWire{}
    72  	for i := range wires {
    73  		wires[i].region = self.region
    74  		ret = append(ret, &wires[i])
    75  	}
    76  	return ret, nil
    77  }
    78  
    79  func (self *SVpc) GetIWireById(id string) (cloudprovider.ICloudWire, error) {
    80  	wire, err := self.region.GetWire()
    81  	if err != nil {
    82  		return nil, err
    83  	}
    84  	wire.region = self.region
    85  	return wire, nil
    86  }
    87  
    88  func (self *SVpc) GetIsDefault() bool {
    89  	return true
    90  }
    91  
    92  func (self *SVpc) GetRegion() cloudprovider.ICloudRegion {
    93  	return self.region
    94  }
    95  
    96  func (self *SVpc) GetStatus() string {
    97  	return api.VPC_STATUS_AVAILABLE
    98  }